Skip to content

Commit

Permalink
feat: add precompiles for BLS12-381 to isthmus (#2000)
Browse files Browse the repository at this point in the history
  • Loading branch information
meyer9 authored Jan 16, 2025
1 parent b88b720 commit 26f0cf8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
4 changes: 3 additions & 1 deletion crates/revm/src/optimism/handler_register.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,9 @@ pub fn reimburse_caller<SPEC: Spec, EXT, DB: Database>(
/// Load precompiles for Optimism chain.
#[inline]
pub fn load_precompiles<SPEC: Spec, EXT, DB: Database>() -> ContextPrecompiles<DB> {
if SPEC::enabled(SpecId::GRANITE) {
if SPEC::enabled(SpecId::ISTHMUS) {
ContextPrecompiles::from_static_precompiles(optimism::precompile::isthmus())
} else if SPEC::enabled(SpecId::GRANITE) {
ContextPrecompiles::from_static_precompiles(optimism::precompile::granite())
} else if SPEC::enabled(SpecId::FJORD) {
ContextPrecompiles::from_static_precompiles(optimism::precompile::fjord())
Expand Down
20 changes: 20 additions & 0 deletions crates/revm/src/optimism/precompile.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use once_cell::race::OnceBox;
#[cfg(feature = "blst")]
use revm_precompile::bls12_381;
use revm_precompile::{secp256r1, Precompiles};
use std::boxed::Box;

Expand Down Expand Up @@ -31,3 +33,21 @@ pub(crate) fn granite() -> &'static Precompiles {
Box::new(precompiles)
})
}

/// Returns precompiles for isthmus
pub(crate) fn isthmus() -> &'static Self {
static INSTANCE: OnceBox<Precompiles> = OnceBox::new();
INSTANCE.get_or_init(|| {
let precompiles = Self::cancun().clone();

// Don't include BLS12-381 precompiles in no_std builds.
#[cfg(feature = "blst")]
let precompiles = {
let mut precompiles = precompiles;
precompiles.extend(bls12_381::precompiles());
precompiles
};

Box::new(precompiles)
})
}

0 comments on commit 26f0cf8

Please sign in to comment.