Add interop hardfork in all relevant places. (#14582)

This commit is contained in:
Solar Mithril
2025-02-19 13:18:37 +01:00
committed by GitHub
parent c9a348dd2c
commit 1ae733a7d1
5 changed files with 36 additions and 2 deletions

View File

@ -159,6 +159,13 @@ impl OpChainSpecBuilder {
self
}
/// Enable Interop at genesis
pub fn interop_activated(mut self) -> Self {
self = self.isthmus_activated();
self.inner = self.inner.with_fork(OpHardfork::Interop, ForkCondition::Timestamp(0));
self
}
/// Build the resulting [`OpChainSpec`].
///
/// # Panics
@ -329,6 +336,7 @@ impl From<Genesis> for OpChainSpec {
(OpHardfork::Granite.boxed(), genesis_info.granite_time),
(OpHardfork::Holocene.boxed(), genesis_info.holocene_time),
(OpHardfork::Isthmus.boxed(), genesis_info.isthmus_time),
// (OpHardfork::Interop.boxed(), genesis_info.interop_time),
];
let mut time_hardforks = time_hardfork_opts
@ -982,6 +990,7 @@ mod tests {
OpHardfork::Granite.boxed(),
OpHardfork::Holocene.boxed(),
// OpHardfork::Isthmus.boxed(),
// OpHardfork::Interop.boxed(),
];
for (expected, actual) in expected_hardforks.iter().zip(hardforks.iter()) {

View File

@ -17,6 +17,9 @@ pub fn revm_spec_by_timestamp_after_bedrock(
chain_spec: impl OpHardforks,
timestamp: u64,
) -> OpSpecId {
// if chain_spec.is_interop_active_at_timestamp(timestamp) {
// OpSpecId::INTEROP
// } else
if chain_spec.is_isthmus_active_at_timestamp(timestamp) {
OpSpecId::ISTHMUS
} else if chain_spec.is_holocene_active_at_timestamp(timestamp) {
@ -49,6 +52,10 @@ mod tests {
let cs = ChainSpecBuilder::mainnet().chain(reth_chainspec::Chain::from_id(10)).into();
f(cs).build()
}
// assert_eq!(
// revm_spec_by_timestamp_after_bedrock(op_cs(|cs| cs.interop_activated()), 0),
// OpSpecId::INTEROP
// );
assert_eq!(
revm_spec_by_timestamp_after_bedrock(op_cs(|cs| cs.isthmus_activated()), 0),
OpSpecId::ISTHMUS

View File

@ -35,6 +35,8 @@ hardfork!(
Holocene,
/// Isthmus: <https://github.com/ethereum-optimism/specs/blob/main/specs/protocol/isthmus/overview.md>
Isthmus,
/// TODO: add interop hardfork overview when available
Interop,
}
);
@ -162,6 +164,7 @@ impl OpHardfork {
Self::Granite => Some(1723478400),
Self::Holocene => Some(1732633200),
Self::Isthmus => todo!(),
Self::Interop => todo!(),
},
)
}
@ -198,6 +201,7 @@ impl OpHardfork {
Self::Granite => Some(1726070401),
Self::Holocene => Some(1736445601),
Self::Isthmus => todo!(),
Self::Interop => todo!(),
},
)
}
@ -378,8 +382,10 @@ mod tests {
#[test]
fn check_op_hardfork_from_str() {
let hardfork_str =
["beDrOck", "rEgOlITH", "cAnYoN", "eCoToNe", "FJorD", "GRaNiTe", "hOlOcEnE", "isthMUS"];
let hardfork_str = [
"beDrOck", "rEgOlITH", "cAnYoN", "eCoToNe", "FJorD", "GRaNiTe", "hOlOcEnE", "isthMUS",
"inTerOP",
];
let expected_hardforks = [
OpHardfork::Bedrock,
OpHardfork::Regolith,
@ -389,6 +395,7 @@ mod tests {
OpHardfork::Granite,
OpHardfork::Holocene,
OpHardfork::Isthmus,
OpHardfork::Interop,
];
let hardforks: Vec<OpHardfork> =

View File

@ -69,4 +69,10 @@ pub trait OpHardforks: EthereumHardforks {
fn is_isthmus_active_at_timestamp(&self, timestamp: u64) -> bool {
self.op_fork_activation(OpHardfork::Isthmus).active_at_timestamp(timestamp)
}
/// Returns `true` if [`Interop`](OpHardfork::Interop) is active at given block
/// timestamp.
fn is_interop_active_at_timestamp(&self, timestamp: u64) -> bool {
self.op_fork_activation(OpHardfork::Interop).active_at_timestamp(timestamp)
}
}

View File

@ -793,6 +793,11 @@ where
self.chain_spec.is_isthmus_active_at_timestamp(self.attributes().timestamp())
}
/// Returns true if interop is active for the payload.
pub fn is_interop_active(&self) -> bool {
self.chain_spec.is_interop_active_at_timestamp(self.attributes().timestamp())
}
/// Returns true if the fees are higher than the previous payload.
pub fn is_better_payload(&self, total_fees: U256) -> bool {
is_better_payload(self.best_payload.as_ref(), total_fees)