Skip to content
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
9 changes: 9 additions & 0 deletions crates/optimism/chainspec/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this we need to add to the genesis info type

];

let mut time_hardforks = time_hardfork_opts
Expand Down Expand Up @@ -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()) {
Expand Down
7 changes: 7 additions & 0 deletions crates/optimism/evm/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment on lines +20 to +22
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

afaik there are no evm changes for interop?
possible that we don't need to roll a new spec but probably should anyway for consistency
FYI @klkvr

if chain_spec.is_isthmus_active_at_timestamp(timestamp) {
OpSpecId::ISTHMUS
} else if chain_spec.is_holocene_active_at_timestamp(timestamp) {
Expand Down Expand Up @@ -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
Expand Down
11 changes: 9 additions & 2 deletions crates/optimism/hardforks/src/hardfork.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
);

Expand Down Expand Up @@ -162,6 +164,7 @@ impl OpHardfork {
Self::Granite => Some(1723478400),
Self::Holocene => Some(1732633200),
Self::Isthmus => todo!(),
Self::Interop => todo!(),
},
)
}
Expand Down Expand Up @@ -198,6 +201,7 @@ impl OpHardfork {
Self::Granite => Some(1726070401),
Self::Holocene => Some(1736445601),
Self::Isthmus => todo!(),
Self::Interop => todo!(),
},
)
}
Expand Down Expand Up @@ -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,
Expand All @@ -389,6 +395,7 @@ mod tests {
OpHardfork::Granite,
OpHardfork::Holocene,
OpHardfork::Isthmus,
OpHardfork::Interop,
];

let hardforks: Vec<OpHardfork> =
Expand Down
6 changes: 6 additions & 0 deletions crates/optimism/hardforks/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
5 changes: 5 additions & 0 deletions crates/optimism/payload/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,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)
Expand Down
Loading