-
Notifications
You must be signed in to change notification settings - Fork 158
Expand file tree
/
Copy pathISequencerInbox.sol
More file actions
366 lines (306 loc) · 15.7 KB
/
ISequencerInbox.sol
File metadata and controls
366 lines (306 loc) · 15.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
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
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
// Copyright 2021-2022, Offchain Labs, Inc.
// For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE
// SPDX-License-Identifier: BUSL-1.1
// solhint-disable-next-line compiler-version
pragma solidity >=0.6.9 <0.9.0;
pragma experimental ABIEncoderV2;
import "../libraries/IGasRefunder.sol";
import "./IDelayedMessageProvider.sol";
import "./IBridge.sol";
import "./Messages.sol";
import "./DelayBufferTypes.sol";
interface ISequencerInbox is IDelayedMessageProvider {
/// @notice The maximum amount of time variatin between a message being posted on the L1 and being executed on the L2
/// @param delayBlocks The max amount of blocks in the past that a message can be received on L2
/// @param futureBlocks The max amount of blocks in the future that a message can be received on L2
/// @param delaySeconds The max amount of seconds in the past that a message can be received on L2
/// @param futureSeconds The max amount of seconds in the future that a message can be received on L2
struct MaxTimeVariation {
uint256 delayBlocks;
uint256 futureBlocks;
uint256 delaySeconds;
uint256 futureSeconds;
}
event SequencerBatchDelivered(
uint256 indexed batchSequenceNumber,
bytes32 indexed beforeAcc,
bytes32 indexed afterAcc,
bytes32 delayedAcc,
uint256 afterDelayedMessagesRead,
IBridge.TimeBounds timeBounds,
IBridge.BatchDataLocation dataLocation
);
event OwnerFunctionCalled(uint256 indexed id);
/// @dev a separate event that emits batch data when this isn't easily accessible in the tx.input
event SequencerBatchData(uint256 indexed batchSequenceNumber, bytes data);
/// @dev a valid keyset was added
event SetValidKeyset(bytes32 indexed keysetHash, bytes keysetBytes);
/// @dev a keyset was invalidated
event InvalidateKeyset(bytes32 indexed keysetHash);
/// @dev Owner set max time variation.
/// This event may have been introduced in an upgrade and therefore might not give the full history.
/// To get the full history, search for `OwnerFunctionCalled(0)` events.
event MaxTimeVariationSet(MaxTimeVariation maxTimeVariation);
/// @dev Owner set a batch poster.
/// This event may have been introduced in an upgrade and therefore might not give the full history.
/// To get the full history, search for `OwnerFunctionCalled(1)` events.
event BatchPosterSet(address batchPoster, bool isBatchPoster);
/// @dev Owner or batch poster manager set a sequencer.
/// This event may have been introduced in an upgrade and therefore might not give the full history.
/// To get the full history, search for `OwnerFunctionCalled(4)` events.
event SequencerSet(address addr, bool isSequencer);
/// @dev Owner set the batch poster manager.
/// This event may have been introduced in an upgrade and therefore might not give the full history.
/// To get the full history, search for `OwnerFunctionCalled(5)` events.
event BatchPosterManagerSet(address newBatchPosterManager);
/// @dev Owner set the buffer config.
event BufferConfigSet(BufferConfig bufferConfig);
/// @dev Owner set the fee token pricer.
event FeeTokenPricerSet(address feeTokenPricer);
function totalDelayedMessagesRead() external view returns (uint256);
function bridge() external view returns (IBridge);
/// @dev The size of the batch header
// solhint-disable-next-line func-name-mixedcase
function HEADER_LENGTH() external view returns (uint256);
/// @dev If the first batch data byte after the header has this bit set,
/// the sequencer inbox has authenticated the data. Currently only used for 4844 blob support.
/// See: https://github.com/OffchainLabs/nitro/blob/69de0603abf6f900a4128cab7933df60cad54ded/arbstate/das_reader.go
// solhint-disable-next-line func-name-mixedcase
function DATA_AUTHENTICATED_FLAG() external view returns (bytes1);
/// @dev If the first data byte after the header has this bit set,
/// then the batch data is to be found in 4844 data blobs
/// See: https://github.com/OffchainLabs/nitro/blob/69de0603abf6f900a4128cab7933df60cad54ded/arbstate/das_reader.go
// solhint-disable-next-line func-name-mixedcase
function DATA_BLOB_HEADER_FLAG() external view returns (bytes1);
/// @dev If the first data byte after the header has this bit set,
/// then the batch data is a das message
/// See: https://github.com/OffchainLabs/nitro/blob/69de0603abf6f900a4128cab7933df60cad54ded/arbstate/das_reader.go
// solhint-disable-next-line func-name-mixedcase
function DAS_MESSAGE_HEADER_FLAG() external view returns (bytes1);
/// @dev If the first data byte after the header has this bit set,
/// then the batch data is a das message that employs a merklesization strategy
/// See: https://github.com/OffchainLabs/nitro/blob/69de0603abf6f900a4128cab7933df60cad54ded/arbstate/das_reader.go
// solhint-disable-next-line func-name-mixedcase
function TREE_DAS_MESSAGE_HEADER_FLAG() external view returns (bytes1);
/// @dev If the first data byte after the header has this bit set,
/// then the batch data has been brotli compressed
/// See: https://github.com/OffchainLabs/nitro/blob/69de0603abf6f900a4128cab7933df60cad54ded/arbstate/das_reader.go
// solhint-disable-next-line func-name-mixedcase
function BROTLI_MESSAGE_HEADER_FLAG() external view returns (bytes1);
/// @dev If the first data byte after the header has this bit set,
/// then the batch data uses a zero heavy encoding
/// See: https://github.com/OffchainLabs/nitro/blob/69de0603abf6f900a4128cab7933df60cad54ded/arbstate/das_reader.go
// solhint-disable-next-line func-name-mixedcase
function ZERO_HEAVY_MESSAGE_HEADER_FLAG() external view returns (bytes1);
function rollup() external view returns (IOwnable);
function isBatchPoster(
address
) external view returns (bool);
function isSequencer(
address
) external view returns (bool);
/// @notice True is the sequencer inbox is delay bufferable
function isDelayBufferable() external view returns (bool);
function maxDataSize() external view returns (uint256);
/// @notice The batch poster manager has the ability to change the batch poster addresses
/// This enables the batch poster to do key rotation
function batchPosterManager() external view returns (address);
/// @notice The fee token pricer is used to get the exchange rate between the child chain's fee token
/// and parent chain's fee token. This is needed when the child chain uses a custom fee
/// token which is different from the parent chain's fee token. The exchange rate is
/// used to correctly report converted gas price in the batch spending reports, so
/// the batch poster can get properly reimbursed on the child chain. If the chain uses
/// a custom fee token, but the pricer is not set, then the batch poster reports won't be reported
/// and the batch poster won't get reimbursed.
function feeTokenPricer() external view returns (IFeeTokenPricer);
struct DasKeySetInfo {
bool isValidKeyset;
uint64 creationBlock;
}
/// @dev returns 4 uint256 to be compatible with older version
function maxTimeVariation()
external
view
returns (
uint256 delayBlocks,
uint256 futureBlocks,
uint256 delaySeconds,
uint256 futureSeconds
);
function dasKeySetInfo(
bytes32
) external view returns (bool, uint64);
/// @notice Remove force inclusion delay after a L1 chainId fork
function removeDelayAfterFork() external;
/// @notice Force messages from the delayed inbox to be included in the chain
/// Callable by any address, but message can only be force-included after maxTimeVariation.delayBlocks
/// has elapsed. As part of normal behaviour the sequencer will include these
/// messages so it's only necessary to call this if the sequencer is down, or not including any delayed messages.
/// @param _totalDelayedMessagesRead The total number of messages to read up to
/// @param kind The kind of the last message to be included
/// @param l1BlockAndTime The l1 block and the l1 timestamp of the last message to be included
/// @param baseFeeL1 The l1 gas price of the last message to be included
/// @param sender The sender of the last message to be included
/// @param messageDataHash The messageDataHash of the last message to be included
function forceInclusion(
uint256 _totalDelayedMessagesRead,
uint8 kind,
uint64[2] calldata l1BlockAndTime,
uint256 baseFeeL1,
address sender,
bytes32 messageDataHash
) external;
function inboxAccs(
uint256 index
) external view returns (bytes32);
function batchCount() external view returns (uint256);
function isValidKeysetHash(
bytes32 ksHash
) external view returns (bool);
/// @notice the creation block is intended to still be available after a keyset is deleted
function getKeysetCreationBlock(
bytes32 ksHash
) external view returns (uint256);
/// @dev The delay buffer can change due to pending depletion/replenishment.
/// This function applies pending buffer changes to proactively calculate the force inclusion deadline.
/// This is only relevant when the buffer is less than the delayBlocks (unhappy case), otherwise force inclusion deadline is fixed at delayBlocks.
/// @notice Calculates the upper bounds of the delay buffer
/// @param blockNumber The block number when a delayed message was created
/// @return blockNumberDeadline The block number at when the message can be force included
function forceInclusionDeadline(
uint64 blockNumber
) external view returns (uint64 blockNumberDeadline);
// ---------- BatchPoster functions ----------
/// @dev Deprecated, kept for abi generation and will be removed in the future
function addSequencerL2BatchFromOrigin(
uint256 sequenceNumber,
bytes calldata data,
uint256 afterDelayedMessagesRead,
IGasRefunder gasRefunder
) external;
/// @dev Will be deprecated due to EIP-3074, use `addSequencerL2Batch` instead
function addSequencerL2BatchFromOrigin(
uint256 sequenceNumber,
bytes calldata data,
uint256 afterDelayedMessagesRead,
IGasRefunder gasRefunder,
uint256 prevMessageCount,
uint256 newMessageCount
) external;
function addSequencerL2Batch(
uint256 sequenceNumber,
bytes calldata data,
uint256 afterDelayedMessagesRead,
IGasRefunder gasRefunder,
uint256 prevMessageCount,
uint256 newMessageCount
) external;
function addSequencerL2BatchFromBlobs(
uint256 sequenceNumber,
uint256 afterDelayedMessagesRead,
IGasRefunder gasRefunder,
uint256 prevMessageCount,
uint256 newMessageCount
) external;
/// @dev Proves message delays, updates delay buffers, and posts an L2 batch with blob data.
/// DelayProof proves the delay of the message and syncs the delay buffer.
function addSequencerL2BatchFromBlobsDelayProof(
uint256 sequenceNumber,
uint256 afterDelayedMessagesRead,
IGasRefunder gasRefunder,
uint256 prevMessageCount,
uint256 newMessageCount,
DelayProof calldata delayProof
) external;
/// @dev Proves message delays, updates delay buffers, and posts an L2 batch with calldata posted from an EOA.
/// DelayProof proves the delay of the message and syncs the delay buffer.
/// Will be deprecated due to EIP-3074, use `addSequencerL2BatchDelayProof` instead
function addSequencerL2BatchFromOriginDelayProof(
uint256 sequenceNumber,
bytes calldata data,
uint256 afterDelayedMessagesRead,
IGasRefunder gasRefunder,
uint256 prevMessageCount,
uint256 newMessageCount,
DelayProof calldata delayProof
) external;
/// @dev Proves message delays, updates delay buffers, and posts an L2 batch with calldata.
/// delayProof is used to prove the delay of the message and syncs the delay buffer.
function addSequencerL2BatchDelayProof(
uint256 sequenceNumber,
bytes calldata data,
uint256 afterDelayedMessagesRead,
IGasRefunder gasRefunder,
uint256 prevMessageCount,
uint256 newMessageCount,
DelayProof calldata delayProof
) external;
// ---------- onlyRollupOrOwner functions ----------
/**
* @notice Set max delay for sequencer inbox
* @param maxTimeVariation_ the maximum time variation parameters
*/
function setMaxTimeVariation(
MaxTimeVariation memory maxTimeVariation_
) external;
/**
* @notice Updates whether an address is authorized to be a batch poster at the sequencer inbox
* @param addr the address
* @param isBatchPoster_ if the specified address should be authorized as a batch poster
*/
function setIsBatchPoster(address addr, bool isBatchPoster_) external;
/**
* @notice Makes Data Availability Service keyset valid
* @param keysetBytes bytes of the serialized keyset
*/
function setValidKeyset(
bytes calldata keysetBytes
) external;
/**
* @notice Invalidates a Data Availability Service keyset
* @param ksHash hash of the keyset
*/
function invalidateKeysetHash(
bytes32 ksHash
) external;
/**
* @notice Updates whether an address is authorized to be a sequencer.
* @dev The IsSequencer information is used only off-chain by the nitro node to validate sequencer feed signer.
* @param addr the address
* @param isSequencer_ if the specified address should be authorized as a sequencer
*/
function setIsSequencer(address addr, bool isSequencer_) external;
/**
* @notice Updates the batch poster manager, the address which has the ability to rotate batch poster keys
* @param newBatchPosterManager The new batch poster manager to be set
*/
function setBatchPosterManager(
address newBatchPosterManager
) external;
/**
* @notice Updates the fee token pricer, the contract which is used to get the exchange rate between child
* chain's fee token and parent chain's fee token in rollups that use a custom fee token.
* @param newFeeTokenPricer The new fee token pricer to be set
*/
function setFeeTokenPricer(
IFeeTokenPricer newFeeTokenPricer
) external;
/// @notice Allows the rollup owner to sync the rollup address
function updateRollupAddress() external;
// ---------- initializer ----------
function initialize(
IBridge bridge_,
MaxTimeVariation calldata maxTimeVariation_,
BufferConfig calldata bufferConfig_,
IFeeTokenPricer feeTokenPricer_
) external;
}
interface IFeeTokenPricer {
/**
* @notice Get the number of child chain fee tokens per 1 parent chain fee token. Exchange rate must be
* denominated in 18 decimals. Function is mutable so it allows the pricer to keep internal state.
* @dev For example, parent chain's native token is ETH, fee token is DAI. If price of 1ETH = 2000DAI, then function should return 2000*1e18.
* If fee token is USDC instead and price of 1ETH = 2000USDC, function should still return 2000*1e18, despite USDC using 6 decimals.
*/
function getExchangeRate() external returns (uint256);
}