Skip to content

Commit

Permalink
geth import allowlist (#243)
Browse files Browse the repository at this point in the history
* geth import allowlist

* attempt 2

* add permission / minimize diff

* fix allowlist: should pass

* add || true

* changes from review comments

* remove rawdb

* remove rawdb

* remove abi and params
  • Loading branch information
darioush authored Sep 1, 2022
1 parent 5bfb71e commit b98d745
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/lint-tests-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion cmd/simulator/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
2 changes: 1 addition & 1 deletion cmd/simulator/worker/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
2 changes: 1 addition & 1 deletion core/state/snapshot/generate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion core/state_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
2 changes: 1 addition & 1 deletion core/vm/runtime/runtime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
15 changes: 15 additions & 0 deletions scripts/geth-allowed-packages.txt
Original file line number Diff line number Diff line change
@@ -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"
19 changes: 19 additions & 0 deletions scripts/lint_allowed_geth_imports.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit b98d745

Please sign in to comment.