From e4db8dab99387b6c21f18cedf0e14ab6a8c10774 Mon Sep 17 00:00:00 2001 From: yutianwu Date: Thu, 5 Sep 2024 15:05:11 +0800 Subject: [PATCH 1/6] feat: update order of the hardforks --- crates/precompile/src/lib.rs | 4 +++- crates/revm/src/optimism/handler_register.rs | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/precompile/src/lib.rs b/crates/precompile/src/lib.rs index cb476d3f..f6465a69 100644 --- a/crates/precompile/src/lib.rs +++ b/crates/precompile/src/lib.rs @@ -486,13 +486,15 @@ impl PrecompileSpecId { #[cfg(feature = "optimism")] BEDROCK | REGOLITH | CANYON => Self::BERLIN, #[cfg(feature = "optimism")] - ECOTONE | FJORD => Self::CANCUN, + ECOTONE => Self::CANCUN, #[cfg(feature = "opbnb")] FERMAT => Self::FERMAT, #[cfg(any(feature = "bsc", feature = "opbnb"))] HABER => Self::HABER, #[cfg(feature = "opbnb")] WRIGHT => Self::HABER, + #[cfg(feature = "opbnb")] + FJORD => Self::HABER, #[cfg(feature = "bsc")] HABER_FIX => Self::HABER, #[cfg(feature = "bsc")] diff --git a/crates/revm/src/optimism/handler_register.rs b/crates/revm/src/optimism/handler_register.rs index 6098dc73..a19d7729 100644 --- a/crates/revm/src/optimism/handler_register.rs +++ b/crates/revm/src/optimism/handler_register.rs @@ -149,7 +149,7 @@ pub fn last_frame_return( pub fn load_precompiles() -> ContextPrecompiles { let mut precompiles = ContextPrecompiles::new(PrecompileSpecId::from_spec_id(SPEC::SPEC_ID)); - if SPEC::enabled(SpecId::FJORD) { + if SPEC::enabled(SpecId::FJORD) || SPEC::enabled(SpecId::HABER) { precompiles.extend([ // EIP-7212: secp256r1 P256verify secp256r1::P256VERIFY, From 2a51505c2c550a2e445feff3d2e5d72f599ed4b6 Mon Sep 17 00:00:00 2001 From: yutianwu Date: Thu, 5 Sep 2024 15:18:06 +0800 Subject: [PATCH 2/6] compatible with optimims --- crates/precompile/src/lib.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/precompile/src/lib.rs b/crates/precompile/src/lib.rs index f6465a69..c883ca8d 100644 --- a/crates/precompile/src/lib.rs +++ b/crates/precompile/src/lib.rs @@ -46,6 +46,7 @@ use cfg_if::cfg_if; use core::hash::Hash; use once_cell::race::OnceBox; use std::{boxed::Box, vec::Vec}; +use revm_primitives::{ECOTONE, FJORD}; pub fn calc_linear_cost_u32(len: usize, base: u64, word: u64) -> u64 { (len as u64 + 32 - 1) / 32 * word + base @@ -485,7 +486,9 @@ impl PrecompileSpecId { PRAGUE | PRAGUE_EOF => Self::PRAGUE, #[cfg(feature = "optimism")] BEDROCK | REGOLITH | CANYON => Self::BERLIN, - #[cfg(feature = "optimism")] + #[cfg(all(feature = "optimism", not(feature = "opbnb")))] + ECOTONE | FJORD=> Self::CANCUN, + #[cfg(all(feature = "optimism", feature = "opbnb"))] ECOTONE => Self::CANCUN, #[cfg(feature = "opbnb")] FERMAT => Self::FERMAT, @@ -493,7 +496,7 @@ impl PrecompileSpecId { HABER => Self::HABER, #[cfg(feature = "opbnb")] WRIGHT => Self::HABER, - #[cfg(feature = "opbnb")] + #[cfg(all(feature = "optimism", feature = "opbnb"))] FJORD => Self::HABER, #[cfg(feature = "bsc")] HABER_FIX => Self::HABER, From 907223093edf2a3863393a90d01f39a5d8bebdc5 Mon Sep 17 00:00:00 2001 From: yutianwu Date: Fri, 6 Sep 2024 10:10:26 +0800 Subject: [PATCH 3/6] fix ci --- crates/precompile/src/lib.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/precompile/src/lib.rs b/crates/precompile/src/lib.rs index c883ca8d..a214d9f9 100644 --- a/crates/precompile/src/lib.rs +++ b/crates/precompile/src/lib.rs @@ -46,7 +46,6 @@ use cfg_if::cfg_if; use core::hash::Hash; use once_cell::race::OnceBox; use std::{boxed::Box, vec::Vec}; -use revm_primitives::{ECOTONE, FJORD}; pub fn calc_linear_cost_u32(len: usize, base: u64, word: u64) -> u64 { (len as u64 + 32 - 1) / 32 * word + base @@ -487,7 +486,7 @@ impl PrecompileSpecId { #[cfg(feature = "optimism")] BEDROCK | REGOLITH | CANYON => Self::BERLIN, #[cfg(all(feature = "optimism", not(feature = "opbnb")))] - ECOTONE | FJORD=> Self::CANCUN, + ECOTONE | FJORD => Self::CANCUN, #[cfg(all(feature = "optimism", feature = "opbnb"))] ECOTONE => Self::CANCUN, #[cfg(feature = "opbnb")] From bf12cf6f37db335e4f24f635f93e69de0d15f07e Mon Sep 17 00:00:00 2001 From: yutianwu Date: Fri, 6 Sep 2024 10:35:20 +0800 Subject: [PATCH 4/6] fix ci --- crates/interpreter/src/function_stack.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/interpreter/src/function_stack.rs b/crates/interpreter/src/function_stack.rs index e6482d8e..7851add1 100644 --- a/crates/interpreter/src/function_stack.rs +++ b/crates/interpreter/src/function_stack.rs @@ -51,9 +51,8 @@ impl FunctionStack { /// Pops a frame from the stack and sets current_code_idx to the popped frame's idx. pub fn pop(&mut self) -> Option { - self.return_stack.pop().map(|frame| { + self.return_stack.pop().inspect(|frame| { self.current_code_idx = frame.idx; - frame }) } From 47ac5e0672bd37e73bf9c1c7a038142b3695cb29 Mon Sep 17 00:00:00 2001 From: yutianwu Date: Fri, 6 Sep 2024 10:39:52 +0800 Subject: [PATCH 5/6] fix ci --- crates/revm/src/evm.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/crates/revm/src/evm.rs b/crates/revm/src/evm.rs index a7ceec6b..47c1b3c9 100644 --- a/crates/revm/src/evm.rs +++ b/crates/revm/src/evm.rs @@ -199,9 +199,8 @@ impl Evm<'_, EXT, DB> { .handler .validation() .initial_tx_gas(&self.context.evm.env) - .map_err(|e| { + .inspect_err(|e| { self.clear(); - e })?; let output = self.transact_preverified_inner(initial_gas_spend); let output = self.handler.post_execution().end(&mut self.context, output); @@ -228,9 +227,8 @@ impl Evm<'_, EXT, DB> { /// This function will validate the transaction. #[inline] pub fn transact(&mut self) -> EVMResult { - let initial_gas_spend = self.preverify_transaction_inner().map_err(|e| { + let initial_gas_spend = self.preverify_transaction_inner().inspect_err(|e| { self.clear(); - e })?; let output = self.transact_preverified_inner(initial_gas_spend); From ae0c348ba369ca386b84cdd3a9b228e2646fd09b Mon Sep 17 00:00:00 2001 From: yutianwu Date: Fri, 6 Sep 2024 10:45:14 +0800 Subject: [PATCH 6/6] fix ci --- crates/revm/src/evm.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/revm/src/evm.rs b/crates/revm/src/evm.rs index 47c1b3c9..1c45187e 100644 --- a/crates/revm/src/evm.rs +++ b/crates/revm/src/evm.rs @@ -199,7 +199,7 @@ impl Evm<'_, EXT, DB> { .handler .validation() .initial_tx_gas(&self.context.evm.env) - .inspect_err(|e| { + .inspect_err(|_| { self.clear(); })?; let output = self.transact_preverified_inner(initial_gas_spend); @@ -227,7 +227,7 @@ impl Evm<'_, EXT, DB> { /// This function will validate the transaction. #[inline] pub fn transact(&mut self) -> EVMResult { - let initial_gas_spend = self.preverify_transaction_inner().inspect_err(|e| { + let initial_gas_spend = self.preverify_transaction_inner().inspect_err(|_| { self.clear(); })?;