Skip to content

Commit dd18990

Browse files
authored
chore: remove tracing::info usage (#578)
* chore: remove tracing::info in favour of pure stdout * chore: linting * chore: fix formatting * feat: move to use shell io * feat: introduce shell io abstraction for logging * chore: remove clippy unused println * chore: linting * feat: make use of anstream and anystyle, remove use of atty * chore: linting * feat: turn tracing off by default, update messages * chore: resolve conflicts * chore: make requested changes * chore: update pool_rs * chore: linting, fix formatting. Remove uneeded colorize * chore: make requested changes * chore: linting
1 parent ee49bb9 commit dd18990

32 files changed

+564
-291
lines changed

Cargo.lock

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ members = [
77
"crates/core",
88
"crates/l1_sidecar",
99
"crates/types",
10+
"crates/common",
1011
]
1112
resolver = "2"
1213

@@ -80,6 +81,8 @@ tracing-subscriber = { version = "0.3", features = [
8081
"local-time",
8182
] }
8283
url = "2.5.4"
84+
anstream = "0.6.18"
85+
anstyle = "1.0.10"
8386

8487
#########################
8588
# Test dependencies #
@@ -98,3 +101,4 @@ anvil_zksync_config = { path = "crates/config" }
98101
anvil_zksync_core = { path = "crates/core" }
99102
anvil_zksync_l1_sidecar = { path = "crates/l1_sidecar" }
100103
anvil_zksync_types = { path = "crates/types" }
104+
anvil_zksync_common = { path = "crates/common" }

crates/api_server/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ anvil_zksync_api_decl.workspace = true
1515
anvil_zksync_core.workspace = true
1616
anvil_zksync_l1_sidecar.workspace = true
1717
anvil_zksync_types.workspace = true
18+
anvil_zksync_common.workspace = true
1819

1920
zksync_types.workspace = true
2021
zksync_web3_decl.workspace = true

crates/api_server/src/impls/anvil.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::error::RpcError;
22
use anvil_zksync_api_decl::AnvilNamespaceServer;
3+
use anvil_zksync_common::sh_warn;
34
use anvil_zksync_core::node::InMemoryNode;
45
use anvil_zksync_types::api::{DetailedTransaction, ResetRequest};
56
use anvil_zksync_types::Numeric;
@@ -100,9 +101,7 @@ impl AnvilNamespaceServer for AnvilNamespace {
100101
}
101102

102103
async fn set_min_gas_price(&self, _gas: U256) -> RpcResult<()> {
103-
tracing::info!(
104-
"Setting minimum gas price is unsupported as ZKsync is a post-EIP1559 chain"
105-
);
104+
sh_warn!("Setting minimum gas price is unsupported as ZKsync is a post-EIP1559 chain");
106105
Err(RpcError::Unsupported.into())
107106
}
108107

crates/cli/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ anvil_zksync_config.workspace = true
1616
anvil_zksync_core.workspace = true
1717
anvil_zksync_l1_sidecar.workspace = true
1818
anvil_zksync_types.workspace = true
19+
anvil_zksync_common.workspace = true
1920

2021
zksync_types.workspace = true
2122

crates/cli/src/bytecode_override.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub async fn override_bytecodes(node: &InMemoryNode, bytecodes_dir: String) -> a
4444
node.override_bytecode(address, bytecode)
4545
.await
4646
.expect("Failed to override bytecode");
47-
tracing::info!("+++++ Replacing bytecode at address {:?} +++++", address);
47+
tracing::debug!("Replacing bytecode at address {:?}", address);
4848
}
4949
}
5050
}

crates/cli/src/cli.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::utils::parse_genesis_file;
22
use alloy::signers::local::coins_bip39::{English, Mnemonic};
3+
use anvil_zksync_common::{sh_eprintln, sh_err};
34
use anvil_zksync_config::constants::{
45
DEFAULT_DISK_CACHE_DIR, DEFAULT_MNEMONIC, TEST_NODE_NETWORK_ID,
56
};
@@ -440,7 +441,7 @@ impl Cli {
440441
/// Checks for deprecated options and warns users.
441442
pub fn deprecated_config_option() {
442443
if env::args().any(|arg| arg == "--config" || arg.starts_with("--config=")) {
443-
eprintln!(
444+
sh_eprintln!(
444445
"Warning: The '--config' option has been removed. \
445446
Please migrate to using other configuration options or defaults."
446447
);
@@ -611,28 +612,28 @@ impl PeriodicStateDumper {
611612
let state_bytes = match node.dump_state(preserve_historical_states).await {
612613
Ok(bytes) => bytes,
613614
Err(err) => {
614-
tracing::error!("Failed to dump state: {:?}", err);
615+
sh_err!("Failed to dump state: {:?}", err);
615616
return;
616617
}
617618
};
618619

619620
let mut decoder = GzDecoder::new(&state_bytes.0[..]);
620621
let mut json_str = String::new();
621622
if let Err(err) = decoder.read_to_string(&mut json_str) {
622-
tracing::error!(?err, "Failed to decompress state bytes");
623+
sh_err!("Failed to decompress state bytes: {}", err);
623624
return;
624625
}
625626

626627
let state = match serde_json::from_str::<VersionedState>(&json_str) {
627628
Ok(state) => state,
628629
Err(err) => {
629-
tracing::error!(?err, "Failed to parse state JSON");
630+
sh_err!("Failed to parse state JSON: {}", err);
630631
return;
631632
}
632633
};
633634

634635
if let Err(err) = write_json_file(&dump_path, &state) {
635-
tracing::error!(?err, "Failed to write state to file");
636+
sh_err!("Failed to write state to file: {}", err);
636637
} else {
637638
tracing::trace!(path = ?dump_path, "Dumped state successfully");
638639
}

crates/cli/src/main.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use crate::bytecode_override::override_bytecodes;
22
use crate::cli::{Cli, Command, ForkUrl, PeriodicStateDumper};
33
use crate::utils::update_with_fork_details;
44
use anvil_zksync_api_server::NodeServerBuilder;
5+
use anvil_zksync_common::{sh_eprintln, sh_err, sh_warn};
56
use anvil_zksync_config::constants::{
67
DEFAULT_ESTIMATE_GAS_PRICE_SCALE_FACTOR, DEFAULT_ESTIMATE_GAS_SCALE_FACTOR,
78
DEFAULT_FAIR_PUBDATA_PRICE, DEFAULT_L1_GAS_PRICE, DEFAULT_L2_GAS_PRICE, LEGACY_RICH_WALLETS,
@@ -62,7 +63,7 @@ async fn main() -> anyhow::Result<()> {
6263
let (fork_client, transactions_to_replay) = match command {
6364
Command::Run => {
6465
if config.offline {
65-
tracing::warn!("Running in offline mode: default fee parameters will be used.");
66+
sh_warn!("Running in offline mode: default fee parameters will be used.");
6667
config = config
6768
.clone()
6869
.with_l1_gas_price(config.l1_gas_price.or(Some(DEFAULT_L1_GAS_PRICE)))
@@ -154,7 +155,7 @@ async fn main() -> anyhow::Result<()> {
154155
SystemContractsOptions::Local
155156
) {
156157
if let Some(path) = env::var_os("ZKSYNC_HOME") {
157-
tracing::info!("+++++ Reading local contracts from {:?} +++++", path);
158+
tracing::debug!("Reading local contracts from {:?}", path);
158159
}
159160
}
160161

@@ -265,7 +266,7 @@ async fn main() -> anyhow::Result<()> {
265266
// during replay. Otherwise, replay would send commands and hang.
266267
tokio::spawn(async move {
267268
if let Err(err) = node_executor.run().await {
268-
tracing::error!("node executor ended with error: {:?}", err);
269+
sh_err!("node executor ended with error: {:?}", err);
269270
}
270271
});
271272

@@ -328,7 +329,7 @@ async fn main() -> anyhow::Result<()> {
328329
server_handles.push(server.run());
329330
}
330331
Err(err) => {
331-
tracing::info!(
332+
sh_eprintln!(
332333
"Failed to bind to address {}:{}: {}. Retrying with a different port...",
333334
host,
334335
config.port,

crates/common/Cargo.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[package]
2+
name = "anvil_zksync_common"
3+
description = "anvil-zksync common"
4+
version.workspace = true
5+
edition.workspace = true
6+
authors.workspace = true
7+
homepage.workspace = true
8+
repository.workspace = true
9+
license.workspace = true
10+
keywords.workspace = true
11+
categories.workspace = true
12+
13+
[dependencies]
14+
anstream.workspace = true
15+
anstyle.workspace = true

crates/common/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub mod shell;

0 commit comments

Comments
 (0)