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 |
blocks
Mapping from block hash to block index.
Parameters
| Name |
Type |
Description |
| _0 |
bytes32 |
undefined |
Returns
| Name |
Type |
Description |
| header |
IZKRollup.BlockHeader |
undefined |
| transactionRoot |
bytes32 |
undefined |
| verified |
bool |
undefined |
commitBlock
Parameters
| Name |
Type |
Description |
| _header |
IZKRollup.BlockHeader |
undefined |
| _txn |
IZKRollup.Layer2Transaction[] |
undefined |
finalizeBlockWithProof
finalize commited block in layer 1
will add more parameters if needed.
Parameters
| Name |
Type |
Description |
| _blockHash |
bytes32 |
The block hash of the commited block. |
| _proof |
uint256[] |
The corresponding proof of the commited block. |
| _instances |
uint256[] |
Instance used to verify, generated from block. |
finalizedBlocks
Mapping from block height to finalized block hash.
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.BlockHeader |
undefined |
initialize
Parameters
| Name |
Type |
Description |
| _chainId |
uint256 |
undefined |
lastFinalizedBlockHash
The hash of the latest finalized block.
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.
revertBlock
revert a pending block.
one can only revert unfinalized blocks.
Parameters
| Name |
Type |
Description |
| _blockHash |
bytes32 |
The block hash of the block. |
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 |
| _blockNumber |
uint256 |
undefined |
Returns
| Name |
Type |
Description |
| _0 |
bool |
undefined |
Events
CommitBlock
Parameters
| Name |
Type |
Description |
_blockHash indexed |
bytes32 |
undefined |
_blockHeight indexed |
uint64 |
undefined |
| _parentHash |
bytes32 |
undefined |
FinalizeBlock
Parameters
| Name |
Type |
Description |
_blockHash indexed |
bytes32 |
undefined |
_blockHeight indexed |
uint64 |
undefined |
OwnershipTransferred
Parameters
| Name |
Type |
Description |
previousOwner indexed |
address |
undefined |
newOwner indexed |
address |
undefined |
RevertBlock
Parameters
| Name |
Type |
Description |
_blockHash 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. |