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

feat: introduces verbosity cli option with foundry-style traces #577

Draft
wants to merge 16 commits into
base: main
Choose a base branch
from
Draft
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
3 changes: 3 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 @@ -81,6 +81,7 @@ tracing-subscriber = { version = "0.3", features = [
"local-time",
] }
url = "2.5.4"
colorchoice = "1.0"
anstream = "0.6.18"
anstyle = "1.0.10"

Expand All @@ -102,3 +103,6 @@ anvil_zksync_core = { path = "crates/core" }
anvil_zksync_l1_sidecar = { path = "crates/l1_sidecar" }
anvil_zksync_types = { path = "crates/types" }
anvil_zksync_common = { path = "crates/common" }

# macros
derive_more = { version = "1.0", features = ["full"] }
14 changes: 12 additions & 2 deletions crates/cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use anvil_zksync_types::{
LogLevel, ShowCalls, ShowGasDetails, ShowStorageLogs, ShowVMDetails, TransactionOrder,
};
use anyhow::Result;
use clap::{arg, command, Parser, Subcommand};
use clap::{arg, command, ArgAction, Parser, Subcommand};
use flate2::read::GzDecoder;
use futures::FutureExt;
use rand::{rngs::StdRng, SeedableRng};
Expand Down Expand Up @@ -132,6 +132,16 @@ pub struct Cli {
/// May decrease performance.
pub resolve_hashes: Option<bool>,

/// Increments verbosity each time it is used. (-vv, -vvv)
///
/// Example usage:
/// - `-vv` => verbosity level 2 (includes user calls and event calls)
/// - `-vvv` => level 3 (includes system calls, system event calls)
/// - `-vvvv` => level 4 (includes system calls, system event calls, and precompiles)
/// - `-vvvvv` => level 5 (includes everything)
#[arg(short = 'v', long = "verbosity", action = ArgAction::Count, help_heading = "Debugging Options")]
pub verbosity: u8,

// Gas Configuration
#[arg(long, help_heading = "Gas Configuration")]
/// Custom L1 gas price (in wei).
Expand Down Expand Up @@ -490,7 +500,7 @@ impl Cli {
.with_resolve_hashes(self.resolve_hashes)
.with_gas_limit_scale(self.limit_scale_factor)
.with_price_scale(self.price_scale_factor)
.with_resolve_hashes(self.resolve_hashes)
.with_verbosity_level(self.verbosity)
.with_show_node_config(self.show_node_config)
.with_silent(self.silent)
.with_system_contracts(self.dev_system_contracts)
Expand Down
7 changes: 7 additions & 0 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::shell::get_shell;
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,
Expand Down Expand Up @@ -47,6 +48,12 @@ async fn main() -> anyhow::Result<()> {

let mut config = opt.into_test_node_config().map_err(|e| anyhow!(e))?;

// Set verbosity level for the shell
{
let mut shell = get_shell();
shell.verbosity = config.verbosity;
}

let log_level_filter = LevelFilter::from(config.log_level);
let log_file = File::create(&config.log_file_path)?;

Expand Down
15 changes: 15 additions & 0 deletions crates/config/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ pub struct TestNodeConfig {
pub show_vm_details: ShowVMDetails,
/// Level of detail for gas usage logs
pub show_gas_details: ShowGasDetails,
/// Numeric verbosity derived from repeated `-v` flags (e.g. -v = 1, -vv = 2, etc.).
pub verbosity: u8,
/// Whether to resolve hash references
pub resolve_hashes: bool,
/// Don’t print anything on startup if true
Expand Down Expand Up @@ -162,6 +164,7 @@ impl Default for TestNodeConfig {
show_vm_details: Default::default(),
show_gas_details: Default::default(),
resolve_hashes: false,
verbosity: 0,
silent: false,
system_contracts_options: Default::default(),
override_bytecodes_dir: None,
Expand Down Expand Up @@ -700,6 +703,18 @@ Port: {}
self
}

/// Sets the numeric verbosity derived from repeated `-v` flags
#[must_use]
pub fn with_verbosity_level(mut self, verbosity: u8) -> Self {
self.verbosity = verbosity;
self
}

/// Get the numeric verbosity derived from repeated `-v` flags
pub fn get_verbosity_level(&self) -> u8 {
self.verbosity
}

/// Enable or disable silent mode
#[must_use]
pub fn with_silent(mut self, silent: Option<bool>) -> Self {
Expand Down
10 changes: 9 additions & 1 deletion crates/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ tokio.workspace = true
futures.workspace = true
once_cell.workspace = true

alloy = { workspace = true, default-features = false, features = ["json-abi", "dyn-abi", "eip712"] }
alloy = { workspace = true, default-features = false, features = ["json-abi", "dyn-abi", "sol-types", "eip712"] }

reqwest.workspace = true
serde.workspace = true
Expand All @@ -45,9 +45,17 @@ thiserror.workspace = true
async-trait.workspace = true
url.workspace = true

derive_more.workspace = true
anstyle.workspace = true
colorchoice.workspace = true

[dev-dependencies]
maplit.workspace = true
httptest.workspace = true
tempdir.workspace = true
test-case.workspace = true
backon.workspace = true

[features]
serde = []
arbitrary = []
1 change: 1 addition & 0 deletions crates/core/src/data/HardhatConsole.json

Large diffs are not rendered by default.

33 changes: 32 additions & 1 deletion crates/core/src/data/address_map.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,36 @@
["0x0000000000000000000000000000000000000007", "EcMul", "Precompile"],
["0x0000000000000000000000000000000000000008", "EcPairing", "Precompile"],
["0xc706EC7dfA5D4Dc87f29f859094165E8290530f5", "GasBoundCaller", "System"],
["0x0000000000000000000000000000000000000100", "P256Verify", "System"]
["0x0000000000000000000000000000000000000100", "P256Verify", "System"],
["0x000000000000000000636F6e736F6c652e6c6f67", "console", "Popular"],
["0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", "GenesisAccount", "Popular"],
["0x70997970C51812dc3A010C7d01b50e0d17dc79C8", "GenesisAccount", "Popular"],
["0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC", "GenesisAccount", "Popular"],
["0x90F79bf6EB2c4f870365E785982E1f101E93b906", "GenesisAccount", "Popular"],
["0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65", "GenesisAccount", "Popular"],
["0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc", "GenesisAccount", "Popular"],
["0x976EA74026E726554dB657fA54763abd0C3a0aa9", "GenesisAccount", "Popular"],
["0x14dC79964da2C08b23698B3D3cc7Ca32193d9955", "GenesisAccount", "Popular"],
["0x23618e81E3f5cdF7f54C3d65f7FBc0aBf5B21E8f", "GenesisAccount", "Popular"],
["0xa0Ee7A142d267C1f36714E4a8F75612F20a79720", "GenesisAccount", "Popular"],
["0xBC989fDe9e54cAd2aB4392Af6dF60f04873A033A", "RichAccount", "Popular"],
["0x55bE1B079b53962746B2e86d12f158a41DF294A6", "RichAccount", "Popular"],
["0xCE9e6063674DC585F6F3c7eaBe82B9936143Ba6C", "RichAccount", "Popular"],
["0xd986b0cB0D1Ad4CCCF0C4947554003fC0Be548E9", "RichAccount", "Popular"],
["0x87d6ab9fE5Adef46228fB490810f0F5CB16D6d04", "RichAccount", "Popular"],
["0x78cAD996530109838eb016619f5931a03250489A", "RichAccount", "Popular"],
["0xc981b213603171963F81C687B9fC880d33CaeD16", "RichAccount", "Popular"],
["0x42F3dc38Da81e984B92A95CBdAAA5fA2bd5cb1Ba", "RichAccount", "Popular"],
["0x64F47EeD3dC749d13e49291d46Ea8378755fB6DF", "RichAccount", "Popular"],
["0xe2b8Cb53a43a56d4d2AB6131C81Bd76B86D3AFe5", "RichAccount", "Popular"],
["0x36615Cf349d7F6344891B1e7CA7C72883F5dc049", "RichAccount", "Popular"],
["0xa61464658AfeAf65CccaaFD3a512b69A83B77618", "RichAccount", "Popular"],
["0x0D43eB5B8a47bA8900d84AA36656c92024e9772e", "RichAccount", "Popular"],
["0xA13c10C0D5bd6f79041B9835c63f91de35A15883", "RichAccount", "Popular"],
["0x8002cD98Cfb563492A6fB3E7C8243b7B9Ad4cc92", "RichAccount", "Popular"],
["0x4F9133D1d3F50011A6859807C837bdCB31Aaab13", "RichAccount", "Popular"],
["0xbd29A1B981925B94eEc5c4F1125AF02a2Ec4d1cA", "RichAccount", "Popular"],
["0xedB6F5B4aab3dD95C7806Af42881FF12BE7e9daa", "RichAccount", "Popular"],
["0xe706e60ab5Dc512C36A4646D719b889F398cbBcB", "RichAccount", "Popular"],
["0xE90E12261CCb0F3F7976Ae611A29e84a6A85f424", "RichAccount", "Popular"]
]
Loading
Loading