Skip to content

Commit

Permalink
fix: fixes gas params usage and add alias (#440)
Browse files Browse the repository at this point in the history
* fix: fixes broken gas params cli settings

* chore: fix gas params and add alias

* feat: adds support for configuring gas params for fork instances
  • Loading branch information
dutterbutter authored Nov 27, 2024
1 parent 47b3bf2 commit d3e51cc
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/config/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ pub struct Cli {
/// Custom L1 gas price (in wei).
pub l1_gas_price: Option<u64>,

#[arg(long, help_heading = "Gas Configuration")]
#[arg(long, alias = "gas-price", help_heading = "Gas Configuration")]
/// Custom L2 gas price (in wei).
pub l2_gas_price: Option<u64>,

Expand Down
24 changes: 18 additions & 6 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -730,12 +730,24 @@ impl TestNodeConfig {
) -> Result<Option<ForkDetails>, anyhow::Error> {
match fork_details_result {
Ok(fd) => {
self.update_l1_gas_price(Some(fd.l1_gas_price))
.update_l2_gas_price(Some(fd.l2_fair_gas_price))
.update_l1_pubdata_price(Some(fd.fair_pubdata_price))
.update_price_scale(Some(fd.estimate_gas_price_scale_factor))
.update_gas_limit_scale(Some(fd.estimate_gas_scale_factor))
.update_chain_id(Some(fd.chain_id.as_u64() as u32));
let l1_gas_price = self.l1_gas_price.or(Some(fd.l1_gas_price));
let l2_gas_price = self.l2_gas_price.or(Some(fd.l2_fair_gas_price));
let l1_pubdata_price = self.l1_pubdata_price.or(Some(fd.fair_pubdata_price));
let price_scale = self
.price_scale_factor
.or(Some(fd.estimate_gas_price_scale_factor));
let gas_limit_scale = self
.limit_scale_factor
.or(Some(fd.estimate_gas_scale_factor));
let chain_id = self.chain_id.or(Some(fd.chain_id.as_u64() as u32));

self.update_l1_gas_price(l1_gas_price)
.update_l2_gas_price(l2_gas_price)
.update_l1_pubdata_price(l1_pubdata_price)
.update_price_scale(price_scale)
.update_gas_limit_scale(gas_limit_scale)
.update_chain_id(chain_id);

Ok(Some(fd))
}
Err(error) => {
Expand Down
25 changes: 20 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,26 @@ async fn main() -> anyhow::Result<()> {
match fee {
FeeParams::V2(fee_v2) => {
config = config
.with_l1_gas_price(Some(fee_v2.l1_gas_price()))
.with_l2_gas_price(Some(fee_v2.config().minimal_l2_gas_price))
.with_price_scale(Some(DEFAULT_ESTIMATE_GAS_PRICE_SCALE_FACTOR))
.with_gas_limit_scale(Some(DEFAULT_ESTIMATE_GAS_SCALE_FACTOR))
.with_l1_pubdata_price(Some(fee_v2.l1_pubdata_price()));
.clone()
.with_l1_gas_price(config.l1_gas_price.or(Some(fee_v2.l1_gas_price())))
.with_l2_gas_price(
config
.l2_gas_price
.or(Some(fee_v2.config().minimal_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(fee_v2.l1_pubdata_price())),
);
}
FeeParams::V1(_) => {
return Err(anyhow!("Unsupported FeeParams::V1 in this context"));
Expand Down

0 comments on commit d3e51cc

Please sign in to comment.