LayerZero Explained With Seals
As promised, I try to simplify what happens in the background with LayerZero via drawings of seals. Great explainer for friends, family, and semiaquatic mammals.
Intro
LayerZero is a blockchain primitive (read: very core piece of technology) that allows applications with deployments on different chains to communicate with one another. The core difference is that LayerZero does not require any intermediary blockchains or consensus mechanisms. This effectively makes it a messaging protocol that allows apps to seamlessly communicate across chains, which yes, is a big deal. Existing approaches to this problem either compromise security or are extremely expensive to implement on certain chains.
The first major implementation of LayerZero is the Stargate Finance DEX, an exchange that allows omni-chain native asset swaps. Yes that sounds complicated. Now to the seals.
LayerZero Explained
Two seals from the same seal tribe meet. One seal is on Iceberg A (first chain) and the other on Iceberg B (second chain). They usually share fish, but want to ensure that any request to transfer a fish from A to B is legitimate.
Seal A (first chain) decides he wants to transfer a fish to Seal B. A nearby bridge claims that it can solve this problem effectively.
In DeFi (decentralized fish), seals must use cross-chain bridges to send requests/assets to other chains (in this case the other iceberg). Existing bridge solutions use an intermediate consensus layer, asset conversions, and wrapped assets. For the seals, these are essentially alternate representations of fish that are required to bridge the asset from A to B.
The problem with an intermediate layer is that the seals need to trust the security of the lobster layer. They also need to bear the costs of converting to lobster, then back to fish. This doesn’t always work out well. Billions of dollars in assets have been compromised in cross chain bridge hacks to date.
From the user perspective, this typically isn’t too bad. That said, this method represents a major systemic security risk and limits the scalability of DeFi overall. Lucky for Seal A and B, they stumble upon a new solution.
They see LayerZero floating on a nearby iceberg, perfectly situated between them.
Two extremely helpful seals offer to help them solve their issue with existing bridge solutions. Things get a little complicated here, but stay focused.
These next few sections will break down the communication flow of a standard LayerZero implementation. This implementation typically looks like this and can be explored in depth in their whitepaper:
We’re going to stick with the seals though, don’t worry. Before we jump into the explainer, there are a few things you should know:
Seal A and B basically represent the User Applications above, which interface with LayerZero endpoints on the source and destination chain
An Oracle and Relayer seal will be in play, these two work separately from each other to enhance the security profile of the entire system
The Oracle is the Wizard, the Relayer is the one with the megaphone strapped to his head
This explanation abstracts away some of the details including what happens at the endpoints (communicator, validator, network) but the core premise remains
I reference block IDs as being similar to the time a request happened; this is not the textbook definition, but works well in these diagrams
Here we go.
Seal A makes his request through the LayerZero endpoint. Send 1 fish to Seal B’s chain at block ID 11:00PM. This request gets split out to the Relayer and the Oracle.
The Relayer, which operates off-chain, now has the message and the proof of the original transaction. This is essentially information that proves the request was made and can eventually be matched to a block ID (via complicated math).
The Oracle passes along the block information of the original request and lets him know he should probably look into it.
Seal B can now talk with the Relayer. Seal B provides the block info and the Relayer returns any message and transaction proof that matches that block (math). Now with all the required info available, Seal B can verify that the request is valid and grant 1 fish on his iceberg.
Now you may be wondering, wait wasn’t that just a message? How did the fish actually move across chains/icebergs? Good question. LayerZero is exactly that - a messaging protocol. This fish transaction was made possible via:
The Seals having two endpoints for their collective “application”, one on Chain A and one on Chain B
The implementation of a DEX/app that is able to balance fish supplies across endpoints and ensure that no one runs out
This balancing technology, in the case of LayerZero, is provided by Stargate Finance. Stargate’s delta algorithm ensures that omnichain liquidity remains balanced and available, pictured here:
Simply put, LayerZero handles the communication, the apps (and associated math seals) deal with everything else. The combination allows the seals (users) to unify fish balances across all icebergs securely.
This is a major development for blockchain applications that enables everything from unified DeFi liquidity to NFTs that can live across chains.
Conclusion
You might be able to tell that I’m extremely excited by what LayerZero technology unlocks. It is ground breaking for the iceberg-based seal community. There are tons of interesting details and nuances in their whitepaper, which I definitely encourage you to explore. Action items: