mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: add osaka hardfork (#11984)
This commit is contained in:
@ -617,6 +617,7 @@ impl From<Genesis> for ChainSpec {
|
|||||||
(EthereumHardfork::Shanghai.boxed(), genesis.config.shanghai_time),
|
(EthereumHardfork::Shanghai.boxed(), genesis.config.shanghai_time),
|
||||||
(EthereumHardfork::Cancun.boxed(), genesis.config.cancun_time),
|
(EthereumHardfork::Cancun.boxed(), genesis.config.cancun_time),
|
||||||
(EthereumHardfork::Prague.boxed(), genesis.config.prague_time),
|
(EthereumHardfork::Prague.boxed(), genesis.config.prague_time),
|
||||||
|
(EthereumHardfork::Osaka.boxed(), genesis.config.osaka_time),
|
||||||
];
|
];
|
||||||
|
|
||||||
let mut time_hardforks = time_hardfork_opts
|
let mut time_hardforks = time_hardfork_opts
|
||||||
@ -864,6 +865,13 @@ impl ChainSpecBuilder {
|
|||||||
self
|
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`].
|
/// Build the resulting [`ChainSpec`].
|
||||||
///
|
///
|
||||||
/// # Panics
|
/// # Panics
|
||||||
|
|||||||
@ -49,6 +49,8 @@ hardfork!(
|
|||||||
Cancun,
|
Cancun,
|
||||||
/// Prague: <https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/prague.md>
|
/// Prague: <https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/prague.md>
|
||||||
Prague,
|
Prague,
|
||||||
|
/// Osaka: <https://eips.ethereum.org/EIPS/eip-7607>
|
||||||
|
Osaka,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -21,6 +21,11 @@ pub trait EthereumHardforks: Hardforks {
|
|||||||
self.is_fork_active_at_timestamp(EthereumHardfork::Prague, timestamp)
|
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
|
/// Convenience method to check if [`EthereumHardfork::Byzantium`] is active at a given block
|
||||||
/// number.
|
/// number.
|
||||||
fn is_byzantium_active_at_block(&self, block_number: u64) -> bool {
|
fn is_byzantium_active_at_block(&self, block_number: u64) -> bool {
|
||||||
|
|||||||
@ -89,7 +89,8 @@ mod tests {
|
|||||||
"terminalTotalDifficulty": 0,
|
"terminalTotalDifficulty": 0,
|
||||||
"shanghaiTime": 0,
|
"shanghaiTime": 0,
|
||||||
"cancunTime": 0,
|
"cancunTime": 0,
|
||||||
"pragueTime": 0
|
"pragueTime": 0,
|
||||||
|
"osakaTime": 0
|
||||||
}
|
}
|
||||||
}"#;
|
}"#;
|
||||||
|
|
||||||
@ -97,5 +98,6 @@ mod tests {
|
|||||||
assert!(spec.is_shanghai_active_at_timestamp(0));
|
assert!(spec.is_shanghai_active_at_timestamp(0));
|
||||||
assert!(spec.is_cancun_active_at_timestamp(0));
|
assert!(spec.is_cancun_active_at_timestamp(0));
|
||||||
assert!(spec.is_prague_active_at_timestamp(0));
|
assert!(spec.is_prague_active_at_timestamp(0));
|
||||||
|
assert!(spec.is_osaka_active_at_timestamp(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,7 +11,9 @@ pub fn revm_spec_by_timestamp_after_merge(
|
|||||||
chain_spec: &ChainSpec,
|
chain_spec: &ChainSpec,
|
||||||
timestamp: u64,
|
timestamp: u64,
|
||||||
) -> revm_primitives::SpecId {
|
) -> 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
|
revm_primitives::PRAGUE
|
||||||
} else if chain_spec.is_cancun_active_at_timestamp(timestamp) {
|
} else if chain_spec.is_cancun_active_at_timestamp(timestamp) {
|
||||||
revm_primitives::CANCUN
|
revm_primitives::CANCUN
|
||||||
|
|||||||
Reference in New Issue
Block a user