From 36cfd96ca5f1de94781ad269c43b0e9866c3a8d0 Mon Sep 17 00:00:00 2001 From: j75689 Date: Mon, 3 Jun 2024 18:57:57 +0800 Subject: [PATCH] feat: introduce Haber fork into opBNB testnet --- Cargo.lock | 30 +++++++++++++++++++++++---- Cargo.toml | 4 ++-- crates/ethereum-forks/src/hardfork.rs | 5 +++++ crates/primitives/src/chain/spec.rs | 1 + crates/primitives/src/revm/config.rs | 8 +++++-- 5 files changed, 40 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 289d2e9b8f..22dd5abf93 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5734,6 +5734,18 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" +[[package]] +name = "p256" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9863ad85fa8f4460f9c48cb909d38a0d689dba1f6f6988a5e3e0d31071bcd4b" +dependencies = [ + "ecdsa", + "elliptic-curve", + "primeorder", + "sha2 0.10.8", +] + [[package]] name = "page_size" version = "0.6.0" @@ -6170,6 +6182,15 @@ dependencies = [ "syn 2.0.65", ] +[[package]] +name = "primeorder" +version = "0.13.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "353e1ca18966c16d9deb1c69278edbc5f194139612772bd9537af60ac231e1e6" +dependencies = [ + "elliptic-curve", +] + [[package]] name = "primitive-types" version = "0.12.2" @@ -8383,7 +8404,7 @@ dependencies = [ [[package]] name = "revm" version = "8.0.0" -source = "git+https://github.com/bnb-chain/revm.git?rev=deb253b#deb253b578e40130daaf4fb0243244cbb56baf6e" +source = "git+https://github.com/bnb-chain/revm.git?rev=2f38e6c#2f38e6c6f82c8c664e4302cadde0df68f6b4cfbf" dependencies = [ "auto_impl", "cfg-if", @@ -8415,7 +8436,7 @@ dependencies = [ [[package]] name = "revm-interpreter" version = "4.0.0" -source = "git+https://github.com/bnb-chain/revm.git?rev=deb253b#deb253b578e40130daaf4fb0243244cbb56baf6e" +source = "git+https://github.com/bnb-chain/revm.git?rev=2f38e6c#2f38e6c6f82c8c664e4302cadde0df68f6b4cfbf" dependencies = [ "revm-primitives", "serde", @@ -8424,7 +8445,7 @@ dependencies = [ [[package]] name = "revm-precompile" version = "6.0.0" -source = "git+https://github.com/bnb-chain/revm.git?rev=deb253b#deb253b578e40130daaf4fb0243244cbb56baf6e" +source = "git+https://github.com/bnb-chain/revm.git?rev=2f38e6c#2f38e6c6f82c8c664e4302cadde0df68f6b4cfbf" dependencies = [ "aurora-engine-modexp", "bls_on_arkworks", @@ -8435,6 +8456,7 @@ dependencies = [ "cometbft-proto", "k256", "once_cell", + "p256", "prost", "revm-primitives", "ripemd", @@ -8446,7 +8468,7 @@ dependencies = [ [[package]] name = "revm-primitives" version = "3.1.1" -source = "git+https://github.com/bnb-chain/revm.git?rev=deb253b#deb253b578e40130daaf4fb0243244cbb56baf6e" +source = "git+https://github.com/bnb-chain/revm.git?rev=2f38e6c#2f38e6c6f82c8c664e4302cadde0df68f6b4cfbf" dependencies = [ "alloy-primitives", "auto_impl", diff --git a/Cargo.toml b/Cargo.toml index 5f1620b559..60a4c30ca2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -401,6 +401,6 @@ similar-asserts = "1.5.0" test-fuzz = "5" [patch.crates-io] -revm = { git = "https://github.com/bnb-chain/revm.git", rev = "deb253b" } -revm-primitives = { git = "https://github.com/bnb-chain/revm.git", rev = "deb253b" } +revm = { git = "https://github.com/bnb-chain/revm.git", rev = "2f38e6c" } +revm-primitives = { git = "https://github.com/bnb-chain/revm.git", rev = "2f38e6c" } alloy-chains = { git = "https://github.com/alloy-rs/chains.git", rev = "906d6fb" } diff --git a/crates/ethereum-forks/src/hardfork.rs b/crates/ethereum-forks/src/hardfork.rs index 22ebb40f26..ec4664c0cf 100644 --- a/crates/ethereum-forks/src/hardfork.rs +++ b/crates/ethereum-forks/src/hardfork.rs @@ -74,6 +74,9 @@ pub enum Hardfork { /// Fermat #[cfg(all(feature = "optimism", feature = "opbnb"))] Fermat, + /// Haber + #[cfg(all(feature = "optimism", feature = "opbnb"))] + Haber, // ArbOS20Atlas, // Upcoming @@ -564,6 +567,8 @@ impl FromStr for Hardfork { "precontractforkblock" => Hardfork::PreContractForkBlock, #[cfg(all(feature = "optimism", feature = "opbnb"))] "fermat" => Hardfork::Fermat, + #[cfg(all(feature = "optimism", feature = "opbnb"))] + "haber" => Hardfork::Haber, #[cfg(feature = "optimism")] "canyon" => Hardfork::Canyon, #[cfg(feature = "optimism")] diff --git a/crates/primitives/src/chain/spec.rs b/crates/primitives/src/chain/spec.rs index 6c6ebca361..d7eb3ba110 100644 --- a/crates/primitives/src/chain/spec.rs +++ b/crates/primitives/src/chain/spec.rs @@ -530,6 +530,7 @@ pub static OPBNB_TESTNET: Lazy> = Lazy::new(|| { (Hardfork::Canyon, ForkCondition::Timestamp(1715753400)), (Hardfork::Cancun, ForkCondition::Timestamp(1715754600)), (Hardfork::Ecotone, ForkCondition::Timestamp(1715754600)), + (Hardfork::Haber, ForkCondition::Timestamp(1717048800)), ]), base_fee_params: BaseFeeParamsKind::Variable( vec![(Hardfork::London, BaseFeeParams::ethereum())].into(), diff --git a/crates/primitives/src/revm/config.rs b/crates/primitives/src/revm/config.rs index 2fe8111a60..ad44b79ad1 100644 --- a/crates/primitives/src/revm/config.rs +++ b/crates/primitives/src/revm/config.rs @@ -10,7 +10,9 @@ pub fn revm_spec_by_timestamp_after_merge( ) -> revm_primitives::SpecId { #[cfg(feature = "optimism")] if chain_spec.is_optimism() { - return if chain_spec.fork(Hardfork::Ecotone).active_at_timestamp(timestamp) { + return if chain_spec.fork(Hardfork::Haber).active_at_timestamp(timestamp) { + revm_primitives::HABER + } else if chain_spec.fork(Hardfork::Ecotone).active_at_timestamp(timestamp) { revm_primitives::ECOTONE } else if chain_spec.fork(Hardfork::Canyon).active_at_timestamp(timestamp) { revm_primitives::CANYON @@ -36,7 +38,9 @@ pub fn revm_spec_by_timestamp_after_merge( pub fn revm_spec(chain_spec: &ChainSpec, block: Head) -> revm_primitives::SpecId { #[cfg(feature = "optimism")] if chain_spec.is_optimism() { - if chain_spec.fork(Hardfork::Ecotone).active_at_head(&block) { + if chain_spec.fork(Hardfork::Haber).active_at_head(&block) { + return revm_primitives::HABER + } else if chain_spec.fork(Hardfork::Ecotone).active_at_head(&block) { return revm_primitives::ECOTONE } else if chain_spec.fork(Hardfork::Canyon).active_at_head(&block) { return revm_primitives::CANYON