Skip to content

Commit 26f0cf8

Browse files
authored
feat: add precompiles for BLS12-381 to isthmus (#2000)
1 parent b88b720 commit 26f0cf8

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

crates/revm/src/optimism/handler_register.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,9 @@ pub fn reimburse_caller<SPEC: Spec, EXT, DB: Database>(
310310
/// Load precompiles for Optimism chain.
311311
#[inline]
312312
pub fn load_precompiles<SPEC: Spec, EXT, DB: Database>() -> ContextPrecompiles<DB> {
313-
if SPEC::enabled(SpecId::GRANITE) {
313+
if SPEC::enabled(SpecId::ISTHMUS) {
314+
ContextPrecompiles::from_static_precompiles(optimism::precompile::isthmus())
315+
} else if SPEC::enabled(SpecId::GRANITE) {
314316
ContextPrecompiles::from_static_precompiles(optimism::precompile::granite())
315317
} else if SPEC::enabled(SpecId::FJORD) {
316318
ContextPrecompiles::from_static_precompiles(optimism::precompile::fjord())

crates/revm/src/optimism/precompile.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
use once_cell::race::OnceBox;
2+
#[cfg(feature = "blst")]
3+
use revm_precompile::bls12_381;
24
use revm_precompile::{secp256r1, Precompiles};
35
use std::boxed::Box;
46

@@ -31,3 +33,21 @@ pub(crate) fn granite() -> &'static Precompiles {
3133
Box::new(precompiles)
3234
})
3335
}
36+
37+
/// Returns precompiles for isthmus
38+
pub(crate) fn isthmus() -> &'static Self {
39+
static INSTANCE: OnceBox<Precompiles> = OnceBox::new();
40+
INSTANCE.get_or_init(|| {
41+
let precompiles = Self::cancun().clone();
42+
43+
// Don't include BLS12-381 precompiles in no_std builds.
44+
#[cfg(feature = "blst")]
45+
let precompiles = {
46+
let mut precompiles = precompiles;
47+
precompiles.extend(bls12_381::precompiles());
48+
precompiles
49+
};
50+
51+
Box::new(precompiles)
52+
})
53+
}

0 commit comments

Comments
 (0)