Skip to content

Commit 2485147

Browse files
ceyonurJonathanOppenheimeralarso16
authored
feat: replace deployer allowlist hardhat tests with simulated backend (#1845)
Signed-off-by: Jonathan Oppenheimer <[email protected]> Signed-off-by: Jonathan Oppenheimer <[email protected]> Signed-off-by: Ceyhun Onur <[email protected]> Co-authored-by: Jonathan Oppenheimer <[email protected]> Co-authored-by: Austin Larson <[email protected]>
1 parent 2d775e6 commit 2485147

File tree

18 files changed

+1417
-270
lines changed

18 files changed

+1417
-270
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ jobs:
2222
cache-dependency-path: |
2323
go.sum
2424
tools/go.sum
25+
tools/legacy-golangci-lint.sum
26+
- name: Set up solc
27+
uses: ARR4N/[email protected]
28+
with:
29+
versions: '0.8.30'
2530
- name: Run all lint checks
2631
run: ./scripts/run_task.sh lint-all-ci
2732
- name: Check go.mod and go.sum are up-to-date

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,6 @@ avalanchego/
6464

6565
# Contract compilation artifacts (binary files are not committed)
6666
contracts/artifacts/
67+
68+
# solc downloads from setup-solc GitHub Action
69+
setup-solc_downloads/

Taskfile.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ tasks:
6666
- task: generate-rlp
6767
- task: check-clean-branch
6868

69+
check-generate-bindings:
70+
desc: Checks that generated Go bindings from Solidity contracts in precompile are up-to-date (requires a clean git working tree)
71+
cmds:
72+
- task: generate-bindings
73+
- task: check-clean-branch
74+
6975
check-go-mod-tidy:
7076
desc: Checks that all go.mod and go.sum files are up-to-date (requires a clean git working tree)
7177
cmds:
@@ -96,6 +102,17 @@ tasks:
96102
- cmd: grep -lr -E '^// Code generated by rlpgen\. DO NOT EDIT.\.$' . | xargs -r rm
97103
- cmd: go generate -run rlpgen ./...
98104

105+
generate-bindings:
106+
desc: Generates Go bindings from Solidity contracts in precompile
107+
cmds:
108+
- cmd: |
109+
# Find and remove generated binding files in precompile directories only
110+
find ./precompile -type f -name 'gen_*binding.go' -exec grep -l '^// Code generated - DO NOT EDIT\.$' {} \; | xargs -r rm
111+
- cmd: |
112+
# Generate bindings for precompile packages (contracts/ bindings are handled by setup-contracts separately)
113+
go generate ./precompile/...
114+
115+
99116
install-avalanchego-release:
100117
desc: Download and install AvalancheGo release binary for testing, with fallback to building from source
101118
cmd: ./scripts/install_avalanchego_release.sh # ci.yml
@@ -113,6 +130,7 @@ tasks:
113130
- check-generate-codec
114131
- check-generate-mocks
115132
- check-generate-rlp
133+
- check-generate-bindings
116134

117135
lint-all-ci:
118136
desc: Runs all lint checks one-by-one
@@ -123,6 +141,7 @@ tasks:
123141
- task: check-generate-codec
124142
- task: check-generate-mocks
125143
- task: check-generate-rlp
144+
- task: check-generate-bindings
126145

127146
lint-fix:
128147
desc: Run golangci-lint with auto-fix where possible

contracts/contracts/ExampleDeployerList.sol

Lines changed: 0 additions & 22 deletions
This file was deleted.

contracts/contracts/compile.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44
package contracts
55

66
// Step 1: Compile Solidity contracts to generate ABI and bin files
7-
//go:generate solc-v0.8.30 -o ../artifacts --overwrite --abi --bin --base-path . @openzeppelin/contracts/=../node_modules/@openzeppelin/contracts/ AllowList.sol ERC20NativeMinter.sol ExampleDeployerList.sol ExampleFeeManager.sol ExampleRewardManager.sol ExampleTxAllowList.sol ExampleWarp.sol
7+
//go:generate solc-v0.8.30 -o ../artifacts --overwrite --abi --bin --base-path . @openzeppelin/contracts/=../node_modules/@openzeppelin/contracts/ AllowList.sol ERC20NativeMinter.sol ExampleFeeManager.sol ExampleRewardManager.sol ExampleTxAllowList.sol ExampleWarp.sol
88

99
// Step 2: Generate Go bindings from the compiled artifacts
1010
//go:generate go run github.com/ava-labs/libevm/cmd/abigen --pkg bindings --type AllowList --abi ../artifacts/AllowList.abi --bin ../artifacts/AllowList.bin --out ../bindings/gen_allowlist.go
1111
//go:generate go run github.com/ava-labs/libevm/cmd/abigen --pkg bindings --type ERC20NativeMinter --abi ../artifacts/ERC20NativeMinter.abi --bin ../artifacts/ERC20NativeMinter.bin --out ../bindings/gen_erc20nativeminter.go
12-
//go:generate go run github.com/ava-labs/libevm/cmd/abigen --pkg bindings --type ExampleDeployerList --abi ../artifacts/ExampleDeployerList.abi --bin ../artifacts/ExampleDeployerList.bin --out ../bindings/gen_exampledeployerlist.go
1312
//go:generate go run github.com/ava-labs/libevm/cmd/abigen --pkg bindings --type ExampleFeeManager --abi ../artifacts/ExampleFeeManager.abi --bin ../artifacts/ExampleFeeManager.bin --out ../bindings/gen_examplefeemanager.go
1413
//go:generate go run github.com/ava-labs/libevm/cmd/abigen --pkg bindings --type ExampleRewardManager --abi ../artifacts/ExampleRewardManager.abi --bin ../artifacts/ExampleRewardManager.bin --out ../bindings/gen_examplerewardmanager.go
1514
//go:generate go run github.com/ava-labs/libevm/cmd/abigen --pkg bindings --type ExampleTxAllowList --abi ../artifacts/ExampleTxAllowList.abi --bin ../artifacts/ExampleTxAllowList.bin --out ../bindings/gen_exampletxallowlist.go

contracts/contracts/test/ExampleDeployerListTest.sol

Lines changed: 0 additions & 122 deletions
This file was deleted.

contracts/scripts/deployExampleDeployerList.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.

contracts/test/contract_deployer_allow_list.ts

Lines changed: 0 additions & 101 deletions
This file was deleted.

ethclient/simulated/options.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,10 @@ func WithCallGasLimit(gaslimit uint64) func(nodeConf *node.Config, ethConf *ethc
5151
ethConf.RPCGasCap = gaslimit
5252
}
5353
}
54+
55+
// WithChainConfig configures the simulated backend to use a specific chain configuration.
56+
func WithChainConfig(chainConfig *params.ChainConfig) func(nodeConf *node.Config, ethConf *ethconfig.Config) {
57+
return func(nodeConf *node.Config, ethConf *ethconfig.Config) {
58+
ethConf.Genesis.Config = chainConfig
59+
}
60+
}

precompile/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
artifacts/

0 commit comments

Comments
 (0)