Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(optimism): implement BLS precompiles for isthmus #2000

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
})
}