Skip to content

Commit

Permalink
feat(op): Isthmus precompiles (#2054)
Browse files Browse the repository at this point in the history
* feat(op): Isthmus precompiles

* put behind feature flag
  • Loading branch information
rakita authored Feb 8, 2025
1 parent e803ed0 commit 32d5eba
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 18 deletions.
9 changes: 4 additions & 5 deletions bins/revme/src/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,16 @@ pub enum Error {
impl MainCmd {
pub fn run(&self) -> Result<(), Error> {
match self {
Self::Statetest(cmd) => cmd.run().map_err(Into::into),
Self::EofValidation(cmd) => cmd.run().map_err(Into::into),
Self::Evm(cmd) => cmd.run().map_err(Into::into),
Self::Statetest(cmd) => cmd.run()?,
Self::EofValidation(cmd) => cmd.run()?,
Self::Evm(cmd) => cmd.run()?,
Self::Bytecode(cmd) => {
cmd.run();
Ok(())
}
Self::Bench(cmd) => {
cmd.run();
Ok(())
}
}
Ok(())
}
}
2 changes: 1 addition & 1 deletion bins/revme/src/cmd/statetest/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ pub fn execute_test_suite(
access_list
.iter()
.map(|item| (item.address, item.storage_keys.clone()))
.collect::<Vec<_>>()
.collect()
})
.unwrap_or_default();

Expand Down
30 changes: 21 additions & 9 deletions crates/optimism/src/handler/precompiles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ impl<CTX> OpPrecompileProvider<CTX> {
#[inline]
pub fn new_with_spec(spec: OpSpec) -> Self {
match spec {
// No changes
spec @ (OpSpec::Eth(
SpecId::FRONTIER
| SpecId::FRONTIER_THAWING
Expand All @@ -57,16 +56,12 @@ impl<CTX> OpPrecompileProvider<CTX> {
| SpecId::CANCUN,
)
| OpSpec::Op(
OpSpecId::BEDROCK
| OpSpecId::REGOLITH
| OpSpecId::CANYON
| OpSpecId::ECOTONE
| OpSpecId::HOLOCENE
| OpSpecId::ISTHMUS,
OpSpecId::BEDROCK | OpSpecId::REGOLITH | OpSpecId::CANYON | OpSpecId::ECOTONE,
)) => Self::new(Precompiles::new(spec.into_eth_spec().into())),
OpSpec::Op(OpSpecId::FJORD) => Self::new(fjord()),
OpSpec::Op(OpSpecId::GRANITE)
| OpSpec::Eth(SpecId::PRAGUE | SpecId::OSAKA | SpecId::LATEST) => Self::new(granite()),
OpSpec::Op(OpSpecId::GRANITE | OpSpecId::HOLOCENE) => Self::new(granite()),
OpSpec::Op(OpSpecId::ISTHMUS)
| OpSpec::Eth(SpecId::PRAGUE | SpecId::OSAKA | SpecId::LATEST) => Self::new(isthumus()),
}
}
}
Expand All @@ -93,6 +88,23 @@ pub fn granite() -> &'static Precompiles {
})
}

/// Returns precompiles for isthumus spec.
pub fn isthumus() -> &'static Precompiles {
static INSTANCE: OnceBox<Precompiles> = OnceBox::new();
INSTANCE.get_or_init(|| {
let precompiles = granite().clone();
// Prague bls12 precompiles
// Don't include BLS12-381 precompiles in no_std builds.
#[cfg(feature = "blst")]
let precompiles = {
let mut precompiles = precompiles;
precompiles.extend(precompile::bls12_381::precompiles());
precompiles
};
Box::new(precompiles)
})
}

impl<CTX> PrecompileProvider for OpPrecompileProvider<CTX>
where
CTX: ContextTrait<Cfg: Cfg<Spec = OpSpec>>,
Expand Down
5 changes: 2 additions & 3 deletions crates/optimism/src/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ impl OpSpecId {
match self {
Self::BEDROCK | Self::REGOLITH => SpecId::MERGE,
Self::CANYON => SpecId::SHANGHAI,
Self::ECOTONE | Self::FJORD | Self::GRANITE | Self::HOLOCENE | Self::ISTHMUS => {
SpecId::CANCUN
}
Self::ECOTONE | Self::FJORD | Self::GRANITE | Self::HOLOCENE => SpecId::CANCUN,
Self::ISTHMUS => SpecId::PRAGUE,
}
}

Expand Down

0 comments on commit 32d5eba

Please sign in to comment.