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: remove tracing::info usage #578

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
12 changes: 12 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ members = [
"crates/config",
"crates/core",
"crates/types",
"crates/common",
]
resolver = "2"

Expand Down Expand Up @@ -74,6 +75,8 @@ tracing-subscriber = { version = "0.3", features = [
"local-time",
] }
url = "2.5.4"
anstream = "0.6.18"
anstyle = "1.0.10"

#########################
# Test dependencies #
Expand All @@ -92,3 +95,4 @@ anvil_zksync_api_server = { path = "crates/api_server" }
anvil_zksync_config = { path = "crates/config" }
anvil_zksync_core = { path = "crates/core" }
anvil_zksync_types = { path = "crates/types" }
anvil_zksync_common = { path = "crates/common" }
1 change: 1 addition & 0 deletions crates/api_server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ categories.workspace = true
anvil_zksync_api_decl.workspace = true
anvil_zksync_core.workspace = true
anvil_zksync_types.workspace = true
anvil_zksync_common.workspace = true

zksync_types.workspace = true
zksync_web3_decl.workspace = true
Expand Down
5 changes: 2 additions & 3 deletions crates/api_server/src/impls/anvil.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::error::RpcError;
use anvil_zksync_api_decl::AnvilNamespaceServer;
use anvil_zksync_common::sh_warn;
use anvil_zksync_core::node::InMemoryNode;
use anvil_zksync_types::api::{DetailedTransaction, ResetRequest};
use anvil_zksync_types::Numeric;
Expand Down Expand Up @@ -100,9 +101,7 @@ impl AnvilNamespaceServer for AnvilNamespace {
}

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

Expand Down
1 change: 1 addition & 0 deletions crates/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ anvil_zksync_core.workspace = true
anvil_zksync_config.workspace = true
anvil_zksync_api_server.workspace = true
anvil_zksync_types.workspace = true
anvil_zksync_common.workspace = true

alloy = { workspace = true, default-features = false, features = ["signer-mnemonic"] }

Expand Down
2 changes: 1 addition & 1 deletion crates/cli/src/bytecode_override.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub async fn override_bytecodes(node: &InMemoryNode, bytecodes_dir: String) -> a
node.override_bytecode(address, bytecode)
.await
.expect("Failed to override bytecode");
tracing::info!("+++++ Replacing bytecode at address {:?} +++++", address);
tracing::debug!("Replacing bytecode at address {:?}", address);
}
}
}
Expand Down
11 changes: 6 additions & 5 deletions crates/cli/src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::utils::parse_genesis_file;
use alloy::signers::local::coins_bip39::{English, Mnemonic};
use anvil_zksync_common::{sh_eprintln, sh_err};
use anvil_zksync_config::constants::{
DEFAULT_DISK_CACHE_DIR, DEFAULT_MNEMONIC, TEST_NODE_NETWORK_ID,
};
Expand Down Expand Up @@ -432,7 +433,7 @@ impl Cli {
/// Checks for deprecated options and warns users.
pub fn deprecated_config_option() {
if env::args().any(|arg| arg == "--config" || arg.starts_with("--config=")) {
eprintln!(
sh_eprintln!(
"Warning: The '--config' option has been removed. \
Please migrate to using other configuration options or defaults."
);
Expand Down Expand Up @@ -600,28 +601,28 @@ impl PeriodicStateDumper {
let state_bytes = match node.dump_state(preserve_historical_states).await {
Ok(bytes) => bytes,
Err(err) => {
tracing::error!("Failed to dump state: {:?}", err);
sh_err!("Failed to dump state: {:?}", err);
return;
}
};

let mut decoder = GzDecoder::new(&state_bytes.0[..]);
let mut json_str = String::new();
if let Err(err) = decoder.read_to_string(&mut json_str) {
tracing::error!(?err, "Failed to decompress state bytes");
sh_err!("Failed to decompress state bytes: {}", err);
return;
}

let state = match serde_json::from_str::<VersionedState>(&json_str) {
Ok(state) => state,
Err(err) => {
tracing::error!(?err, "Failed to parse state JSON");
sh_err!("Failed to parse state JSON: {}", err);
return;
}
};

if let Err(err) = write_json_file(&dump_path, &state) {
tracing::error!(?err, "Failed to write state to file");
sh_err!("Failed to write state to file: {}", err);
} else {
tracing::trace!(path = ?dump_path, "Dumped state successfully");
}
Expand Down
9 changes: 5 additions & 4 deletions crates/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::bytecode_override::override_bytecodes;
use crate::cli::{Cli, Command, ForkUrl, PeriodicStateDumper};
use crate::utils::update_with_fork_details;
use anvil_zksync_api_server::NodeServerBuilder;
use anvil_zksync_common::{sh_eprintln, sh_err, sh_warn};
use anvil_zksync_config::constants::{
DEFAULT_ESTIMATE_GAS_PRICE_SCALE_FACTOR, DEFAULT_ESTIMATE_GAS_SCALE_FACTOR,
DEFAULT_FAIR_PUBDATA_PRICE, DEFAULT_L1_GAS_PRICE, DEFAULT_L2_GAS_PRICE, LEGACY_RICH_WALLETS,
Expand Down Expand Up @@ -59,7 +60,7 @@ async fn main() -> anyhow::Result<()> {
let (fork_client, transactions_to_replay) = match command {
Command::Run => {
if config.offline {
tracing::warn!("Running in offline mode: default fee parameters will be used.");
sh_warn!("Running in offline mode: default fee parameters will be used.");
config = config
.clone()
.with_l1_gas_price(config.l1_gas_price.or(Some(DEFAULT_L1_GAS_PRICE)))
Expand Down Expand Up @@ -151,7 +152,7 @@ async fn main() -> anyhow::Result<()> {
SystemContractsOptions::Local
) {
if let Some(path) = env::var_os("ZKSYNC_HOME") {
tracing::info!("+++++ Reading local contracts from {:?} +++++", path);
tracing::debug!("Reading local contracts from {:?}", path);
}
}

Expand Down Expand Up @@ -251,7 +252,7 @@ async fn main() -> anyhow::Result<()> {
// during replay. Otherwise, replay would send commands and hang.
tokio::spawn(async move {
if let Err(err) = node_executor.run().await {
tracing::error!("node executor ended with error: {:?}", err);
sh_err!("node executor ended with error: {:?}", err);
}
});

Expand Down Expand Up @@ -313,7 +314,7 @@ async fn main() -> anyhow::Result<()> {
server_handles.push(server.run());
}
Err(err) => {
tracing::info!(
sh_eprintln!(
"Failed to bind to address {}:{}: {}. Retrying with a different port...",
host,
config.port,
Expand Down
15 changes: 15 additions & 0 deletions crates/common/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "anvil_zksync_common"
description = "anvil-zksync common"
version.workspace = true
edition.workspace = true
authors.workspace = true
homepage.workspace = true
repository.workspace = true
license.workspace = true
keywords.workspace = true
categories.workspace = true

[dependencies]
anstream.workspace = true
anstyle.workspace = true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: missing newline

1 change: 1 addition & 0 deletions crates/common/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod shell;
Loading