From 8c17ce778c4e945f7e45e7ac4558a6c18da412c5 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Mon, 13 May 2024 11:03:59 +0300 Subject: [PATCH 1/2] fix(primitives): specify the optimism cfg on spec_to_generic (#1412) --- crates/primitives/src/specification.rs | 73 ++++++++++++++++++++++++-- 1 file changed, 68 insertions(+), 5 deletions(-) diff --git a/crates/primitives/src/specification.rs b/crates/primitives/src/specification.rs index fbd8d22abc..52abf9ecba 100644 --- a/crates/primitives/src/specification.rs +++ b/crates/primitives/src/specification.rs @@ -208,10 +208,77 @@ spec!(CANYON, CanyonSpec); #[cfg(feature = "optimism")] spec!(ECOTONE, EcotoneSpec); +#[cfg(not(feature = "optimism"))] +#[macro_export] +macro_rules! spec_to_generic { + ($spec_id:expr, $e:expr) => {{ + match $spec_id { + $crate::SpecId::FRONTIER | SpecId::FRONTIER_THAWING => { + use $crate::FrontierSpec as SPEC; + $e + } + $crate::SpecId::HOMESTEAD | SpecId::DAO_FORK => { + use $crate::HomesteadSpec as SPEC; + $e + } + $crate::SpecId::TANGERINE => { + use $crate::TangerineSpec as SPEC; + $e + } + $crate::SpecId::SPURIOUS_DRAGON => { + use $crate::SpuriousDragonSpec as SPEC; + $e + } + $crate::SpecId::BYZANTIUM => { + use $crate::ByzantiumSpec as SPEC; + $e + } + $crate::SpecId::PETERSBURG | $crate::SpecId::CONSTANTINOPLE => { + use $crate::PetersburgSpec as SPEC; + $e + } + $crate::SpecId::ISTANBUL | $crate::SpecId::MUIR_GLACIER => { + use $crate::IstanbulSpec as SPEC; + $e + } + $crate::SpecId::BERLIN => { + use $crate::BerlinSpec as SPEC; + $e + } + $crate::SpecId::LONDON + | $crate::SpecId::ARROW_GLACIER + | $crate::SpecId::GRAY_GLACIER => { + use $crate::LondonSpec as SPEC; + $e + } + $crate::SpecId::MERGE => { + use $crate::MergeSpec as SPEC; + $e + } + $crate::SpecId::SHANGHAI => { + use $crate::ShanghaiSpec as SPEC; + $e + } + $crate::SpecId::CANCUN => { + use $crate::CancunSpec as SPEC; + $e + } + $crate::SpecId::LATEST => { + use $crate::LatestSpec as SPEC; + $e + } + $crate::SpecId::PRAGUE => { + use $crate::PragueSpec as SPEC; + $e + } + } + }}; +} + +#[cfg(feature = "optimism")] #[macro_export] macro_rules! spec_to_generic { ($spec_id:expr, $e:expr) => {{ - // We are transitioning from var to generic spec. match $spec_id { $crate::SpecId::FRONTIER | SpecId::FRONTIER_THAWING => { use $crate::FrontierSpec as SPEC; @@ -271,22 +338,18 @@ macro_rules! spec_to_generic { use $crate::PragueSpec as SPEC; $e } - #[cfg(feature = "optimism")] $crate::SpecId::BEDROCK => { use $crate::BedrockSpec as SPEC; $e } - #[cfg(feature = "optimism")] $crate::SpecId::REGOLITH => { use $crate::RegolithSpec as SPEC; $e } - #[cfg(feature = "optimism")] $crate::SpecId::CANYON => { use $crate::CanyonSpec as SPEC; $e } - #[cfg(feature = "optimism")] $crate::SpecId::ECOTONE => { use $crate::EcotoneSpec as SPEC; $e From 79dc955df9f1bc02341171ab1f7cc39428a472e8 Mon Sep 17 00:00:00 2001 From: rakita Date: Mon, 13 May 2024 17:21:07 +0300 Subject: [PATCH 2/2] chore(EOF): rename extcall opcode/names --- crates/interpreter/src/instructions/contract.rs | 4 ++-- crates/interpreter/src/opcode.rs | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/interpreter/src/instructions/contract.rs b/crates/interpreter/src/instructions/contract.rs index c3f701f28a..4797d72a3c 100644 --- a/crates/interpreter/src/instructions/contract.rs +++ b/crates/interpreter/src/instructions/contract.rs @@ -314,7 +314,7 @@ pub fn extcall(interpreter: &mut Interpreter, host interpreter.instruction_result = InstructionResult::CallOrCreate; } -pub fn extdcall(interpreter: &mut Interpreter, host: &mut H) { +pub fn extdelegatecall(interpreter: &mut Interpreter, host: &mut H) { require_eof!(interpreter); pop_address!(interpreter, target_address); @@ -347,7 +347,7 @@ pub fn extdcall(interpreter: &mut Interpreter, hos interpreter.instruction_result = InstructionResult::CallOrCreate; } -pub fn extscall(interpreter: &mut Interpreter, host: &mut H) { +pub fn extstaticcall(interpreter: &mut Interpreter, host: &mut H) { require_eof!(interpreter); pop_address!(interpreter, target_address); diff --git a/crates/interpreter/src/opcode.rs b/crates/interpreter/src/opcode.rs index 5114c2ae19..e2163ed68f 100644 --- a/crates/interpreter/src/opcode.rs +++ b/crates/interpreter/src/opcode.rs @@ -769,11 +769,11 @@ opcodes! { 0xF4 => DELEGATECALL => contract::delegate_call:: => stack_io(6, 1), not_eof; 0xF5 => CREATE2 => contract::create:: => stack_io(4, 1), not_eof; // 0xF6 - 0xF7 => RETURNDATALOAD => system::returndataload => stack_io(1, 1); - 0xF8 => EXTCALL => contract::extcall:: => stack_io(4, 1); - 0xF9 => EXFCALL => contract::extdcall:: => stack_io(3, 1); - 0xFA => STATICCALL => contract::static_call:: => stack_io(6, 1), not_eof; - 0xFB => EXTSCALL => contract::extscall => stack_io(3, 1); + 0xF7 => RETURNDATALOAD => system::returndataload => stack_io(1, 1); + 0xF8 => EXTCALL => contract::extcall:: => stack_io(4, 1); + 0xF9 => EXTDELEGATECALL => contract::extdelegatecall:: => stack_io(3, 1); + 0xFA => STATICCALL => contract::static_call:: => stack_io(6, 1), not_eof; + 0xFB => EXTSTATICCALL => contract::extstaticcall => stack_io(3, 1); // 0xFC 0xFD => REVERT => control::revert:: => stack_io(2, 0), terminating; 0xFE => INVALID => control::invalid => stack_io(0, 0), terminating;