@@ -74,9 +74,6 @@ contract ScrollChain is OwnableUpgradeable, PausableUpgradeable, IScrollChain {
74
74
/// @dev Thrown when the previous state root doesn't match stored one.
75
75
error ErrorIncorrectPreviousStateRoot ();
76
76
77
- /// @dev Thrown when the batch header version is invalid.
78
- error ErrorInvalidBatchHeaderVersion ();
79
-
80
77
/// @dev Thrown when the last message is skipped.
81
78
error ErrorLastL1MessageSkipped ();
82
79
@@ -119,7 +116,8 @@ contract ScrollChain is OwnableUpgradeable, PausableUpgradeable, IScrollChain {
119
116
120
117
/// @dev BLS Modulus value defined in EIP-4844 and the magic value returned from a successful call to the
121
118
/// point evaluation precompile
122
- uint256 private constant BLS_MODULUS = 52435875175126190479447740508185965837690552500527637822603658699938581184513 ;
119
+ uint256 private constant BLS_MODULUS =
120
+ 52435875175126190479447740508185965837690552500527637822603658699938581184513 ;
123
121
124
122
/// @notice The chain id of the corresponding layer 2 chain.
125
123
uint64 public immutable layer2ChainId;
@@ -310,7 +308,10 @@ contract ScrollChain is OwnableUpgradeable, PausableUpgradeable, IScrollChain {
310
308
batchPtr,
311
309
BatchHeaderV0Codec.BATCH_HEADER_FIXED_LENGTH + _skippedL1MessageBitmap.length
312
310
);
313
- } else if (_version == 1 ) {
311
+ } else if (_version >= 1 ) {
312
+ // versions 1 and 2 both use ChunkCodecV1 and BatchHeaderV1Codec,
313
+ // but they use different blob encoding and different verifiers.
314
+
314
315
bytes32 blobVersionedHash;
315
316
(blobVersionedHash, _dataHash, _totalL1MessagesPoppedInBatch) = _commitChunksV1 (
316
317
_totalL1MessagesPoppedOverall,
@@ -322,7 +323,7 @@ contract ScrollChain is OwnableUpgradeable, PausableUpgradeable, IScrollChain {
322
323
_totalL1MessagesPoppedOverall := add (_totalL1MessagesPoppedOverall, _totalL1MessagesPoppedInBatch)
323
324
}
324
325
// store entries, the order matters
325
- BatchHeaderV1Codec.storeVersion (batchPtr, 1 );
326
+ BatchHeaderV1Codec.storeVersion (batchPtr, _version );
326
327
BatchHeaderV1Codec.storeBatchIndex (batchPtr, _batchIndex);
327
328
BatchHeaderV1Codec.storeL1MessagePopped (batchPtr, _totalL1MessagesPoppedInBatch);
328
329
BatchHeaderV1Codec.storeTotalL1MessagePopped (batchPtr, _totalL1MessagesPoppedOverall);
@@ -335,8 +336,6 @@ contract ScrollChain is OwnableUpgradeable, PausableUpgradeable, IScrollChain {
335
336
batchPtr,
336
337
BatchHeaderV1Codec.BATCH_HEADER_FIXED_LENGTH + _skippedL1MessageBitmap.length
337
338
);
338
- } else {
339
- revert ErrorInvalidBatchHeaderVersion ();
340
339
}
341
340
342
341
// check the length of bitmap
@@ -711,18 +710,15 @@ contract ScrollChain is OwnableUpgradeable, PausableUpgradeable, IScrollChain {
711
710
version := shr (248 , calldataload (_batchHeader.offset))
712
711
}
713
712
714
- // version should be always 0 or 1 in current code
715
713
uint256 _length;
716
714
if (version == 0 ) {
717
715
(batchPtr, _length) = BatchHeaderV0Codec.loadAndValidate (_batchHeader);
718
716
_batchHash = BatchHeaderV0Codec.computeBatchHash (batchPtr, _length);
719
717
_batchIndex = BatchHeaderV0Codec.getBatchIndex (batchPtr);
720
- } else if (version = = 1 ) {
718
+ } else if (version > = 1 ) {
721
719
(batchPtr, _length) = BatchHeaderV1Codec.loadAndValidate (_batchHeader);
722
720
_batchHash = BatchHeaderV1Codec.computeBatchHash (batchPtr, _length);
723
721
_batchIndex = BatchHeaderV1Codec.getBatchIndex (batchPtr);
724
- } else {
725
- revert ErrorInvalidBatchHeaderVersion ();
726
722
}
727
723
// only check when genesis is imported
728
724
if (committedBatches[_batchIndex] != _batchHash && finalizedStateRoots[0 ] != bytes32 (0 )) {
0 commit comments