|
|
|
|
@@ -392,8 +392,8 @@ contract ScrollChain is OwnableUpgradeable, PausableUpgradeable, IScrollChain {
|
|
|
|
|
(uint256 memPtr, bytes32 _batchHash, uint256 _batchIndex, ) = _loadBatchHeader(_batchHeader);
|
|
|
|
|
bytes32 _dataHash = BatchHeaderV0Codec.getDataHash(memPtr);
|
|
|
|
|
|
|
|
|
|
// verify previous state root.
|
|
|
|
|
if (finalizedStateRoots[_batchIndex - 1] != _prevStateRoot) revert ErrorIncorrectPreviousStateRoot();
|
|
|
|
|
// // verify previous state root.
|
|
|
|
|
// if (finalizedStateRoots[_batchIndex - 1] != _prevStateRoot) revert ErrorIncorrectPreviousStateRoot();
|
|
|
|
|
|
|
|
|
|
// avoid duplicated verification
|
|
|
|
|
if (finalizedStateRoots[_batchIndex] != bytes32(0)) revert ErrorBatchIsAlreadyVerified();
|
|
|
|
|
@@ -408,20 +408,20 @@ contract ScrollChain is OwnableUpgradeable, PausableUpgradeable, IScrollChain {
|
|
|
|
|
|
|
|
|
|
// check and update lastFinalizedBatchIndex
|
|
|
|
|
unchecked {
|
|
|
|
|
if (lastFinalizedBatchIndex + 1 != _batchIndex) revert ErrorIncorrectBatchIndex();
|
|
|
|
|
lastFinalizedBatchIndex = _batchIndex;
|
|
|
|
|
// if (lastFinalizedBatchIndex + 1 != _batchIndex) revert ErrorIncorrectBatchIndex();
|
|
|
|
|
if (_batchIndex > lastFinalizedBatchIndex) lastFinalizedBatchIndex = _batchIndex;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// record state root and withdraw root
|
|
|
|
|
finalizedStateRoots[_batchIndex] = _postStateRoot;
|
|
|
|
|
withdrawRoots[_batchIndex] = _withdrawRoot;
|
|
|
|
|
|
|
|
|
|
// Pop finalized and non-skipped message from L1MessageQueue.
|
|
|
|
|
_popL1Messages(
|
|
|
|
|
BatchHeaderV0Codec.getSkippedBitmapPtr(memPtr),
|
|
|
|
|
BatchHeaderV0Codec.getTotalL1MessagePopped(memPtr),
|
|
|
|
|
BatchHeaderV0Codec.getL1MessagePopped(memPtr)
|
|
|
|
|
);
|
|
|
|
|
// // Pop finalized and non-skipped message from L1MessageQueue.
|
|
|
|
|
// _popL1Messages(
|
|
|
|
|
// BatchHeaderV0Codec.getSkippedBitmapPtr(memPtr),
|
|
|
|
|
// BatchHeaderV0Codec.getTotalL1MessagePopped(memPtr),
|
|
|
|
|
// BatchHeaderV0Codec.getL1MessagePopped(memPtr)
|
|
|
|
|
// );
|
|
|
|
|
|
|
|
|
|
emit FinalizeBatch(_batchIndex, _batchHash, _postStateRoot, _withdrawRoot);
|
|
|
|
|
}
|
|
|
|
|
@@ -439,16 +439,16 @@ contract ScrollChain is OwnableUpgradeable, PausableUpgradeable, IScrollChain {
|
|
|
|
|
// compute batch hash and verify
|
|
|
|
|
(uint256 memPtr, bytes32 _batchHash, uint256 _batchIndex, ) = _loadBatchHeader(_batchHeader);
|
|
|
|
|
|
|
|
|
|
// verify previous state root.
|
|
|
|
|
if (finalizedStateRoots[_batchIndex - 1] != _prevStateRoot) revert ErrorIncorrectPreviousStateRoot();
|
|
|
|
|
// // verify previous state root.
|
|
|
|
|
// if (finalizedStateRoots[_batchIndex - 1] != _prevStateRoot) revert ErrorIncorrectPreviousStateRoot();
|
|
|
|
|
|
|
|
|
|
// avoid duplicated verification
|
|
|
|
|
if (finalizedStateRoots[_batchIndex] != bytes32(0)) revert ErrorBatchIsAlreadyVerified();
|
|
|
|
|
|
|
|
|
|
// check and update lastFinalizedBatchIndex
|
|
|
|
|
unchecked {
|
|
|
|
|
if (lastFinalizedBatchIndex + 1 != _batchIndex) revert ErrorIncorrectBatchIndex();
|
|
|
|
|
lastFinalizedBatchIndex = _batchIndex;
|
|
|
|
|
// if (lastFinalizedBatchIndex + 1 != _batchIndex) revert ErrorIncorrectBatchIndex();
|
|
|
|
|
if (_batchIndex > lastFinalizedBatchIndex) lastFinalizedBatchIndex = _batchIndex;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// record state root and withdraw root
|
|
|
|
|
@@ -456,11 +456,11 @@ contract ScrollChain is OwnableUpgradeable, PausableUpgradeable, IScrollChain {
|
|
|
|
|
withdrawRoots[_batchIndex] = _withdrawRoot;
|
|
|
|
|
|
|
|
|
|
// Pop finalized and non-skipped message from L1MessageQueue.
|
|
|
|
|
_popL1Messages(
|
|
|
|
|
BatchHeaderV0Codec.getSkippedBitmapPtr(memPtr),
|
|
|
|
|
BatchHeaderV0Codec.getTotalL1MessagePopped(memPtr),
|
|
|
|
|
BatchHeaderV0Codec.getL1MessagePopped(memPtr)
|
|
|
|
|
);
|
|
|
|
|
// _popL1Messages(
|
|
|
|
|
// BatchHeaderV0Codec.getSkippedBitmapPtr(memPtr),
|
|
|
|
|
// BatchHeaderV0Codec.getTotalL1MessagePopped(memPtr),
|
|
|
|
|
// BatchHeaderV0Codec.getL1MessagePopped(memPtr)
|
|
|
|
|
// );
|
|
|
|
|
|
|
|
|
|
emit FinalizeBatch(_batchIndex, _batchHash, _postStateRoot, _withdrawRoot);
|
|
|
|
|
}
|
|
|
|
|
@@ -500,8 +500,8 @@ contract ScrollChain is OwnableUpgradeable, PausableUpgradeable, IScrollChain {
|
|
|
|
|
if (result != BLS_MODULUS) revert ErrorUnexpectedPointEvaluationPrecompileOutput();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// verify previous state root.
|
|
|
|
|
if (finalizedStateRoots[_batchIndex - 1] != _prevStateRoot) revert ErrorIncorrectPreviousStateRoot();
|
|
|
|
|
// // verify previous state root.
|
|
|
|
|
// if (finalizedStateRoots[_batchIndex - 1] != _prevStateRoot) revert ErrorIncorrectPreviousStateRoot();
|
|
|
|
|
|
|
|
|
|
// avoid duplicated verification
|
|
|
|
|
if (finalizedStateRoots[_batchIndex] != bytes32(0)) revert ErrorBatchIsAlreadyVerified();
|
|
|
|
|
@@ -528,20 +528,20 @@ contract ScrollChain is OwnableUpgradeable, PausableUpgradeable, IScrollChain {
|
|
|
|
|
|
|
|
|
|
// check and update lastFinalizedBatchIndex
|
|
|
|
|
unchecked {
|
|
|
|
|
if (lastFinalizedBatchIndex + 1 != _batchIndex) revert ErrorIncorrectBatchIndex();
|
|
|
|
|
lastFinalizedBatchIndex = _batchIndex;
|
|
|
|
|
// if (lastFinalizedBatchIndex + 1 != _batchIndex) revert ErrorIncorrectBatchIndex();
|
|
|
|
|
if (_batchIndex > lastFinalizedBatchIndex) lastFinalizedBatchIndex = _batchIndex;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// record state root and withdraw root
|
|
|
|
|
finalizedStateRoots[_batchIndex] = _postStateRoot;
|
|
|
|
|
withdrawRoots[_batchIndex] = _withdrawRoot;
|
|
|
|
|
|
|
|
|
|
// Pop finalized and non-skipped message from L1MessageQueue.
|
|
|
|
|
_popL1Messages(
|
|
|
|
|
BatchHeaderV1Codec.getSkippedBitmapPtr(memPtr),
|
|
|
|
|
BatchHeaderV1Codec.getTotalL1MessagePopped(memPtr),
|
|
|
|
|
BatchHeaderV1Codec.getL1MessagePopped(memPtr)
|
|
|
|
|
);
|
|
|
|
|
// // Pop finalized and non-skipped message from L1MessageQueue.
|
|
|
|
|
// _popL1Messages(
|
|
|
|
|
// BatchHeaderV1Codec.getSkippedBitmapPtr(memPtr),
|
|
|
|
|
// BatchHeaderV1Codec.getTotalL1MessagePopped(memPtr),
|
|
|
|
|
// BatchHeaderV1Codec.getL1MessagePopped(memPtr)
|
|
|
|
|
// );
|
|
|
|
|
|
|
|
|
|
emit FinalizeBatch(_batchIndex, _batchHash, _postStateRoot, _withdrawRoot);
|
|
|
|
|
}
|
|
|
|
|
@@ -573,28 +573,28 @@ contract ScrollChain is OwnableUpgradeable, PausableUpgradeable, IScrollChain {
|
|
|
|
|
if (result != BLS_MODULUS) revert ErrorUnexpectedPointEvaluationPrecompileOutput();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// verify previous state root.
|
|
|
|
|
if (finalizedStateRoots[_batchIndex - 1] != _prevStateRoot) revert ErrorIncorrectPreviousStateRoot();
|
|
|
|
|
// // verify previous state root.
|
|
|
|
|
// if (finalizedStateRoots[_batchIndex - 1] != _prevStateRoot) revert ErrorIncorrectPreviousStateRoot();
|
|
|
|
|
|
|
|
|
|
// avoid duplicated verification
|
|
|
|
|
if (finalizedStateRoots[_batchIndex] != bytes32(0)) revert ErrorBatchIsAlreadyVerified();
|
|
|
|
|
|
|
|
|
|
// check and update lastFinalizedBatchIndex
|
|
|
|
|
unchecked {
|
|
|
|
|
if (lastFinalizedBatchIndex + 1 != _batchIndex) revert ErrorIncorrectBatchIndex();
|
|
|
|
|
lastFinalizedBatchIndex = _batchIndex;
|
|
|
|
|
// if (lastFinalizedBatchIndex + 1 != _batchIndex) revert ErrorIncorrectBatchIndex();
|
|
|
|
|
if (_batchIndex > lastFinalizedBatchIndex) lastFinalizedBatchIndex = _batchIndex;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// record state root and withdraw root
|
|
|
|
|
finalizedStateRoots[_batchIndex] = _postStateRoot;
|
|
|
|
|
withdrawRoots[_batchIndex] = _withdrawRoot;
|
|
|
|
|
|
|
|
|
|
// Pop finalized and non-skipped message from L1MessageQueue.
|
|
|
|
|
_popL1Messages(
|
|
|
|
|
BatchHeaderV1Codec.getSkippedBitmapPtr(memPtr),
|
|
|
|
|
BatchHeaderV1Codec.getTotalL1MessagePopped(memPtr),
|
|
|
|
|
BatchHeaderV1Codec.getL1MessagePopped(memPtr)
|
|
|
|
|
);
|
|
|
|
|
// // Pop finalized and non-skipped message from L1MessageQueue.
|
|
|
|
|
// _popL1Messages(
|
|
|
|
|
// BatchHeaderV1Codec.getSkippedBitmapPtr(memPtr),
|
|
|
|
|
// BatchHeaderV1Codec.getTotalL1MessagePopped(memPtr),
|
|
|
|
|
// BatchHeaderV1Codec.getL1MessagePopped(memPtr)
|
|
|
|
|
// );
|
|
|
|
|
|
|
|
|
|
emit FinalizeBatch(_batchIndex, _batchHash, _postStateRoot, _withdrawRoot);
|
|
|
|
|
}
|
|
|
|
|
|