From 03cf3acb0a3c7bbfae78d02a55032087080b157b Mon Sep 17 00:00:00 2001 From: Daniel Wang Date: Thu, 8 Aug 2024 11:45:24 +0800 Subject: [PATCH 1/6] Update TaikoL2.sol --- packages/protocol/contracts/L2/TaikoL2.sol | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/protocol/contracts/L2/TaikoL2.sol b/packages/protocol/contracts/L2/TaikoL2.sol index 68b73e4873..44b740bc42 100644 --- a/packages/protocol/contracts/L2/TaikoL2.sol +++ b/packages/protocol/contracts/L2/TaikoL2.sol @@ -39,8 +39,8 @@ contract TaikoL2 is EssentialContract { /// @notice The last synced L1 block height. uint64 public lastSyncedBlock; - uint64 private parentTimestamp; - uint64 private parentGasTarget; + uint64 public parentTimestamp; + uint64 public parentGasTarget; /// @notice The L1's chain ID. uint64 public l1ChainId; From 3e1e3a159b207512b19ee634f1d29599b8e75764 Mon Sep 17 00:00:00 2001 From: Daniel Wang Date: Thu, 8 Aug 2024 11:49:49 +0800 Subject: [PATCH 2/6] Update TaikoL2.sol --- packages/protocol/contracts/L2/TaikoL2.sol | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/packages/protocol/contracts/L2/TaikoL2.sol b/packages/protocol/contracts/L2/TaikoL2.sol index 44b740bc42..59de5dc340 100644 --- a/packages/protocol/contracts/L2/TaikoL2.sol +++ b/packages/protocol/contracts/L2/TaikoL2.sol @@ -222,6 +222,23 @@ contract TaikoL2 is EssentialContract { return LibL2Config.get(); } + /// @notice Returns the new gas excess that will keep the basefee the same. + /// @param _oldGasExcess The current gas excess value. + /// @param _gasTarget The previous gas target. + /// @param _newGasTarget The new gas target. + /// @return newGasExcess_ The new gas excess value. + function adjustExcess( + uint64 _oldGasExcess, + uint64 _oldGasTarget, + uint64 _newGasTarget + ) + public + pure + returns (uint64 newGasExcess_) + { + return Lib1559Math.adjustExcess(_oldGasExcess, _oldGasTarget, _newGasTarget); + } + /// @notice Tells if we need to validate basefee (for simulation). /// @return Returns true to skip checking basefee mismatch. function skipFeeCheck() public pure virtual returns (bool) { @@ -290,8 +307,7 @@ contract TaikoL2 is EssentialContract { if (postFork && newGasTarget != parentGasTarget) { // adjust parentGasExcess to keep the basefee unchanged. Note that due to math // calculation precision, the basefee may change slightly. - parentGasExcess = - Lib1559Math.adjustExcess(parentGasExcess, parentGasTarget, newGasTarget); + parentGasExcess = adjustExcess(parentGasExcess, parentGasTarget, newGasTarget); } // Verify the base fee per gas is correct From 7b7668bc14eddc9b78729a2af0c2c0e66ae90ff6 Mon Sep 17 00:00:00 2001 From: Daniel Wang Date: Thu, 8 Aug 2024 11:52:09 +0800 Subject: [PATCH 3/6] Update TaikoL2.sol --- packages/protocol/contracts/L2/TaikoL2.sol | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/protocol/contracts/L2/TaikoL2.sol b/packages/protocol/contracts/L2/TaikoL2.sol index 59de5dc340..2b118d15e2 100644 --- a/packages/protocol/contracts/L2/TaikoL2.sol +++ b/packages/protocol/contracts/L2/TaikoL2.sol @@ -224,7 +224,7 @@ contract TaikoL2 is EssentialContract { /// @notice Returns the new gas excess that will keep the basefee the same. /// @param _oldGasExcess The current gas excess value. - /// @param _gasTarget The previous gas target. + /// @param _oldGasTarget The previous gas target. /// @param _newGasTarget The new gas target. /// @return newGasExcess_ The new gas excess value. function adjustExcess( @@ -287,8 +287,8 @@ contract TaikoL2 is EssentialContract { private { if ( - _anchorStateRoot == 0 || _anchorBlockId == 0 - || (block.number != 1 && _parentGasUsed == 0) + _anchorStateRoot == 0 || _anchorBlockId == 0 || _gasIssuancePerSecond == 0 + || _basefeeAdjustmentQuotient || (block.number != 1 && _parentGasUsed == 0) ) { revert L2_INVALID_PARAM(); } From c4516cc3f1f0224d9230187be1a3749ee4521b87 Mon Sep 17 00:00:00 2001 From: Daniel Wang Date: Thu, 8 Aug 2024 11:52:26 +0800 Subject: [PATCH 4/6] Update TaikoL2.sol --- packages/protocol/contracts/L2/TaikoL2.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/protocol/contracts/L2/TaikoL2.sol b/packages/protocol/contracts/L2/TaikoL2.sol index 2b118d15e2..349ac2a4b8 100644 --- a/packages/protocol/contracts/L2/TaikoL2.sol +++ b/packages/protocol/contracts/L2/TaikoL2.sol @@ -288,7 +288,7 @@ contract TaikoL2 is EssentialContract { { if ( _anchorStateRoot == 0 || _anchorBlockId == 0 || _gasIssuancePerSecond == 0 - || _basefeeAdjustmentQuotient || (block.number != 1 && _parentGasUsed == 0) + || _basefeeAdjustmentQuotient == 0 || (block.number != 1 && _parentGasUsed == 0) ) { revert L2_INVALID_PARAM(); } From 20925607451e83d806d40df1f2e3286b0e45cede Mon Sep 17 00:00:00 2001 From: Daniel Wang <99078276+dantaik@users.noreply.github.com> Date: Thu, 8 Aug 2024 11:55:32 +0800 Subject: [PATCH 5/6] Update packages/protocol/contracts/L2/TaikoL2.sol --- packages/protocol/contracts/L2/TaikoL2.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/protocol/contracts/L2/TaikoL2.sol b/packages/protocol/contracts/L2/TaikoL2.sol index 349ac2a4b8..a018a4719d 100644 --- a/packages/protocol/contracts/L2/TaikoL2.sol +++ b/packages/protocol/contracts/L2/TaikoL2.sol @@ -224,7 +224,7 @@ contract TaikoL2 is EssentialContract { /// @notice Returns the new gas excess that will keep the basefee the same. /// @param _oldGasExcess The current gas excess value. - /// @param _oldGasTarget The previous gas target. + /// @param _oldGasTarget The current gas target. /// @param _newGasTarget The new gas target. /// @return newGasExcess_ The new gas excess value. function adjustExcess( From 27097d7f97bf6b7b381f8f9f548999d3937aa724 Mon Sep 17 00:00:00 2001 From: Daniel Wang Date: Thu, 8 Aug 2024 11:56:35 +0800 Subject: [PATCH 6/6] Update TaikoL2.sol --- packages/protocol/contracts/L2/TaikoL2.sol | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/protocol/contracts/L2/TaikoL2.sol b/packages/protocol/contracts/L2/TaikoL2.sol index a018a4719d..9cc1ea635c 100644 --- a/packages/protocol/contracts/L2/TaikoL2.sol +++ b/packages/protocol/contracts/L2/TaikoL2.sol @@ -223,20 +223,20 @@ contract TaikoL2 is EssentialContract { } /// @notice Returns the new gas excess that will keep the basefee the same. - /// @param _oldGasExcess The current gas excess value. - /// @param _oldGasTarget The current gas target. + /// @param _currGasExcess The current gas excess value. + /// @param _currGasTarget The current gas target. /// @param _newGasTarget The new gas target. /// @return newGasExcess_ The new gas excess value. function adjustExcess( - uint64 _oldGasExcess, - uint64 _oldGasTarget, + uint64 _currGasExcess, + uint64 _currGasTarget, uint64 _newGasTarget ) public pure returns (uint64 newGasExcess_) { - return Lib1559Math.adjustExcess(_oldGasExcess, _oldGasTarget, _newGasTarget); + return Lib1559Math.adjustExcess(_currGasExcess, _currGasTarget, _newGasTarget); } /// @notice Tells if we need to validate basefee (for simulation).