-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathIScrollChain.sol
More file actions
132 lines (111 loc) · 5.7 KB
/
Copy pathIScrollChain.sol
File metadata and controls
132 lines (111 loc) · 5.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
/// @title IScrollChain
/// @notice The interface for ScrollChain.
interface IScrollChain {
/**********
* Events *
**********/
/// @notice Emitted when a new batch is committed.
/// @param batchIndex The index of the batch.
/// @param batchHash The hash of the batch.
event CommitBatch(uint256 indexed batchIndex, bytes32 indexed batchHash);
/// @notice revert a pending batch.
/// @param batchIndex The index of the batch.
/// @param batchHash The hash of the batch
event RevertBatch(uint256 indexed batchIndex, bytes32 indexed batchHash);
/// @notice revert a range of batches.
/// @param startBatchIndex The start batch index of the range (inclusive).
/// @param finishBatchIndex The finish batch index of the range (inclusive).
event RevertBatch(uint256 indexed startBatchIndex, uint256 indexed finishBatchIndex);
/// @notice Emitted when a batch is finalized.
/// @param batchIndex The index of the batch.
/// @param batchHash The hash of the batch
/// @param stateRoot The state root on layer 2 after this batch.
/// @param withdrawRoot The merkle root on layer2 after this batch.
event FinalizeBatch(uint256 indexed batchIndex, bytes32 indexed batchHash, bytes32 stateRoot, bytes32 withdrawRoot);
/// @notice Emitted when owner updates the status of sequencer.
/// @param account The address of account updated.
/// @param status The status of the account updated.
event UpdateSequencer(address indexed account, bool status);
/// @notice Emitted when owner updates the status of prover.
/// @param account The address of account updated.
/// @param status The status of the account updated.
event UpdateProver(address indexed account, bool status);
/// @notice Emitted when we enter or exit enforced batch mode.
/// @param enabled True if we are entering enforced batch mode, false otherwise.
/// @param lastCommittedBatchIndex The index of the last committed batch.
event UpdateEnforcedBatchMode(bool enabled, uint256 lastCommittedBatchIndex);
/*************************
* Public View Functions *
*************************/
/// @return The latest finalized batch index.
function lastFinalizedBatchIndex() external view returns (uint256);
/// @param batchIndex The index of the batch.
/// @return The batch hash of a committed batch.
function committedBatches(uint256 batchIndex) external view returns (bytes32);
/// @param batchIndex The index of the batch.
/// @return The state root of a committed batch.
function finalizedStateRoots(uint256 batchIndex) external view returns (bytes32);
/// @param batchIndex The index of the batch.
/// @return The message root of a committed batch.
function withdrawRoots(uint256 batchIndex) external view returns (bytes32);
/// @param batchIndex The index of the batch.
/// @return Whether the batch is finalized by batch index.
function isBatchFinalized(uint256 batchIndex) external view returns (bool);
/*****************************
* Public Mutating Functions *
*****************************/
/// @notice Commit one or more batches after the EuclidV2 upgrade.
/// @param version The version of the committed batches.
/// @param parentBatchHash The hash of parent batch.
/// @param lastBatchHash The hash of the last committed batch after this call.
/// @dev The batch payload is stored in the blobs.
function commitBatches(
uint8 version,
bytes32 parentBatchHash,
bytes32 lastBatchHash
) external;
/// @notice Revert pending batches.
/// @dev one can only revert unfinalized batches.
/// @param batchHeader The header of the last batch we want to keep.
function revertBatch(bytes calldata batchHeader) external;
/// @notice Finalize a list of committed batches (i.e. bundle) on layer 1 after the EuclidV2 upgrade.
/// @param batchHeader The header of the last batch in this bundle.
/// @param totalL1MessagesPoppedOverall The number of messages processed after this bundle.
/// @param postStateRoot The state root after this bundle.
/// @param withdrawRoot The withdraw trie root after this bundle.
/// @param aggrProof The bundle proof for this bundle.
/// @dev See `BatchHeaderV7Codec` for the batch header encoding.
function finalizeBundlePostEuclidV2(
bytes calldata batchHeader,
uint256 totalL1MessagesPoppedOverall,
bytes32 postStateRoot,
bytes32 withdrawRoot,
bytes calldata aggrProof
) external;
/// @notice The struct for permissionless batch finalization.
/// @param batchHeader The header of this batch.
/// @param totalL1MessagesPoppedOverall The number of messages processed after this bundle.
/// @param postStateRoot The state root after this batch.
/// @param withdrawRoot The withdraw trie root after this batch.
/// @param zkProof The bundle proof for this batch (single-batch bundle).
/// @dev See `BatchHeaderV7Codec` for the batch header encoding.
struct FinalizeStruct {
bytes batchHeader;
uint256 totalL1MessagesPoppedOverall;
bytes32 postStateRoot;
bytes32 withdrawRoot;
bytes zkProof;
}
/// @notice Commit and finalize a batch in permissionless mode.
/// @param version The version of current batch.
/// @param parentBatchHash The hash of parent batch.
/// @param finalizeStruct The data needed to finalize this batch.
/// @dev The batch payload is stored in the blob.
function commitAndFinalizeBatch(
uint8 version,
bytes32 parentBatchHash,
FinalizeStruct calldata finalizeStruct
) external;
}