Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(protocol): make two state variables in TaikoL2.sol public and add adjustExcess #17891

Merged
merged 6 commits into from
Aug 8, 2024
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions packages/protocol/contracts/L2/TaikoL2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 _oldGasTarget The current 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) {
Expand Down Expand Up @@ -270,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 == 0 || (block.number != 1 && _parentGasUsed == 0)
) {
revert L2_INVALID_PARAM();
}
Expand All @@ -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
Expand Down