Skip to content

Commit

Permalink
Add placeholder OpHardfork::Isthmus (#13112)
Browse files Browse the repository at this point in the history
Co-authored-by: Matthias Seitz <[email protected]>
  • Loading branch information
emhane and mattsse authored Dec 7, 2024
1 parent 6b35b05 commit 4fa86c5
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 7 deletions.
11 changes: 10 additions & 1 deletion crates/optimism/chainspec/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use reth_chainspec::{
};
use reth_ethereum_forks::{ChainHardforks, EthereumHardfork, ForkCondition, Hardfork};
use reth_network_peers::NodeRecord;
use reth_optimism_forks::OpHardforks;
use reth_optimism_forks::{OpHardfork, OpHardforks};
#[cfg(feature = "std")]
pub(crate) use std::sync::LazyLock;

Expand Down Expand Up @@ -166,6 +166,13 @@ impl OpChainSpecBuilder {
self
}

/// Enable Isthmus at genesis
pub fn isthmus_activated(mut self) -> Self {
self = self.holocene_activated();
self.inner = self.inner.with_fork(OpHardfork::Isthmus, ForkCondition::Timestamp(0));
self
}

/// Build the resulting [`OpChainSpec`].
///
/// # Panics
Expand Down Expand Up @@ -414,6 +421,7 @@ impl From<Genesis> for OpChainSpec {
(OpHardfork::Fjord.boxed(), genesis_info.fjord_time),
(OpHardfork::Granite.boxed(), genesis_info.granite_time),
(OpHardfork::Holocene.boxed(), genesis_info.holocene_time),
(OpHardfork::Isthmus.boxed(), genesis_info.isthmus_time),
];

let mut time_hardforks = time_hardfork_opts
Expand Down Expand Up @@ -1030,6 +1038,7 @@ mod tests {
OpHardfork::Fjord.boxed(),
OpHardfork::Granite.boxed(),
OpHardfork::Holocene.boxed(),
// OpHardfork::Isthmus.boxed(),
];

assert!(expected_hardforks
Expand Down
8 changes: 6 additions & 2 deletions crates/optimism/evm/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ pub fn revm_spec_by_timestamp_after_bedrock(
chain_spec: &OpChainSpec,
timestamp: u64,
) -> revm_primitives::SpecId {
if chain_spec.fork(OpHardfork::Holocene).active_at_timestamp(timestamp) {
if chain_spec.fork(OpHardfork::Isthmus).active_at_timestamp(timestamp) {
todo!()
} else if chain_spec.fork(OpHardfork::Holocene).active_at_timestamp(timestamp) {
revm_primitives::HOLOCENE
} else if chain_spec.fork(OpHardfork::Granite).active_at_timestamp(timestamp) {
revm_primitives::GRANITE
Expand All @@ -31,7 +33,9 @@ pub fn revm_spec_by_timestamp_after_bedrock(

/// Map the latest active hardfork at the given block to a revm [`SpecId`](revm_primitives::SpecId).
pub fn revm_spec(chain_spec: &OpChainSpec, block: &Head) -> revm_primitives::SpecId {
if chain_spec.fork(OpHardfork::Holocene).active_at_head(block) {
if chain_spec.fork(OpHardfork::Isthmus).active_at_head(block) {
todo!()
} else if chain_spec.fork(OpHardfork::Holocene).active_at_head(block) {
revm_primitives::HOLOCENE
} else if chain_spec.fork(OpHardfork::Granite).active_at_head(block) {
revm_primitives::GRANITE
Expand Down
7 changes: 6 additions & 1 deletion crates/optimism/hardforks/src/hardfork.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ hardfork!(
Granite,
/// Holocene: <https://github.com/ethereum-optimism/specs/blob/main/specs/protocol/superchain-upgrades.md#holocene>
Holocene,
/// Isthmus: <https://github.com/ethereum-optimism/specs/blob/main/specs/protocol/isthmus/overview.md>
Isthmus,
}
);

Expand Down Expand Up @@ -159,6 +161,7 @@ impl OpHardfork {
Self::Fjord => Some(1716998400),
Self::Granite => Some(1723478400),
Self::Holocene => Some(1732633200),
Self::Isthmus => todo!(),
},
)
}
Expand Down Expand Up @@ -194,6 +197,7 @@ impl OpHardfork {
Self::Fjord => Some(1720627201),
Self::Granite => Some(1726070401),
Self::Holocene => None,
Self::Isthmus => todo!(),
},
)
}
Expand Down Expand Up @@ -357,7 +361,7 @@ mod tests {
#[test]
fn check_op_hardfork_from_str() {
let hardfork_str =
["beDrOck", "rEgOlITH", "cAnYoN", "eCoToNe", "FJorD", "GRaNiTe", "hOlOcEnE"];
["beDrOck", "rEgOlITH", "cAnYoN", "eCoToNe", "FJorD", "GRaNiTe", "hOlOcEnE", "isthMUS"];
let expected_hardforks = [
OpHardfork::Bedrock,
OpHardfork::Regolith,
Expand All @@ -366,6 +370,7 @@ mod tests {
OpHardfork::Fjord,
OpHardfork::Granite,
OpHardfork::Holocene,
OpHardfork::Isthmus,
];

let hardforks: Vec<OpHardfork> =
Expand Down
12 changes: 9 additions & 3 deletions crates/optimism/hardforks/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ pub trait OpHardforks: EthereumHardforks {
self.fork(OpHardfork::Bedrock).active_at_block(block_number)
}

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

/// Returns `true` if [`Canyon`](OpHardfork::Canyon) is active at given block timestamp.
fn is_canyon_active_at_timestamp(&self, timestamp: u64) -> bool {
self.fork(OpHardfork::Canyon).active_at_timestamp(timestamp)
Expand All @@ -53,9 +59,9 @@ pub trait OpHardforks: EthereumHardforks {
self.fork(OpHardfork::Holocene).active_at_timestamp(timestamp)
}

/// Returns `true` if [`Regolith`](OpHardfork::Regolith) is active at given block
/// Returns `true` if [`Isthmus`](OpHardfork::Isthmus) is active at given block
/// timestamp.
fn is_regolith_active_at_timestamp(&self, timestamp: u64) -> bool {
self.fork(OpHardfork::Regolith).active_at_timestamp(timestamp)
fn is_isthmus_active_at_timestamp(&self, timestamp: u64) -> bool {
self.fork(OpHardfork::Isthmus).active_at_timestamp(timestamp)
}
}

0 comments on commit 4fa86c5

Please sign in to comment.