diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 2619afb..780d947 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -26,7 +26,7 @@ "version": "latest" }, "ghcr.io/devcontainers/features/node:1": {}, - "ghcr.io/devcontainers/features/go:1": {} + "ghcr.io/devcontainers/features/go:1": {"version": 1.22} }, // Use 'forwardPorts' to make a list of ports inside the container available locally. diff --git a/README.md b/README.md index 56b0cee..e9f03f3 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,15 @@ # 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. +Precompile-EVM is a repository for registering precompiles to Subnet-EVM without forking the Subnet-EVM codebase. Subnet-EVM supports registering external precompiles through the `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. ## Environment Setup To effectively build, run, and test Precompile-EVM, the following is a (non-exhaustive) list of dependencies that you will need: -- Golang -- Node.js +- Golang (1.21 || 1.22) +- Node.js (^20.0) - [AvalancheGo](https://github.com/ava-labs/avalanchego) +- [Avalanche-CLI](https://github.com/ava-labs/avalanche-cli) To get started easily, we provide a Dev Container specification, that can be used using GitHub Codespace or locally using Docker and VS Code. DevContainers are a concept that utilizes containerization (via Docker containers) to create consistent and isolated development environment. We can access this environment through VS code, which allows for the development experience to feel as if you were developing locally.. @@ -28,38 +29,42 @@ In order to run the Dev Container locally: ## Learn about Precompile-EVM -To get a comprehensive introduction to Precompile-EVM, take the Avalanche Academy course on [Customizing the EVM](https://academy.avax.com/course/customize-evm). +To get a comprehensive introduction to Precompile-EVM, take the Avalanche Academy course on [Customizing the EVM](https://academy.avax.com/course/customizing-evm). ## How to use There is an example branch [hello-world-example](https://github.com/ava-labs/precompile-evm/tree/hello-world-example) in this repository. You can check the example branch to see how to register precompiles and test them. -### Generate Precompile Files +### 1. 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. +First, you need to create your precompile contract interface in the `contracts` directory and build the ABI. Then you can generate your precompile as such: +```bash +./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 +### 2. 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`. +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. -### Build +### 3. 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. -### Run +### 4. Run You can run you Precompile-EVM by using the Avalanche CLI. First, create the configuration for your subnet. ```bash -avalanche subnet create mysubnet --custom --vm $AVALANCHEGO_PLUGIN_PATH/srEXiWaHuhNyGwPUi444Tu47ZEDwxTWrbQiuD7FmgSAQ6X7Dy --genesis ./.devcontainer/genesis-example.json +avalanche blockchain create myblockchain --custom --vm $AVALANCHEGO_PLUGIN_PATH/srEXiWaHuhNyGwPUi444Tu47ZEDwxTWrbQiuD7FmgSAQ6X7Dy --genesis ./.devcontainer/genesis-example.json ``` Next, launch the Subnet with your custom VM: ```bash -avalanche subnet deploy mysubnet +avalanche blockchain deploy myblockchain ``` ### Test