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

Merged
merged 22 commits into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
36767a6
chore: remove tracing::info in favour of pure stdout
dutterbutter Feb 4, 2025
debc56d
chore: linting
dutterbutter Feb 4, 2025
0d3b49f
chore: fix formatting
dutterbutter Feb 4, 2025
32abbd8
feat: move to use shell io
dutterbutter Feb 4, 2025
83e902d
feat: introduce shell io abstraction for logging
dutterbutter Feb 4, 2025
270831f
Merge branch 'main' into db/remove-tracing-info
dutterbutter Feb 4, 2025
8903105
chore: remove clippy unused println
dutterbutter Feb 4, 2025
df52cfc
Merge branch 'db/remove-tracing-info' of github.com:matter-labs/anvil…
dutterbutter Feb 4, 2025
89e04dd
chore: linting
dutterbutter Feb 4, 2025
edb2789
feat: make use of anstream and anystyle, remove use of atty
dutterbutter Feb 6, 2025
82af8fe
chore: linting
dutterbutter Feb 6, 2025
a1701ff
Merge branch 'main' into db/remove-tracing-info
dutterbutter Feb 6, 2025
5e2e87d
feat: turn tracing off by default, update messages
dutterbutter Feb 6, 2025
fcba826
Merge branch 'db/remove-tracing-info' of github.com:matter-labs/anvil…
dutterbutter Feb 6, 2025
649e492
chore: resolve conflicts
dutterbutter Feb 6, 2025
b6c9d62
Merge branch 'main' into db/remove-tracing-info
dutterbutter Feb 7, 2025
9a8de7f
chore: make requested changes
dutterbutter Feb 10, 2025
85d5c9e
chore: update pool_rs
dutterbutter Feb 10, 2025
5508301
chore: linting, fix formatting. Remove uneeded colorize
dutterbutter Feb 10, 2025
4908676
chore: make requested changes
dutterbutter Feb 11, 2025
5801503
chore: linting
dutterbutter Feb 11, 2025
ffba45a
chore: resolve conflicts
dutterbutter Feb 12, 2025
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
35 changes: 33 additions & 2 deletions Cargo.lock

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

3 changes: 3 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,7 @@ tracing-subscriber = { version = "0.3", features = [
"local-time",
] }
url = "2.5.4"
atty = "0.2"
dutterbutter marked this conversation as resolved.
Show resolved Hide resolved

#########################
# Test dependencies #
Expand All @@ -92,3 +94,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
3 changes: 2 additions & 1 deletion crates/cli/src/bytecode_override.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use anvil_zksync_common::sh_println;
use anvil_zksync_core::node::InMemoryNode;
use anyhow::Context;
use hex::FromHex;
Expand Down Expand Up @@ -44,7 +45,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);
sh_println!("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
11 changes: 6 additions & 5 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_println, 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);
sh_println!("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 All @@ -325,7 +326,7 @@ async fn main() -> anyhow::Result<()> {
match server_builder.clone().build(addr).await {
Ok(server) => {
config.port = server.local_addr().port();
tracing::info!(
sh_println!(
"Successfully started server on port {} for host {}",
config.port,
host
Expand Down
14 changes: 14 additions & 0 deletions crates/common/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[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]
atty.workspace = true
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