Files
evm/cmd/precompilegen/template-readme.md
2024-01-03 09:44:09 +01:00

2.0 KiB

There are some must-be-done changes waiting in the generated file. Each area requiring you to add your code is marked with CUSTOM CODE to make them easy to find and modify. Additionally there are other files you need to edit to activate your precompile. These areas are highlighted with comments "ADD YOUR PRECOMPILE HERE". For testing take a look at other precompile tests in contract_test.go and config_test.go in other precompile folders. See the tutorial in https://docs.lux.network/subnets/hello-world-precompile-tutorial for more information about precompile development.

General guidelines for precompile development: 1- Set a suitable config key in generated module.go. E.g: "yourPrecompileConfig" 2- Read the comment and set a suitable contract address in generated module.go. E.g: ContractAddress = common.HexToAddress("ASUITABLEHEXADDRESS") 3- It is recommended to only modify code in the highlighted areas marked with "CUSTOM CODE STARTS HERE". Typically, custom codes are required in only those areas. Modifying code outside of these areas should be done with caution and with a deep understanding of how these changes may impact the EVM. 4- Set gas costs in generated contract.go 5- Force import your precompile package in precompile/registry/registry.go 6- Add your config unit tests under generated package config_test.go 7- Add your contract unit tests under generated package contract_test.go 8- Additionally you can add a full-fledged VM test for your precompile under plugin/vm/vm_test.go. See existing precompile tests for examples. 9- Add your solidity interface and test contract to contracts/contracts 10- Write solidity contract tests for your precompile in contracts/contracts/test 11- Write TypeScript DS-Test counterparts for your solidity tests in contracts/test 12- Create your genesis with your precompile enabled in tests/precompile/genesis/ 13- Create e2e test for your solidity test in tests/precompile/solidity/suites.go 14- Run your e2e precompile Solidity tests with './scripts/run_ginkgo.sh`