diff --git a/crates/evm/fuzz/src/inspector.rs b/crates/evm/fuzz/src/inspector.rs index 6190c073dfc6d..65c6e5ec99c8f 100644 --- a/crates/evm/fuzz/src/inspector.rs +++ b/crates/evm/fuzz/src/inspector.rs @@ -1,7 +1,5 @@ use crate::{invariant::RandomCallGenerator, strategies::EvmFuzzState}; use alloy_primitives::Bytes; -use foundry_common::types::ToEthers; -use foundry_evm_core::utils; use revm::{ interpreter::{CallInputs, CallScheme, Gas, InstructionResult, Interpreter}, Database, EVMData, Inspector, @@ -73,7 +71,7 @@ impl Fuzzer { let mut state = self.fuzz_state.write(); for slot in interpreter.stack().data() { - state.values_mut().insert(utils::u256_to_h256_be(slot.to_ethers()).into()); + state.values_mut().insert(slot.to_be_bytes()); } // TODO: disabled for now since it's flooding the dictionary diff --git a/crates/evm/fuzz/src/strategies/state.rs b/crates/evm/fuzz/src/strategies/state.rs index 33a0ddf329284..8f7feb2093209 100644 --- a/crates/evm/fuzz/src/strategies/state.rs +++ b/crates/evm/fuzz/src/strategies/state.rs @@ -4,10 +4,7 @@ use alloy_dyn_abi::{DynSolType, JsonAbiExt}; use alloy_json_abi::Function; use alloy_primitives::{Address, Bytes, B256, U256}; use ethers_core::types::Log; -use foundry_common::{ - contracts::{ContractsByAddress, ContractsByArtifact}, - types::ToEthers, -}; +use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact}; use foundry_config::FuzzDictionaryConfig; use foundry_evm_core::utils::StateChangeset; use hashbrown::HashSet; @@ -232,7 +229,7 @@ fn collect_push_bytes(code: &[u8]) -> Vec<[u8; 32]> { } let push_value = U256::try_from_be_slice(&code[push_start..push_end]).unwrap(); - bytes.push(push_value.to_ethers().into()); + bytes.push(push_value.to_be_bytes()); // also add the value below and above the push value to the dictionary. if push_value != U256::ZERO { bytes.push((push_value - U256::from(1)).to_be_bytes()); diff --git a/crates/evm/traces/src/node.rs b/crates/evm/traces/src/node.rs deleted file mode 100644 index 5eff992956a33..0000000000000 --- a/crates/evm/traces/src/node.rs +++ /dev/null @@ -1,83 +0,0 @@ -use crate::{CallTrace, LogCallOrder, TraceLog}; -use ethers_core::types::{Action, Call, CallResult, Create, CreateResult, Res, Suicide}; -use foundry_common::types::ToEthers; -use foundry_evm_core::utils::CallKind; -use revm::interpreter::InstructionResult; -use serde::{Deserialize, Serialize}; - -/// A node in the arena -#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] -pub struct CallTraceNode { - /// Parent node index in the arena - pub parent: Option, - /// Children node indexes in the arena - pub children: Vec, - /// This node's index in the arena - pub idx: usize, - /// The call trace - pub trace: CallTrace, - /// Logs - #[serde(skip)] - pub logs: Vec, - /// Ordering of child calls and logs - pub ordering: Vec, -} - -impl CallTraceNode { - /// Returns the kind of call the trace belongs to - pub fn kind(&self) -> CallKind { - self.trace.kind - } - - /// Returns the status of the call - pub fn status(&self) -> InstructionResult { - self.trace.status - } - - /// Returns the `Res` for a parity trace - pub fn parity_result(&self) -> Res { - match self.kind() { - CallKind::Call | CallKind::StaticCall | CallKind::CallCode | CallKind::DelegateCall => { - Res::Call(CallResult { - gas_used: self.trace.gas_cost.into(), - output: self.trace.output.to_raw().into(), - }) - } - CallKind::Create | CallKind::Create2 => Res::Create(CreateResult { - gas_used: self.trace.gas_cost.into(), - code: self.trace.output.to_raw().into(), - address: self.trace.address.to_ethers(), - }), - } - } - - /// Returns the `Action` for a parity trace - pub fn parity_action(&self) -> Action { - if self.status() == InstructionResult::SelfDestruct { - return Action::Suicide(Suicide { - address: self.trace.address.to_ethers(), - // TODO deserialize from calldata here? - refund_address: Default::default(), - balance: self.trace.value.to_ethers(), - }) - } - match self.kind() { - CallKind::Call | CallKind::StaticCall | CallKind::CallCode | CallKind::DelegateCall => { - Action::Call(Call { - from: self.trace.caller.to_ethers(), - to: self.trace.address.to_ethers(), - value: self.trace.value.to_ethers(), - gas: self.trace.gas_cost.into(), - input: self.trace.data.as_bytes().to_vec().into(), - call_type: self.kind().into(), - }) - } - CallKind::Create | CallKind::Create2 => Action::Create(Create { - from: self.trace.caller.to_ethers(), - value: self.trace.value.to_ethers(), - gas: self.trace.gas_cost.into(), - init: self.trace.data.as_bytes().to_vec().into(), - }), - } - } -}