forked from ethereum/go-ethereum
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a1d82ee
commit 870b51c
Showing
4 changed files
with
34 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,3 +50,5 @@ profile.cov | |
logs/ | ||
|
||
tests/spec-tests/ | ||
|
||
precompile/out/ |
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,9 @@ | ||
# Writing a Precompile Contract | ||
|
||
1. Create Solidity interface in `contracts/interfaces`, e.g, IExampleContract.sol | ||
|
||
2. Generate bindings with `./gen.sh` | ||
|
||
3. Implement the precompile in Go. The struct should implement the `StatefulPrecompiledContract` interface and methods defined in the Solidity interface. | ||
|
||
See NativeMinter as an example implementation |
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,10 @@ | ||
[profile.default] | ||
fuzz_runs = 1024 | ||
evm_version = 'shanghai' | ||
solc_version = '0.8.24' | ||
cache = false | ||
force = false | ||
optimizer = false | ||
|
||
[profile.ci] | ||
fuzz_runs = 8192 |
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,13 @@ | ||
forge build --extra-output-files bin --extra-output-files abi --root . | ||
|
||
for dir in ./out/*/ | ||
do | ||
NAME=$(basename $dir) | ||
NAME=${NAME%.sol} | ||
NAME_LOWER=$(echo "${NAME:1}" | tr '[:upper:]' '[:lower:]') | ||
abigen --pkg bindings \ | ||
--abi ./out/$NAME.sol/$NAME.abi.json \ | ||
--bin ./out/$NAME.sol/$NAME.bin \ | ||
--out ./bindings/i_${NAME_LOWER}.abigen.go \ | ||
--type ${NAME:1} | ||
done |