Skip to content

Commit

Permalink
fix: make macro crate-agnostic (#1802)
Browse files Browse the repository at this point in the history
* fix: make macro crate-agnostic

* fix: clippy
  • Loading branch information
Wodann authored Sep 25, 2024
1 parent 30c9199 commit e477c7f
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 44 deletions.
80 changes: 40 additions & 40 deletions crates/interpreter/src/instruction_result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,58 +151,58 @@ impl From<HaltReason> for InstructionResult {
#[macro_export]
macro_rules! return_ok {
() => {
InstructionResult::Continue
| InstructionResult::Stop
| InstructionResult::Return
| InstructionResult::SelfDestruct
| InstructionResult::ReturnContract
$crate::InstructionResult::Continue
| $crate::InstructionResult::Stop
| $crate::InstructionResult::Return
| $crate::InstructionResult::SelfDestruct
| $crate::InstructionResult::ReturnContract
};
}

#[macro_export]
macro_rules! return_revert {
() => {
InstructionResult::Revert
| InstructionResult::CallTooDeep
| InstructionResult::OutOfFunds
| InstructionResult::InvalidEOFInitCode
| InstructionResult::CreateInitCodeStartingEF00
| InstructionResult::InvalidExtDelegateCallTarget
$crate::InstructionResult::Revert
| $crate::InstructionResult::CallTooDeep
| $crate::InstructionResult::OutOfFunds
| $crate::InstructionResult::InvalidEOFInitCode
| $crate::InstructionResult::CreateInitCodeStartingEF00
| $crate::InstructionResult::InvalidExtDelegateCallTarget
};
}

#[macro_export]
macro_rules! return_error {
() => {
InstructionResult::OutOfGas
| InstructionResult::MemoryOOG
| InstructionResult::MemoryLimitOOG
| InstructionResult::PrecompileOOG
| InstructionResult::InvalidOperandOOG
| InstructionResult::ReentrancySentryOOG
| InstructionResult::OpcodeNotFound
| InstructionResult::CallNotAllowedInsideStatic
| InstructionResult::StateChangeDuringStaticCall
| InstructionResult::InvalidFEOpcode
| InstructionResult::InvalidJump
| InstructionResult::NotActivated
| InstructionResult::StackUnderflow
| InstructionResult::StackOverflow
| InstructionResult::OutOfOffset
| InstructionResult::CreateCollision
| InstructionResult::OverflowPayment
| InstructionResult::PrecompileError
| InstructionResult::NonceOverflow
| InstructionResult::CreateContractSizeLimit
| InstructionResult::CreateContractStartingWithEF
| InstructionResult::CreateInitCodeSizeLimit
| InstructionResult::FatalExternalError
| InstructionResult::ReturnContractInNotInitEOF
| InstructionResult::EOFOpcodeDisabledInLegacy
| InstructionResult::EOFFunctionStackOverflow
| InstructionResult::EofAuxDataTooSmall
| InstructionResult::EofAuxDataOverflow
| InstructionResult::InvalidEXTCALLTarget
$crate::InstructionResult::OutOfGas
| $crate::InstructionResult::MemoryOOG
| $crate::InstructionResult::MemoryLimitOOG
| $crate::InstructionResult::PrecompileOOG
| $crate::InstructionResult::InvalidOperandOOG
| $crate::InstructionResult::ReentrancySentryOOG
| $crate::InstructionResult::OpcodeNotFound
| $crate::InstructionResult::CallNotAllowedInsideStatic
| $crate::InstructionResult::StateChangeDuringStaticCall
| $crate::InstructionResult::InvalidFEOpcode
| $crate::InstructionResult::InvalidJump
| $crate::InstructionResult::NotActivated
| $crate::InstructionResult::StackUnderflow
| $crate::InstructionResult::StackOverflow
| $crate::InstructionResult::OutOfOffset
| $crate::InstructionResult::CreateCollision
| $crate::InstructionResult::OverflowPayment
| $crate::InstructionResult::PrecompileError
| $crate::InstructionResult::NonceOverflow
| $crate::InstructionResult::CreateContractSizeLimit
| $crate::InstructionResult::CreateContractStartingWithEF
| $crate::InstructionResult::CreateInitCodeSizeLimit
| $crate::InstructionResult::FatalExternalError
| $crate::InstructionResult::ReturnContractInNotInitEOF
| $crate::InstructionResult::EOFOpcodeDisabledInLegacy
| $crate::InstructionResult::EOFFunctionStackOverflow
| $crate::InstructionResult::EofAuxDataTooSmall
| $crate::InstructionResult::EofAuxDataOverflow
| $crate::InstructionResult::InvalidEXTCALLTarget
};
}

Expand Down
4 changes: 2 additions & 2 deletions crates/optimism/src/handler_register.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use revm::{
mainnet::{self, deduct_caller_inner},
register::EvmHandler,
},
interpreter::{return_ok, return_revert, Gas, InstructionResult},
interpreter::{return_ok, return_revert, Gas},
precompile::{secp256r1, PrecompileSpecId},
primitives::{HashMap, U256},
state::Account,
Expand Down Expand Up @@ -432,7 +432,7 @@ mod tests {
use database::InMemoryDB;
use revm::{
database_interface::EmptyDB,
interpreter::{CallOutcome, InterpreterResult},
interpreter::{CallOutcome, InstructionResult, InterpreterResult},
primitives::{bytes, Address, Bytes, B256},
state::AccountInfo,
};
Expand Down
5 changes: 3 additions & 2 deletions crates/revm/src/handler/mainnet/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use crate::{
use core::mem;
use interpreter::{
return_ok, return_revert, table::InstructionTables, CallInputs, CallOutcome, CreateInputs,
CreateOutcome, EOFCreateInputs, Gas, InstructionResult, InterpreterAction, InterpreterResult,
SharedMemory, EMPTY_SHARED_MEMORY,
CreateOutcome, EOFCreateInputs, Gas, InterpreterAction, InterpreterResult, SharedMemory,
EMPTY_SHARED_MEMORY,
};
use specification::hardfork::Spec;
use std::boxed::Box;
Expand Down Expand Up @@ -194,6 +194,7 @@ pub fn insert_eofcreate_outcome<EvmWiringT: EvmWiring>(
mod tests {
use super::*;
use crate::handler::mainnet::refund;
use interpreter::InstructionResult;
use primitives::Bytes;
use specification::hardfork::CancunSpec;
use wiring::{default::EnvWiring, DefaultEthereumWiring};
Expand Down

0 comments on commit e477c7f

Please sign in to comment.