Skip to content

Commit

Permalink
improve L2 block.number check in init
Browse files Browse the repository at this point in the history
  • Loading branch information
dong77 committed Nov 13, 2023
1 parent 5223804 commit 716644f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 1 addition & 2 deletions packages/protocol/contracts/L1/libs/LibProposing.sol
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,7 @@ library LibProposing {

// Validate the prover assignment, then charge Ether or ERC20 as the
// prover fee based on the block's minTier.
uint256 proverFee =
_payProverFeeAndTip(
uint256 proverFee = _payProverFeeAndTip(
meta.minTier, meta.blobHash, blk.blockId, params.assignment
);

Expand Down
8 changes: 6 additions & 2 deletions packages/protocol/contracts/L2/TaikoL2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,15 @@ contract TaikoL2 is Ownable2StepUpgradeable, TaikoL2Signer, ICrossChainSync {
if (block.chainid <= 1 || block.chainid >= type(uint64).max) {
revert L2_INVALID_CHAIN_ID();
}
if (block.number > 1) revert L2_TOO_LATE();

if (block.number > 0) {
if (block.number == 0) {
// This is the case in real L2 genesis
} else if (block.number == 1) {
// This is the case in tests
uint256 parentHeight = block.number - 1;
l2Hashes[parentHeight] = blockhash(parentHeight);
} else {
revert L2_TOO_LATE();
}

gasExcess = _gasExcess;
Expand Down

0 comments on commit 716644f

Please sign in to comment.