Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions contracts/contracts/l1/rollup/Rollup.sol
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ contract Rollup is IRollup, OwnableUpgradeable, PausableUpgradeable {

(uint256 memPtr, bytes32 _batchHash) = _loadBatchHeader(_batchHeader);
uint256 _batchIndex = BatchHeaderCodecV0.getBatchIndex(memPtr);
// check batch index is 0
require(_batchIndex == 0, "invalid batch index");
bytes32 _postStateRoot = BatchHeaderCodecV0.getPostStateHash(memPtr);
require(_postStateRoot != bytes32(0), "zero state root");
// check all fields except `dataHash` and `lastBlockHash` are zero
Expand Down
9 changes: 9 additions & 0 deletions contracts/contracts/test/Rollup.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,15 @@ contract RollupTest is L1MessageBaseTest {
function test_importGenesisBlock_succeeds() public {
bytes memory batchHeader;
bytes32 bytesData1 = bytes32(uint256(1));
// invalid batch index, revert
batchHeader = new bytes(249);
assembly {
mstore(add(batchHeader, add(0x20, 1)), shl(192, 1)) // batchIndex = 1
}
hevm.expectRevert("invalid batch index");
hevm.prank(multisig);
rollup.importGenesisBatch(batchHeader);

// zero state root, revert
batchHeader = new bytes(249);
hevm.expectRevert("zero state root");
Expand Down