Skip to content

Commit

Permalink
feat(core): Implement gateway transaction fee methods in GasAdjuster
Browse files Browse the repository at this point in the history
Implements get_gateway_tx_base_fee() and get_gateway_tx_pubdata_price() methods in the GasAdjuster's TxParamsProvider implementation. These methods handle fee calculation for gateway transactions in L2 mode by:

- Using L2 pubdata price statistics for base fee calculation
- Applying consistent price bounds and multipliers
- Respecting configuration overrides
- Following the same fee capping mechanisms as regular transactions

This implementation ensures proper fee handling for gateway transactions while maintaining consistency with the existing fee model architecture.
  • Loading branch information
VolodymyrBg authored Jan 29, 2025
1 parent 361243f commit 1b33255
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions core/node/fee_model/src/l1_gas_price/gas_adjuster/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,11 +369,27 @@ impl TxParamsProvider for GasAdjuster {
}

fn get_gateway_tx_base_fee(&self) -> u64 {
todo!()
// For gateway transactions, we use the L2 pubdata price statistics
// since we're operating in L2 mode
if let Some(price) = self.config.internal_enforced_l1_gas_price {
return price;
}

let base_fee = self.l2_pubdata_price_statistics.median().as_u64();
let calculated_price = (self.config.internal_l1_pricing_multiplier * base_fee as f64) as u64;

// Apply the same bounds as regular transactions
self.bound_gas_price(calculated_price)
}

fn get_gateway_tx_pubdata_price(&self) -> u64 {
todo!()
// For gateway transactions, pubdata price is determined by L2 statistics
if let Some(price) = self.config.internal_enforced_pubdata_price {
return price;
}

let pubdata_price = self.l2_pubdata_price_statistics.median().as_u64() as f64;
self.cap_pubdata_fee(pubdata_price)
}
}

Expand Down

0 comments on commit 1b33255

Please sign in to comment.