ZKRollup
ZKRollup
This contract maintains essential data for zk rollup, including: 1. a list of pending messages, which will be relayed to layer 2; 2. the block tree generated by layer 2 and it's status.
the message queue is not used yet, the offline relayer only use events in L1ScrollMessenger.
Methods
appendMessage
Append a cross chain message to message queue.
This function should only be called by L1ScrollMessenger for safety.
Parameters
| Name |
Type |
Description |
| _sender |
address |
The address of message sender in layer 1. |
| _target |
address |
The address of message recipient in layer 2. |
| _value |
uint256 |
The amount of ether sent to recipient in layer 2. |
| _fee |
uint256 |
The amount of ether paid to relayer in layer 2. |
| _deadline |
uint256 |
The deadline of the message. |
| _message |
bytes |
The content of the message. |
| _gasLimit |
uint256 |
Unused, but included for potential forward compatibility considerations. |
Returns
| Name |
Type |
Description |
| _0 |
uint256 |
undefined |
batches
Mapping from batch id to batch struct.
Parameters
| Name |
Type |
Description |
| _0 |
bytes32 |
undefined |
Returns
| Name |
Type |
Description |
| batchHash |
bytes32 |
undefined |
| parentHash |
bytes32 |
undefined |
| batchIndex |
uint64 |
undefined |
| verified |
bool |
undefined |
blocks
Mapping from block hash to block struct.
Parameters
| Name |
Type |
Description |
| _0 |
bytes32 |
undefined |
Returns
| Name |
Type |
Description |
| parentHash |
bytes32 |
undefined |
| transactionRoot |
bytes32 |
undefined |
| blockHeight |
uint64 |
undefined |
| batchIndex |
uint64 |
undefined |
commitBatch
Parameters
| Name |
Type |
Description |
| _batch |
IZKRollup.Layer2Batch |
undefined |
finalizeBatchWithProof
finalize commited batch in layer 1
will add more parameters if needed.
Parameters
| Name |
Type |
Description |
| _batchId |
bytes32 |
The identification of the commited batch. |
| _proof |
uint256[] |
The corresponding proof of the commited batch. |
| _instances |
uint256[] |
Instance used to verify, generated from batch. |
finalizedBatches
Mapping from batch index to finalized batch id.
Parameters
| Name |
Type |
Description |
| _0 |
uint256 |
undefined |
Returns
| Name |
Type |
Description |
| _0 |
bytes32 |
undefined |
getMessageHashByIndex
Return the message hash by index.
Parameters
| Name |
Type |
Description |
| _index |
uint256 |
The index to query. |
Returns
| Name |
Type |
Description |
| _0 |
bytes32 |
undefined |
getNextQueueIndex
Return the index of the first queue element not yet executed.
Returns
| Name |
Type |
Description |
| _0 |
uint256 |
undefined |
getQeueuLength
Return the total number of appended message.
Returns
| Name |
Type |
Description |
| _0 |
uint256 |
undefined |
importGenesisBlock
Parameters
| Name |
Type |
Description |
| _genesis |
IZKRollup.Layer2BlockHeader |
undefined |
initialize
Parameters
| Name |
Type |
Description |
| _chainId |
uint256 |
undefined |
isBlockFinalized
Return whether the block is finalized by block hash.
Parameters
| Name |
Type |
Description |
| _blockHash |
bytes32 |
undefined |
Returns
| Name |
Type |
Description |
| _0 |
bool |
undefined |
isBlockFinalized
Return whether the block is finalized by block height.
Parameters
| Name |
Type |
Description |
| _blockHeight |
uint256 |
undefined |
Returns
| Name |
Type |
Description |
| _0 |
bool |
undefined |
lastFinalizedBatchID
The latest finalized batch id.
Returns
| Name |
Type |
Description |
| _0 |
bytes32 |
undefined |
layer2ChainId
The chain id of the corresponding layer 2 chain.
Returns
| Name |
Type |
Description |
| _0 |
uint256 |
undefined |
layer2GasLimit
Return the layer 2 block gas limit.
Parameters
| Name |
Type |
Description |
| _0 |
uint256 |
undefined |
Returns
| Name |
Type |
Description |
| _0 |
uint256 |
undefined |
messenger
The address of L1ScrollMessenger.
Returns
| Name |
Type |
Description |
| _0 |
address |
undefined |
operator
The address of operator.
Returns
| Name |
Type |
Description |
| _0 |
address |
undefined |
owner
Returns the address of the current owner.
Returns
| Name |
Type |
Description |
| _0 |
address |
undefined |
renounceOwnership
Leaves the contract without owner. It will not be possible to call onlyOwner functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.
revertBatch
revert a pending batch.
one can only revert unfinalized batches.
Parameters
| Name |
Type |
Description |
| _batchId |
bytes32 |
The identification of the batch. |
transferOwnership
Transfers ownership of the contract to a new account (newOwner). Can only be called by the current owner.
Parameters
| Name |
Type |
Description |
| newOwner |
address |
undefined |
updateMessenger
Update the address of messenger.
This function can only called by contract owner.
Parameters
| Name |
Type |
Description |
| _newMessenger |
address |
The new messenger address to update. |
updateOperator
Update the address of operator.
This function can only called by contract owner.
Parameters
| Name |
Type |
Description |
| _newOperator |
address |
The new operator address to update. |
verifyMessageStateProof
Verify a state proof for message relay.
add more fields.
Parameters
| Name |
Type |
Description |
| _batchIndex |
uint256 |
undefined |
| _blockHeight |
uint256 |
undefined |
Returns
| Name |
Type |
Description |
| _0 |
bool |
undefined |
Events
CommitBatch
Emitted when a new batch is commited.
Parameters
| Name |
Type |
Description |
_batchId indexed |
bytes32 |
undefined |
| _batchHash |
bytes32 |
undefined |
| _batchIndex |
uint256 |
undefined |
| _parentHash |
bytes32 |
undefined |
FinalizeBatch
Emitted when a batch is finalized.
Parameters
| Name |
Type |
Description |
_batchId indexed |
bytes32 |
undefined |
| _batchHash |
bytes32 |
undefined |
| _batchIndex |
uint256 |
undefined |
| _parentHash |
bytes32 |
undefined |
OwnershipTransferred
Parameters
| Name |
Type |
Description |
previousOwner indexed |
address |
undefined |
newOwner indexed |
address |
undefined |
RevertBatch
Emitted when a batch is reverted.
Parameters
| Name |
Type |
Description |
_batchId indexed |
bytes32 |
undefined |
UpdateMesssenger
Emitted when owner updates address of messenger
Parameters
| Name |
Type |
Description |
| _oldMesssenger |
address |
The address of old messenger contract. |
| _newMesssenger |
address |
The address of new messenger contract. |
UpdateOperator
Emitted when owner updates address of operator
Parameters
| Name |
Type |
Description |
| _oldOperator |
address |
The address of old operator. |
| _newOperator |
address |
The address of new operator. |