feat(revm): record_logs boolean in TracingInspectorConfig to limit log record (#3286)

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
Thomas Coratger
2023-06-21 15:36:26 +02:00
committed by GitHub
parent 0c222e5258
commit 35b005ea0a
3 changed files with 18 additions and 3 deletions

View File

@@ -16,6 +16,8 @@ pub struct TracingInspectorConfig {
pub record_state_diff: bool,
/// Whether to ignore precompile calls.
pub exclude_precompile_calls: bool,
/// Whether to record logs
pub record_logs: bool,
}
impl TracingInspectorConfig {
@@ -27,6 +29,7 @@ impl TracingInspectorConfig {
record_stack_snapshots: true,
record_state_diff: false,
exclude_precompile_calls: false,
record_logs: true,
}
}
@@ -40,6 +43,7 @@ impl TracingInspectorConfig {
record_stack_snapshots: false,
record_state_diff: false,
exclude_precompile_calls: true,
record_logs: false,
}
}
@@ -53,6 +57,7 @@ impl TracingInspectorConfig {
record_stack_snapshots: true,
record_state_diff: true,
exclude_precompile_calls: false,
record_logs: false,
}
}
@@ -97,4 +102,10 @@ impl TracingInspectorConfig {
self.record_state_diff = record_state_diff;
self
}
/// Configure whether the tracer should record logs
pub fn set_record_logs(mut self, record_logs: bool) -> Self {
self.record_logs = record_logs;
self
}
}

View File

@@ -336,8 +336,11 @@ where
let trace_idx = self.last_trace_idx();
let trace = &mut self.traces.arena[trace_idx];
trace.ordering.push(LogCallOrder::Log(trace.logs.len()));
trace.logs.push(RawLog { topics: topics.to_vec(), data: data.clone() });
if self.config.record_logs {
trace.ordering.push(LogCallOrder::Log(trace.logs.len()));
trace.logs.push(RawLog { topics: topics.to_vec(), data: data.clone() });
}
}
fn step_end(

View File

@@ -290,7 +290,8 @@ where
.map_err(|_| EthApiError::InvalidTracerConfig)?;
let mut inspector = TracingInspector::new(
TracingInspectorConfig::from_geth_config(&config),
TracingInspectorConfig::from_geth_config(&config)
.set_record_logs(call_config.with_log.unwrap_or_default()),
);
let _ = self