Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add missing is active at timestamp fns #12206

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions crates/optimism/hardforks/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,35 @@ pub trait OptimismHardforks: EthereumHardforks {
self.fork(OptimismHardfork::Bedrock).active_at_block(block_number)
}

/// Returns `true` if [`Canyon`](OptimismHardfork::Canyon) is active at given block timestamp.
fn is_canyon_active_at_timestamp(&self, timestamp: u64) -> bool {
self.fork(OptimismHardfork::Canyon).active_at_timestamp(timestamp)
}

/// Returns `true` if [`Ecotone`](OptimismHardfork::Ecotone) is active at given block timestamp.
fn is_ecotone_active_at_timestamp(&self, timestamp: u64) -> bool {
self.fork(OptimismHardfork::Ecotone).active_at_timestamp(timestamp)
}

/// Returns `true` if [`Ecotone`](OptimismHardfork::Ecotone) is active at given block timestamp.
/// Returns `true` if [`Fjord`](OptimismHardfork::Fjord) is active at given block timestamp.
fn is_fjord_active_at_timestamp(&self, timestamp: u64) -> bool {
self.fork(OptimismHardfork::Ecotone).active_at_timestamp(timestamp)
self.fork(OptimismHardfork::Fjord).active_at_timestamp(timestamp)
}

/// Returns `true` if [`Granite`](OptimismHardfork::Granite) is active at given block timestamp.
fn is_granite_active_at_timestamp(&self, timestamp: u64) -> bool {
self.fork(OptimismHardfork::Granite).active_at_timestamp(timestamp)
}

/// Returns `true` if [`Holocene`](OptimismHardfork::Holocene) is active at given block
/// timestamp.
fn is_holocene_active_at_timestamp(&self, timestamp: u64) -> bool {
self.fork(OptimismHardfork::Holocene).active_at_timestamp(timestamp)
}

/// Returns `true` if [`Regolith`](OptimismHardfork::Regolith) is active at given block
/// timestamp.
fn is_regolith_active_at_timestamp(&self, timestamp: u64) -> bool {
self.fork(OptimismHardfork::Regolith).active_at_timestamp(timestamp)
}
}
8 changes: 3 additions & 5 deletions crates/optimism/node/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use reth_node_api::{
validate_version_specific_fields, EngineTypes, EngineValidator,
};
use reth_optimism_chainspec::OpChainSpec;
use reth_optimism_forks::OptimismHardfork;
use reth_optimism_forks::{OptimismHardfork, OptimismHardforks};
use reth_optimism_payload_builder::{
builder::decode_eip_1559_params, OptimismBuiltPayload, OptimismPayloadBuilderAttributes,
};
Expand Down Expand Up @@ -149,10 +149,8 @@ where
))
}

if self.chain_spec.is_fork_active_at_timestamp(
OptimismHardfork::Holocene,
attributes.payload_attributes.timestamp,
) {
if self.chain_spec.is_holocene_active_at_timestamp(attributes.payload_attributes.timestamp)
{
let Some(eip_1559_params) = attributes.eip_1559_params else {
return Err(EngineObjectValidationError::InvalidParams(
"MissingEip1559ParamsInPayloadAttributes".to_string().into(),
Expand Down
19 changes: 6 additions & 13 deletions crates/optimism/payload/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use reth_evm::{system_calls::SystemCaller, ConfigureEvm, ConfigureEvmEnv, NextBl
use reth_execution_types::ExecutionOutcome;
use reth_optimism_chainspec::OpChainSpec;
use reth_optimism_consensus::calculate_receipt_root_no_memo_optimism;
use reth_optimism_forks::{OptimismHardfork, OptimismHardforks};
use reth_optimism_forks::OptimismHardforks;
use reth_payload_primitives::{PayloadBuilderAttributes, PayloadBuilderError};
use reth_primitives::{
proofs,
Expand Down Expand Up @@ -193,10 +193,8 @@ where

let block_number = initialized_block_env.number.to::<u64>();

let is_regolith = chain_spec.is_fork_active_at_timestamp(
OptimismHardfork::Regolith,
attributes.payload_attributes.timestamp,
);
let is_regolith =
chain_spec.is_regolith_active_at_timestamp(attributes.payload_attributes.timestamp);

// apply eip-4788 pre block contract call
let mut system_caller = SystemCaller::new(evm_config.clone(), &chain_spec);
Expand Down Expand Up @@ -315,10 +313,7 @@ where
// receipt hashes should be computed when set. The state transition process
// ensures this is only set for post-Canyon deposit transactions.
deposit_receipt_version: chain_spec
.is_fork_active_at_timestamp(
OptimismHardfork::Canyon,
attributes.payload_attributes.timestamp,
)
.is_canyon_active_at_timestamp(attributes.payload_attributes.timestamp)
.then_some(1),
}));

Expand Down Expand Up @@ -473,10 +468,8 @@ where
(None, None)
};

let is_holocene = chain_spec.is_fork_active_at_timestamp(
OptimismHardfork::Holocene,
attributes.payload_attributes.timestamp,
);
let is_holocene =
chain_spec.is_holocene_active_at_timestamp(attributes.payload_attributes.timestamp);

if is_holocene {
extra_data = attributes
Expand Down
Loading