-
Notifications
You must be signed in to change notification settings - Fork 238
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* nit improvements * move comments to README * Update cmd/precompilegen/template-readme.md
- Loading branch information
Showing
6 changed files
with
62 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
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.avax.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 contract-examples/contracts | ||
10- Write solidity tests for your precompile in contract-examples/test | ||
11- Create your genesis with your precompile enabled in tests/e2e/genesis/ | ||
12- Create e2e test for your solidity test in tests/e2e/solidity/suites.go | ||
13- Run your e2e precompile Solidity tests with 'E2E=true ./scripts/run.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters