Coder Social home page Coder Social logo

hyperlane-interpreter's Introduction

hyperlane-interpreter

Overview

This is intended to be library of routers that is built based on Hyperlane's Router and works to replacing other messaging protocols with Hyperlane protocol. This allows easier migration of your contract and works as follow:

Diagram

For more information on how Hyperlane works please check out: Hyperlane Doc

How To Use

Begin by cloning the repo:

git clone https://github.com/PxGnome/hyperlane-interpreter.git

To Test

To run tests to see how it works you can run

forge test

To Deploy LayerZero Router

Using Hardhat (Recommended)

To deploy using the deployment scripts you can use the hardhat tasks (more info here) and can be done using the command:

npx hardhat ${TASK_NAME} ${PARAMETERS}

Here are the current tasks (be sure to replace your parameters):

  1. lzrouter_deploy ${isMainnet} - you can use this to deploy your LayerZero router, it includes deployment, initialized routers and domain mapping. Set it to be true for mainnet, false for testnet.
  2. lzrouter_enroll ${originRouterAddr} ${destinationNetwork} ${enrollRouterAddr} - for enrolling router after you it has been deployed
  3. lzrouter_sendMessage ${originRouterAddr} ${destinationNetwork} ${enrollRouterAddr} ${message} - for sending a test message on your router to ensure it works

Below are some other tasks to help deployment if there are issues:

  1. lzrouter_init ${lzRouterAddr} - you can use this to initialize LayerZero router if the deployment did not manage to do so
  2. lzrouter_mapping ${lzRouterAddr} ${mappingFor} - you can use this to handle the domain mapping for LayerZero router if the deployment did not manage to do so

To see the code for the task you can head to the tasks folder.

Using Foundry

To deploy using the deployment scripts you will need to set up an .env file just like the .env.example. and use the files in script folder

  • script/01_Deploy_LayerZeroRouter.s.sol -- This handles the deployment and needs to be done step by step since it is written in foundry
  • script/02_Test_LayerZeroRouter.s.sol -- This uses the deployed routers to send some test messages which can be seen on Hyperlane Explorer

To understand how this works please take a look at the script folder in which each deployment is split up one by one by functions.

How It Works

Library is set up using the foundry file structure and it is advised you take a look at these files and edit as you see fit in order to make it suit your needs. The main files you will be interested in are:

LayerZeroRouter.sol

This is the file with the core logic as it is designed based on:

  • Hyperlane's Router -- Inherits from this, so has all the base configuration to make it work on any chain
  • LayerZero's ILayerZeroEndpoint -- Designed to work with the standard necessary and supported LayerZero endpoints.

Note that some of the non-core features on ILayerZeroEndpoint are not supported by Hyperlane.

Also the following custom functions may need attention:

  • setEstGasAmount -- Default gas is set to be 200,000 by default but you can set a higher gas if your computation on the destination chain is more complex

SimulateLzReceiver.sol

This is to simulate the LzReceiver and is used in testing so you can see how the LayerZeroRouter interacts with the lzReceiver accordingly.

Other Files of Note

Some other files of note:

  • environment/hyperlane/addresses.json -- list of all the addresses of the Mailbox, InterchainPaymaster and InterSecurityModule for Hyperlane
  • environment/layerzero/domainId.json -- list of all the domain Ids supported by HyperLane and LayerZero

Update Log

  • 2023 May 27 -- Added hardhat and deploy script using typescript to make it easier to deploy.

  • 2023 May 18 -- Added AxelarRouter and finished basic unit testing but pending live deployment testing, will work on hardhat deployment as well for both set of code. Will be submitting for this bounty as well (link)

  • 2023 May 15 -- Initial deployment and preparation for submission for Hyperlane bounty on LayerZero implementation (link)

hyperlane-interpreter's People

Contributors

pxgnome avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.