Skip to content
Merged
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
19 changes: 17 additions & 2 deletions crates/precompile/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ impl Precompiles {
PrecompileSpecId::ISTANBUL => Self::istanbul(),
PrecompileSpecId::BERLIN => Self::berlin(),
PrecompileSpecId::CANCUN => Self::cancun(),
PrecompileSpecId::PRAGUE => Self::prague(),
PrecompileSpecId::LATEST => Self::latest(),
}
}
Expand Down Expand Up @@ -154,9 +155,21 @@ impl Precompiles {
})
}

/// Returns precompiles for Prague spec.
pub fn prague() -> &'static Self {
static INSTANCE: OnceBox<Precompiles> = OnceBox::new();
INSTANCE.get_or_init(|| {
let precompiles = Self::cancun().clone();
// EIP-2537: Precompile for BLS12-381 curve operations
// TODO(alexey): add BLS12-381 precompiles
// precompiles.extend(bls12_381::precompiles());
Box::new(precompiles)
})
}

/// Returns the precompiles for the latest spec.
pub fn latest() -> &'static Self {
Self::cancun()
Self::prague()
}

/// Returns an iterator over the precompiles addresses.
Expand Down Expand Up @@ -229,6 +242,7 @@ pub enum PrecompileSpecId {
ISTANBUL,
BERLIN,
CANCUN,
PRAGUE,
LATEST,
}

Expand All @@ -243,7 +257,8 @@ impl PrecompileSpecId {
BYZANTIUM | CONSTANTINOPLE | PETERSBURG => Self::BYZANTIUM,
ISTANBUL | MUIR_GLACIER => Self::ISTANBUL,
BERLIN | LONDON | ARROW_GLACIER | GRAY_GLACIER | MERGE | SHANGHAI => Self::BERLIN,
CANCUN | PRAGUE => Self::CANCUN,
CANCUN => Self::CANCUN,
PRAGUE => Self::PRAGUE,
LATEST => Self::LATEST,
#[cfg(feature = "optimism")]
BEDROCK | REGOLITH | CANYON => Self::BERLIN,
Expand Down