This section describes how asset transfers are enabled by three smart contracts.
The ZKEVM bridge smart contract (ZkEVMBridge.sol) has two main functions:
With these functions, we can bridge assets from one network to another, as well as claim assets received in the destination network.
Deposit
transfers assets layer 2 -> layer 1 or layer 1 -> layer 2. The bridge smart contract SC adds an exit leaf to the layer 2 exit tree, which holds the relevant transfer data.Claim
assets on opposite chain bridge SC.The Global Exit Root Manager SC, implemented as ZkEVMGlobalExitRoot.sol
, serves as the overseer of the Global Exit Tree Root. Its primary responsibilities include updating the Global Exit Tree Root and serving as a storage hub for the historical data of the Global Exit Tree.
This contract has a main function:
updateExitRoot
This separation of logic between the ZKEVM bridge SC and the Global Exit Root Manager SC has been strategically implemented to enhance interoperability, which uses the function updateExitRoot
.This means that the ZKEVM bridge SC, in conjunction with the Global Exit Root Manager SC, can be installed on any network to achieve the same results.
The ZkEVM.sol
smart contract is the consensus algorithm used in X Layer. It is located in L1 for batch verification purposes.
The consensus smart contract (ZkEVM.sol) has two main functions:
sequenceBatchesValidium
verifyBatchesTrustedAggregator
With these functions, layer 2 tx data can be rolled up and verified.
sequenceBatchesValidium
function.verifyBatchesTrustedAggregator
. This proof is ZK-proof and is verified using the Verifier.sol
contract.ZkEVMGlobalExitRoot.sol
to update the Global Exit Root.The following diagram illustrates the interactions among the three bridge-related smart contracts when assets are bridged. It describes the overall process of transferring assets from layer 1 to layer 2 and from layer 2 to layer 1 through contracts.
ZkEVMBridge.sol
uses the Bridge method to append the corresponding exit leaf to the L1 Exit Tree.ZkEVMGlobalExitRoot.sol
for an update of the Global Exit Root.ZkEVM.sol
retrieves the updated Global Exit Root from the Global Exit Root Manager, which is used for syncing with the ZKEVM as the destination network for bridged assets.The transfer from layer 1 to ZKEVM is completed with the Claim
method of the bridge SC, but this time in the ZKEVM side.
Now the reverse process, while focusing only at the L1 smart contracts.
sequenceBatchesValidium
function to sequence batches, which includes, among other transactions, asset transfer information.Verify.sol
calls the VerifyBatches
function and takes batch info as input. As part of the consensus process, but not shown in the above figure, the aggregator produces a validity proof for the sequenced batches. And this proof is automatically verified in this step.ZkEVM.sol
) sends the updated ZKEVM Exit Root to the Global Exit Root Manager, which subsequently updates the Global Exit Root.ZkEVMBridge.sol
) then retrieves the updated Global Exit Root and uses the Claim
function to complete the transfer.The focus in this subsection is on the bridge-related smart contracts used in layer 2, especially in the ZKEVM.
ZkEVMBridge.sol
) in layer 2 is the same smart contract deployed on layer 1.ZkEVMGlobalExitRootL2.sol
. This is a special contract that allows synchronization of L2 Exit Tree Root and the Global Exit Root.Here is the step-by-step process:
ZkEVMBridge.sol
appends an exit leaf with the batch information to the L2 Exit Tree and updates the L2 Exit Tree Root.The circuit for generating ZK-proofs also writes the L2 Exit Tree Root to the mainnet. The ZKEVM bridge SC deployed on L1 can then finalize the transfer by using the Claim
function.