Skip to content

Commit 75ecf23

Browse files
authored
feat: better cheatcodes tracing (foundry-rs#4950)
1 parent 58a2729 commit 75ecf23

File tree

29 files changed

+64
-67
lines changed

29 files changed

+64
-67
lines changed

evm/src/coverage/analysis.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use ethers::solc::artifacts::ast::{self, Ast, Node, NodeType};
33
use foundry_common::TestFunctionExt;
44
use semver::Version;
55
use std::collections::{HashMap, HashSet};
6-
use tracing::warn;
76

87
/// A visitor that walks the AST of a single contract and finds coverage items.
98
#[derive(Debug, Clone)]

evm/src/coverage/anchors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ pub fn find_anchors(
3131
_ => panic!("Too many paths for branch"),
3232
},
3333
Err(e) => {
34-
tracing::warn!("Could not find anchor for item: {}, error: {e}", item);
34+
warn!("Could not find anchor for item: {}, error: {e}", item);
3535
None
3636
}
3737
}
3838
}
3939
_ => match find_anchor_simple(source_map, ic_pc_map, *item_id, &item.loc) {
4040
Ok(anchor) => Some(anchor),
4141
Err(e) => {
42-
tracing::warn!("Could not find anchor for item: {}, error: {e}", item);
42+
warn!("Could not find anchor for item: {}, error: {e}", item);
4343
None
4444
}
4545
},

evm/src/executor/backend/fuzz.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use revm::{
1616
Database, Inspector, JournaledState,
1717
};
1818
use std::borrow::Cow;
19-
use tracing::trace;
2019

2120
/// A wrapper around `Backend` that ensures only `revm::DatabaseRef` functions are called.
2221
///

evm/src/executor/backend/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ use revm::{
2626
Database, DatabaseCommit, Inspector, JournaledState, EVM,
2727
};
2828
use std::collections::{HashMap, HashSet};
29-
use tracing::{trace, warn};
3029

3130
mod fuzz;
3231
pub mod snapshot;

evm/src/executor/fork/backend.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ use std::{
3030
Arc,
3131
},
3232
};
33-
use tracing::{error, trace, warn};
3433

3534
// Various future/request type aliases
3635

evm/src/executor/fork/cache.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use revm::{
77
};
88
use serde::{ser::SerializeMap, Deserialize, Deserializer, Serialize, Serializer};
99
use std::{collections::BTreeSet, fs, io::BufWriter, path::PathBuf, sync::Arc};
10-
use tracing::{trace, warn};
10+
1111
use url::Url;
1212

1313
pub type StorageInfo = Map<U256, U256>;

evm/src/executor/fork/database.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ use revm::{
1717
Database, DatabaseCommit,
1818
};
1919
use std::sync::Arc;
20-
use tracing::{trace, warn};
2120

2221
/// a [revm::Database] that's forked off another client
2322
///

evm/src/executor/fork/multi.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ use std::{
3131
},
3232
time::Duration,
3333
};
34-
use tracing::trace;
3534

3635
/// The identifier for a specific fork, this could be the name of the network a custom descriptive
3736
/// name.

evm/src/executor/inspector/cheatcodes/config.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::{ensure, err, Result};
1+
use super::{ensure, fmt_err, Result};
22
use crate::executor::opts::EvmOpts;
33
use ethers::solc::{utils::canonicalize, ProjectPathsConfig};
44
use foundry_common::fs::normalize_path;
@@ -7,7 +7,6 @@ use foundry_config::{
77
ResolvedRpcEndpoints,
88
};
99
use std::path::{Path, PathBuf};
10-
use tracing::trace;
1110

1211
/// Additional, configurable context the `Cheatcodes` inspector has access to
1312
///
@@ -135,7 +134,7 @@ impl CheatsConfig {
135134
}
136135
None => {
137136
if !url_or_alias.starts_with("http") && !url_or_alias.starts_with("ws") {
138-
Err(err!("invalid rpc url {url_or_alias}"))
137+
Err(fmt_err!("invalid rpc url {url_or_alias}"))
139138
} else {
140139
Ok(url_or_alias)
141140
}

evm/src/executor/inspector/cheatcodes/env.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::{ensure, err, Cheatcodes, Result};
1+
use super::{ensure, fmt_err, Cheatcodes, Result};
22
use crate::{
33
abi::HEVMCalls,
44
executor::{
@@ -21,7 +21,6 @@ use revm::{
2121
Database, EVMData,
2222
};
2323
use std::collections::BTreeMap;
24-
use tracing::trace;
2524

2625
#[derive(Clone, Debug, Default)]
2726
pub struct Broadcast {
@@ -217,7 +216,8 @@ fn add_breakpoint(state: &mut Cheatcodes, caller: Address, inner: &str, add: boo
217216
let mut chars = inner.chars();
218217
let point = chars.next();
219218

220-
let point = point.ok_or_else(|| err!("Please provide at least one char for the breakpoint"))?;
219+
let point =
220+
point.ok_or_else(|| fmt_err!("Please provide at least one char for the breakpoint"))?;
221221

222222
ensure!(chars.next().is_none(), "Provide only one character for the breakpoint");
223223
ensure!(point.is_alphabetic(), "Only alphabetic characters are accepted as breakpoints");
@@ -232,6 +232,7 @@ fn add_breakpoint(state: &mut Cheatcodes, caller: Address, inner: &str, add: boo
232232
Ok(Bytes::new())
233233
}
234234

235+
#[instrument(level = "error", name = "env", target = "evm::cheatcodes", skip_all)]
235236
pub fn apply<DB: DatabaseExt>(
236237
state: &mut Cheatcodes,
237238
data: &mut EVMData<'_, DB>,

0 commit comments

Comments
 (0)