Skip to content

Latest commit

 

History

History
110 lines (75 loc) · 5.16 KB

README.md

File metadata and controls

110 lines (75 loc) · 5.16 KB

LayerKit - Local Roll-up LayerZero Testing Environment

Overview

This project provides a simple and efficient way to deploy and test LayerZero across Ethereum and Optimism roll-up chains in a local environment. Instead of relying on just simulation frameworks like Foundry, this setup deploys real Ethereum and Optimism chains, allowing you to test in a more realistic blockchain environment.

With just one command, you'll be able to spin up LayerZero's infrastructure in under 10 minutes, including the deployment of LayerZero Endpoints, Message Libraries (ULN302), Executor, PriceFeed, Worker, and DVN across both chains. You’ll also get Blockscout explorers for each chain, allowing you to visually inspect and interact with the deployed contracts.

The system is designed to offer high flexibility, allowing you to customize components like the UltraLightNode (ULN) and DVN (Default Validator Node) while still being simple enough to get up and running quickly.

Features

  • Real Blockchain Networks: Deploys actual Ethereum and Optimism chains locally for testing, allowing for real-world simulation.
  • LayerZero Protocol Components: Automatically deploys LayerZero components like Endpoints, MessageLib (ULN302), Executor, DVN, PriceFeed, and Worker contracts.
  • Cross-Chain Messaging: Establishes a connection between the Ethereum and Optimism chains, enabling cross-chain communication.
  • Customizable ULN and DVN: Offers the flexibility to easily customize and integrate your own UltraLightNode or DVN implementations.
  • Blockscout Integration: Provides Blockscout explorers for each chain, enabling you to monitor transactions, smart contracts, and block data.
  • Easy Setup: Requires just one command to deploy the entire system within 10 minutes.

Quickstart

  1. Install Docker & start the Docker Daemon if you haven't done so already

  2. Install the Kurtosis CLI, or upgrade it to the latest version if it's already installed

  3. Run the package with default configurations from the command line:

    kurtosis run --enclave my-testnet github.com/tiljrd/LayerKit

Within minutes, the following components will be deployed:

  1. Ethereum Chain (with Blockscout)
  2. Optimism Chain (with Blockscout)
  3. LayerZero Endpoints on both chains
  4. MessageLib (ULN302) on both chains
  5. Executor contracts
  6. PriceFeed contracts
  7. Worker contracts
  8. DVN (Decentralised Validator Network)

Management

The Kurtosis CLI can be used to inspect and interact with the enclave. An enclave represents a logical group of an Ethereum and Optimism, connected by LayerZero.

For example, if you need shell access, simply run:

kurtosis service shell my-testnet $SERVICE_NAME

And if you need the logs for a service, simply run:

kurtosis service logs my-testnet $SERVICE_NAME

To stop an enclave run:

kurtosis enclave stop $THE_ENCLAVE_NAME

To clear the resources, you can remove an enclave:

kurtosis enclave rm $THE_ENCLAVE_NAME

You can also pass the -f flag to stop an enclave and remove resources in one command.

An easy way to clean all unused resources and shut down all networks:

kurtosis clean -a

Check out the full list of CLI commands here

Debugging

To grab any files generated by the package, simply run:

kurtosis files download my-testnet $FILE_NAME $OUTPUT_DIRECTORY

You can use these explorers to interact with the deployed contracts and inspect blockchain data.

How It Works

Local Ethereum and Optimism Chains

The setup includes fully functional Ethereum and Optimism chains, allowing you to test LayerZero's cross-chain messaging in a real blockchain environment. Unlike Foundry's simulated environment, this local setup mimics production networks, giving you a better understanding of how your contracts will behave in real-world conditions.

LayerZero Protocol Deployment

The following LayerZero components are deployed on both the Ethereum and Optimism chains:

  • Endpoints: Responsible for sending and receiving cross-chain messages.
  • MessageLib (ULN302): Provides the logic for message validation and relaying.
  • Executor: Handles the execution of cross-chain messages.
  • PriceFeed: Used for price conversions and gas calculations.
  • Worker: Manages the validation of messages and interacts with the DVN.
  • DVN (Default Validator Node): Validates cross-chain messages and ensures message integrity.

Cross-Chain Connection

After deploying the LayerZero contracts, the system establishes a connection between the two chains using the deployed endpoints. This connection allows for seamless cross-chain messaging, making it ideal for testing protocols and decentralized applications that need to interact with multiple blockchains.