From 1b332553ff37d4c7c317af02fab90b585198a9fc Mon Sep 17 00:00:00 2001 From: VolodymyrBg Date: Wed, 29 Jan 2025 23:05:51 +0200 Subject: [PATCH] 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. --- .../src/l1_gas_price/gas_adjuster/mod.rs | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/core/node/fee_model/src/l1_gas_price/gas_adjuster/mod.rs b/core/node/fee_model/src/l1_gas_price/gas_adjuster/mod.rs index 6fce46f77225..ebf6b74a2b54 100644 --- a/core/node/fee_model/src/l1_gas_price/gas_adjuster/mod.rs +++ b/core/node/fee_model/src/l1_gas_price/gas_adjuster/mod.rs @@ -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) } }