/
IZkEvmV2.sol
92 lines (80 loc) · 2.69 KB
/
IZkEvmV2.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
87
88
89
90
91
92
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.19;
interface IZkEvmV2 {
struct BlockData {
bytes32 blockRootHash;
uint32 l2BlockTimestamp;
bytes[] transactions;
bytes32[] l2ToL1MsgHashes;
bytes fromAddresses;
uint16[] batchReceptionIndices;
}
/**
* @dev Emitted when a L2 block has been finalized on L1
*/
event BlockFinalized(uint256 indexed blockNumber, bytes32 indexed stateRootHash);
/**
* @dev Emitted when a L2 blocks have been finalized on L1
*/
event BlocksVerificationDone(uint256 indexed lastBlockFinalized, bytes32 startingRootHash, bytes32 finalRootHash);
/**
* @dev Emitted when a verifier is set for a particular proof type
*/
event VerifierAddressChanged(
address indexed verifierAddress,
uint256 indexed proofType,
address indexed verifierSetBy
);
/**
* @dev Thrown when l2 block timestamp is not correct
*/
error BlockTimestampError();
/**
* @dev Thrown when the starting rootHash does not match the existing state
*/
error StartingRootHashDoesNotMatch();
/**
* @dev Thrown when block contains zero transactions
*/
error EmptyBlock();
/**
* @dev Thrown when zk proof is empty bytes
*/
error ProofIsEmpty();
/**
* @dev Thrown when zk proof type is invalid
*/
error InvalidProofType();
/**
* @dev Thrown when zk proof is invalid
*/
error InvalidProof();
/**
* @notice Adds or updated the verifier contract address for a proof type
* @dev DEFAULT_ADMIN_ROLE is required to execute
* @param _newVerifierAddress The address for the verifier contract
* @param _proofType The proof type being set/updated
**/
function setVerifierAddress(address _newVerifierAddress, uint256 _proofType) external;
/**
* @notice Finalizes blocks without using a proof
* @dev DEFAULT_ADMIN_ROLE is required to execute
* @param _calldata The full BlockData collection - block, transaction and log data
**/
function finalizeBlocksWithoutProof(BlockData[] calldata _calldata) external;
/**
* @notice Finalizes blocks without using a proof
* @dev OPERATOR_ROLE is required to execute
* @dev If the verifier based on proof type is not found, it defaults to the default verifier type
* @param _calldata The full BlockData collection - block, transaction and log data
* @param _proof The proof to verified with the proof type verifier contract
* @param _proofType The proof type to determine which verifier contract to use
* @param _parentStateRootHash The beginning roothash to start with
**/
function finalizeBlocks(
BlockData[] calldata _calldata,
bytes calldata _proof,
uint256 _proofType,
bytes32 _parentStateRootHash
) external;
}