-
Notifications
You must be signed in to change notification settings - Fork 70
Sequencer failure #849
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Sequencer failure #849
Changes from all commits
6d012da
ff3eca1
31d04b5
a2e23e4
cc9ed4c
fd60e32
641830e
7fb5bf8
0e7472b
59fb9e8
84bd123
c80a76f
5ed2108
cb73fe9
db36567
7092af0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -100,6 +100,10 @@ contract Rollup is IRollup, OwnableUpgradeable, PausableUpgradeable { | |
| /// @notice committedStateRoots | ||
| mapping(uint256 batchIndex => bytes32 stateRoot) public committedStateRoots; | ||
|
|
||
| /// @notice The delay period for permissionless batch submission. | ||
| /// @dev After this period, anyone can submit batches if sequencers are offline or censoring. | ||
| uint256 public rollupDelayPeriod; | ||
|
|
||
| /********************** | ||
| * Function Modifiers * | ||
| **********************/ | ||
|
|
@@ -183,6 +187,14 @@ contract Rollup is IRollup, OwnableUpgradeable, PausableUpgradeable { | |
| } | ||
| } | ||
|
|
||
| /// @notice Initializer for upgrade to version 3. | ||
| /// @param _rollupDelayPeriod The delay period for permissionless batch submission. | ||
| function initialize3(uint256 _rollupDelayPeriod) external reinitializer(3) { | ||
| require(_rollupDelayPeriod != 0, "invalid rollup delay period"); | ||
| rollupDelayPeriod = _rollupDelayPeriod; | ||
| emit UpdateRollupDelayPeriod(0, _rollupDelayPeriod); | ||
| } | ||
|
|
||
| /************************ | ||
| * Restricted Functions * | ||
| ************************/ | ||
|
|
@@ -220,6 +232,19 @@ contract Rollup is IRollup, OwnableUpgradeable, PausableUpgradeable { | |
| BatchDataInput calldata batchDataInput, | ||
| BatchSignatureInput calldata batchSignatureInput | ||
| ) external payable override onlyActiveStaker nonReqRevert whenNotPaused { | ||
| // check l1msg delay - sequencer must process L1 messages when delayed | ||
| if ( | ||
| IL1MessageQueue(messageQueue).getFirstUnfinalizedMessageEnqueueTime() + rollupDelayPeriod < block.timestamp | ||
| ) { | ||
| require(batchDataInput.numL1Messages > 0, "l1msg delay"); | ||
| } | ||
|
Comment on lines
+235
to
+240
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not check rollupDelay?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because commitBatch invalidates rollupDelay, which is exactly what we expect. |
||
| _commitBatchWithBatchData(batchDataInput, batchSignatureInput); | ||
| } | ||
Kukoomomo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| function _commitBatchWithBatchData( | ||
| BatchDataInput calldata batchDataInput, | ||
| BatchSignatureInput calldata batchSignatureInput | ||
| ) internal { | ||
| require(batchDataInput.version == 0 || batchDataInput.version == 1, "invalid version"); | ||
| require(batchDataInput.prevStateRoot != bytes32(0), "previous state root is zero"); | ||
| require(batchDataInput.postStateRoot != bytes32(0), "new state root is zero"); | ||
|
|
@@ -259,7 +284,7 @@ contract Rollup is IRollup, OwnableUpgradeable, PausableUpgradeable { | |
| } | ||
| bytes32 _blobVersionedHash = (blobhash(0) == bytes32(0)) ? ZERO_VERSIONED_HASH : blobhash(0); | ||
|
|
||
| { | ||
| { | ||
| uint256 _headerLength = BatchHeaderCodecV0.BATCH_HEADER_LENGTH; | ||
| if (batchDataInput.version == 1) { | ||
| _headerLength = BatchHeaderCodecV1.BATCH_HEADER_LENGTH; | ||
|
|
@@ -318,6 +343,46 @@ contract Rollup is IRollup, OwnableUpgradeable, PausableUpgradeable { | |
| emit CommitBatch(_batchIndex, committedBatches[_batchIndex]); | ||
| } | ||
|
|
||
| /// @inheritdoc IRollup | ||
| /// @dev Allows permissionless batch submission when sequencers are offline or censoring. | ||
| /// Entry conditions: rollup delay OR L1 message queue delay must be met. | ||
| function commitBatchWithProof( | ||
| BatchDataInput calldata batchDataInput, | ||
| BatchSignatureInput calldata batchSignatureInput, | ||
| bytes calldata _batchHeader, | ||
| bytes calldata _batchProof | ||
| ) external override nonReqRevert whenNotPaused { | ||
| // check delay timing - allow if EITHER batch submission OR L1 message processing is stalled | ||
| // This enables permissionless batch submission when sequencers are offline or censoring | ||
| bool rollupDelay = batchDataStore[lastCommittedBatchIndex].originTimestamp + rollupDelayPeriod < | ||
| block.timestamp; | ||
|
|
||
| // Check if L1 message queue is delayed | ||
| bool l1MsgQueueDelayed = IL1MessageQueue(messageQueue).getFirstUnfinalizedMessageEnqueueTime() + | ||
| rollupDelayPeriod < | ||
| block.timestamp; | ||
|
|
||
| if (!rollupDelay && l1MsgQueueDelayed) { | ||
| require(batchDataInput.numL1Messages > 0, "l1msg delay"); | ||
| } | ||
| require(rollupDelay || l1MsgQueueDelayed, "invalid timing"); | ||
|
|
||
| _commitBatchWithBatchData(batchDataInput, batchSignatureInput); | ||
|
|
||
| // get batch data from batch header | ||
| (uint256 memPtr, bytes32 _batchHash) = _loadBatchHeader(_batchHeader); | ||
| // check batch hash | ||
| uint256 _batchIndex = BatchHeaderCodecV0.getBatchIndex(memPtr); | ||
| require(lastCommittedBatchIndex == _batchIndex, "incorrect batch header"); | ||
| require(committedBatches[_batchIndex] == _batchHash, "incorrect batch hash"); | ||
|
|
||
| // Override finalizeTimestamp for ZKP-backed immediate finality | ||
| batchDataStore[_batchIndex].finalizeTimestamp = block.timestamp; | ||
|
|
||
| // verify proof | ||
| _verifyProof(memPtr, _batchProof); | ||
| } | ||
|
|
||
| /// @inheritdoc IRollup | ||
| /// @dev If the owner wants to revert a sequence of batches by sending multiple transactions, | ||
| /// make sure to revert recent batches first. | ||
|
|
@@ -407,6 +472,15 @@ contract Rollup is IRollup, OwnableUpgradeable, PausableUpgradeable { | |
| emit UpdateFinalizationPeriodSeconds(_oldFinalizationPeriodSeconds, finalizationPeriodSeconds); | ||
| } | ||
|
|
||
| /// @notice Update rollupDelayPeriod. | ||
| /// @param _newPeriod New rollup delay period. | ||
| function updateRollupDelayPeriod(uint256 _newPeriod) external onlyOwner { | ||
| require(_newPeriod > 0 && _newPeriod != rollupDelayPeriod, "invalid new rollup delay period"); | ||
| uint256 _oldRollupDelayPeriod = rollupDelayPeriod; | ||
| rollupDelayPeriod = _newPeriod; | ||
| emit UpdateRollupDelayPeriod(_oldRollupDelayPeriod, rollupDelayPeriod); | ||
| } | ||
|
|
||
| /// @notice Add an account to the challenger list. | ||
| /// @param _account The address of account to add. | ||
| function addChallenger(address _account) external onlyOwner { | ||
|
|
@@ -477,7 +551,10 @@ contract Rollup is IRollup, OwnableUpgradeable, PausableUpgradeable { | |
| *****************************/ | ||
|
|
||
| /// @dev proveState proves a batch by submitting a proof. | ||
| function proveState(bytes calldata _batchHeader, bytes calldata _batchProof) external nonReqRevert whenNotPaused onlyActiveStaker{ | ||
| function proveState( | ||
| bytes calldata _batchHeader, | ||
| bytes calldata _batchProof | ||
| ) external nonReqRevert whenNotPaused onlyActiveStaker { | ||
| // get batch data from batch header | ||
| (uint256 memPtr, bytes32 _batchHash) = _loadBatchHeader(_batchHeader); | ||
| // check batch hash | ||
|
|
@@ -727,7 +804,7 @@ contract Rollup is IRollup, OwnableUpgradeable, PausableUpgradeable { | |
| if (_version == 0) { | ||
| (_memPtr, _length) = BatchHeaderCodecV0.loadAndValidate(_batchHeader); | ||
| } else if (_version == 1) { | ||
| (_memPtr, _length) = BatchHeaderCodecV1.loadAndValidate(_batchHeader); | ||
| (_memPtr, _length) = BatchHeaderCodecV1.loadAndValidate(_batchHeader); | ||
| } else { | ||
| revert("Unsupported batch version"); | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.