diff --git a/packages/protocol/contracts/layer2/based/TaikoL2.sol b/packages/protocol/contracts/layer2/based/TaikoL2.sol index 5af1e610325..e9baedd74aa 100644 --- a/packages/protocol/contracts/layer2/based/TaikoL2.sol +++ b/packages/protocol/contracts/layer2/based/TaikoL2.sol @@ -187,6 +187,7 @@ contract TaikoL2 is EssentialContract, IBlockHash, TaikoL2Deprecated { /// @return newGasExcess_ The new gas excess value. function getBasefeeV2( uint32 _parentGasUsed, + uint64 _blockTimestamp, LibSharedData.BaseFeeConfig calldata _baseFeeConfig ) public @@ -201,7 +202,7 @@ contract TaikoL2 is EssentialContract, IBlockHash, TaikoL2Deprecated { LibEIP1559.adjustExcess(parentGasTarget, newGasTarget, parentGasExcess); uint64 gasIssuance = - uint64(block.timestamp - parentTimestamp) * _baseFeeConfig.gasIssuancePerSecond; + (_blockTimestamp - parentTimestamp) * _baseFeeConfig.gasIssuancePerSecond; if ( _baseFeeConfig.maxGasIssuancePerBlock != 0 @@ -292,7 +293,7 @@ contract TaikoL2 is EssentialContract, IBlockHash, TaikoL2Deprecated { private { (uint256 basefee, uint64 newGasTarget, uint64 newGasExcess) = - getBasefeeV2(_parentGasUsed, _baseFeeConfig); + getBasefeeV2(_parentGasUsed, uint64(block.timestamp), _baseFeeConfig); require(block.basefee == basefee || skipFeeCheck(), L2_BASEFEE_MISMATCH()); diff --git a/packages/protocol/test/layer2/TaikoL2.t.sol b/packages/protocol/test/layer2/TaikoL2.t.sol index e312af8ecf7..f917525f816 100644 --- a/packages/protocol/test/layer2/TaikoL2.t.sol +++ b/packages/protocol/test/layer2/TaikoL2.t.sol @@ -123,7 +123,8 @@ contract TaikoL2Tests is TaikoL2Test { maxGasIssuancePerBlock: _maxGasIssuancePerBlock }); - (uint256 basefee_,,) = L2.getBasefeeV2(_parentGasUsed, baseFeeConfig); + (uint256 basefee_,,) = + L2.getBasefeeV2(_parentGasUsed, uint64(block.timestamp), baseFeeConfig); assertTrue(basefee_ != 0, "basefee is 0"); } @@ -156,7 +157,8 @@ contract TaikoL2Tests is TaikoL2Test { vm.prank(L2.GOLDEN_TOUCH_ADDRESS()); L2.anchorV2(++anchorBlockId, anchorStateRoot, _parentGasUsed, baseFeeConfig); - (uint256 basefee, uint64 newGasTarget,) = L2.getBasefeeV2(_parentGasUsed, baseFeeConfig); + (uint256 basefee, uint64 newGasTarget,) = + L2.getBasefeeV2(_parentGasUsed, uint64(block.timestamp), baseFeeConfig); assertTrue(basefee != 0, "basefee is 0"); assertEq(newGasTarget, L2.parentGasTarget()); @@ -164,7 +166,8 @@ contract TaikoL2Tests is TaikoL2Test { // change the gas issuance to change the gas target baseFeeConfig.gasIssuancePerSecond += 1; - (basefee, newGasTarget,) = L2.getBasefeeV2(_parentGasUsed, baseFeeConfig); + (basefee, newGasTarget,) = + L2.getBasefeeV2(_parentGasUsed, uint64(block.timestamp), baseFeeConfig); assertTrue(basefee != 0, "basefee is 0"); assertTrue(newGasTarget != L2.parentGasTarget());