diff --git a/crates/evm/core/src/decode.rs b/crates/evm/core/src/decode.rs index 2646edabedfb..bf82c2d34920 100644 --- a/crates/evm/core/src/decode.rs +++ b/crates/evm/core/src/decode.rs @@ -19,7 +19,6 @@ pub fn decode_console_logs(logs: &[Log]) -> Vec { /// /// This function returns [None] if it is not a DSTest log or the result of a Hardhat /// `console.log`. -#[instrument(level = "debug", skip_all, fields(topics=?log.data.topics(), data=%log.data.data), ret)] pub fn decode_console_log(log: &Log) -> Option { Console::ConsoleEvents::decode_log(log, false).ok().map(|decoded| decoded.to_string()) } diff --git a/crates/evm/traces/src/decoder/mod.rs b/crates/evm/traces/src/decoder/mod.rs index 9e881488eb63..6b5aaf35deaf 100644 --- a/crates/evm/traces/src/decoder/mod.rs +++ b/crates/evm/traces/src/decoder/mod.rs @@ -204,11 +204,11 @@ impl CallTraceDecoder { pub fn push_function(&mut self, function: Function) { match self.functions.entry(function.selector()) { Entry::Occupied(entry) => { - // This shouldn't happen that often + // This shouldn't happen that often. if entry.get().contains(&function) { return; } - debug!(target: "evm::traces", selector=%entry.key(), new=%function.signature(), "duplicate function selector"); + trace!(target: "evm::traces", selector=%entry.key(), new=%function.signature(), "duplicate function selector"); entry.into_mut().push(function); } Entry::Vacant(entry) => { @@ -241,6 +241,11 @@ impl CallTraceDecoder { } fn collect_identities(&mut self, identities: Vec>) { + // Skip logging if there are no identities. + if identities.is_empty() { + return; + } + trace!(target: "evm::traces", len=identities.len(), "collecting address identities"); for AddressIdentity { address, label, contract, abi, artifact_id: _ } in identities { let _span = trace_span!(target: "evm::traces", "identity", ?contract, ?label).entered(); diff --git a/crates/forge/bin/cmd/coverage.rs b/crates/forge/bin/cmd/coverage.rs index ab78bdff2ff3..7b674138a3b9 100644 --- a/crates/forge/bin/cmd/coverage.rs +++ b/crates/forge/bin/cmd/coverage.rs @@ -149,7 +149,7 @@ impl CoverageArgs { } /// Builds the coverage report. - #[instrument(name = "prepare coverage", skip_all)] + #[instrument(name = "prepare", skip_all)] fn prepare(&self, config: &Config, output: ProjectCompileOutput) -> Result { let project_paths = config.project_paths(); diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index 2f981892aec5..67b96cb2326a 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -8,7 +8,7 @@ use crate::{ use alloy_json_abi::{Function, JsonAbi}; use alloy_primitives::{Address, Bytes, U256}; use eyre::{OptionExt, Result}; -use foundry_common::{ContractsByArtifact, TestFunctionExt}; +use foundry_common::{get_contract_name, ContractsByArtifact, TestFunctionExt}; use foundry_compilers::{contracts::ArtifactContracts, Artifact, ArtifactId, ProjectCompileOutput}; use foundry_evm::{ backend::Backend, @@ -202,7 +202,6 @@ impl MultiContractRunner { }) } - #[instrument(skip_all, fields(name = %name))] #[allow(clippy::too_many_arguments)] fn run_tests( &self, @@ -214,6 +213,16 @@ impl MultiContractRunner { filter: &dyn TestFilter, test_options: TestOptions, ) -> SuiteResult { + let span = info_span!("run_tests"); + if !span.is_disabled() { + if enabled!(tracing::Level::TRACE) { + span.record("contract", name); + } else { + span.record("contract", get_contract_name(name)); + } + } + let _guard = span.enter(); + let runner = ContractRunner::new( name, executor, diff --git a/crates/forge/src/runner.rs b/crates/forge/src/runner.rs index 493ec704d997..6f955f6133f1 100644 --- a/crates/forge/src/runner.rs +++ b/crates/forge/src/runner.rs @@ -313,8 +313,18 @@ impl<'a> ContractRunner<'a> { /// /// State modifications are not committed to the evm database but discarded after the call, /// similar to `eth_call`. - #[instrument(name = "test", skip_all, fields(name = %func.signature(), %should_fail))] pub fn run_test(&self, func: &Function, should_fail: bool, setup: TestSetup) -> TestResult { + let span = info_span!("test", %should_fail); + if !span.is_disabled() { + let sig = &func.signature()[..]; + if enabled!(tracing::Level::TRACE) { + span.record("sig", &sig); + } else { + span.record("sig", sig.split('(').next().unwrap()); + } + } + let _guard = span.enter(); + let TestSetup { address, mut logs, mut traces, mut labeled_addresses, mut coverage, .. } = setup; @@ -426,7 +436,7 @@ impl<'a> ContractRunner<'a> { } } - #[instrument(name = "invariant-test", skip_all)] + #[instrument(name = "invariant_test", skip_all)] pub fn run_invariant_test( &self, runner: TestRunner, @@ -555,7 +565,7 @@ impl<'a> ContractRunner<'a> { } } - #[instrument(name = "fuzz-test", skip_all, fields(name = %func.signature(), %should_fail))] + #[instrument(name = "fuzz_test", skip_all, fields(name = %func.signature(), %should_fail))] pub fn run_fuzz_test( &self, func: &Function, @@ -564,6 +574,17 @@ impl<'a> ContractRunner<'a> { setup: TestSetup, fuzz_config: FuzzConfig, ) -> TestResult { + let span = info_span!("fuzz_test", %should_fail); + if !span.is_disabled() { + let sig = &func.signature()[..]; + if enabled!(tracing::Level::TRACE) { + span.record("test", &sig); + } else { + span.record("test", sig.split('(').next().unwrap()); + } + } + let _guard = span.enter(); + let TestSetup { address, mut logs, mut traces, mut labeled_addresses, mut coverage, .. } = setup;