Git Product home page Git Product logo

my-precompile-evm2's Introduction

Precompile-EVM

Precompile-EVM is a repository for registering precompiles to Subnet-EVM without forking the Subnet-EVM codebase. Subnet-EVM supports registering external precompiles through precompile/modules package. By importing Subnet-EVM as a library, you can register your own precompiles to Subnet-EVM and build it together with Subnet-EVM.

How to use

There is an example branch hello-world-example in this repository. You can check the example branch to see how to register precompiles and test them.

Generate Precompile Files

First, you need to create your precompile contract interface in the contracts directory and build the ABI. Then you can generate your precompile files with ./scripts/generate_precompile.sh --abi {abiPath} --out {outPath}. This script installs the precompilegen tool from Subnet-EVM and runs it to generate your precompile.

Register Precompile

In plugin/main.go Subnet-EVM is already imported and ready to be Run from the main package. All you need to do is explicitly register your precompiles to Subnet-EVM in plugin/main.go and build it together with Subnet-EVM. Precompiles generated by precompilegen tool have a self-registering mechanism in their module.go/init() function. All you need to do is to force-import your precompile packprecompile package in plugin/main.go.

Build

You can build your precompile and Subnet-EVM with ./scripts/build.sh. This script builds Subnet-EVM, and your precompile together and generates a binary file. The binary file is compatible with AvalancheGo plugins.

Test

You can create contract tests in contracts/test with the Hardhat test framework. These can be run by adding ginkgko test cases in tests/precompile/solidity/suites.go and a suitable genesis file in tests/precompile/genesis. You can install AvalancheGo binaries with ./scripts/install_avalanchego_release.sh then run the tests with ./scripts/run_ginkgo.sh

Changing Versions

In order to upgrade the Subnet-EVM version, you need to change the version in go.mod and scripts/versions.sh. You can also change the AvalancheGo version through scripts/versions.sh as well. Then you can run ./scripts/build.sh to build the plugin with the new version.

AvalancheGo Compatibility

[v0.1.0-v0.1.1] [email protected] (Protocol Version: 26)
[v0.1.2] [email protected] (Protocol Version: 27)

my-precompile-evm2's People

Contributors

martineckardt 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.