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(precompile): add Prague hardfork specification #1387

Merged
merged 1 commit into from
May 8, 2024
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
Loading