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 osaka hardfork #11984

Merged
merged 1 commit into from
Oct 23, 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
8 changes: 8 additions & 0 deletions crates/chainspec/src/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,7 @@ impl From<Genesis> for ChainSpec {
(EthereumHardfork::Shanghai.boxed(), genesis.config.shanghai_time),
(EthereumHardfork::Cancun.boxed(), genesis.config.cancun_time),
(EthereumHardfork::Prague.boxed(), genesis.config.prague_time),
(EthereumHardfork::Osaka.boxed(), genesis.config.osaka_time),
];

let mut time_hardforks = time_hardfork_opts
Expand Down Expand Up @@ -864,6 +865,13 @@ impl ChainSpecBuilder {
self
}

/// Enable Osaka at genesis.
pub fn osaka_activated(mut self) -> Self {
self = self.prague_activated();
self.hardforks.insert(EthereumHardfork::Osaka, ForkCondition::Timestamp(0));
self
}

/// Build the resulting [`ChainSpec`].
///
/// # Panics
Expand Down
2 changes: 2 additions & 0 deletions crates/ethereum-forks/src/hardfork/ethereum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ hardfork!(
Cancun,
/// Prague: <https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/prague.md>
Prague,
/// Osaka: <https://eips.ethereum.org/EIPS/eip-7607>
Osaka,
}
);

Expand Down
5 changes: 5 additions & 0 deletions crates/ethereum-forks/src/hardforks/ethereum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ pub trait EthereumHardforks: Hardforks {
self.is_fork_active_at_timestamp(EthereumHardfork::Prague, timestamp)
}

/// Convenience method to check if [`EthereumHardfork::Osaka`] is active at a given timestamp.
fn is_osaka_active_at_timestamp(&self, timestamp: u64) -> bool {
self.is_fork_active_at_timestamp(EthereumHardfork::Osaka, timestamp)
}

/// Convenience method to check if [`EthereumHardfork::Byzantium`] is active at a given block
/// number.
fn is_byzantium_active_at_block(&self, block_number: u64) -> bool {
Expand Down
4 changes: 3 additions & 1 deletion crates/ethereum/cli/src/chainspec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,15 @@ mod tests {
"terminalTotalDifficulty": 0,
"shanghaiTime": 0,
"cancunTime": 0,
"pragueTime": 0
"pragueTime": 0,
"osakaTime": 0
}
}"#;

let spec = <EthereumChainSpecParser as ChainSpecParser>::parse(s).unwrap();
assert!(spec.is_shanghai_active_at_timestamp(0));
assert!(spec.is_cancun_active_at_timestamp(0));
assert!(spec.is_prague_active_at_timestamp(0));
assert!(spec.is_osaka_active_at_timestamp(0));
}
}
4 changes: 3 additions & 1 deletion crates/ethereum/evm/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ pub fn revm_spec_by_timestamp_after_merge(
chain_spec: &ChainSpec,
timestamp: u64,
) -> revm_primitives::SpecId {
if chain_spec.is_prague_active_at_timestamp(timestamp) {
if chain_spec.is_osaka_active_at_timestamp(timestamp) {
revm_primitives::OSAKA
} else if chain_spec.is_prague_active_at_timestamp(timestamp) {
revm_primitives::PRAGUE
} else if chain_spec.is_cancun_active_at_timestamp(timestamp) {
revm_primitives::CANCUN
Expand Down
Loading