THE BLOG
Published on

Understanding LayerZero V1 - An Ongoing Exploration of Cross-Chain Communication

Note: This research was done for LayerZero V1, currently there is a new version of LayerZero (V2) which is not covered in this article.

Introduction

At the time of writing this article, the blockchain ecosystem resembles the Wild West. Blockchain networks are popping up left and right, from new L1s to L2s, app-chains — you name it, and someone is probably working on it. One thing is sure: for the time being, we need a reliable and secure way of transferring arbitrary data from one chain to another.

A few months ago, I came accross an article stating that LayerZero just passed 50M cross-chain messages just 3 months after they raised 120M from 33 backers. All this data underscores the importance of cross-chain communication in the current landscape.

But with so many bridging protocols available, what makes LayerZero stand out? In this blog, I will share everything I've learned while researching LayerZero.

This blog post is the first in a series where I will attempt to understand how different blockchain bridging protocols work. By clicking on the Blockchain Bridging tag, you can view other posts on the same topic.

The Challenge: Trustless Valid Delivery

For any cross-chain protocol, the main goal is to achieve something called Trustless Valid Delivery. This is essential for these protocols to work properly.

Trustless Valid Delivery means two things:

  1. Trustless: This means the process doesn’t need to depend on trusting any single person or group. In the blockchain world, this translates to the system being decentralized. There's no single point where someone can control or mess up the data being transferred.
  2. Valid Delivery: It’s not just about sending data from one place to another. It's crucial that the data reaches its destination without being changed and is correctly used on the blockchain where it arrives. This requires ways to check that what's sent is exactly what's received and used.

Trustless Valid Delivery is really important. In blockchain, where safety and not relying on central control are key, making sure data can move between chains safely and without needing a central authority is crucial for strong and dependable cross-chain protocols.

LayerZero

LayerZero is an omnichain interoperability protocol designed for lightweight message passing across chains. LayerZero provides authentic and guaranteed message delivery with configurable trustlessness.

LayerZero is not a blockchain; it is a protocol. Much like how HTTPS facilitates secure data packet transfers between servers on the internet, LayerZero aims to provide a straightforward method for connecting two blockchain networks. This enables the seamless transmission of arbitrary data between them. In essence, LayerZero can be utilized to link both EVM chains and EVM with non-EVM chains.

cross-chain

The next subsection provides just an overview of LayerZero. For a complete understanding of the full protocol, I highly recommend going through the LayerZero whitepaper. It's a really great read and offers in-depth insights into how everything works. You can find the whitepaper

Overview

The main part of LayerZero is the LayerZero Endpoint, which consists of smart contracts on each blockchain in the network. These contracts are responsible for sending, verifying, and receiving messages. The endpoints have been set up on various mainnets, enabling them to communicate with different blockchains.

The way LayerZero works is that a User Application (UA) on one blockchain sends a message to a UA on another blockchain through these endpoints. The endpoints ensure that the messages are not just sent but are also correctly received and understood on the other side.

To make sure the message transfer is both secure and decentralized, LayerZero uses Oracles and Relayers. Oracles are there to provide reliable, up-to-date information from outside the blockchain. Relayers are responsible for moving the messages between blockchains. They check that the message sent is exactly the same as the one received, keeping the transaction safe and trustworthy.

Visualizing the Transaction Flow

After reading the LayerZero whitepaper, I decided to create my own illustration of the transaction flow in Excalidraw. This visual representation is based on the explanations in the whitepaper and is designed to help clarify how transactions move through the LayerZero protocol.

protocol

Examining the Independence of Oracle and Relayer in LayerZero

While reading the whitepaper, one aspect that particularly caught my attention was the security concern related to the independence of the Oracle and Relayer in the LayerZero protocol. The whitepaper explicitly states:

To ensure valid delivery, the only requirement is that for any given message sent using the LayerZero protocol, the Oracle and Relayer must be independent of each other.

This implies that the protocol itself doesn't guarantee that these entities are always separate, which is a critical point for ensuring the security and trustlessness of the system.

Furthermore, the whitepaper points out a scenario that amplifies this concern:

The block header provided by the Oracle and the transaction proof provided by the Relayer are both invalid, but still match.

Interestingly, I'm not the only one who noticed this potential issue. The team at L2Beat has delved into this topic extensively in their article. They provide a thorough examination of how the interdependence of the Oracle and Relayer could be circumvented, posing a risk to the protocol's integrity.

This article from L2Beat highlights the importance of independent Oracles and Relayers in maintaining the security framework of LayerZero. It’s a crucial read for anyone looking to understand the potential vulnerabilities and the necessary measures to mitigate them.

The Strengths of LayerZero's Design

On the positive side, I was particularly impressed by its flexibility, especially how it allows individuals to create and run their own Relayer and Oracle implementations. This feature really stood out to me as it emphasizes a decentralized approach, which is at the core of blockchain technology. For anyone who's curious or wants to experiment, LayerZero provides detailed guidelines for custom setups of a Relayer and an Oracle in their documentation.

Another aspect that caught my attention is the diversity of Oracles supported by LayerZero. Currently, the protocol works with:

  1. Google Cloud Oracle (default)
  2. Chainlink Oracle
  3. ZklightClient
  4. TSS Oracle

Each Oracle brings its unique strength to the table, enhancing the protocol's capability. I see this as a strategic move that not only boosts LayerZero's functionality but also its reliability and enable great partnerships.

Furthermore, the concept of the LayerZero Endpoint makes sense. Its presence on each supported chain means any blockchain with this Endpoint can interact with others in the network. This approach simplifies adding new blockchains, enhancing the network effect. I find this particularly advantageous as it means more networks can join easily, potentially leading to greater user adoption. The easier it is to connect different blockchains, the more beneficial the protocol is for everyone involved.

Conclusion

As I wrap up this exploration of LayerZero, I want to share the resources that were instrumental in deepening my understanding of this protocol. These materials provided a mix of technical details, security insights, and practical examples that helped shape my perspective.

Reading:

  1. The starting point was the [Official LayerZero Documentation](Official Doc: https://layerzero.gitbook.io/docs/), which laid the foundation.
  2. For a summarized take on the whitepaper, this Medium Article was quite great.
  3. The in-depth LayerZero Whitepaper itself offered comprehensive insights.
  4. Security aspects were covered in this Medium Article
  5. And for another take i looked into this Medium Article

Watching:

  1. This QuickNode Explanation on YouTube provided a great visual aid.

Code:

  1. Diving into the LayerZero Official GitHub Repository was particularly helpful for understanding the technical implementation.
  2. And the Official Solidity Examples gave me some practical coding insights.

Each of these resources played a part in shaping my understanding of LayerZero, from its basic functioning to its more intricate security considerations and practical applications.

Happy coding!