From 28365549c842e757e9f5d92b2258979926550f49 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Mon, 19 Jun 2023 13:03:35 -0600 Subject: [PATCH 1/2] Track L1 gas separately from basefee in batch posting report --- src/bridge/SequencerInbox.sol | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/bridge/SequencerInbox.sol b/src/bridge/SequencerInbox.sol index b0c88a32..1698e115 100644 --- a/src/bridge/SequencerInbox.sol +++ b/src/bridge/SequencerInbox.sol @@ -392,18 +392,19 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox // this msg isn't included in the current sequencer batch, but instead added to // the delayed messages queue that is yet to be included address batchPoster = msg.sender; - uint256 dataCost = block.basefee; - if (hostChainIsArbitrum) { - // Include extra cost for the host chain's L1 gas charging - dataCost += ArbGasInfo(address(0x6c)).getL1BaseFeeEstimate(); - } bytes memory spendingReportMsg = abi.encodePacked( block.timestamp, batchPoster, dataHash, seqMessageIndex, - dataCost + block.basefee ); + if (hostChainIsArbitrum) { + // Include extra gas for the host chain's L1 gas charging + uint256 l1Fees = ArbGasInfo(address(0x6c)).getCurrentTxL1GasFees(); + uint64 extraGas = uint64(l1Fees / block.basefee); + spendingReportMsg = abi.encodePacked(spendingReportMsg, extraGas); + } uint256 msgNum = bridge.submitBatchSpendingReport( batchPoster, keccak256(spendingReportMsg) From 1b10711dc5f2eeefebc8c9f07d5c5f580534f703 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Tue, 20 Jun 2023 09:43:13 -0600 Subject: [PATCH 2/2] Address PR comments --- src/bridge/SequencerInbox.sol | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/src/bridge/SequencerInbox.sol b/src/bridge/SequencerInbox.sol index 1698e115..9b28ef41 100644 --- a/src/bridge/SequencerInbox.sol +++ b/src/bridge/SequencerInbox.sol @@ -392,18 +392,28 @@ contract SequencerInbox is DelegateCallAware, GasRefundEnabled, ISequencerInbox // this msg isn't included in the current sequencer batch, but instead added to // the delayed messages queue that is yet to be included address batchPoster = msg.sender; - bytes memory spendingReportMsg = abi.encodePacked( - block.timestamp, - batchPoster, - dataHash, - seqMessageIndex, - block.basefee - ); + bytes memory spendingReportMsg; if (hostChainIsArbitrum) { // Include extra gas for the host chain's L1 gas charging uint256 l1Fees = ArbGasInfo(address(0x6c)).getCurrentTxL1GasFees(); - uint64 extraGas = uint64(l1Fees / block.basefee); - spendingReportMsg = abi.encodePacked(spendingReportMsg, extraGas); + uint256 extraGas = l1Fees / block.basefee; + require(extraGas <= type(uint64).max, "L1_GAS_NOT_UINT64"); + spendingReportMsg = abi.encodePacked( + block.timestamp, + batchPoster, + dataHash, + seqMessageIndex, + block.basefee, + uint64(extraGas) + ); + } else { + spendingReportMsg = abi.encodePacked( + block.timestamp, + batchPoster, + dataHash, + seqMessageIndex, + block.basefee + ); } uint256 msgNum = bridge.submitBatchSpendingReport( batchPoster,