Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add from_flat_call_config #203

Merged
merged 5 commits into from
Sep 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}
Loading