From 2cf41a801e7e59cd54c60caa13cb059039713bcc Mon Sep 17 00:00:00 2001 From: Dustin Brickwood Date: Wed, 4 Dec 2024 11:35:31 -0600 Subject: [PATCH 1/2] fix: fix issue with gas params --- src/config/cli.rs | 1 + src/config/constants.rs | 2 +- src/config/mod.rs | 14 +++++++------- src/main.rs | 26 +++++++++++++++++++++++--- 4 files changed, 32 insertions(+), 11 deletions(-) diff --git a/src/config/cli.rs b/src/config/cli.rs index 81a80316..c59448a7 100644 --- a/src/config/cli.rs +++ b/src/config/cli.rs @@ -332,6 +332,7 @@ impl Cli { let mut config = TestNodeConfig::default() .with_port(self.port) + .with_offline(if self.offline { Some(true) } else { None }) .with_l1_gas_price(self.l1_gas_price) .with_l2_gas_price(self.l2_gas_price) .with_l1_pubdata_price(self.l1_pubdata_price) diff --git a/src/config/constants.rs b/src/config/constants.rs index 36ad3fda..f2bc3c42 100644 --- a/src/config/constants.rs +++ b/src/config/constants.rs @@ -1,7 +1,7 @@ /// Default directory for disk cache pub const DEFAULT_DISK_CACHE_DIR: &str = ".cache"; /// Default L1 gas price for transactions -pub const DEFAULT_L1_GAS_PRICE: u64 = 14_932_364_075; +pub const DEFAULT_L1_GAS_PRICE: u64 = 35_932_364_075; /// Default L2 gas price for transactions if not provided via CLI pub const DEFAULT_L2_GAS_PRICE: u64 = 45_250_000; /// Default price for fair pubdata based on predefined value diff --git a/src/config/mod.rs b/src/config/mod.rs index 39a3a416..28bfae82 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -156,14 +156,14 @@ impl Default for TestNodeConfig { system_contracts_options: Default::default(), override_bytecodes_dir: None, use_evm_emulator: false, - chain_id: Some(TEST_NODE_NETWORK_ID), + chain_id: None, // Gas configuration defaults - l1_gas_price: Some(DEFAULT_L1_GAS_PRICE), - l2_gas_price: Some(DEFAULT_L2_GAS_PRICE), - l1_pubdata_price: Some(DEFAULT_FAIR_PUBDATA_PRICE), - price_scale_factor: Some(DEFAULT_ESTIMATE_GAS_PRICE_SCALE_FACTOR), - limit_scale_factor: Some(DEFAULT_ESTIMATE_GAS_SCALE_FACTOR), + l1_gas_price: None, + l2_gas_price: None, + l1_pubdata_price: None, + price_scale_factor: None, + limit_scale_factor: None, // Log configuration defaults log_level: Default::default(), @@ -215,7 +215,7 @@ impl TestNodeConfig { let color = CustomColor::new(13, 71, 198); println!("{}", BANNER.custom_color(color)); - println!("testing"); + tracing::info!("Version: {}", VERSION_MESSAGE.green()); tracing::info!( "Repository: {}", diff --git a/src/main.rs b/src/main.rs index f88d2e16..80bd4792 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,11 +1,13 @@ use crate::observability::Observability; +use anvil_zksync::config::constants::DEFAULT_L1_GAS_PRICE; use anyhow::anyhow; use bytecode_override::override_bytecodes; use clap::Parser; use config::cli::{Cli, Command}; use config::constants::{ DEFAULT_ESTIMATE_GAS_PRICE_SCALE_FACTOR, DEFAULT_ESTIMATE_GAS_SCALE_FACTOR, - LEGACY_RICH_WALLETS, RICH_WALLETS, + DEFAULT_FAIR_PUBDATA_PRICE, DEFAULT_L2_GAS_PRICE, LEGACY_RICH_WALLETS, RICH_WALLETS, + TEST_NODE_NETWORK_ID, }; use config::ForkPrintInfo; use fork::{ForkDetails, ForkSource}; @@ -111,7 +113,6 @@ async fn build_json_http< async fn main() -> anyhow::Result<()> { // Check for deprecated options Cli::deprecated_config_option(); - tracing::info!(target: "anvil-zksync", "This is a test log with explicit target"); let opt = Cli::parse(); let command = opt.command.clone(); @@ -135,6 +136,24 @@ async fn main() -> anyhow::Result<()> { Command::Run => { if config.offline { tracing::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))) + .with_l2_gas_price(config.l2_gas_price.or(Some(DEFAULT_L2_GAS_PRICE))) + .with_price_scale( + config + .price_scale_factor + .or(Some(DEFAULT_ESTIMATE_GAS_PRICE_SCALE_FACTOR)), + ) + .with_gas_limit_scale( + config + .limit_scale_factor + .or(Some(DEFAULT_ESTIMATE_GAS_SCALE_FACTOR)), + ) + .with_l1_pubdata_price( + config.l1_pubdata_price.or(Some(DEFAULT_FAIR_PUBDATA_PRICE)), + ) + .with_chain_id(config.chain_id.or(Some(TEST_NODE_NETWORK_ID))); None } else { // Initialize the client to get the fee params @@ -168,7 +187,8 @@ async fn main() -> anyhow::Result<()> { ) .with_l1_pubdata_price( config.l1_pubdata_price.or(Some(fee_v2.l1_pubdata_price())), - ); + ) + .with_chain_id(Some(TEST_NODE_NETWORK_ID)); } FeeParams::V1(_) => { return Err(anyhow!("Unsupported FeeParams::V1 in this context")); From 702f0e8b00858d6546774047a73dc5b4f658fc19 Mon Sep 17 00:00:00 2001 From: Dustin Brickwood Date: Wed, 4 Dec 2024 12:01:00 -0600 Subject: [PATCH 2/2] chore: fix tests --- src/node/zks.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/node/zks.rs b/src/node/zks.rs index 101d385b..11b0de22 100644 --- a/src/node/zks.rs +++ b/src/node/zks.rs @@ -623,10 +623,10 @@ mod tests { let result = node.estimate_fee(mock_request).await.unwrap(); - assert_eq!(result.gas_limit, U256::from(279779)); + assert_eq!(result.gas_limit, U256::from(409123)); assert_eq!(result.max_fee_per_gas, U256::from(45250000)); assert_eq!(result.max_priority_fee_per_gas, U256::from(0)); - assert_eq!(result.gas_per_pubdata_limit, U256::from(1658)); + assert_eq!(result.gas_per_pubdata_limit, U256::from(3143)); } #[tokio::test]