-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathScrollChainInterface.sol
More file actions
268 lines (233 loc) · 11.3 KB
/
ScrollChainInterface.sol
File metadata and controls
268 lines (233 loc) · 11.3 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
/// @notice ScrollChainInterface collects all past and present ScrollChain
/// events and functions that are needed to index data.
/// @dev We store these here for easier access to the full ABI, since some
/// of these functions were removed in later versions of ScrollChain.
interface ScrollChainInterface {
/**********
* 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 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);
/********************
* Commit Functions *
********************/
/// @notice Import layer 2 genesis block
/// @param _batchHeader The header of the genesis batch.
/// @param _stateRoot The state root of the genesis block.
function importGenesisBatch(bytes calldata _batchHeader, bytes32 _stateRoot) external;
/// @notice Commit a batch of transactions on layer 1.
///
/// @param version The version of current batch.
/// @param parentBatchHeader The header of parent batch, see the comments of `BatchHeaderV0Codec`.
/// @param chunks The list of encoded chunks, see the comments of `ChunkCodec`.
/// @param skippedL1MessageBitmap The bitmap indicates whether each L1 message is skipped or not.
function commitBatch(
uint8 version,
bytes calldata parentBatchHeader,
bytes[] memory chunks,
bytes calldata skippedL1MessageBitmap
) external;
/// @notice Commit a batch of transactions on layer 1 with blob data proof.
///
/// @dev Memory layout of `blobDataProof`:
/// | z | y | kzg_commitment | kzg_proof |
/// |---------|---------|----------------|-----------|
/// | bytes32 | bytes32 | bytes48 | bytes48 |
///
/// @param version The version of current batch.
/// @param parentBatchHeader The header of parent batch.
/// @param chunks The list of encoded chunks, see the comments of `ChunkCodec`.
/// @param skippedL1MessageBitmap The bitmap indicates whether each L1 message is skipped or not.
/// @param blobDataProof The proof for blob data.
function commitBatchWithBlobProof(
uint8 version,
bytes calldata parentBatchHeader,
bytes[] memory chunks,
bytes calldata skippedL1MessageBitmap,
bytes calldata blobDataProof
) external;
/// @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;
/********************
* Revert Functions *
********************/
/// @notice Revert a pending batch.
/// @dev one can only revert unfinalized batches.
/// @param batchHeader The header of current batch, see the encoding in comments of `commitBatch`.
/// @param count The number of subsequent batches to revert, including current batch.
function revertBatch(bytes calldata batchHeader, uint256 count) 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;
/**********************
* Finalize Functions *
**********************/
/// @notice Finalize a committed batch on layer 1.
/// @param batchHeader The header of current batch, see the encoding in comments of `commitBatch.
/// @param prevStateRoot The state root of parent batch.
/// @param postStateRoot The state root of current batch.
/// @param withdrawRoot The withdraw trie root of current batch.
/// @param aggrProof The aggregation proof for current batch.
function finalizeBatchWithProof(
bytes calldata batchHeader,
bytes32 prevStateRoot,
bytes32 postStateRoot,
bytes32 withdrawRoot,
bytes calldata aggrProof
) external;
/// @notice Finalize a committed batch (with blob) on layer 1.
///
/// @dev Memory layout of `blobDataProof`:
/// | z | y | kzg_commitment | kzg_proof |
/// |---------|---------|----------------|-----------|
/// | bytes32 | bytes32 | bytes48 | bytes48 |
///
/// @param batchHeader The header of current batch, see the encoding in comments of `commitBatch.
/// @param prevStateRoot The state root of parent batch.
/// @param postStateRoot The state root of current batch.
/// @param withdrawRoot The withdraw trie root of current batch.
/// @param blobDataProof The proof for blob data.
/// @param aggrProof The aggregation proof for current batch.
function finalizeBatchWithProof4844(
bytes calldata batchHeader,
bytes32 prevStateRoot,
bytes32 postStateRoot,
bytes32 withdrawRoot,
bytes calldata blobDataProof,
bytes calldata aggrProof
) external;
/// @notice Finalize a list of committed batches (i.e. bundle) on layer 1.
/// @param batchHeader The header of last batch in current bundle, see the encoding in comments of `commitBatch.
/// @param postStateRoot The state root after current bundle.
/// @param withdrawRoot The withdraw trie root after current batch.
/// @param aggrProof The aggregation proof for current bundle.
function finalizeBundleWithProof(
bytes calldata batchHeader,
bytes32 postStateRoot,
bytes32 withdrawRoot,
bytes calldata aggrProof
) external;
/// @notice Finalize the initial Euclid batch.
/// @param postStateRoot The state root after current batch.
function finalizeEuclidInitialBatch(bytes32 postStateRoot) 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;
/**********************
* Enforced Functions *
**********************/
/// @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;
/*********************
* Mocking Functions *
*********************/
/// @notice Finalize batch without proof, See the comments of {finalizeBatchWithProof}.
function finalizeBatch(
bytes calldata _batchHeader,
bytes32 _prevStateRoot,
bytes32 _postStateRoot,
bytes32 _withdrawRoot
) external;
/// @notice Finalize 4844 batch without proof, See the comments of {finalizeBatchWithProof4844}.
function finalizeBatch4844(
bytes calldata _batchHeader,
bytes32, /*_prevStateRoot*/
bytes32 _postStateRoot,
bytes32 _withdrawRoot,
bytes calldata _blobDataProof
) external;
/// @notice Finalize bundle without proof, See the comments of {finalizeBundleWithProof}.
function finalizeBundle(
bytes calldata batchHeader,
bytes32 postStateRoot,
bytes32 withdrawRoot
) external;
/// @notice Finalize post Euclid phase 2 bundle without proof, See the comments of {finalizeBundlePostEuclidV2}.
function finalizeBundlePostEuclidV2NoProof(
bytes calldata batchHeader,
uint256 totalL1MessagesPoppedOverall,
bytes32 postStateRoot,
bytes32 withdrawRoot
) external;
}