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: fix issue with gas params #471

Merged
merged 2 commits into from
Dec 4, 2024
Merged
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
1 change: 1 addition & 0 deletions src/config/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/config/constants.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
14 changes: 7 additions & 7 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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: {}",
Expand Down
26 changes: 23 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -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();
Expand All @@ -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
Expand Down Expand Up @@ -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"));
Expand Down
4 changes: 2 additions & 2 deletions src/node/zks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Loading