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 new L1 cost function for Fjord #1420

Merged
merged 15 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from 14 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
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/precompile/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ impl PrecompileSpecId {
#[cfg(feature = "optimism")]
BEDROCK | REGOLITH | CANYON => Self::BERLIN,
#[cfg(feature = "optimism")]
ECOTONE => Self::CANCUN,
ECOTONE | FJORD => Self::CANCUN,
}
}
}
Expand Down
41 changes: 41 additions & 0 deletions crates/primitives/src/specification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ pub enum SpecId {
CANCUN = 20,
ECOTONE = 21,
PRAGUE = 22,
FJORD = 23,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should FJORD be after or before PRAGUE? In secp256r1 precompile PR it was before.

Copy link
Member

@rakita rakita May 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have put FJORD before PRAGUE as Prague is still not activated

#[default]
LATEST = u8::MAX,
}
Expand Down Expand Up @@ -114,6 +115,8 @@ impl From<&str> for SpecId {
"Canyon" => SpecId::CANYON,
#[cfg(feature = "optimism")]
"Ecotone" => SpecId::ECOTONE,
#[cfg(feature = "optimism")]
"Fjord" => SpecId::FJORD,
_ => Self::LATEST,
}
}
Expand Down Expand Up @@ -149,6 +152,8 @@ impl From<SpecId> for &'static str {
SpecId::CANYON => "Canyon",
#[cfg(feature = "optimism")]
SpecId::ECOTONE => "Ecotone",
#[cfg(feature = "optimism")]
SpecId::FJORD => "Fjord",
SpecId::LATEST => "Latest",
}
}
Expand Down Expand Up @@ -207,6 +212,8 @@ spec!(REGOLITH, RegolithSpec);
spec!(CANYON, CanyonSpec);
#[cfg(feature = "optimism")]
spec!(ECOTONE, EcotoneSpec);
#[cfg(feature = "optimism")]
spec!(FJORD, FjordSpec);

#[cfg(not(feature = "optimism"))]
#[macro_export]
Expand Down Expand Up @@ -354,6 +361,10 @@ macro_rules! spec_to_generic {
use $crate::EcotoneSpec as SPEC;
$e
}
$crate::SpecId::FJORD => {
use $crate::FjordSpec as SPEC;
$e
}
}
}};
}
Expand Down Expand Up @@ -390,7 +401,11 @@ mod tests {
#[cfg(feature = "optimism")]
spec_to_generic!(CANYON, assert_eq!(SPEC::SPEC_ID, CANYON));
spec_to_generic!(CANCUN, assert_eq!(SPEC::SPEC_ID, CANCUN));
#[cfg(feature = "optimism")]
spec_to_generic!(ECOTONE, assert_eq!(SPEC::SPEC_ID, ECOTONE));
spec_to_generic!(PRAGUE, assert_eq!(SPEC::SPEC_ID, PRAGUE));
#[cfg(feature = "optimism")]
spec_to_generic!(FJORD, assert_eq!(SPEC::SPEC_ID, FJORD));
spec_to_generic!(LATEST, assert_eq!(SPEC::SPEC_ID, LATEST));
}
}
Expand Down Expand Up @@ -485,4 +500,30 @@ mod optimism_tests {
assert!(SpecId::enabled(SpecId::ECOTONE, SpecId::CANYON));
assert!(SpecId::enabled(SpecId::ECOTONE, SpecId::ECOTONE));
}

#[test]
fn test_fjord_post_merge_hardforks() {
assert!(FjordSpec::enabled(SpecId::MERGE));
assert!(FjordSpec::enabled(SpecId::SHANGHAI));
assert!(FjordSpec::enabled(SpecId::CANCUN));
assert!(!FjordSpec::enabled(SpecId::LATEST));
assert!(FjordSpec::enabled(SpecId::BEDROCK));
assert!(FjordSpec::enabled(SpecId::REGOLITH));
assert!(FjordSpec::enabled(SpecId::CANYON));
assert!(FjordSpec::enabled(SpecId::ECOTONE));
assert!(FjordSpec::enabled(SpecId::FJORD));
}

#[test]
fn test_fjord_post_merge_hardforks_spec_id() {
assert!(SpecId::enabled(SpecId::FJORD, SpecId::MERGE));
assert!(SpecId::enabled(SpecId::FJORD, SpecId::SHANGHAI));
assert!(SpecId::enabled(SpecId::FJORD, SpecId::CANCUN));
assert!(!SpecId::enabled(SpecId::FJORD, SpecId::LATEST));
assert!(SpecId::enabled(SpecId::FJORD, SpecId::BEDROCK));
assert!(SpecId::enabled(SpecId::FJORD, SpecId::REGOLITH));
assert!(SpecId::enabled(SpecId::FJORD, SpecId::CANYON));
assert!(SpecId::enabled(SpecId::FJORD, SpecId::ECOTONE));
assert!(SpecId::enabled(SpecId::FJORD, SpecId::FJORD));
}
}
1 change: 1 addition & 0 deletions crates/revm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ anyhow = "1.0.83"
criterion = "0.5"
indicatif = "0.17"
reqwest = { version = "0.12" }
rstest = "0.19.0"

alloy-provider = { git = "https://github.com/alloy-rs/alloy.git", rev = "44b8a6d", default-features = false, features = [
"reqwest",
Expand Down
1 change: 1 addition & 0 deletions crates/revm/src/optimism.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Optimism-specific constants, types, and helpers.

mod fast_lz;
mod handler_register;
mod l1block;

Expand Down
Loading
Loading