108 lines
5.3 KiB
Solidity
108 lines
5.3 KiB
Solidity
// SPDX-License-Identifier: MIT
|
|
|
|
pragma solidity ^0.8.13;
|
|
|
|
import {IBase} from "./IBase.sol";
|
|
|
|
/// @dev Enum used by L2 System Contracts to differentiate logs.
|
|
enum SystemLogKey {
|
|
L2_TO_L1_LOGS_TREE_ROOT_KEY,
|
|
TOTAL_L2_TO_L1_PUBDATA_KEY,
|
|
STATE_DIFF_HASH_KEY,
|
|
PACKED_BATCH_AND_L2_BLOCK_TIMESTAMP_KEY,
|
|
PREV_BATCH_HASH_KEY,
|
|
CHAINED_PRIORITY_TXN_HASH_KEY,
|
|
NUMBER_OF_LAYER_1_TXS_KEY,
|
|
EXPECTED_SYSTEM_CONTRACT_UPGRADE_TX_HASH_KEY
|
|
}
|
|
|
|
/// @dev Offset used to pull Address From Log. Equal to 4 (bytes for isService)
|
|
uint256 constant L2_LOG_ADDRESS_OFFSET = 4;
|
|
|
|
/// @dev Offset used to pull Key From Log. Equal to 4 (bytes for isService) + 20 (bytes for address)
|
|
uint256 constant L2_LOG_KEY_OFFSET = 24;
|
|
|
|
/// @dev Offset used to pull Value From Log. Equal to 4 (bytes for isService) + 20 (bytes for address) + 32 (bytes for key)
|
|
uint256 constant L2_LOG_VALUE_OFFSET = 56;
|
|
|
|
interface IExecutor is IBase {
|
|
/// @notice Rollup batch stored data
|
|
/// @param batchNumber Rollup batch number
|
|
/// @param batchHash Hash of L2 batch
|
|
/// @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 batch
|
|
/// @param l2LogsTreeRoot Root hash of tree that contains L2 -> L1 messages from this batch
|
|
/// @param timestamp Rollup batch timestamp, have the same format as Ethereum batch constant
|
|
/// @param commitment Verified input for the zkSync circuit
|
|
struct StoredBatchInfo {
|
|
uint64 batchNumber;
|
|
bytes32 batchHash;
|
|
uint64 indexRepeatedStorageChanges;
|
|
uint256 numberOfLayer1Txs;
|
|
bytes32 priorityOperationsHash;
|
|
bytes32 l2LogsTreeRoot;
|
|
uint256 timestamp;
|
|
bytes32 commitment;
|
|
}
|
|
|
|
/// @notice Data needed to commit new batch
|
|
/// @param batchNumber Number of the committed batch
|
|
/// @param timestamp Unix timestamp denoting the start of the batch 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 numberOfLayer1Txs Number of priority operations to be processed
|
|
/// @param priorityOperationsHash Hash of all priority operations from this batch
|
|
/// @param bootloaderHeapInitialContentsHash Hash of the initial contents of the bootloader heap. In practice it serves as the commitment to the transactions in the batch.
|
|
/// @param eventsQueueStateHash Hash of the events queue state. In practice it serves as the commitment to the events in the batch.
|
|
/// @param systemLogs concatenation of all L2 -> L1 system logs in the batch
|
|
/// @param totalL2ToL1Pubdata Total pubdata committed to as part of bootloader run. Contents are: l2Tol1Logs <> l2Tol1Messages <> publishedBytecodes <> stateDiffs
|
|
struct CommitBatchInfo {
|
|
uint64 batchNumber;
|
|
uint64 timestamp;
|
|
uint64 indexRepeatedStorageChanges;
|
|
bytes32 newStateRoot;
|
|
uint256 numberOfLayer1Txs;
|
|
bytes32 priorityOperationsHash;
|
|
bytes32 bootloaderHeapInitialContentsHash;
|
|
bytes32 eventsQueueStateHash;
|
|
bytes systemLogs;
|
|
bytes totalL2ToL1Pubdata;
|
|
}
|
|
|
|
/// @notice Recursive proof input data (individual commitments are constructed onchain)
|
|
struct ProofInput {
|
|
uint256[] recursiveAggregationInput;
|
|
uint256[] serializedProof;
|
|
}
|
|
|
|
function commitBatches(StoredBatchInfo calldata _lastCommittedBatchData, CommitBatchInfo[] calldata _newBatchesData)
|
|
external;
|
|
|
|
function proveBatches(
|
|
StoredBatchInfo calldata _prevBatch,
|
|
StoredBatchInfo[] calldata _committedBatches,
|
|
ProofInput calldata _proof
|
|
) external;
|
|
|
|
function executeBatches(StoredBatchInfo[] calldata _batchesData) external;
|
|
|
|
function revertBatches(uint256 _newLastBatch) external;
|
|
|
|
/// @notice Event emitted when a batch is committed
|
|
/// @dev It has the name "BlockCommit" and not "BatchCommit" due to backward compatibility considerations
|
|
event BlockCommit(uint256 indexed batchNumber, bytes32 indexed batchHash, bytes32 indexed commitment);
|
|
|
|
/// @notice Event emitted when batches are verified
|
|
/// @dev It has the name "BlocksVerification" and not "BatchesVerification" due to backward compatibility considerations
|
|
event BlocksVerification(uint256 indexed previousLastVerifiedBatch, uint256 indexed currentLastVerifiedBatch);
|
|
|
|
/// @notice Event emitted when a batch is executed
|
|
/// @dev It has the name "BlockExecution" and not "BatchExecution" due to backward compatibility considerations
|
|
event BlockExecution(uint256 indexed batchNumber, bytes32 indexed batchHash, bytes32 indexed commitment);
|
|
|
|
/// @notice Event emitted when batches are reverted
|
|
/// @dev It has the name "BlocksRevert" and not "BatchesRevert" due to backward compatibility considerations
|
|
event BlocksRevert(uint256 totalBatchesCommitted, uint256 totalBatchesVerified, uint256 totalBatchesExecuted);
|
|
}
|