Maybe a LayerZero?

Maybe a LayerZero?

In one of the previous posts, we presented a ChainBridge solution for bridging on EVM (and Substrate) compatible blockchains, which we find as an alternative to the Polymer bridging solution from the IBC and Cosmos realm. This post will stick to the EVM-compatible chains and present a new bridging solution called LayerZero.

What is LayerZero?

The LayerZero is a trustless omnichain interoperability protocol. With a focus not only on bridging multiple chains but also on enabling developers to build seamless inter-chain applications like a cross-chain DEX without trusted custodians or intermediate transactions. The project’s goal is to make the inter-chain applications as easy as possible for the end users, which should also save a lot of your time and clicks!

With what blockchains LayerZero work?

Currently, only EVM is supported, so one can freely interconnect all EVM-compatible blockchains. The project plans to expand also to Cosmos, Solana, Terra, and Substrate — according to the Interfaces list from the guide. And probably, LayerZero will integrate more blockchains in the future.

Is LayerZero trusted?

No, the LayerZero is trustless, which is the key advantage of the LayerZero over the ChainBridge. The trustlessness of the LayerZero is based on the assumption that the set of Oracles and Relayers, key off-chain actors of the protocol, are independent of each other. Meaning that if there is no collusion between Oracles and Relayers, then the trustlessness is given by the fact of their separation.

How does LayerZero work?

  1. A user interacts with a Source Bridge Contract or any user application that uses the bridging library.
  2. The Source Bridge Contract invokes the Communicator Smart Contract with a description of a transaction.
  3. The Communicator constructs a LayerZero packet based on the data provided by the Source Bridge Contract. Then the packet is relayed to the Validator Smart Contract.
  4. The Validator informs the Network Smart Contract that the block header for the current block on Blockchain A needs to be sent to Blockchain B.
  5. The Validator forwards the packet to the Relayer, which informs the Relayer that a transaction proof must be prefetched and relayed to Blockchain B. The Relayer stores the packet. This happens at the same time as step 4.
  6. The Network notifies the Oracle to fetch the block header for the current block on Blockchain A and send it to the destination blockchain.
  7. The Oracle reads the block header from Blockchain A, which includes the transaction in transit.
  8. The Relayer reads the transaction proof from Blockchain A and stores it off-chain.
  9. The Oracle, independently from the Relayer, confirms that the block associated with the previously delivered block header is indeed committed on Blockchain A. About which, the Oracle informs the Network on Blockchain B.
  10. The Network forwards this block header confirmation to the Validator.
  11. The Validator relays the block header confirmation to the Relayer.
  12. The Relayer receives the confirmation and replies to the Relayer with the transaction, its packet (from step 5), and its proof (from step 8) for all packets that match the block header confirmation.
  13. The Validator receives and validates the transaction data received from the Relayer and compares them with the block header information stored by the Network and previously delivered by the Oracle (in step 9). If everything is valid, then the packet is sent to the Communicator (on Blockchain B).
  14. The Communicator relays the packet to the Destination Bridge Contract.
  15. The Destination Bridge Contract parses the packet and executes its logic which settles the cross-chain transaction.

Uff… That is one of the most complex designs we have ever described in this series! Nevertheless, we hope that you have enjoyed it. We also wish that we have been able to give enough details to understand the general design of the LayerZero, and still be able to make the reading experience digestible. Till the next one!

Read more