mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
Add interop hardfork in all relevant places. (#14582)
This commit is contained in:
@ -159,6 +159,13 @@ impl OpChainSpecBuilder {
|
|||||||
self
|
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`].
|
/// Build the resulting [`OpChainSpec`].
|
||||||
///
|
///
|
||||||
/// # Panics
|
/// # Panics
|
||||||
@ -329,6 +336,7 @@ impl From<Genesis> for OpChainSpec {
|
|||||||
(OpHardfork::Granite.boxed(), genesis_info.granite_time),
|
(OpHardfork::Granite.boxed(), genesis_info.granite_time),
|
||||||
(OpHardfork::Holocene.boxed(), genesis_info.holocene_time),
|
(OpHardfork::Holocene.boxed(), genesis_info.holocene_time),
|
||||||
(OpHardfork::Isthmus.boxed(), genesis_info.isthmus_time),
|
(OpHardfork::Isthmus.boxed(), genesis_info.isthmus_time),
|
||||||
|
// (OpHardfork::Interop.boxed(), genesis_info.interop_time),
|
||||||
];
|
];
|
||||||
|
|
||||||
let mut time_hardforks = time_hardfork_opts
|
let mut time_hardforks = time_hardfork_opts
|
||||||
@ -982,6 +990,7 @@ mod tests {
|
|||||||
OpHardfork::Granite.boxed(),
|
OpHardfork::Granite.boxed(),
|
||||||
OpHardfork::Holocene.boxed(),
|
OpHardfork::Holocene.boxed(),
|
||||||
// OpHardfork::Isthmus.boxed(),
|
// OpHardfork::Isthmus.boxed(),
|
||||||
|
// OpHardfork::Interop.boxed(),
|
||||||
];
|
];
|
||||||
|
|
||||||
for (expected, actual) in expected_hardforks.iter().zip(hardforks.iter()) {
|
for (expected, actual) in expected_hardforks.iter().zip(hardforks.iter()) {
|
||||||
|
|||||||
@ -17,6 +17,9 @@ pub fn revm_spec_by_timestamp_after_bedrock(
|
|||||||
chain_spec: impl OpHardforks,
|
chain_spec: impl OpHardforks,
|
||||||
timestamp: u64,
|
timestamp: u64,
|
||||||
) -> OpSpecId {
|
) -> OpSpecId {
|
||||||
|
// if chain_spec.is_interop_active_at_timestamp(timestamp) {
|
||||||
|
// OpSpecId::INTEROP
|
||||||
|
// } else
|
||||||
if chain_spec.is_isthmus_active_at_timestamp(timestamp) {
|
if chain_spec.is_isthmus_active_at_timestamp(timestamp) {
|
||||||
OpSpecId::ISTHMUS
|
OpSpecId::ISTHMUS
|
||||||
} else if chain_spec.is_holocene_active_at_timestamp(timestamp) {
|
} 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();
|
let cs = ChainSpecBuilder::mainnet().chain(reth_chainspec::Chain::from_id(10)).into();
|
||||||
f(cs).build()
|
f(cs).build()
|
||||||
}
|
}
|
||||||
|
// assert_eq!(
|
||||||
|
// revm_spec_by_timestamp_after_bedrock(op_cs(|cs| cs.interop_activated()), 0),
|
||||||
|
// OpSpecId::INTEROP
|
||||||
|
// );
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
revm_spec_by_timestamp_after_bedrock(op_cs(|cs| cs.isthmus_activated()), 0),
|
revm_spec_by_timestamp_after_bedrock(op_cs(|cs| cs.isthmus_activated()), 0),
|
||||||
OpSpecId::ISTHMUS
|
OpSpecId::ISTHMUS
|
||||||
|
|||||||
@ -35,6 +35,8 @@ hardfork!(
|
|||||||
Holocene,
|
Holocene,
|
||||||
/// Isthmus: <https://github.com/ethereum-optimism/specs/blob/main/specs/protocol/isthmus/overview.md>
|
/// Isthmus: <https://github.com/ethereum-optimism/specs/blob/main/specs/protocol/isthmus/overview.md>
|
||||||
Isthmus,
|
Isthmus,
|
||||||
|
/// TODO: add interop hardfork overview when available
|
||||||
|
Interop,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -162,6 +164,7 @@ impl OpHardfork {
|
|||||||
Self::Granite => Some(1723478400),
|
Self::Granite => Some(1723478400),
|
||||||
Self::Holocene => Some(1732633200),
|
Self::Holocene => Some(1732633200),
|
||||||
Self::Isthmus => todo!(),
|
Self::Isthmus => todo!(),
|
||||||
|
Self::Interop => todo!(),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -198,6 +201,7 @@ impl OpHardfork {
|
|||||||
Self::Granite => Some(1726070401),
|
Self::Granite => Some(1726070401),
|
||||||
Self::Holocene => Some(1736445601),
|
Self::Holocene => Some(1736445601),
|
||||||
Self::Isthmus => todo!(),
|
Self::Isthmus => todo!(),
|
||||||
|
Self::Interop => todo!(),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -378,8 +382,10 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn check_op_hardfork_from_str() {
|
fn check_op_hardfork_from_str() {
|
||||||
let hardfork_str =
|
let hardfork_str = [
|
||||||
["beDrOck", "rEgOlITH", "cAnYoN", "eCoToNe", "FJorD", "GRaNiTe", "hOlOcEnE", "isthMUS"];
|
"beDrOck", "rEgOlITH", "cAnYoN", "eCoToNe", "FJorD", "GRaNiTe", "hOlOcEnE", "isthMUS",
|
||||||
|
"inTerOP",
|
||||||
|
];
|
||||||
let expected_hardforks = [
|
let expected_hardforks = [
|
||||||
OpHardfork::Bedrock,
|
OpHardfork::Bedrock,
|
||||||
OpHardfork::Regolith,
|
OpHardfork::Regolith,
|
||||||
@ -389,6 +395,7 @@ mod tests {
|
|||||||
OpHardfork::Granite,
|
OpHardfork::Granite,
|
||||||
OpHardfork::Holocene,
|
OpHardfork::Holocene,
|
||||||
OpHardfork::Isthmus,
|
OpHardfork::Isthmus,
|
||||||
|
OpHardfork::Interop,
|
||||||
];
|
];
|
||||||
|
|
||||||
let hardforks: Vec<OpHardfork> =
|
let hardforks: Vec<OpHardfork> =
|
||||||
|
|||||||
@ -69,4 +69,10 @@ pub trait OpHardforks: EthereumHardforks {
|
|||||||
fn is_isthmus_active_at_timestamp(&self, timestamp: u64) -> bool {
|
fn is_isthmus_active_at_timestamp(&self, timestamp: u64) -> bool {
|
||||||
self.op_fork_activation(OpHardfork::Isthmus).active_at_timestamp(timestamp)
|
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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -793,6 +793,11 @@ where
|
|||||||
self.chain_spec.is_isthmus_active_at_timestamp(self.attributes().timestamp())
|
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.
|
/// Returns true if the fees are higher than the previous payload.
|
||||||
pub fn is_better_payload(&self, total_fees: U256) -> bool {
|
pub fn is_better_payload(&self, total_fees: U256) -> bool {
|
||||||
is_better_payload(self.best_payload.as_ref(), total_fees)
|
is_better_payload(self.best_payload.as_ref(), total_fees)
|
||||||
|
|||||||
Reference in New Issue
Block a user