mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
feat: add FlatCallTracer (#11114)
This commit is contained in:
4
Cargo.lock
generated
4
Cargo.lock
generated
@ -9104,9 +9104,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "revm-inspectors"
|
name = "revm-inspectors"
|
||||||
version = "0.7.4"
|
version = "0.7.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "48294aab02ed5d1940ad9b06f2a3230c3f0d98db6eacd618878cf143e204f6b0"
|
checksum = "b57b33a24b5b8b8efa1da3f60d44f02d6e649f06ef925d7780723ff14ff55321"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"alloy-primitives",
|
"alloy-primitives",
|
||||||
"alloy-rpc-types-eth",
|
"alloy-rpc-types-eth",
|
||||||
|
|||||||
@ -413,7 +413,7 @@ revm = { version = "14.0.2", features = [
|
|||||||
"secp256k1",
|
"secp256k1",
|
||||||
"blst",
|
"blst",
|
||||||
], default-features = false }
|
], default-features = false }
|
||||||
revm-inspectors = "0.7"
|
revm-inspectors = "0.7.6"
|
||||||
revm-primitives = { version = "9.0.2", features = [
|
revm-primitives = { version = "9.0.2", features = [
|
||||||
"std",
|
"std",
|
||||||
], default-features = false }
|
], default-features = false }
|
||||||
|
|||||||
@ -1,11 +1,14 @@
|
|||||||
use alloy_primitives::{Address, Bytes, B256, U256};
|
use alloy_primitives::{Address, Bytes, B256, U256};
|
||||||
use alloy_rlp::{Decodable, Encodable};
|
use alloy_rlp::{Decodable, Encodable};
|
||||||
use alloy_rpc_types::{state::EvmOverrides, Block as RpcBlock, BlockError, Bundle, StateContext};
|
use alloy_rpc_types::{
|
||||||
|
state::EvmOverrides, Block as RpcBlock, BlockError, Bundle, StateContext, TransactionInfo,
|
||||||
|
};
|
||||||
use alloy_rpc_types_debug::ExecutionWitness;
|
use alloy_rpc_types_debug::ExecutionWitness;
|
||||||
use alloy_rpc_types_eth::transaction::TransactionRequest;
|
use alloy_rpc_types_eth::transaction::TransactionRequest;
|
||||||
use alloy_rpc_types_trace::geth::{
|
use alloy_rpc_types_trace::geth::{
|
||||||
BlockTraceResult, FourByteFrame, GethDebugBuiltInTracerType, GethDebugTracerType,
|
call::FlatCallFrame, BlockTraceResult, FourByteFrame, GethDebugBuiltInTracerType,
|
||||||
GethDebugTracingCallOptions, GethDebugTracingOptions, GethTrace, NoopFrame, TraceResult,
|
GethDebugTracerType, GethDebugTracingCallOptions, GethDebugTracingOptions, GethTrace,
|
||||||
|
NoopFrame, TraceResult,
|
||||||
};
|
};
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use jsonrpsee::core::RpcResult;
|
use jsonrpsee::core::RpcResult;
|
||||||
@ -388,9 +391,32 @@ where
|
|||||||
return Ok(frame)
|
return Ok(frame)
|
||||||
}
|
}
|
||||||
GethDebugBuiltInTracerType::FlatCallTracer => {
|
GethDebugBuiltInTracerType::FlatCallTracer => {
|
||||||
return Err(
|
let flat_call_config = tracer_config
|
||||||
EthApiError::Unsupported("Flatcall tracer is not supported yet").into()
|
.into_flat_call_config()
|
||||||
)
|
.map_err(|_| EthApiError::InvalidTracerConfig)?;
|
||||||
|
|
||||||
|
let mut inspector = TracingInspector::new(
|
||||||
|
TracingInspectorConfig::from_flat_call_config(&flat_call_config),
|
||||||
|
);
|
||||||
|
|
||||||
|
let frame: FlatCallFrame = self
|
||||||
|
.inner
|
||||||
|
.eth_api
|
||||||
|
.spawn_with_call_at(call, at, overrides, move |db, env| {
|
||||||
|
let (_res, env) =
|
||||||
|
this.eth_api().inspect(db, env, &mut inspector)?;
|
||||||
|
let tx_info = TransactionInfo::default();
|
||||||
|
let frame: FlatCallFrame = inspector
|
||||||
|
.with_transaction_gas_limit(env.tx.gas_limit)
|
||||||
|
.into_parity_builder()
|
||||||
|
.into_localized_transaction_traces(tx_info)
|
||||||
|
.pop()
|
||||||
|
.unwrap();
|
||||||
|
Ok(frame)
|
||||||
|
})
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
return Ok(frame.into());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
#[cfg(not(feature = "js-tracer"))]
|
#[cfg(not(feature = "js-tracer"))]
|
||||||
@ -689,8 +715,7 @@ where
|
|||||||
opts: GethDebugTracingOptions,
|
opts: GethDebugTracingOptions,
|
||||||
env: EnvWithHandlerCfg,
|
env: EnvWithHandlerCfg,
|
||||||
db: &mut StateCacheDb<'_>,
|
db: &mut StateCacheDb<'_>,
|
||||||
#[cfg(not(feature = "js-tracer"))] _transaction_context: Option<TransactionContext>,
|
transaction_context: Option<TransactionContext>,
|
||||||
#[cfg(feature = "js-tracer")] transaction_context: Option<TransactionContext>,
|
|
||||||
) -> Result<(GethTrace, revm_primitives::EvmState), Eth::Error> {
|
) -> Result<(GethTrace, revm_primitives::EvmState), Eth::Error> {
|
||||||
let GethDebugTracingOptions { config, tracer, tracer_config, .. } = opts;
|
let GethDebugTracingOptions { config, tracer, tracer_config, .. } = opts;
|
||||||
|
|
||||||
@ -756,9 +781,31 @@ where
|
|||||||
return Ok((frame.into(), res.state))
|
return Ok((frame.into(), res.state))
|
||||||
}
|
}
|
||||||
GethDebugBuiltInTracerType::FlatCallTracer => {
|
GethDebugBuiltInTracerType::FlatCallTracer => {
|
||||||
return Err(
|
let flat_call_config = tracer_config
|
||||||
EthApiError::Unsupported("Flatcall tracer is not supported yet").into()
|
.into_flat_call_config()
|
||||||
)
|
.map_err(|_| EthApiError::InvalidTracerConfig)?;
|
||||||
|
|
||||||
|
let mut inspector = TracingInspector::new(
|
||||||
|
TracingInspectorConfig::from_flat_call_config(&flat_call_config),
|
||||||
|
);
|
||||||
|
|
||||||
|
let (res, env) = self.eth_api().inspect(db, env, &mut inspector)?;
|
||||||
|
|
||||||
|
let tx_info = TransactionInfo {
|
||||||
|
hash: transaction_context.unwrap().tx_hash,
|
||||||
|
index: transaction_context.unwrap().tx_index.map(|index| index as u64),
|
||||||
|
block_hash: transaction_context.unwrap().block_hash,
|
||||||
|
block_number: Some(env.block.number.try_into().unwrap_or_default()),
|
||||||
|
base_fee: Some(env.block.basefee.try_into().unwrap_or_default()),
|
||||||
|
};
|
||||||
|
let frame: FlatCallFrame = inspector
|
||||||
|
.with_transaction_gas_limit(env.tx.gas_limit)
|
||||||
|
.into_parity_builder()
|
||||||
|
.into_localized_transaction_traces(tx_info)
|
||||||
|
.pop()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
return Ok((frame.into(), res.state));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
#[cfg(not(feature = "js-tracer"))]
|
#[cfg(not(feature = "js-tracer"))]
|
||||||
|
|||||||
Reference in New Issue
Block a user