-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathIExecutor.sol
86 lines (74 loc) · 4.12 KB
/
IExecutor.sol
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
// SPDX-License-Identifier: MIT OR Apache-2.0
pragma solidity ^0.8;
interface IExecutor {
/// @notice Rollup block stored data
/// @param blockNumber Rollup block number
/// @param blockHash Hash of L2 block
/// @param indexRepeatedStorageChanges The serial number of the shortcut index that's used as a unique identifier for storage keys that were used twice or more
/// @param numberOfLayer1Txs Number of priority operations to be processed
/// @param priorityOperationsHash Hash of all priority operations from this block
/// @param l2LogsTreeRoot Root hash of tree that contains L2 -> L1 messages from this block
/// @param timestamp Rollup block timestamp, have the same format as Ethereum block constant
/// @param commitment Verified input for the zkSync circuit
struct StoredBlockInfo {
uint64 blockNumber;
bytes32 blockHash;
uint64 indexRepeatedStorageChanges;
uint256 numberOfLayer1Txs;
bytes32 priorityOperationsHash;
bytes32 l2LogsTreeRoot;
uint256 timestamp;
bytes32 commitment;
}
/// @notice Data needed to commit new block
/// @param blockNumber Number of the committed block
/// @param timestamp Unix timestamp denoting the start of the block execution
/// @param indexRepeatedStorageChanges The serial number of the shortcut index that's used as a unique identifier for storage keys that were used twice or more
/// @param newStateRoot The state root of the full state tree
/// @param ergsPerPubdataByteInBlock Price in ergs per one byte of published pubdata in block
/// @param numberOfLayer1Txs Number of priority operations to be processed
/// @param l2LogsTreeRoot The root hash of the tree that contains all L2 -> L1 logs in the block
/// @param priorityOperationsHash Hash of all priority operations from this block
/// @param initialStorageChanges Storage write access as a concatenation key-value
/// @param repeatedStorageChanges Storage write access as a concatenation index-value
/// @param l2Logs concatenation of all L2 -> L1 logs in the block
/// @param l2ArbitraryLengthMessages array of hash preimages that were sent as value of L2 logs by special system L2 contract
/// @param factoryDeps array of l2 bytecodes that were marked as known on L2
struct CommitBlockInfo {
uint64 blockNumber;
uint64 timestamp;
uint64 indexRepeatedStorageChanges;
bytes32 newStateRoot;
uint256 numberOfLayer1Txs;
bytes32 l2LogsTreeRoot;
bytes32 priorityOperationsHash;
bytes initialStorageChanges;
bytes repeatedStorageChanges;
bytes l2Logs;
bytes[] l2ArbitraryLengthMessages;
bytes[] factoryDeps;
}
/// @notice Recursive proof input data (individual commitments are constructed onchain)
/// TODO: The verifier integration is not finished yet, change the structure for compatibility later
struct ProofInput {
uint256[] recurisiveAggregationInput;
uint256[] serializedProof;
}
function commitBlocks(StoredBlockInfo calldata _lastCommittedBlockData, CommitBlockInfo[] calldata _newBlocksData)
external;
function proveBlocks(
StoredBlockInfo calldata _prevBlock,
StoredBlockInfo[] calldata _committedBlocks,
ProofInput calldata _proof
) external;
function executeBlocks(StoredBlockInfo[] calldata _blocksData) external;
function revertBlocks(uint256 _newLastBlock) external;
/// @notice Event emitted when a block is committed
event BlockCommit(uint256 indexed blockNumber, bytes32 indexed blockHash, bytes32 indexed commitment);
/// @notice Event emitted when blocks are verified
event BlocksVerification(uint256 indexed previousLastVerifiedBlock, uint256 indexed currentLastVerifiedBlock);
/// @notice Event emitted when a block is executed
event BlockExecution(uint256 indexed blockNumber, bytes32 indexed blockHash, bytes32 indexed commitment);
/// @notice Event emitted when blocks are reverted
event BlocksRevert(uint256 totalBlocksCommitted, uint256 totalBlocksVerified, uint256 totalBlocksExecuted);
}