Skip to content

Commit

Permalink
chore: add from_flat_call_config (paradigmxyz#203)
Browse files Browse the repository at this point in the history
For use and uniformity wrt
paradigmxyz/reth#10991

Simple tests included

I could do the PR without this but seems correct to maintain uniformity
instead of modifying the `TracingInspector` in ad hoc ways

---------

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
  • Loading branch information
2 people authored and lwedge99 committed Oct 8, 2024
1 parent 1ebca4b commit 82c0fc9
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/tracing/config.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use alloy_primitives::U256;
use alloy_rpc_types_trace::{
geth::{CallConfig, GethDefaultTracingOptions, PreStateConfig},
geth::{CallConfig, FlatCallConfig, GethDefaultTracingOptions, PreStateConfig},
parity::TraceType,
};
use revm::interpreter::OpCode;
Expand Down Expand Up @@ -188,6 +188,19 @@ impl TracingInspectorConfig {
.set_record_logs(config.with_log.unwrap_or_default())
}

/// Returns a config for geth's
/// [FlatCallTracer](alloy_rpc_types_trace::geth::call::FlatCallFrame).
///
/// This returns [Self::default_parity] and sets
/// [TracingInspectorConfig::exclude_precompile_calls] if configured in the given
/// [FlatCallConfig]
#[inline]
pub fn from_flat_call_config(config: &FlatCallConfig) -> Self {
Self::default_parity()
// call tracer is similar parity tracer with optional support for logs
.set_exclude_precompile_calls(!config.include_precompiles.unwrap_or_default())
}

/// Returns a config for geth's [PrestateTracer](alloy_rpc_types_trace::geth::PreStateFrame).
///
/// Note: This currently returns [Self::none] because the prestate tracer result currently
Expand Down Expand Up @@ -389,4 +402,15 @@ mod tests {
// not required for StateDiff
assert!(!config.record_state_diff);
}

#[test]
fn test_flat_call_config() {
let config = FlatCallConfig { include_precompiles: Some(true), ..Default::default() };
let config = TracingInspectorConfig::from_flat_call_config(&config);
assert!(!config.exclude_precompile_calls);

let config = FlatCallConfig { include_precompiles: Some(false), ..Default::default() };
let config = TracingInspectorConfig::from_flat_call_config(&config);
assert!(config.exclude_precompile_calls);
}
}

0 comments on commit 82c0fc9

Please sign in to comment.