From 251f515def110440628cf14eab9f8eec1fa97508 Mon Sep 17 00:00:00 2001 From: gzeon Date: Wed, 2 Apr 2025 13:07:36 +0100 Subject: [PATCH 1/2] feat: FeeTokenPricerSet event --- src/bridge/ISequencerInbox.sol | 3 +++ src/bridge/SequencerInbox.sol | 1 + 2 files changed, 4 insertions(+) diff --git a/src/bridge/ISequencerInbox.sol b/src/bridge/ISequencerInbox.sol index 77831066..829f6aee 100644 --- a/src/bridge/ISequencerInbox.sol +++ b/src/bridge/ISequencerInbox.sol @@ -69,6 +69,9 @@ interface ISequencerInbox is IDelayedMessageProvider { /// @dev Owner set the buffer config. event BufferConfigSet(BufferConfig bufferConfig); + /// @dev Owner set the fee token pricer. + event FeeTokenPricerSet(address feeTokenPricer); + function totalDelayedMessagesRead() external view returns (uint256); function bridge() external view returns (IBridge); diff --git a/src/bridge/SequencerInbox.sol b/src/bridge/SequencerInbox.sol index cbbbbcad..5b47eff6 100644 --- a/src/bridge/SequencerInbox.sol +++ b/src/bridge/SequencerInbox.sol @@ -880,6 +880,7 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox } feeTokenPricer = feeTokenPricer_; + emit FeeTokenPricerSet(address(feeTokenPricer_)); emit OwnerFunctionCalled(6); } From c177d0cf850b1345b25198e4c8a9a27b80ddb8cc Mon Sep 17 00:00:00 2001 From: gzeon Date: Wed, 2 Apr 2025 13:22:00 +0100 Subject: [PATCH 2/2] feat: always send batch posting report --- src/bridge/SequencerInbox.sol | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/bridge/SequencerInbox.sol b/src/bridge/SequencerInbox.sol index 5b47eff6..4b8003e1 100644 --- a/src/bridge/SequencerInbox.sol +++ b/src/bridge/SequencerInbox.sol @@ -672,11 +672,7 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox ) internal { // When using a fee token the batch poster needs to be reimbursed on the child chain in units of the child chain fee token. // We need to get the exchange rate between the child chain fee token and the parent chain fee token using the pricer. - // If the pricer is not set, then we do not send batch reports and batch poster never gets reimbursed IFeeTokenPricer _feeTokenPricer = feeTokenPricer; - if (isUsingFeeToken && address(_feeTokenPricer) == address(0)) { - return; - } // report the account who paid the gas (tx.origin) for the tx as batch poster // if msg.sender is used and is a contract, it might not be able to spend the refund on l2 @@ -690,12 +686,17 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox } if (extraGas > type(uint64).max) revert ExtraGasNotUint64(); - if (isUsingFeeToken && address(_feeTokenPricer) != address(0)) { - // gasPrice is originally denominated in parent chain's native token and we want to scale it to the child - // chain's fee token. For that we need the exchange rate which tells us how many child chain fee tokens - // we get for 1 parent chain fee token. Exchange rate is denominated in 18 decimals. - uint256 exchangeRate = _feeTokenPricer.getExchangeRate(); - gasPrice = (gasPrice * exchangeRate) / 1e18; + if (isUsingFeeToken) { + if (address(_feeTokenPricer) != address(0)) { + // gasPrice is originally denominated in parent chain's native token and we want to scale it to the child + // chain's fee token. For that we need the exchange rate which tells us how many child chain fee tokens + // we get for 1 parent chain fee token. Exchange rate is denominated in 18 decimals. + uint256 exchangeRate = _feeTokenPricer.getExchangeRate(); + gasPrice = (gasPrice * exchangeRate) / 1e18; + } else { + // If the pricer is not set, we mimick the behavior of a pricer that return 0 + gasPrice = 0; + } } // this msg isn't included in the current sequencer batch, but instead added to