LayerZero DVN Example (CosmWasm)
This example demonstrates how to build DVN + BVS integration with LayerZero for cross-chain packet verification and broadcasting leveraging on SatLayer’s BVS ecosystem.
For EVM control plane, see evm/examples/layerzero-dvn.
Typically, each DVN is responsible for verifying packets in LayerZero ecosystem, by integrating BVS ecosystem in SatLayer, we can leverage cryptoeconomic incentives to secure the verification process.
Overview
For this example we will build a simple message passing OApp
(SimpleOApp) that sends a message packet from eth mainnet to optimism mainnet using custom DVN (CustomDVN) and BVS (bvs-dvn-contract) integration.
On-chain contracts
CustomDVN
- An EVM contract to be deployed on Source (ETH) and Destination chains (OP) that implements LayerZero DVN interface.
- It will be the entry point to LZ core contracts for sending and receiving packets.
SimpleOApp
- An EVM contract that implements LayerZero OApp interface to send and receive packets cross-chain.
- Uses custom routing logic that sends packets through
CustomDVNfor verification.
bvs-dvn-contract
- A CosmWasm contract that acts as a BVS for the
CustomDVNcontract. - It will broadcast packets received from
CustomDVNto the BVS ecosystem on SatLayer. - The Operators will listen for broadcasted packets and verify them, submitting the payload hash to the BVS contract.
- Through Quorum, the BVS contract will ensure that the packet is verified by a sufficient number of operators before finalizing it.
Off-chain nodes
DVNNode
- An off-chain node that integrates
CustomDVNwithbvs-dvn-contract. - It listens for
PacketSentevents from LZEndpointV2andPacketAssignedevents fromCustomDVNand then broadcast the relevant packets tobvs-dvn-contract. - It also finalizes the payload hash when the quorum of operators has verified the packet.
OperatorNode
- An off-chain node that listens for broadcasted packets from
bvs-dvn-contract. - It verifies the packet (i.e., checks the signature and payload)
- It produces payload hash and submits it to the
bvs-dvn-contractas a proof that it has verified the packet.
Project Structure
examples/dvn
├── src
│ ├── evm # Contains EVM Contracts
│ │ └── contracts
│ │ ├── CustomDVN.sol # Custom DVN contract for LayerZero integration
│ │ └── SimpleOApp.sol # Simple OApp contract to send and receive packets cross-chain
│ ├── bvs-contract # CosmWasm contract acts as BVS for SatLayer integration
│ │ └── ...
│ ├── bvs-dvn-contract.ts # Generated TypeScript bindings for the BVS CosmWasm contract
│ ├── configHelper.ts # Helper function for LZ OApp DVN configuration
│ ├── dvnNode.ts # Off-chain DVN Node that integrates DVN -> BVS
│ ├── lifecycle.test.ts # 👀 Shows the full flow of message passing using DVN + BVS
│ ├── lz.constant.ts # Stores LZ core contracts constants
│ └── operatorNode.ts # Off-chain Operator Node that verifies packets and submits payload hash
├── foundry.toml
├── remappings.txt
└── package.jsonFlow
Shows the flow found in lifecycle.test.ts:
Setup
# Install dependencies
pnpm installBuild
# Compile EVM contracts with Foundry, optimize CosmWasm, and generate TS bindings
pnpm run buildbuild:forge: Compiles Solidity contracts undersrc/evm/contracts.build:cargo: Build the CosmWasm contract undersrc/bvs-contract.build:schema: Generates TypeScript bindings (bvs-dvn-contract.ts) for the CosmWasm contract.
Running the lifecycle test
# Install dependencies
pnpm install
# Build the project
pnpm run build
# Run the lifecycle test
pnpm run testNote
Because this example spans multiple chains, there is a need to be careful with differing chain behaviour.
For instance, in evm chains hex are normally represented with 0x prefix, while in Cosmos chains they are not.