Skip to content

Commit

Permalink
rename GethTrace GethTraceFrame
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse committed Feb 3, 2023
1 parent 01666f9 commit cf42cbb
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 18 deletions.
6 changes: 3 additions & 3 deletions anvil/src/eth/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use anvil_core::{
use anvil_rpc::{error::RpcError, response::ResponseResult};
use ethers::{
abi::ethereum_types::H64,
prelude::{GethTrace, TxpoolInspect},
prelude::{DefaultFrame, TxpoolInspect},
providers::ProviderError,
types::{
transaction::{
Expand Down Expand Up @@ -1268,7 +1268,7 @@ impl EthApi {
&self,
tx_hash: H256,
opts: GethDebugTracingOptions,
) -> Result<GethTrace> {
) -> Result<DefaultFrame> {
node_info!("debug_traceTransaction");
if opts.tracer.is_some() {
return Err(RpcError::invalid_params("non-default tracer not supported yet").into())
Expand All @@ -1285,7 +1285,7 @@ impl EthApi {
request: EthTransactionRequest,
block_number: Option<BlockId>,
opts: GethDebugTracingOptions,
) -> Result<GethTrace> {
) -> Result<DefaultFrame> {
node_info!("debug_traceCall");
if opts.tracer.is_some() {
return Err(RpcError::invalid_params("non-default tracer not supported yet").into())
Expand Down
8 changes: 4 additions & 4 deletions anvil/src/eth/backend/fork.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use ethers::{
prelude::BlockNumber,
providers::{Middleware, ProviderError},
types::{
transaction::eip2930::AccessListWithGasUsed, Address, Block, BlockId, Bytes, FeeHistory,
Filter, GethDebugTracingOptions, GethTrace, Log, Trace, Transaction, TransactionReceipt,
transaction::eip2930::AccessListWithGasUsed, Address, Block, BlockId, Bytes, DefaultFrame,
FeeHistory, Filter, GethDebugTracingOptions, Log, Trace, Transaction, TransactionReceipt,
TxHash, H256, U256,
},
};
Expand Down Expand Up @@ -307,7 +307,7 @@ impl ClientFork {
&self,
hash: H256,
opts: GethDebugTracingOptions,
) -> Result<GethTrace, ProviderError> {
) -> Result<DefaultFrame, ProviderError> {
if let Some(traces) = self.storage_read().geth_transaction_traces.get(&hash).cloned() {
return Ok(traces)
}
Expand Down Expand Up @@ -556,7 +556,7 @@ pub struct ForkedStorage {
pub transactions: HashMap<H256, Transaction>,
pub transaction_receipts: HashMap<H256, TransactionReceipt>,
pub transaction_traces: HashMap<H256, Vec<Trace>>,
pub geth_transaction_traces: HashMap<H256, GethTrace>,
pub geth_transaction_traces: HashMap<H256, DefaultFrame>,
pub block_traces: HashMap<u64, Vec<Trace>>,
pub code_at: HashMap<(Address, u64), Bytes>,
}
Expand Down
12 changes: 6 additions & 6 deletions anvil/src/eth/backend/mem/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ use ethers::{
abi::ethereum_types::BigEndianHash,
prelude::{BlockNumber, TxHash, H256, U256, U64},
types::{
transaction::eip2930::AccessList, Address, Block as EthersBlock, BlockId, Bytes, Filter,
FilteredParams, GethDebugTracingOptions, GethTrace, Log, Trace, Transaction,
transaction::eip2930::AccessList, Address, Block as EthersBlock, BlockId, Bytes,
DefaultFrame, Filter, FilteredParams, GethDebugTracingOptions, Log, Trace, Transaction,
TransactionReceipt,
},
utils::{get_contract_address, keccak256, rlp},
Expand Down Expand Up @@ -897,7 +897,7 @@ impl Backend {
fee_details: FeeDetails,
block_request: Option<BlockRequest>,
opts: GethDebugTracingOptions,
) -> Result<GethTrace, BlockchainError> {
) -> Result<DefaultFrame, BlockchainError> {
self.with_database_at(block_request, |state, block| {
let mut inspector = Inspector::default().with_steps_tracing();
let block_number = block.number;
Expand Down Expand Up @@ -1547,7 +1547,7 @@ impl Backend {
&self,
hash: H256,
opts: GethDebugTracingOptions,
) -> Result<GethTrace, BlockchainError> {
) -> Result<DefaultFrame, BlockchainError> {
if let Some(traces) = self.mined_geth_trace_transaction(hash, opts.clone()) {
return Ok(traces)
}
Expand All @@ -1556,14 +1556,14 @@ impl Backend {
return Ok(fork.debug_trace_transaction(hash, opts).await?)
}

Ok(GethTrace::default())
Ok(DefaultFrame::default())
}

fn mined_geth_trace_transaction(
&self,
hash: H256,
opts: GethDebugTracingOptions,
) -> Option<GethTrace> {
) -> Option<DefaultFrame> {
self.blockchain.storage.read().transactions.get(&hash).map(|tx| tx.geth_trace(opts))
}

Expand Down
4 changes: 2 additions & 2 deletions anvil/src/eth/backend/mem/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use anvil_core::eth::{
transaction::{MaybeImpersonatedTransaction, TransactionInfo},
};
use ethers::{
prelude::{BlockId, BlockNumber, GethTrace, Trace, H256, H256 as TxHash, U64},
prelude::{BlockId, BlockNumber, DefaultFrame, Trace, H256, H256 as TxHash, U64},
types::{ActionType, GethDebugTracingOptions, U256},
};
use forge::revm::{Env, Return};
Expand Down Expand Up @@ -382,7 +382,7 @@ impl MinedTransaction {
traces
}

pub fn geth_trace(&self, opts: GethDebugTracingOptions) -> GethTrace {
pub fn geth_trace(&self, opts: GethDebugTracingOptions) -> DefaultFrame {
self.info.traces.geth_trace(self.receipt.gas_used(), opts)
}
}
Expand Down
10 changes: 7 additions & 3 deletions evm/src/trace/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pub use decoder::{CallTraceDecoder, CallTraceDecoderBuilder};
use ethers::{
abi::{ethereum_types::BigEndianHash, Address, RawLog},
core::utils::to_checksum,
types::{Bytes, GethDebugTracingOptions, GethTrace, StructLog, H256, U256},
types::{Bytes, DefaultFrame, GethDebugTracingOptions, StructLog, H256, U256},
};
use foundry_common::contracts::{ContractsByAddress, ContractsByArtifact};
use hashbrown::HashMap;
Expand Down Expand Up @@ -150,7 +150,11 @@ impl CallTraceArena {
}

/// Generate a geth-style trace e.g. for debug_traceTransaction
pub fn geth_trace(&self, receipt_gas_used: U256, opts: GethDebugTracingOptions) -> GethTrace {
pub fn geth_trace(
&self,
receipt_gas_used: U256,
opts: GethDebugTracingOptions,
) -> DefaultFrame {
if self.arena.is_empty() {
return Default::default()
}
Expand All @@ -160,7 +164,7 @@ impl CallTraceArena {
let main_trace_node = &self.arena[0];
let main_trace = &main_trace_node.trace;
// Start geth trace
let mut acc = GethTrace {
let mut acc = DefaultFrame {
// If the top-level trace succeeded, then it was a success
failed: !main_trace.success,
gas: receipt_gas_used,
Expand Down

0 comments on commit cf42cbb

Please sign in to comment.