Skip to content

Commit 2f0552b

Browse files
committed
improve the parent batch check
1 parent 6491392 commit 2f0552b

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

contracts/src/L1/rollup/ScrollChain.sol

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -236,12 +236,9 @@ contract ScrollChain is OwnableUpgradeable, IScrollChain {
236236
// check whether the batch is empty
237237
require(_batch.blocks.length > 0, "Batch is empty");
238238

239-
uint64 accTotalL1Messages;
240-
if (!_isGenesis) {
241-
BatchStored storage _parentBatch = batches[_batch.parentBatchHash];
242-
require(_parentBatch.newStateRoot != bytes32(0), "Parent batch is not committed");
243-
accTotalL1Messages = _parentBatch.totalL1Messages;
244-
}
239+
BatchStored storage _parentBatch = batches[_batch.parentBatchHash];
240+
require(_parentBatch.newStateRoot == _batch.prevStateRoot, "prevStateRoot is different from newStateRoot in the parent batch");
241+
uint64 accTotalL1Messages = _parentBatch.totalL1Messages;
245242

246243
bytes32 publicInputHash;
247244
uint64 numTransactionsInBatch;
@@ -253,7 +250,6 @@ contract ScrollChain is OwnableUpgradeable, IScrollChain {
253250

254251
BatchStored storage _batchInStorage = batches[publicInputHash];
255252

256-
// @todo maybe add parent batch check later.
257253
require(_batchInStorage.newStateRoot == bytes32(0), "Batch already commited");
258254
_batchInStorage.newStateRoot = _batch.newStateRoot;
259255
_batchInStorage.withdrawTrieRoot = _batch.withdrawTrieRoot;

0 commit comments

Comments
 (0)