Skip to content

Simplify revm_spec_by_timestamp_and_block_number #18150

@mattsse

Description

@mattsse

Describe the feature

This currently requires additional trait bounds

/// Map the latest active hardfork at the given timestamp or block number to a revm [`SpecId`].
pub fn revm_spec_by_timestamp_and_block_number<C>(
chain_spec: &C,
timestamp: u64,
block_number: u64,
) -> SpecId
where
C: EthereumHardforks + EthChainSpec + Hardforks,
{

just for the panic fallback

panic!(
"invalid hardfork chainspec: expected at least one hardfork, got {}",
chain_spec.display_hardforks()
)

we can expect that at least the frontier spec is active, we assume something similar for the op variant:

} else {
OpSpecId::BEDROCK
}

so we can simplify this by just using EthereumHardforks trait for this

TODO

  • remove EthChainSpec + Hardforks
  • adjust .fork().active calls with the dedicated is_<osaka|..>active_at<timestamp|block> calls or
fn is_ethereum_fork_active_at_block(&self, fork: EthereumHardfork, block_number: u64) -> bool {
        self.ethereum_fork_activation(fork).active_at_block(block_number)
    }

We're missing some functions so we can add those to https://github.com/alloy-rs/hardforks/blob/cf2cdc868fd9e22eb15840e5c2cfa54ca4727040/crates/hardforks/src/hardfork/ethereum.rs#L605

Additional context

No response

Metadata

Metadata

Assignees

Labels

C-debtA clean up/refactor of existing codeC-enhancementNew feature or requestD-good-first-issueNice and easy! A great choice to get started

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions