From 6dbd35ba62393e4a42a6fd6d47ec896b10acdb12 Mon Sep 17 00:00:00 2001 From: AntonD3 Date: Wed, 2 Aug 2023 22:40:32 +0200 Subject: [PATCH] Update default l1 gas price value, add CLI arg --- src/main.rs | 11 +++++++++-- src/node.rs | 14 ++++++++++---- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index 80bf7ad5..04d185fd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -117,6 +117,11 @@ struct Cli { #[arg(long)] /// If true, will load the locally compiled system contracts (useful when doing changes to system contracts or bootloader) dev_use_local_contracts: bool, + + #[arg(long)] + /// Whether to override the l1 gas price. + /// If not set - fork or default value(`1 gwei`) will be used. + override_l1_gas_price: Option, } #[derive(Debug, Parser, Clone, clap::ValueEnum, PartialEq, Eq)] @@ -170,10 +175,11 @@ struct ForkArgs { /// - http://XXX:YY network: String, #[arg(long)] - // Fork at a given L2 miniblock height. - // If not set - will use the current finalized block from the network. + /// Fork at a given L2 miniblock height. + /// If not set - will use the current finalized block from the network. fork_at: Option, } + #[derive(Debug, Parser)] struct ReplayArgs { /// Whether to fork from existing network. @@ -228,6 +234,7 @@ async fn main() -> anyhow::Result<()> { let node = InMemoryNode::new( fork_details, + opt.override_l1_gas_price, opt.show_calls, opt.resolve_hashes, opt.dev_use_local_contracts, diff --git a/src/node.rs b/src/node.rs index 8cb4d6c2..3d931183 100644 --- a/src/node.rs +++ b/src/node.rs @@ -198,10 +198,19 @@ fn contract_address_from_tx_result(execution_result: &VmTxExecutionResult) -> Op impl InMemoryNode { pub fn new( fork: Option, + override_l1_gas_price: Option, show_calls: ShowCalls, resolve_hashes: bool, dev_use_local_contracts: bool, ) -> Self { + let mut l1_gas_price = fork + .as_ref() + .map(|f| f.l1_gas_price) + .unwrap_or(1_000_000_000); // 1 gwei + if let Some(override_l1_gas_price) = override_l1_gas_price { + l1_gas_price = override_l1_gas_price; + } + InMemoryNode { inner: Arc::new(RwLock::new(InMemoryNodeInner { current_timestamp: fork @@ -210,10 +219,7 @@ impl InMemoryNode { .unwrap_or(NON_FORK_FIRST_BLOCK_TIMESTAMP), current_batch: fork.as_ref().map(|f| f.l1_block.0 + 1).unwrap_or(1), current_miniblock: fork.as_ref().map(|f| f.l2_miniblock + 1).unwrap_or(1), - l1_gas_price: fork - .as_ref() - .map(|f| f.l1_gas_price) - .unwrap_or(50_000_000_000), + l1_gas_price, tx_results: Default::default(), blocks: Default::default(), fork_storage: ForkStorage::new(fork, dev_use_local_contracts),