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

fix: fixes broken logging and adds structure to logs #411

Open
wants to merge 15 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
42 changes: 16 additions & 26 deletions src/config/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,14 @@ pub struct Cli {
/// Show call debug information.
pub show_calls: Option<ShowCalls>,

#[arg(long, help_heading = "Debugging Options")]
#[arg(long, requires = "show_calls", help_heading = "Debugging Options")]
/// Show call output information.
pub show_outputs: Option<bool>,

#[arg(long, help_heading = "Debugging Options")]
/// Show event logs information.
pub show_event_logs: Option<bool>,

#[arg(long, help_heading = "Debugging Options")]
/// Show storage log information.
pub show_storage_logs: Option<ShowStorageLogs>,
Expand All @@ -86,7 +90,7 @@ pub struct Cli {
/// Show gas details information.
pub show_gas_details: Option<ShowGasDetails>,

#[arg(long, help_heading = "Debugging Options")]
#[arg(short, long, help_heading = "Debugging Options")]
/// If true, the tool will try to resolve ABI and topic names for better readability.
/// May decrease performance.
pub resolve_hashes: Option<bool>,
Expand Down Expand Up @@ -274,31 +278,20 @@ impl Cli {
pub fn into_test_node_config(self) -> eyre::Result<TestNodeConfig> {
let genesis_balance = U256::from(self.balance as u128 * 10u128.pow(18));

let vm_log_detail = if let Some(output) = self.show_outputs {
if output {
Some(ShowVMDetails::All)
} else {
Some(ShowVMDetails::None)
}
} else if let Some(logs) = self.show_storage_logs {
match logs {
ShowStorageLogs::None => Some(ShowVMDetails::None),
_ => Some(ShowVMDetails::All),
}
} else {
None
};

let config = TestNodeConfig::default()
let mut config = TestNodeConfig::default()
.with_port(self.port)
.with_l1_gas_price(self.l1_gas_price)
.with_l2_gas_price(self.l2_gas_price)
.with_l1_pubdata_price(self.l1_pubdata_price)
.with_show_calls(self.show_calls)
.with_vm_log_detail(vm_log_detail)
.with_vm_log_detail(self.show_vm_details)
.with_show_storage_logs(self.show_storage_logs)
.with_show_gas_details(self.show_gas_details)
.with_show_outputs(self.show_outputs)
.with_show_event_logs(self.show_event_logs)
.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_system_contracts(self.dev_system_contracts)
.with_override_bytecodes_dir(self.override_bytecodes_dir.clone()) // Added
.with_log_level(self.log)
Expand Down Expand Up @@ -336,13 +329,10 @@ impl Cli {
}

if self.debug_mode {
Ok(config
.with_show_calls(Some(ShowCalls::All))
.with_vm_log_detail(Some(ShowVMDetails::All))
.with_resolve_hashes(Some(true)))
} else {
Ok(config)
config = config.with_debug_mode();
}

Ok(config)
}

fn account_generator(&self) -> AccountGenerator {
Expand Down
96 changes: 82 additions & 14 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ pub struct TestNodeConfig {
pub show_vm_details: ShowVMDetails,
/// Level of detail for gas usage logs
pub show_gas_details: ShowGasDetails,
/// Whether to show event logs
pub show_event_logs: bool,
/// Whether to resolve hash references
pub resolve_hashes: bool,
/// Configuration for system contracts
Expand Down Expand Up @@ -122,6 +124,7 @@ impl Default for TestNodeConfig {
show_storage_logs: Default::default(),
show_vm_details: Default::default(),
show_gas_details: Default::default(),
show_event_logs: false,
resolve_hashes: false,
system_contracts_options: Default::default(),
override_bytecodes_dir: None,
Expand Down Expand Up @@ -528,6 +531,15 @@ impl TestNodeConfig {
&self.log_file_path
}

/// Applies the defaults for debug mode.
#[must_use]
pub fn with_debug_mode(mut self) -> Self {
self.show_calls = ShowCalls::User;
self.resolve_hashes = true;
self.show_gas_details = ShowGasDetails::All;
self
}

/// Set the visibility of call logs
#[must_use]
pub fn with_show_calls(mut self, show_calls: Option<ShowCalls>) -> Self {
Expand Down Expand Up @@ -556,6 +568,76 @@ impl TestNodeConfig {
self.resolve_hashes
}

/// Set the visibility of storage logs
#[must_use]
pub fn with_show_storage_logs(mut self, show_storage_logs: Option<ShowStorageLogs>) -> Self {
if let Some(show_storage_logs) = show_storage_logs {
self.show_storage_logs = show_storage_logs;
}
self
}

/// Get the visibility of storage logs
pub fn get_show_storage_logs(&self) -> ShowStorageLogs {
self.show_storage_logs
}

/// Set the detail level of VM execution logs
#[must_use]
pub fn with_vm_log_detail(mut self, detail: Option<ShowVMDetails>) -> Self {
if let Some(detail) = detail {
self.show_vm_details = detail;
}
self
}

/// Get the detail level of VM execution logs
pub fn get_vm_log_detail(&self) -> ShowVMDetails {
self.show_vm_details
}

/// Set the visibility of gas usage logs
#[must_use]
pub fn with_show_gas_details(mut self, show_gas_details: Option<ShowGasDetails>) -> Self {
if let Some(show_gas_details) = show_gas_details {
self.show_gas_details = show_gas_details;
}
self
}

/// Get the visibility of gas usage logs
pub fn get_show_gas_details(&self) -> ShowGasDetails {
self.show_gas_details
}

/// Set the visibility of event logs
#[must_use]
pub fn with_show_event_logs(mut self, show_event_logs: Option<bool>) -> Self {
if let Some(show_event_logs) = show_event_logs {
self.show_event_logs = show_event_logs;
}
self
}

/// Get the visibility of event logs
pub fn get_show_event_logs(&self) -> bool {
self.show_event_logs
}

/// Set show outputs
#[must_use]
pub fn with_show_outputs(mut self, show_outputs: Option<bool>) -> Self {
if let Some(show_outputs) = show_outputs {
self.show_outputs = show_outputs;
}
self
}

/// Get show outputs
pub fn get_show_outputs(&self) -> bool {
self.show_outputs
}

/// Set the gas limit scale factor
#[must_use]
pub fn with_gas_limit_scale(mut self, scale: Option<f32>) -> Self {
Expand Down Expand Up @@ -586,20 +668,6 @@ impl TestNodeConfig {
.unwrap_or(DEFAULT_ESTIMATE_GAS_PRICE_SCALE_FACTOR)
}

/// Set the detail level of VM execution logs
#[must_use]
pub fn with_vm_log_detail(mut self, detail: Option<ShowVMDetails>) -> Self {
if let Some(detail) = detail {
self.show_vm_details = detail;
}
self
}

/// Get the detail level of VM execution logs
pub fn get_vm_log_detail(&self) -> ShowVMDetails {
self.show_vm_details
}

/// Sets the balance of the genesis accounts in the genesis block
#[must_use]
pub fn with_genesis_balance<U: Into<U256>>(mut self, balance: U) -> Self {
Expand Down
145 changes: 44 additions & 101 deletions src/data/address_map.json
Original file line number Diff line number Diff line change
@@ -1,102 +1,45 @@
[
[
"0x0000000000000000000000000000000000008001",
"bootloader",
"System"
],
[
"0x0000000000000000000000000000000000008002",
"Account Code Storage",
"System"
],
[
"0x0000000000000000000000000000000000008003",
"Nonce Holder",
"System"
],
[
"0x0000000000000000000000000000000000008004",
"Known code storage",
"System"
],
[
"0x0000000000000000000000000000000000008005",
"ImmutableSimulator",
"System"
],
[
"0x0000000000000000000000000000000000008006",
"L2 deployer",
"System"
],
[
"0x0000000000000000000000000000000000008007",
"Force L2 deployer",
"System"
],
[
"0x0000000000000000000000000000000000008008",
"L1 messenger",
"System"
],
[
"0x0000000000000000000000000000000000008009",
"Msg Value System Contract",
"System"
],
[
"0x000000000000000000000000000000000000800a",
"EthToken System Contract",
"System"
],
[
"0x000000000000000000000000000000000000800b",
"System context",
"System"
],
[
"0x000000000000000000000000000000000000800c",
"Bootloader utilities",
"System"
],
[
"0x000000000000000000000000000000000000800d",
"Event writer",
"System"
],
[
"0x000000000000000000000000000000000000800e",
"Compressor",
"System"
],
[
"0x000000000000000000000000000000000000800f",
"ComplexUpgrader",
"System"
],
[
"0x0000000000000000000000000000000000008010",
"Keccak",
"Precompile"
],
[
"0x0000000000000000000000000000000000008011",
"PubdataChunkPublisher",
"System"
],
[
"0x0000000000000000000000000000000000008012",
"CodeOracle",
"System"
],
[
"0x000000000000000000636f6e736f6c652e6c6f67",
"Console log",
"Precompile"
],
[
"0x0000000000000000000000000000000000010000",
"Create2Factory",
"Popular"
]
]
["0x0000000000000000000000000000000000008001", "bootloader", "System"],
[
"0x0000000000000000000000000000000000008002",
"AccountCodeStorage",
"System"
],
["0x0000000000000000000000000000000000008003", "NonceHolder", "System"],
["0x0000000000000000000000000000000000008004", "KnownCodesStorage", "System"],
[
"0x0000000000000000000000000000000000008005",
"ImmutableSimulator",
"System"
],
["0x0000000000000000000000000000000000008006", "ContractDeployer", "System"],
["0x0000000000000000000000000000000000008007", "ForceL2Deployer", "System"],
["0x0000000000000000000000000000000000008008", "L1Messenger", "System"],
["0x0000000000000000000000000000000000008009", "MsgValueSimulator", "System"],
["0x000000000000000000000000000000000000800a", "L2BaseToken", "System"],
["0x000000000000000000000000000000000000800b", "SystemContext", "System"],
[
"0x000000000000000000000000000000000000800c",
"BootloaderUtilities",
"System"
],
["0x000000000000000000000000000000000000800d", "EventWriter", "System"],
["0x000000000000000000000000000000000000800e", "Compressor", "System"],
["0x000000000000000000000000000000000000800f", "ComplexUpgrader", "System"],
["0x0000000000000000000000000000000000008010", "Keccak", "Precompile"],
[
"0x0000000000000000000000000000000000008011",
"PubdataChunkPublisher",
"System"
],
["0x0000000000000000000000000000000000008012", "CodeOracle", "System"],
["0x000000000000000000636f6e736f6c652e6c6f67", "ConsoleLog", "Precompile"],
["0x0000000000000000000000000000000000010000", "Create2Factory", "System"],
["0x0000000000000000000000000000000000000002", "SHA256", "Precompile"],
["0x0000000000000000000000000000000000000001", "ECRecover", "Precompile"],
["0x0000000000000000000000000000000000000006", "EcAdd", "Precompile"],
["0x0000000000000000000000000000000000000007", "EcMul", "Precompile"],
["0x0000000000000000000000000000000000000008", "EcPairing", "Precompile"],
["0xc706EC7dfA5D4Dc87f29f859094165E8290530f5", "GasBoundCaller", "System"],
["0x0000000000000000000000000000000000000100", "P256Verify", "System"]
]
Loading