diff --git a/crates/precompile/src/lib.rs b/crates/precompile/src/lib.rs index 6d8796e2..cb476d3f 100644 --- a/crates/precompile/src/lib.rs +++ b/crates/precompile/src/lib.rs @@ -491,6 +491,8 @@ impl PrecompileSpecId { FERMAT => Self::FERMAT, #[cfg(any(feature = "bsc", feature = "opbnb"))] HABER => Self::HABER, + #[cfg(feature = "opbnb")] + WRIGHT => Self::HABER, #[cfg(feature = "bsc")] HABER_FIX => Self::HABER, #[cfg(feature = "bsc")] diff --git a/crates/primitives/src/specification.rs b/crates/primitives/src/specification.rs index 161382be..9976a2d0 100644 --- a/crates/primitives/src/specification.rs +++ b/crates/primitives/src/specification.rs @@ -69,9 +69,10 @@ pub enum SpecId { CANCUN = 21, ECOTONE = 22, HABER = 23, - FJORD = 24, - PRAGUE = 25, - PRAGUE_EOF = 26, + WRIGHT = 24, + FJORD = 25, + PRAGUE = 26, + PRAGUE_EOF = 27, #[default] LATEST = u8::MAX, } @@ -216,6 +217,8 @@ impl From<&str> for SpecId { "HaberFix" => SpecId::HABER_FIX, #[cfg(feature = "bsc")] "Bohr" => SpecId::BOHR, + #[cfg(feature = "opbnb")] + "Wright" => SpecId::WRIGHT, _ => Self::LATEST, } } @@ -290,6 +293,8 @@ impl From for &'static str { SpecId::FEYNMAN_FIX => "FeynmanFix", #[cfg(any(feature = "opbnb", feature = "bsc"))] SpecId::HABER => "Haber", + #[cfg(feature = "opbnb")] + SpecId::WRIGHT => "Wright", #[cfg(feature = "bsc")] SpecId::HABER_FIX => "HaberFix", #[cfg(feature = "bsc")] @@ -377,7 +382,8 @@ spec!(ECOTONE, EcotoneSpec); spec!(FJORD, FjordSpec); #[cfg(feature = "opbnb")] spec!(FERMAT, FermatSpec); - +#[cfg(feature = "opbnb")] +spec!(WRIGHT, WrightSpec); #[cfg(all(not(feature = "optimism"), not(feature = "bsc")))] #[macro_export] macro_rules! spec_to_generic { @@ -542,6 +548,11 @@ macro_rules! spec_to_generic { use $crate::HaberSpec as SPEC; $e } + #[cfg(feature = "opbnb")] + $crate::SpecId::WRIGHT => { + use $crate::WrightSpec as SPEC; + $e + } $crate::SpecId::FJORD => { use $crate::FjordSpec as SPEC; $e diff --git a/crates/revm/src/optimism/handler_register.rs b/crates/revm/src/optimism/handler_register.rs index 348b9cf7..6098dc73 100644 --- a/crates/revm/src/optimism/handler_register.rs +++ b/crates/revm/src/optimism/handler_register.rs @@ -10,7 +10,7 @@ use crate::{ primitives::{ db::Database, spec_to_generic, Account, EVMError, Env, ExecutionResult, HaltReason, HashMap, InvalidTransaction, OptimismInvalidTransaction, ResultAndState, Spec, SpecId, - SpecId::REGOLITH, U256, + SpecId::REGOLITH, SpecId::WRIGHT, U256, }, Context, ContextPrecompiles, FrameResult, }; @@ -211,13 +211,18 @@ pub fn deduct_caller( )); }; - let tx_l1_cost = context - .evm - .inner - .l1_block_info - .as_ref() - .expect("L1BlockInfo should be loaded") - .calculate_tx_l1_cost(enveloped_tx, SPEC::SPEC_ID); + let tx_l1_cost = if context.evm.inner.env.tx.gas_price.is_zero() && SPEC::enabled(WRIGHT) { + U256::ZERO + } else { + context + .evm + .inner + .l1_block_info + .as_ref() + .expect("L1BlockInfo should be loaded") + .calculate_tx_l1_cost(enveloped_tx, SPEC::SPEC_ID) + }; + if tx_l1_cost.gt(&caller_account.info.balance) { return Err(EVMError::Transaction( InvalidTransaction::LackOfFundForMaxFee { @@ -259,7 +264,11 @@ pub fn reward_beneficiary( )); }; - let l1_cost = l1_block_info.calculate_tx_l1_cost(enveloped_tx, SPEC::SPEC_ID); + let l1_cost = if context.evm.inner.env.tx.gas_price.is_zero() && SPEC::enabled(WRIGHT) { + U256::ZERO + } else { + l1_block_info.calculate_tx_l1_cost(enveloped_tx, SPEC::SPEC_ID) + }; // Send the L1 cost of the transaction to the L1 Fee Vault. let (l1_fee_vault_account, _) = context