diff --git a/.github/workflows/lint-tests-release.yml b/.github/workflows/lint-tests-release.yml index 439b346980..b4678527ce 100644 --- a/.github/workflows/lint-tests-release.yml +++ b/.github/workflows/lint-tests-release.yml @@ -14,6 +14,8 @@ jobs: runs-on: ubuntu-18.04 steps: - uses: actions/checkout@v3 + - run: ./scripts/lint_allowed_geth_imports.sh + shell: bash - name: golangci-lint uses: golangci/golangci-lint-action@v2 with: diff --git a/cmd/simulator/metrics/metrics.go b/cmd/simulator/metrics/metrics.go index 70b14460e4..821de7f28e 100644 --- a/cmd/simulator/metrics/metrics.go +++ b/cmd/simulator/metrics/metrics.go @@ -12,7 +12,7 @@ import ( "github.com/ava-labs/subnet-evm/core/types" "github.com/ava-labs/subnet-evm/ethclient" - "github.com/ethereum/go-ethereum/params" + "github.com/ava-labs/subnet-evm/params" ) const ( diff --git a/cmd/simulator/worker/worker.go b/cmd/simulator/worker/worker.go index 4ff8bb62bb..b398ec0988 100644 --- a/cmd/simulator/worker/worker.go +++ b/cmd/simulator/worker/worker.go @@ -15,8 +15,8 @@ import ( "github.com/ava-labs/subnet-evm/cmd/simulator/metrics" "github.com/ava-labs/subnet-evm/core/types" "github.com/ava-labs/subnet-evm/ethclient" + "github.com/ava-labs/subnet-evm/params" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/params" "golang.org/x/sync/errgroup" ) diff --git a/core/state/snapshot/generate_test.go b/core/state/snapshot/generate_test.go index 875341f6b5..fa7e722798 100644 --- a/core/state/snapshot/generate_test.go +++ b/core/state/snapshot/generate_test.go @@ -33,11 +33,11 @@ import ( "testing" "time" + "github.com/ava-labs/subnet-evm/core/rawdb" "github.com/ava-labs/subnet-evm/ethdb" "github.com/ava-labs/subnet-evm/ethdb/memorydb" "github.com/ava-labs/subnet-evm/trie" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/rlp" "golang.org/x/crypto/sha3" diff --git a/core/state_processor_test.go b/core/state_processor_test.go index 42307dc0c1..1c02a6072a 100644 --- a/core/state_processor_test.go +++ b/core/state_processor_test.go @@ -37,9 +37,9 @@ import ( "github.com/ava-labs/subnet-evm/core/vm" "github.com/ava-labs/subnet-evm/params" "github.com/ava-labs/subnet-evm/precompile" + "github.com/ava-labs/subnet-evm/trie" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/trie" "golang.org/x/crypto/sha3" ) diff --git a/core/vm/runtime/runtime_test.go b/core/vm/runtime/runtime_test.go index a2202c085c..f134a1e3e3 100644 --- a/core/vm/runtime/runtime_test.go +++ b/core/vm/runtime/runtime_test.go @@ -34,6 +34,7 @@ import ( "testing" "time" + "github.com/ava-labs/subnet-evm/accounts/abi" "github.com/ava-labs/subnet-evm/consensus" "github.com/ava-labs/subnet-evm/core" "github.com/ava-labs/subnet-evm/core/rawdb" @@ -43,7 +44,6 @@ import ( "github.com/ava-labs/subnet-evm/eth/tracers" "github.com/ava-labs/subnet-evm/eth/tracers/logger" "github.com/ava-labs/subnet-evm/params" - "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/asm" diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index ff5f6b7455..8044373408 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -35,6 +35,7 @@ import ( "time" "github.com/ava-labs/subnet-evm/accounts" + "github.com/ava-labs/subnet-evm/accounts/abi" "github.com/ava-labs/subnet-evm/accounts/keystore" "github.com/ava-labs/subnet-evm/accounts/scwallet" "github.com/ava-labs/subnet-evm/commontype" @@ -47,7 +48,6 @@ import ( "github.com/ava-labs/subnet-evm/rpc" "github.com/ava-labs/subnet-evm/vmerrs" "github.com/davecgh/go-spew/spew" - "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/common/math" diff --git a/scripts/geth-allowed-packages.txt b/scripts/geth-allowed-packages.txt new file mode 100644 index 0000000000..95f53d07b1 --- /dev/null +++ b/scripts/geth-allowed-packages.txt @@ -0,0 +1,15 @@ +"github.com/ethereum/go-ethereum/cmd/utils" +"github.com/ethereum/go-ethereum/common" +"github.com/ethereum/go-ethereum/common/bitutil" +"github.com/ethereum/go-ethereum/common/compiler" +"github.com/ethereum/go-ethereum/common/hexutil" +"github.com/ethereum/go-ethereum/common/math" +"github.com/ethereum/go-ethereum/common/prque" +"github.com/ethereum/go-ethereum/core/asm" +"github.com/ethereum/go-ethereum/crypto" +"github.com/ethereum/go-ethereum/crypto/blake2b" +"github.com/ethereum/go-ethereum/crypto/bls12381" +"github.com/ethereum/go-ethereum/crypto/bn256" +"github.com/ethereum/go-ethereum/event" +"github.com/ethereum/go-ethereum/log" +"github.com/ethereum/go-ethereum/rlp" diff --git a/scripts/lint_allowed_geth_imports.sh b/scripts/lint_allowed_geth_imports.sh new file mode 100755 index 0000000000..ce4e5ab63d --- /dev/null +++ b/scripts/lint_allowed_geth_imports.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +set -o errexit +set -o nounset +set -o pipefail + +extra_imports=$(grep -r --include='*.go' '"github.com/ethereum/go-ethereum/.*"' -o -h | sort -u | comm -23 - ./scripts/geth-allowed-packages.txt) +if [ ! -z "${extra_imports}" ]; then + echo "new go-ethereum imports should be added to ./scripts/geth-allow-list.txt to prevent accidental imports:" + echo "${extra_imports}" + exit 1 +fi + +extra_imports=$(grep -r --include='*.go' '"github.com/ava-labs/coreth/.*"' -o -h || true | sort -u) +if [ ! -z "${extra_imports}" ]; then + echo "subnet-evm should not import packages from coreth:" + echo "${extra_imports}" + exit 1 +fi