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

feat(protocol): Gas limit behavior changes #14339

Merged
merged 11 commits into from
Aug 7, 2023
3 changes: 1 addition & 2 deletions packages/protocol/contracts/L1/TaikoData.sol
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,10 @@ library TaikoData {
uint64 numEthDeposits;
}

// 3 slots
// 2 slots
struct BlockMetadataInput {
bytes32 txListHash;
address beneficiary;
uint32 gasLimit;
uint24 txListByteStart; // byte-wise start index (inclusive)
uint24 txListByteEnd; // byte-wise end index (exclusive)
bool cacheTxListInfo;
Expand Down
10 changes: 2 additions & 8 deletions packages/protocol/contracts/L1/libs/LibProposing.sol
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ library LibProposing {
meta.txListHash = input.txListHash;
meta.txListByteStart = input.txListByteStart;
meta.txListByteEnd = input.txListByteEnd;
meta.gasLimit = input.gasLimit;
meta.gasLimit = config.blockMaxGasLimit;
meta.beneficiary = input.beneficiary;
meta.treasury = resolver.resolve(config.chainId, "treasury", false);
meta.depositsProcessed =
Expand Down Expand Up @@ -183,13 +183,7 @@ library LibProposing {
view
returns (bool cacheTxListInfo)
{
if (
input.beneficiary == address(0)
//
|| input.gasLimit == 0
//
|| input.gasLimit > config.blockMaxGasLimit
) revert L1_INVALID_METADATA();
if (input.beneficiary == address(0)) revert L1_INVALID_METADATA();

if (
state.numBlocks
Expand Down
8 changes: 4 additions & 4 deletions packages/protocol/contracts/L2/TaikoL2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -330,10 +330,10 @@ contract TaikoL2 is EssentialContract, TaikoL2Signer, ICrossChainSync {
{
// Very important to cap _gasExcess uint64
unchecked {
uint32 parentGasUsedNet = parentGasUsed
> LibL2Consts.ANCHOR_GAS_COST
? parentGasUsed - LibL2Consts.ANCHOR_GAS_COST
: 0;
uint32 parentGasUsedNet;
if (parentGasUsed > LibL2Consts.ANCHOR_GAS_COST) {
parentGasUsedNet = parentGasUsed - LibL2Consts.ANCHOR_GAS_COST;
}

uint256 a = uint256(gasExcess) + parentGasUsedNet;
uint256 b = config.gasIssuedPerSecond * timeSinceParent;
Expand Down
5 changes: 4 additions & 1 deletion packages/protocol/docs/how_taiko_proves_blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ A valid transaction (defined in the Ethereum Yellow Paper):
- Has a valid transaction signature.
- Has a valid transaction nonce (equivalent to the sender account's current nonce).
- Has no contract code deployed on the sender account (see EIP-3607 by Feist et al. [2021]).
- Has a gas limit no smaller than the intrinsic gas, _`g0`_, used by the transaction; and the sender account balance contains at least the cost, _`v0`_, required in up-front payment.
- Has a gas limit no smaller than the intrinsic gas, _`g0`_, used by the transaction.
- The sender account balance contains at least the cost, _`v0`_, required in up-front payment.
- The transaction has a gas limit that is smaller or equal to the amount of gas left in the block (with the block gas limit being the protocol constant _`blockMaxGasLimit`_).
- The transaction has a basefee that is greater than or equal the basefee of the block.

#### Slicing and Consistency

Expand Down