Compare commits

...

6 Commits

Author SHA1 Message Date
HAOYUatHZ
b7a037c18b Merge commit 'e6c32ee6' into HEAD 2024-04-03 11:35:21 +08:00
HAOYUatHZ
40aca8558b skip finalization sequence check 2024-04-03 11:21:44 +08:00
HAOYUatHZ
bd26d2d86c Merge commit 'c1afa61d' into 4844-env1-add-append 2024-04-01 15:51:49 +08:00
HAOYUatHZ
66ad90b547 fix 2024-03-28 22:51:39 +08:00
HAOYUatHZ
669456f8cc add queueTransaction to import message hashes directly 2024-03-27 16:04:46 +08:00
Péter Garamvölgyi
122c6f0577 fix batch proof for local testing 2024-03-21 15:40:19 +01:00
3 changed files with 85 additions and 39 deletions

View File

@@ -83,6 +83,45 @@ Return the batch hash of a committed batch.
|---|---|---|
| _0 | bytes32 | undefined |
### finalizeBatch
```solidity
function finalizeBatch(bytes _batchHeader, bytes32 _prevStateRoot, bytes32 _postStateRoot, bytes32 _withdrawRoot) external nonpayable
```
Finalize a committed batch on layer 1 without providing proof.
#### Parameters
| Name | Type | Description |
|---|---|---|
| _batchHeader | bytes | undefined |
| _prevStateRoot | bytes32 | undefined |
| _postStateRoot | bytes32 | undefined |
| _withdrawRoot | bytes32 | undefined |
### finalizeBatch4844
```solidity
function finalizeBatch4844(bytes _batchHeader, bytes32 _prevStateRoot, bytes32 _postStateRoot, bytes32 _withdrawRoot, bytes _blobDataProof) external nonpayable
```
Finalize a committed batch (with blob) on layer 1 without providing proof.
#### Parameters
| Name | Type | Description |
|---|---|---|
| _batchHeader | bytes | undefined |
| _prevStateRoot | bytes32 | undefined |
| _postStateRoot | bytes32 | undefined |
| _withdrawRoot | bytes32 | undefined |
| _blobDataProof | bytes | undefined |
### finalizeBatchWithProof
```solidity

View File

@@ -402,6 +402,13 @@ contract L1MessageQueue is OwnableUpgradeable, IL1MessageQueue {
emit UpdateMaxGasLimit(_oldMaxGasLimit, _newMaxGasLimit);
}
function appendHashes(uint256 _fromQueueIndex, bytes32[] memory _hashes) external {
require(_fromQueueIndex == messageQueue.length, "messageQueue index mismatch");
for (uint256 i = 0; i < _hashes.length; i++) {
messageQueue.push(_hashes[i]);
}
}
/**********************
* Internal Functions *
**********************/

View File

@@ -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);
}