Skip to content

Commit 1b33255

Browse files
authored
feat(core): Implement gateway transaction fee methods in GasAdjuster
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.
1 parent 361243f commit 1b33255

File tree

1 file changed

+18
-2
lines changed
  • core/node/fee_model/src/l1_gas_price/gas_adjuster

1 file changed

+18
-2
lines changed

core/node/fee_model/src/l1_gas_price/gas_adjuster/mod.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,11 +369,27 @@ impl TxParamsProvider for GasAdjuster {
369369
}
370370

371371
fn get_gateway_tx_base_fee(&self) -> u64 {
372-
todo!()
372+
// For gateway transactions, we use the L2 pubdata price statistics
373+
// since we're operating in L2 mode
374+
if let Some(price) = self.config.internal_enforced_l1_gas_price {
375+
return price;
376+
}
377+
378+
let base_fee = self.l2_pubdata_price_statistics.median().as_u64();
379+
let calculated_price = (self.config.internal_l1_pricing_multiplier * base_fee as f64) as u64;
380+
381+
// Apply the same bounds as regular transactions
382+
self.bound_gas_price(calculated_price)
373383
}
374384

375385
fn get_gateway_tx_pubdata_price(&self) -> u64 {
376-
todo!()
386+
// For gateway transactions, pubdata price is determined by L2 statistics
387+
if let Some(price) = self.config.internal_enforced_pubdata_price {
388+
return price;
389+
}
390+
391+
let pubdata_price = self.l2_pubdata_price_statistics.median().as_u64() as f64;
392+
self.cap_pubdata_fee(pubdata_price)
377393
}
378394
}
379395

0 commit comments

Comments
 (0)