diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 175749a01d0..befce3d9194 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -114,3 +114,6 @@ jobs: - name: Test erigon-db run: cd erigon-db && make test + + - name: Test p2p + run: cd p2p && make test diff --git a/.golangci.yml b/.golangci.yml index 17078b21676..b6b16bc0240 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -137,10 +137,6 @@ linters: - gocritic - gosec path: metrics/sample\.go - - linters: - - gocritic - - gosec - path: p2p/simulations - linters: - gocritic - gosec diff --git a/Dockerfile b/Dockerfile index 08cb17ee23e..fd312a45d09 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,6 +10,8 @@ ADD erigon-lib/go.mod erigon-lib/go.mod ADD erigon-lib/go.sum erigon-lib/go.sum ADD erigon-db/go.mod erigon-db/go.mod ADD erigon-db/go.sum erigon-db/go.sum +ADD p2p/go.mod p2p/go.mod +ADD p2p/go.sum p2p/go.sum RUN go mod download ADD . . @@ -32,6 +34,8 @@ ADD erigon-lib/go.mod erigon-lib/go.mod ADD erigon-lib/go.sum erigon-lib/go.sum ADD erigon-db/go.mod erigon-db/go.mod ADD erigon-db/go.sum erigon-db/go.sum +ADD p2p/go.mod p2p/go.mod +ADD p2p/go.sum p2p/go.sum RUN mkdir -p /app/build/bin diff --git a/Makefile b/Makefile index cfe13c9fa88..2d869971d2a 100644 --- a/Makefile +++ b/Makefile @@ -180,15 +180,21 @@ test-erigon-db: test-erigon-db-all: @cd erigon-db && $(MAKE) test-all +test-p2: + @cd p2p && $(MAKE) test + +test-p2p-all: + @cd p2p && $(MAKE) test-all + test-erigon-ext: @cd tests/erigon-ext-test && ./test.sh $(GIT_COMMIT) ## test: run short tests with a 10m timeout -test: test-erigon-lib test-erigon-db +test: test-erigon-lib test-erigon-db test-p2 $(GOTEST) -short --timeout 10m -coverprofile=coverage-test.out ## test-all: run all tests with a 1h timeout -test-all: test-erigon-lib-all test-erigon-db-all +test-all: test-erigon-lib-all test-erigon-db-all test-p2p-all $(GOTEST) --timeout 60m -coverprofile=coverage-test-all.out -race ## test-hive run the hive tests locally off nektos/act workflows simulator @@ -297,6 +303,7 @@ lint: @./erigon-lib/tools/golangci_lint.sh @./erigon-lib/tools/mod_tidy_check.sh @cd erigon-db && ./../erigon-lib/tools/mod_tidy_check.sh + @cd p2p && ./../erigon-lib/tools/mod_tidy_check.sh ## clean: cleans the go cache, build dir, libmdbx db dir clean: diff --git a/cl/beacon/beaconevents/operation_feed.go b/cl/beacon/beaconevents/operation_feed.go index 645fb993875..d096064b664 100644 --- a/cl/beacon/beaconevents/operation_feed.go +++ b/cl/beacon/beaconevents/operation_feed.go @@ -1,6 +1,6 @@ package beaconevents -import ethevent "github.com/erigontech/erigon/event" +import ethevent "github.com/erigontech/erigon-p2p/event" type operationFeed struct { feed *ethevent.Feed diff --git a/cl/beacon/beaconevents/state_feed.go b/cl/beacon/beaconevents/state_feed.go index 7831feb9cb0..db09df1a298 100644 --- a/cl/beacon/beaconevents/state_feed.go +++ b/cl/beacon/beaconevents/state_feed.go @@ -1,7 +1,7 @@ package beaconevents import ( - ethevent "github.com/erigontech/erigon/event" + ethevent "github.com/erigontech/erigon-p2p/event" ) type stateFeed struct { diff --git a/cl/sentinel/discovery.go b/cl/sentinel/discovery.go index 53a840eb08b..1865509c401 100644 --- a/cl/sentinel/discovery.go +++ b/cl/sentinel/discovery.go @@ -27,9 +27,9 @@ import ( "github.com/prysmaticlabs/go-bitfield" "github.com/erigontech/erigon-lib/log/v3" + "github.com/erigontech/erigon-p2p/enode" + "github.com/erigontech/erigon-p2p/enr" "github.com/erigontech/erigon/cl/clparams" - "github.com/erigontech/erigon/p2p/enode" - "github.com/erigontech/erigon/p2p/enr" "golang.org/x/sync/semaphore" ) diff --git a/cl/sentinel/handlers/handlers.go b/cl/sentinel/handlers/handlers.go index 121bbe9674a..7f169d05348 100644 --- a/cl/sentinel/handlers/handlers.go +++ b/cl/sentinel/handlers/handlers.go @@ -24,6 +24,7 @@ import ( "time" "github.com/erigontech/erigon-lib/kv" + "github.com/erigontech/erigon-p2p/enode" "github.com/erigontech/erigon/cl/persistence/blob_storage" "github.com/erigontech/erigon/cl/phase1/forkchoice" "github.com/erigontech/erigon/cl/sentinel/communication" @@ -31,7 +32,6 @@ import ( "github.com/erigontech/erigon/cl/sentinel/peers" "github.com/erigontech/erigon/cl/utils" "github.com/erigontech/erigon/cl/utils/eth_clock" - "github.com/erigontech/erigon/p2p/enode" "github.com/erigontech/erigon/turbo/snapshotsync/freezeblocks" "github.com/libp2p/go-libp2p/core/host" diff --git a/cl/sentinel/handlers/heartbeats.go b/cl/sentinel/handlers/heartbeats.go index 4b3a24b7db5..6c2be0b6b27 100644 --- a/cl/sentinel/handlers/heartbeats.go +++ b/cl/sentinel/handlers/heartbeats.go @@ -20,10 +20,10 @@ import ( "github.com/libp2p/go-libp2p/core/network" "github.com/erigontech/erigon-lib/log/v3" + "github.com/erigontech/erigon-p2p/enr" "github.com/erigontech/erigon/cl/clparams" "github.com/erigontech/erigon/cl/cltypes" "github.com/erigontech/erigon/cl/sentinel/communication/ssz_snappy" - "github.com/erigontech/erigon/p2p/enr" ) // Type safe handlers which all have access to the original stream & decompressed data. diff --git a/cl/sentinel/handlers/heartbeats_test.go b/cl/sentinel/handlers/heartbeats_test.go index 85ea5f3c7ff..1bdfba78086 100644 --- a/cl/sentinel/handlers/heartbeats_test.go +++ b/cl/sentinel/handlers/heartbeats_test.go @@ -31,6 +31,8 @@ import ( "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/crypto" "github.com/erigontech/erigon-lib/log/v3" + "github.com/erigontech/erigon-p2p/enode" + "github.com/erigontech/erigon-p2p/enr" "github.com/erigontech/erigon/cl/clparams" "github.com/erigontech/erigon/cl/cltypes" "github.com/erigontech/erigon/cl/phase1/forkchoice/mock_services" @@ -38,8 +40,6 @@ import ( "github.com/erigontech/erigon/cl/sentinel/communication/ssz_snappy" "github.com/erigontech/erigon/cl/sentinel/handshake" "github.com/erigontech/erigon/cl/sentinel/peers" - "github.com/erigontech/erigon/p2p/enode" - "github.com/erigontech/erigon/p2p/enr" ) var ( diff --git a/cl/sentinel/sentinel.go b/cl/sentinel/sentinel.go index 48cd9400186..ea726d4a5d0 100644 --- a/cl/sentinel/sentinel.go +++ b/cl/sentinel/sentinel.go @@ -43,6 +43,9 @@ import ( sentinelrpc "github.com/erigontech/erigon-lib/gointerfaces/sentinelproto" "github.com/erigontech/erigon-lib/kv" "github.com/erigontech/erigon-lib/log/v3" + "github.com/erigontech/erigon-p2p/discover" + "github.com/erigontech/erigon-p2p/enode" + "github.com/erigontech/erigon-p2p/enr" "github.com/erigontech/erigon/cl/cltypes" "github.com/erigontech/erigon/cl/monitor" "github.com/erigontech/erigon/cl/persistence/blob_storage" @@ -52,9 +55,6 @@ import ( "github.com/erigontech/erigon/cl/sentinel/httpreqresp" "github.com/erigontech/erigon/cl/sentinel/peers" "github.com/erigontech/erigon/cl/utils/eth_clock" - "github.com/erigontech/erigon/p2p/discover" - "github.com/erigontech/erigon/p2p/enode" - "github.com/erigontech/erigon/p2p/enr" "github.com/erigontech/erigon/turbo/snapshotsync/freezeblocks" ) diff --git a/cl/sentinel/utils.go b/cl/sentinel/utils.go index 7c04e988542..b6c0a48d067 100644 --- a/cl/sentinel/utils.go +++ b/cl/sentinel/utils.go @@ -33,9 +33,9 @@ import ( "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/log/v3" + "github.com/erigontech/erigon-p2p/enode" + "github.com/erigontech/erigon-p2p/enr" "github.com/erigontech/erigon/cl/gossip" - "github.com/erigontech/erigon/p2p/enode" - "github.com/erigontech/erigon/p2p/enr" ) func convertToInterfacePubkey(pubkey *ecdsa.PublicKey) (crypto.PubKey, error) { diff --git a/cmd/bootnode/main.go b/cmd/bootnode/main.go index 2bc08c2b34b..b8c62fc4b55 100644 --- a/cmd/bootnode/main.go +++ b/cmd/bootnode/main.go @@ -29,11 +29,11 @@ import ( "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/crypto" + "github.com/erigontech/erigon-p2p/discover" + "github.com/erigontech/erigon-p2p/enode" + "github.com/erigontech/erigon-p2p/nat" + "github.com/erigontech/erigon-p2p/netutil" "github.com/erigontech/erigon/cmd/utils" - "github.com/erigontech/erigon/p2p/discover" - "github.com/erigontech/erigon/p2p/enode" - "github.com/erigontech/erigon/p2p/nat" - "github.com/erigontech/erigon/p2p/netutil" "github.com/erigontech/erigon/turbo/logging" ) diff --git a/cmd/devnet/args/node_args.go b/cmd/devnet/args/node_args.go index 05ba01ad0f8..cedc3e2b6dd 100644 --- a/cmd/devnet/args/node_args.go +++ b/cmd/devnet/args/node_args.go @@ -27,9 +27,9 @@ import ( "github.com/erigontech/erigon-lib/chain/networkname" "github.com/erigontech/erigon-lib/crypto" + "github.com/erigontech/erigon-p2p/enode" "github.com/erigontech/erigon/cmd/devnet/accounts" "github.com/erigontech/erigon/core" - "github.com/erigontech/erigon/p2p/enode" "github.com/erigontech/erigon/params" "github.com/erigontech/erigon/rpc/requests" ) diff --git a/cmd/devnet/contracts/gen_childreceiver.go b/cmd/devnet/contracts/gen_childreceiver.go index 13ac8ae5a24..1340766ab1c 100644 --- a/cmd/devnet/contracts/gen_childreceiver.go +++ b/cmd/devnet/contracts/gen_childreceiver.go @@ -13,7 +13,7 @@ import ( "github.com/erigontech/erigon-lib/abi" "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/types" - "github.com/erigontech/erigon/event" + "github.com/erigontech/erigon-p2p/event" "github.com/erigontech/erigon/execution/abi/bind" ) diff --git a/cmd/devnet/contracts/gen_childsender.go b/cmd/devnet/contracts/gen_childsender.go index cd28987ff33..c111b957f16 100644 --- a/cmd/devnet/contracts/gen_childsender.go +++ b/cmd/devnet/contracts/gen_childsender.go @@ -13,7 +13,7 @@ import ( "github.com/erigontech/erigon-lib/abi" "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/types" - "github.com/erigontech/erigon/event" + "github.com/erigontech/erigon-p2p/event" "github.com/erigontech/erigon/execution/abi/bind" ) diff --git a/cmd/devnet/contracts/gen_faucet.go b/cmd/devnet/contracts/gen_faucet.go index 385b19fbf01..5b191591915 100644 --- a/cmd/devnet/contracts/gen_faucet.go +++ b/cmd/devnet/contracts/gen_faucet.go @@ -13,7 +13,7 @@ import ( "github.com/erigontech/erigon-lib/abi" "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/types" - "github.com/erigontech/erigon/event" + "github.com/erigontech/erigon-p2p/event" "github.com/erigontech/erigon/execution/abi/bind" ) diff --git a/cmd/devnet/contracts/gen_rootreceiver.go b/cmd/devnet/contracts/gen_rootreceiver.go index 205aee36a16..f91f08e6a97 100644 --- a/cmd/devnet/contracts/gen_rootreceiver.go +++ b/cmd/devnet/contracts/gen_rootreceiver.go @@ -13,7 +13,7 @@ import ( "github.com/erigontech/erigon-lib/abi" "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/types" - "github.com/erigontech/erigon/event" + "github.com/erigontech/erigon-p2p/event" "github.com/erigontech/erigon/execution/abi/bind" ) diff --git a/cmd/devnet/contracts/gen_rootsender.go b/cmd/devnet/contracts/gen_rootsender.go index ddceb1b8b89..2bfdf016500 100644 --- a/cmd/devnet/contracts/gen_rootsender.go +++ b/cmd/devnet/contracts/gen_rootsender.go @@ -13,7 +13,7 @@ import ( "github.com/erigontech/erigon-lib/abi" "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/types" - "github.com/erigontech/erigon/event" + "github.com/erigontech/erigon-p2p/event" "github.com/erigontech/erigon/execution/abi/bind" ) diff --git a/cmd/devnet/contracts/gen_subscription.go b/cmd/devnet/contracts/gen_subscription.go index 02f0e605d82..a434bcb2508 100644 --- a/cmd/devnet/contracts/gen_subscription.go +++ b/cmd/devnet/contracts/gen_subscription.go @@ -11,7 +11,7 @@ import ( "github.com/erigontech/erigon-lib/abi" "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/types" - "github.com/erigontech/erigon/event" + "github.com/erigontech/erigon-p2p/event" "github.com/erigontech/erigon/execution/abi/bind" ) diff --git a/cmd/devnet/contracts/gen_testrootchain.go b/cmd/devnet/contracts/gen_testrootchain.go index d0634c5f382..e14930b400c 100644 --- a/cmd/devnet/contracts/gen_testrootchain.go +++ b/cmd/devnet/contracts/gen_testrootchain.go @@ -13,7 +13,7 @@ import ( "github.com/erigontech/erigon-lib/abi" "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/types" - "github.com/erigontech/erigon/event" + "github.com/erigontech/erigon-p2p/event" "github.com/erigontech/erigon/execution/abi/bind" ) diff --git a/cmd/devnet/contracts/gen_teststatesender.go b/cmd/devnet/contracts/gen_teststatesender.go index b5a4d7ac57e..4a779069e7d 100644 --- a/cmd/devnet/contracts/gen_teststatesender.go +++ b/cmd/devnet/contracts/gen_teststatesender.go @@ -13,7 +13,7 @@ import ( "github.com/erigontech/erigon-lib/abi" "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/types" - "github.com/erigontech/erigon/event" + "github.com/erigontech/erigon-p2p/event" "github.com/erigontech/erigon/execution/abi/bind" ) diff --git a/cmd/downloader/downloadernat/nat.go b/cmd/downloader/downloadernat/nat.go index 7a6c715168d..0ab6ecd1bcb 100644 --- a/cmd/downloader/downloadernat/nat.go +++ b/cmd/downloader/downloadernat/nat.go @@ -20,7 +20,7 @@ import ( "github.com/anacrolix/torrent" "github.com/erigontech/erigon-lib/log/v3" - "github.com/erigontech/erigon/p2p/nat" + "github.com/erigontech/erigon-p2p/nat" ) // DoNat can mutate `cfg` parameter diff --git a/cmd/downloader/main.go b/cmd/downloader/main.go index 34ad133123d..09fe252a4b2 100644 --- a/cmd/downloader/main.go +++ b/cmd/downloader/main.go @@ -29,10 +29,6 @@ import ( "strings" "time" - "github.com/erigontech/erigon-lib/common/dbg" - _ "github.com/erigontech/erigon/core/snaptype" //hack - _ "github.com/erigontech/erigon/polygon/heimdall" //hack - "github.com/anacrolix/torrent/metainfo" "github.com/c2h5oh/datasize" grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware" @@ -49,7 +45,9 @@ import ( "github.com/erigontech/erigon-lib/chain/snapcfg" "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/common/datadir" + "github.com/erigontech/erigon-lib/common/dbg" "github.com/erigontech/erigon-lib/common/dir" + "github.com/erigontech/erigon-lib/common/paths" "github.com/erigontech/erigon-lib/downloader" "github.com/erigontech/erigon-lib/downloader/downloadercfg" "github.com/erigontech/erigon-lib/downloader/downloadergrpc" @@ -57,15 +55,16 @@ import ( "github.com/erigontech/erigon-lib/kv" "github.com/erigontech/erigon-lib/kv/mdbx" "github.com/erigontech/erigon-lib/log/v3" - - "github.com/erigontech/erigon-lib/common/paths" + "github.com/erigontech/erigon-p2p/nat" "github.com/erigontech/erigon/cmd/downloader/downloadernat" "github.com/erigontech/erigon/cmd/hack/tool" "github.com/erigontech/erigon/cmd/utils" - "github.com/erigontech/erigon/p2p/nat" "github.com/erigontech/erigon/params" "github.com/erigontech/erigon/turbo/debug" "github.com/erigontech/erigon/turbo/logging" + + _ "github.com/erigontech/erigon-db/snaptype" //hack + _ "github.com/erigontech/erigon/polygon/heimdall" //hack ) func main() { diff --git a/cmd/evm/runner.go b/cmd/evm/runner.go index 8772d3464d9..ee722db5129 100644 --- a/cmd/evm/runner.go +++ b/cmd/evm/runner.go @@ -57,7 +57,6 @@ import ( "github.com/erigontech/erigon/core/vm/runtime" "github.com/erigontech/erigon/eth/tracers" "github.com/erigontech/erigon/eth/tracers/logger" - "github.com/erigontech/erigon/params" ) var runCommand = cli.Command{ @@ -283,7 +282,7 @@ func runCmd(ctx *cli.Context) error { if chainConfig != nil { runtimeConfig.ChainConfig = chainConfig } else { - runtimeConfig.ChainConfig = params.AllProtocolChanges + runtimeConfig.ChainConfig = chain.AllProtocolChanges } var hexInput []byte diff --git a/cmd/integration/commands/stages.go b/cmd/integration/commands/stages.go index 7318408d2dc..a88f9590fb6 100644 --- a/cmd/integration/commands/stages.go +++ b/cmd/integration/commands/stages.go @@ -54,6 +54,8 @@ import ( "github.com/erigontech/erigon-lib/state/stats" "github.com/erigontech/erigon-lib/types" "github.com/erigontech/erigon-lib/wrap" + p2p "github.com/erigontech/erigon-p2p" + "github.com/erigontech/erigon-p2p/sentry" "github.com/erigontech/erigon/cl/clparams" "github.com/erigontech/erigon/cmd/hack/tool/fromdb" "github.com/erigontech/erigon/core" @@ -68,11 +70,9 @@ import ( "github.com/erigontech/erigon/eth/stagedsync/stages" "github.com/erigontech/erigon/execution/builder" "github.com/erigontech/erigon/execution/consensus" + "github.com/erigontech/erigon/execution/sentry_multi_client" "github.com/erigontech/erigon/node/migrations" "github.com/erigontech/erigon/node/nodecfg" - "github.com/erigontech/erigon/p2p" - "github.com/erigontech/erigon/p2p/sentry" - "github.com/erigontech/erigon/p2p/sentry/sentry_multi_client" "github.com/erigontech/erigon/params" "github.com/erigontech/erigon/polygon/bor" "github.com/erigontech/erigon/polygon/bridge" diff --git a/cmd/integration/main.go b/cmd/integration/main.go index f101c11a051..f035292abb7 100644 --- a/cmd/integration/main.go +++ b/cmd/integration/main.go @@ -20,7 +20,7 @@ import ( "fmt" "os" - _ "github.com/erigontech/erigon/core/snaptype" //hack + _ "github.com/erigontech/erigon-db/snaptype" //hack _ "github.com/erigontech/erigon/polygon/heimdall" //hack "github.com/erigontech/erigon-lib/common" diff --git a/cmd/observer/observer/crawler.go b/cmd/observer/observer/crawler.go index 001eb9602fb..e251266d3ab 100644 --- a/cmd/observer/observer/crawler.go +++ b/cmd/observer/observer/crawler.go @@ -28,12 +28,12 @@ import ( "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/log/v3" + "github.com/erigontech/erigon-p2p/enode" + "github.com/erigontech/erigon-p2p/forkid" "github.com/erigontech/erigon/cmd/observer/database" "github.com/erigontech/erigon/cmd/observer/observer/node_utils" "github.com/erigontech/erigon/cmd/observer/observer/sentry_candidates" "github.com/erigontech/erigon/cmd/observer/utils" - "github.com/erigontech/erigon/p2p/enode" - "github.com/erigontech/erigon/p2p/forkid" "github.com/erigontech/erigon/params" ) diff --git a/cmd/observer/observer/diplomat.go b/cmd/observer/observer/diplomat.go index fd1cbff4358..341d9731b45 100644 --- a/cmd/observer/observer/diplomat.go +++ b/cmd/observer/observer/diplomat.go @@ -23,9 +23,9 @@ import ( "time" "github.com/erigontech/erigon-lib/log/v3" + p2p "github.com/erigontech/erigon-p2p" + "github.com/erigontech/erigon-p2p/enode" "github.com/erigontech/erigon/cmd/observer/database" - "github.com/erigontech/erigon/p2p" - "github.com/erigontech/erigon/p2p/enode" ) type Diplomat struct { diff --git a/cmd/observer/observer/handshake.go b/cmd/observer/observer/handshake.go index 65a3630a76e..fc73f06ac5f 100644 --- a/cmd/observer/observer/handshake.go +++ b/cmd/observer/observer/handshake.go @@ -29,10 +29,10 @@ import ( "github.com/erigontech/erigon-lib/crypto" "github.com/erigontech/erigon-lib/direct" "github.com/erigontech/erigon-lib/rlp" - "github.com/erigontech/erigon/p2p" - "github.com/erigontech/erigon/p2p/forkid" - "github.com/erigontech/erigon/p2p/protocols/eth" - "github.com/erigontech/erigon/p2p/rlpx" + p2p "github.com/erigontech/erigon-p2p" + "github.com/erigontech/erigon-p2p/forkid" + "github.com/erigontech/erigon-p2p/protocols/eth" + "github.com/erigontech/erigon-p2p/rlpx" "github.com/erigontech/erigon/params" ) diff --git a/cmd/observer/observer/handshake_test.go b/cmd/observer/observer/handshake_test.go index 1cb79ca422f..fbaa8d7951f 100644 --- a/cmd/observer/observer/handshake_test.go +++ b/cmd/observer/observer/handshake_test.go @@ -25,7 +25,7 @@ import ( "github.com/erigontech/erigon-lib/crypto" "github.com/erigontech/erigon-lib/direct" - "github.com/erigontech/erigon/p2p/enode" + "github.com/erigontech/erigon-p2p/enode" "github.com/erigontech/erigon/params" ) diff --git a/cmd/observer/observer/interrogator.go b/cmd/observer/observer/interrogator.go index da32867ad23..5de8d801bc7 100644 --- a/cmd/observer/observer/interrogator.go +++ b/cmd/observer/observer/interrogator.go @@ -28,10 +28,10 @@ import ( "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/log/v3" + "github.com/erigontech/erigon-p2p/enode" + "github.com/erigontech/erigon-p2p/forkid" + "github.com/erigontech/erigon-p2p/protocols/eth" "github.com/erigontech/erigon/cmd/observer/utils" - "github.com/erigontech/erigon/p2p/enode" - "github.com/erigontech/erigon/p2p/forkid" - "github.com/erigontech/erigon/p2p/protocols/eth" ) type DiscV4Transport interface { diff --git a/cmd/observer/observer/keygen.go b/cmd/observer/observer/keygen.go index 28245aa2af6..1024b7e767b 100644 --- a/cmd/observer/observer/keygen.go +++ b/cmd/observer/observer/keygen.go @@ -23,7 +23,7 @@ import ( "github.com/erigontech/erigon-lib/crypto" "github.com/erigontech/erigon-lib/log/v3" - "github.com/erigontech/erigon/p2p/enode" + "github.com/erigontech/erigon-p2p/enode" ) func keygen( diff --git a/cmd/observer/observer/node_utils/node_addr.go b/cmd/observer/observer/node_utils/node_addr.go index 91685d01d8b..255ac0f1dad 100644 --- a/cmd/observer/observer/node_utils/node_addr.go +++ b/cmd/observer/observer/node_utils/node_addr.go @@ -20,10 +20,10 @@ import ( "fmt" "net" + "github.com/erigontech/erigon-p2p/enode" + "github.com/erigontech/erigon-p2p/enr" "github.com/erigontech/erigon/cmd/observer/database" "github.com/erigontech/erigon/cmd/observer/utils" - "github.com/erigontech/erigon/p2p/enode" - "github.com/erigontech/erigon/p2p/enr" ) func MakeNodeAddr(node *enode.Node) database.NodeAddr { diff --git a/cmd/observer/observer/node_utils/node_id.go b/cmd/observer/observer/node_utils/node_id.go index 410b8cad3ed..4c902fe47f2 100644 --- a/cmd/observer/observer/node_utils/node_id.go +++ b/cmd/observer/observer/node_utils/node_id.go @@ -21,8 +21,8 @@ import ( "fmt" "net/url" + "github.com/erigontech/erigon-p2p/enode" "github.com/erigontech/erigon/cmd/observer/database" - "github.com/erigontech/erigon/p2p/enode" ) func NodeID(node *enode.Node) (database.NodeID, error) { diff --git a/cmd/observer/observer/sentry_candidates/intake.go b/cmd/observer/observer/sentry_candidates/intake.go index 47e4027a814..d5c14ac97a5 100644 --- a/cmd/observer/observer/sentry_candidates/intake.go +++ b/cmd/observer/observer/sentry_candidates/intake.go @@ -24,10 +24,10 @@ import ( "github.com/nxadm/tail" "github.com/erigontech/erigon-lib/log/v3" + "github.com/erigontech/erigon-p2p/enode" "github.com/erigontech/erigon/cmd/observer/database" "github.com/erigontech/erigon/cmd/observer/observer/node_utils" "github.com/erigontech/erigon/cmd/observer/utils" - "github.com/erigontech/erigon/p2p/enode" "github.com/erigontech/erigon/params" ) diff --git a/cmd/observer/observer/sentry_candidates/log.go b/cmd/observer/observer/sentry_candidates/log.go index 69bccd38426..35e3b915d64 100644 --- a/cmd/observer/observer/sentry_candidates/log.go +++ b/cmd/observer/observer/sentry_candidates/log.go @@ -27,7 +27,7 @@ import ( "github.com/nxadm/tail" - "github.com/erigontech/erigon/p2p/protocols/eth" + "github.com/erigontech/erigon-p2p/protocols/eth" ) type Log struct { diff --git a/cmd/observer/observer/server.go b/cmd/observer/observer/server.go index a59926894f1..c3a3ebb6912 100644 --- a/cmd/observer/observer/server.go +++ b/cmd/observer/observer/server.go @@ -26,15 +26,15 @@ import ( "github.com/erigontech/erigon-lib/common/debug" "github.com/erigontech/erigon-lib/log/v3" + p2p "github.com/erigontech/erigon-p2p" + "github.com/erigontech/erigon-p2p/discover" + "github.com/erigontech/erigon-p2p/enode" + "github.com/erigontech/erigon-p2p/enr" + "github.com/erigontech/erigon-p2p/forkid" + "github.com/erigontech/erigon-p2p/nat" + "github.com/erigontech/erigon-p2p/netutil" + "github.com/erigontech/erigon-p2p/protocols/eth" "github.com/erigontech/erigon/cmd/utils" - "github.com/erigontech/erigon/p2p" - "github.com/erigontech/erigon/p2p/discover" - "github.com/erigontech/erigon/p2p/enode" - "github.com/erigontech/erigon/p2p/enr" - "github.com/erigontech/erigon/p2p/forkid" - "github.com/erigontech/erigon/p2p/nat" - "github.com/erigontech/erigon/p2p/netutil" - "github.com/erigontech/erigon/p2p/protocols/eth" "github.com/erigontech/erigon/params" ) diff --git a/cmd/observer/utils/pubkey_hex.go b/cmd/observer/utils/pubkey_hex.go index 8b711959b31..049cf1f6062 100644 --- a/cmd/observer/utils/pubkey_hex.go +++ b/cmd/observer/utils/pubkey_hex.go @@ -22,7 +22,7 @@ import ( "fmt" "github.com/erigontech/erigon-lib/crypto" - "github.com/erigontech/erigon/p2p/enode" + "github.com/erigontech/erigon-p2p/enode" ) func ParseHexPublicKey(keyStr string) (*ecdsa.PublicKey, error) { diff --git a/cmd/p2psim/main.go b/cmd/p2psim/main.go deleted file mode 100644 index 7bf0bb21038..00000000000 --- a/cmd/p2psim/main.go +++ /dev/null @@ -1,439 +0,0 @@ -// Copyright 2017 The go-ethereum Authors -// (original work) -// Copyright 2024 The Erigon Authors -// (modifications) -// This file is part of Erigon. -// -// Erigon is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Erigon is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with Erigon. If not, see . - -// p2psim provides a command-line client for a simulation HTTP API. -// -// Here is an example of creating a 2 node network with the first node -// connected to the second: -// -// $ p2psim node create -// Created node01 -// -// $ p2psim node start node01 -// Started node01 -// -// $ p2psim node create -// Created node02 -// -// $ p2psim node start node02 -// Started node02 -// -// $ p2psim node connect node01 node02 -// Connected node01 to node02 -package main - -import ( - "context" - "encoding/json" - "fmt" - "io" - "os" - "strings" - "text/tabwriter" - - "github.com/urfave/cli/v2" - - "github.com/erigontech/erigon-lib/common" - "github.com/erigontech/erigon-lib/crypto" - "github.com/erigontech/erigon-lib/log/v3" - "github.com/erigontech/erigon/p2p" - "github.com/erigontech/erigon/p2p/enode" - "github.com/erigontech/erigon/p2p/simulations" - "github.com/erigontech/erigon/p2p/simulations/adapters" - "github.com/erigontech/erigon/rpc" - "github.com/erigontech/erigon/turbo/logging" -) - -var client *simulations.Client - -func main() { - app := cli.NewApp() - app.Usage = "devp2p simulation command-line client" - app.Flags = []cli.Flag{ - &cli.StringFlag{ - Name: "api", - Value: "http://localhost:8888", - Usage: "simulation API URL", - EnvVars: []string{"P2PSIM_API_URL"}, - }, - } - app.Before = func(ctx *cli.Context) error { - logger := logging.SetupLoggerCtx("p2psim", ctx, log.LvlInfo, log.LvlInfo, false /* rootLogger */) - client = simulations.NewClient(ctx.String("api"), logger) - return nil - } - app.Commands = []*cli.Command{ - { - Name: "show", - Usage: "show network information", - Action: showNetwork, - }, - { - Name: "events", - Usage: "stream network events", - Action: streamNetwork, - Flags: []cli.Flag{ - &cli.BoolFlag{ - Name: "current", - Usage: "get existing nodes and conns first", - }, - &cli.StringFlag{ - Name: "filter", - Value: "", - Usage: "message filter", - }, - }, - }, - { - Name: "snapshot", - Usage: "create a network snapshot to stdout", - Action: createSnapshot, - }, - { - Name: "load", - Usage: "load a network snapshot from stdin", - Action: loadSnapshot, - }, - { - Name: "node", - Usage: "manage simulation nodes", - Action: listNodes, - Subcommands: []*cli.Command{ - { - Name: "list", - Usage: "list nodes", - Action: listNodes, - }, - { - Name: "create", - Usage: "create a node", - Action: createNode, - Flags: []cli.Flag{ - &cli.StringFlag{ - Name: "name", - Value: "", - Usage: "node name", - }, - &cli.StringFlag{ - Name: "services", - Value: "", - Usage: "node services (comma separated)", - }, - &cli.StringFlag{ - Name: "key", - Value: "", - Usage: "node private key (hex encoded)", - }, - }, - }, - { - Name: "show", - ArgsUsage: "", - Usage: "show node information", - Action: showNode, - }, - { - Name: "start", - ArgsUsage: "", - Usage: "start a node", - Action: startNode, - }, - { - Name: "stop", - ArgsUsage: "", - Usage: "stop a node", - Action: stopNode, - }, - { - Name: "connect", - ArgsUsage: " ", - Usage: "connect a node to a peer node", - Action: connectNode, - }, - { - Name: "disconnect", - ArgsUsage: " ", - Usage: "disconnect a node from a peer node", - Action: disconnectNode, - }, - { - Name: "rpc", - ArgsUsage: " []", - Usage: "call a node RPC method", - Action: rpcNode, - Flags: []cli.Flag{ - &cli.BoolFlag{ - Name: "subscribe", - Usage: "method is a subscription", - }, - }, - }, - }, - }, - } - if err := app.Run(os.Args); err != nil { - fmt.Fprintln(os.Stderr, err) - os.Exit(1) - } -} - -func showNetwork(ctx *cli.Context) error { - if ctx.NArg() != 0 { - return cli.ShowCommandHelp(ctx, ctx.Command.Name) - } - network, err := client.GetNetwork() - if err != nil { - return err - } - w := tabwriter.NewWriter(ctx.App.Writer, 1, 2, 2, ' ', 0) - defer w.Flush() - fmt.Fprintf(w, "NODES\t%d\n", len(network.Nodes)) - fmt.Fprintf(w, "CONNS\t%d\n", len(network.Conns)) - return nil -} - -func streamNetwork(ctx *cli.Context) error { - if ctx.NArg() != 0 { - return cli.ShowCommandHelp(ctx, ctx.Command.Name) - } - events := make(chan *simulations.Event) - sub, err := client.SubscribeNetwork(events, simulations.SubscribeOpts{ - Current: ctx.Bool("current"), - Filter: ctx.String("filter"), - }) - if err != nil { - return err - } - defer sub.Unsubscribe() - enc := json.NewEncoder(ctx.App.Writer) - for { - select { - case event := <-events: - if err := enc.Encode(event); err != nil { - return err - } - case err := <-sub.Err(): - return err - } - } -} - -func createSnapshot(ctx *cli.Context) error { - if ctx.NArg() != 0 { - return cli.ShowCommandHelp(ctx, ctx.Command.Name) - } - snap, err := client.CreateSnapshot() - if err != nil { - return err - } - return json.NewEncoder(os.Stdout).Encode(snap) -} - -func loadSnapshot(ctx *cli.Context) error { - if ctx.NArg() != 0 { - return cli.ShowCommandHelp(ctx, ctx.Command.Name) - } - snap := &simulations.Snapshot{} - if err := json.NewDecoder(os.Stdin).Decode(snap); err != nil { - return err - } - return client.LoadSnapshot(snap) -} - -func listNodes(ctx *cli.Context) error { - if ctx.NArg() != 0 { - return cli.ShowCommandHelp(ctx, ctx.Command.Name) - } - nodes, err := client.GetNodes() - if err != nil { - return err - } - w := tabwriter.NewWriter(ctx.App.Writer, 1, 2, 2, ' ', 0) - defer w.Flush() - fmt.Fprintf(w, "NAME\tPROTOCOLS\tID\n") - for _, node := range nodes { - fmt.Fprintf(w, "%s\t%s\t%s\n", node.Name, strings.Join(protocolList(node), ","), node.ID) - } - return nil -} - -func protocolList(node *p2p.NodeInfo) []string { - protos := make([]string, 0, len(node.Protocols)) - for name := range node.Protocols { - protos = append(protos, name) - } - return protos -} - -func createNode(ctx *cli.Context) error { - if ctx.NArg() != 0 { - return cli.ShowCommandHelp(ctx, ctx.Command.Name) - } - config := adapters.RandomNodeConfig() - config.Name = ctx.String("name") - if key := ctx.String("key"); key != "" { - privKey, err := crypto.HexToECDSA(key) - if err != nil { - return err - } - config.ID = enode.PubkeyToIDV4(&privKey.PublicKey) - config.PrivateKey = privKey - } - if services := ctx.String("services"); services != "" { - config.Lifecycles = common.CliString2Array(services) - } - node, err := client.CreateNode(config) - if err != nil { - return err - } - fmt.Fprintln(ctx.App.Writer, "Created", node.Name) - return nil -} - -func showNode(ctx *cli.Context) error { - args := ctx.Args() - if args.Len() != 1 { - return cli.ShowCommandHelp(ctx, ctx.Command.Name) - } - nodeName := args.First() - node, err := client.GetNode(nodeName) - if err != nil { - return err - } - w := tabwriter.NewWriter(ctx.App.Writer, 1, 2, 2, ' ', 0) - defer w.Flush() - fmt.Fprintf(w, "NAME\t%s\n", node.Name) - fmt.Fprintf(w, "PROTOCOLS\t%s\n", strings.Join(protocolList(node), ",")) - fmt.Fprintf(w, "ID\t%s\n", node.ID) - fmt.Fprintf(w, "ENODE\t%s\n", node.Enode) - for name, proto := range node.Protocols { - fmt.Fprintln(w) - fmt.Fprintf(w, "--- PROTOCOL INFO: %s\n", name) - fmt.Fprintf(w, "%v\n", proto) - fmt.Fprintf(w, "---\n") - } - return nil -} - -func startNode(ctx *cli.Context) error { - args := ctx.Args() - if args.Len() != 1 { - return cli.ShowCommandHelp(ctx, ctx.Command.Name) - } - nodeName := args.First() - if err := client.StartNode(nodeName); err != nil { - return err - } - fmt.Fprintln(ctx.App.Writer, "Started", nodeName) - return nil -} - -func stopNode(ctx *cli.Context) error { - args := ctx.Args() - if args.Len() != 1 { - return cli.ShowCommandHelp(ctx, ctx.Command.Name) - } - nodeName := args.First() - if err := client.StopNode(nodeName); err != nil { - return err - } - fmt.Fprintln(ctx.App.Writer, "Stopped", nodeName) - return nil -} - -func connectNode(ctx *cli.Context) error { - args := ctx.Args() - if args.Len() != 2 { - return cli.ShowCommandHelp(ctx, ctx.Command.Name) - } - nodeName := args.Get(0) - peerName := args.Get(1) - if err := client.ConnectNode(nodeName, peerName); err != nil { - return err - } - fmt.Fprintln(ctx.App.Writer, "Connected", nodeName, "to", peerName) - return nil -} - -func disconnectNode(ctx *cli.Context) error { - args := ctx.Args() - if args.Len() != 2 { - return cli.ShowCommandHelp(ctx, ctx.Command.Name) - } - nodeName := args.Get(0) - peerName := args.Get(1) - if err := client.DisconnectNode(nodeName, peerName); err != nil { - return err - } - fmt.Fprintln(ctx.App.Writer, "Disconnected", nodeName, "from", peerName) - return nil -} - -func rpcNode(ctx *cli.Context) error { - args := ctx.Args() - if args.Len() < 2 { - return cli.ShowCommandHelp(ctx, ctx.Command.Name) - } - nodeName := args.Get(0) - method := args.Get(1) - rpcClient, err := client.RPCClient(context.Background(), nodeName) - if err != nil { - return err - } - if ctx.Bool("subscribe") { - return rpcSubscribe(rpcClient, ctx.App.Writer, method, args.Slice()[3:]...) - } - var result interface{} - params := make([]interface{}, len(args.Slice()[3:])) - for i, v := range args.Slice()[3:] { - params[i] = v - } - if err := rpcClient.Call(&result, method, params...); err != nil { - return err - } - return json.NewEncoder(ctx.App.Writer).Encode(result) -} - -func rpcSubscribe(client *rpc.Client, out io.Writer, method string, args ...string) error { - parts := strings.SplitN(method, "_", 2) - namespace := parts[0] - method = parts[1] - ch := make(chan interface{}) - subArgs := make([]interface{}, len(args)+1) - subArgs[0] = method - for i, v := range args { - subArgs[i+1] = v - } - sub, err := client.Subscribe(context.Background(), namespace, ch, subArgs...) - if err != nil { - return err - } - defer sub.Unsubscribe() - enc := json.NewEncoder(out) - for { - select { - case v := <-ch: - if err := enc.Encode(v); err != nil { - return err - } - case err := <-sub.Err(): - return err - } - } -} diff --git a/cmd/pics/contracts/gen_token.go b/cmd/pics/contracts/gen_token.go index ab5fa202363..f34321e08a1 100644 --- a/cmd/pics/contracts/gen_token.go +++ b/cmd/pics/contracts/gen_token.go @@ -13,7 +13,7 @@ import ( "github.com/erigontech/erigon-lib/abi" "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/types" - "github.com/erigontech/erigon/event" + "github.com/erigontech/erigon-p2p/event" "github.com/erigontech/erigon/execution/abi/bind" ) diff --git a/cmd/pics/state.go b/cmd/pics/state.go index 7890ee35d1c..4877898031f 100644 --- a/cmd/pics/state.go +++ b/cmd/pics/state.go @@ -29,6 +29,7 @@ import ( "github.com/holiman/uint256" + "github.com/erigontech/erigon-lib/chain" "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/crypto" "github.com/erigontech/erigon-lib/kv" @@ -41,7 +42,6 @@ import ( "github.com/erigontech/erigon/core" "github.com/erigontech/erigon/execution/abi/bind" "github.com/erigontech/erigon/execution/abi/bind/backends" - "github.com/erigontech/erigon/params" "github.com/erigontech/erigon/turbo/stages/mock" ) @@ -280,7 +280,7 @@ func initialState1() error { address2 = crypto.PubkeyToAddress(key2.PublicKey) theAddr = common.Address{1} gspec = &types.Genesis{ - Config: params.AllProtocolChanges, + Config: chain.AllProtocolChanges, Alloc: types.GenesisAlloc{ address: {Balance: big.NewInt(9000000000000000000)}, address1: {Balance: big.NewInt(200000000000000000)}, @@ -289,7 +289,7 @@ func initialState1() error { GasLimit: 10000000, } // this code generates a log - signer = types.MakeSigner(params.AllProtocolChanges, 1, 0) + signer = types.MakeSigner(chain.AllProtocolChanges, 1, 0) ) m := mock.MockWithGenesis(nil, gspec, key, false) defer m.DB.Close() diff --git a/cmd/rpcdaemon/main.go b/cmd/rpcdaemon/main.go index 129be1a2402..bdf12062783 100644 --- a/cmd/rpcdaemon/main.go +++ b/cmd/rpcdaemon/main.go @@ -30,7 +30,7 @@ import ( "github.com/erigontech/erigon/rpc/jsonrpc" "github.com/erigontech/erigon/turbo/debug" - _ "github.com/erigontech/erigon/core/snaptype" //hack + _ "github.com/erigontech/erigon-db/snaptype" //hack _ "github.com/erigontech/erigon/polygon/heimdall" //hack ) diff --git a/cmd/rpcdaemon/rpcservices/eth_backend.go b/cmd/rpcdaemon/rpcservices/eth_backend.go index 3d6a9f0b737..02e9185d498 100644 --- a/cmd/rpcdaemon/rpcservices/eth_backend.go +++ b/cmd/rpcdaemon/rpcservices/eth_backend.go @@ -38,8 +38,8 @@ import ( "github.com/erigontech/erigon-lib/log/v3" "github.com/erigontech/erigon-lib/rlp" "github.com/erigontech/erigon-lib/types" + p2p "github.com/erigontech/erigon-p2p" "github.com/erigontech/erigon/eth/ethconfig" - "github.com/erigontech/erigon/p2p" "github.com/erigontech/erigon/polygon/heimdall" "github.com/erigontech/erigon/turbo/privateapi" "github.com/erigontech/erigon/turbo/services" diff --git a/cmd/sentry/main.go b/cmd/sentry/main.go index dca4acd520a..8b16d38279e 100644 --- a/cmd/sentry/main.go +++ b/cmd/sentry/main.go @@ -25,8 +25,8 @@ import ( "github.com/spf13/cobra" "github.com/erigontech/erigon-lib/common/paths" + "github.com/erigontech/erigon-p2p/sentry" "github.com/erigontech/erigon/cmd/utils" - "github.com/erigontech/erigon/p2p/sentry" "github.com/erigontech/erigon/turbo/debug" "github.com/erigontech/erigon/turbo/logging" node2 "github.com/erigontech/erigon/turbo/node" diff --git a/cmd/silkworm_api/snapshot_idx.go b/cmd/silkworm_api/snapshot_idx.go index ff025b0409f..91317ba88cd 100644 --- a/cmd/silkworm_api/snapshot_idx.go +++ b/cmd/silkworm_api/snapshot_idx.go @@ -21,17 +21,17 @@ import ( "os" "time" - "github.com/erigontech/erigon-lib/kv" "github.com/urfave/cli/v2" "golang.org/x/sync/errgroup" + coresnaptype "github.com/erigontech/erigon-db/snaptype" "github.com/erigontech/erigon-lib/common/background" "github.com/erigontech/erigon-lib/common/datadir" "github.com/erigontech/erigon-lib/downloader/snaptype" + "github.com/erigontech/erigon-lib/kv" "github.com/erigontech/erigon-lib/kv/mdbx" "github.com/erigontech/erigon-lib/log/v3" "github.com/erigontech/erigon/cmd/hack/tool/fromdb" - coresnaptype "github.com/erigontech/erigon/core/snaptype" "github.com/erigontech/erigon/turbo/debug" "github.com/erigontech/erigon/turbo/snapshotsync/freezeblocks" ) diff --git a/cmd/snapshots/cmp/cmp.go b/cmd/snapshots/cmp/cmp.go index f599ca830ee..f2625c12edb 100644 --- a/cmd/snapshots/cmp/cmp.go +++ b/cmd/snapshots/cmp/cmp.go @@ -32,17 +32,16 @@ import ( "github.com/urfave/cli/v2" "golang.org/x/sync/errgroup" - "github.com/erigontech/erigon-lib/log/v3" - + coresnaptype "github.com/erigontech/erigon-db/snaptype" "github.com/erigontech/erigon-lib/chain" "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/downloader" "github.com/erigontech/erigon-lib/downloader/snaptype" + "github.com/erigontech/erigon-lib/log/v3" "github.com/erigontech/erigon-lib/types" "github.com/erigontech/erigon/cmd/snapshots/flags" "github.com/erigontech/erigon/cmd/snapshots/sync" "github.com/erigontech/erigon/cmd/utils" - coresnaptype "github.com/erigontech/erigon/core/snaptype" "github.com/erigontech/erigon/eth/ethconfig" "github.com/erigontech/erigon/params" "github.com/erigontech/erigon/turbo/logging" diff --git a/cmd/snapshots/sync/sync.go b/cmd/snapshots/sync/sync.go index c9566c7f86f..f17e268dba6 100644 --- a/cmd/snapshots/sync/sync.go +++ b/cmd/snapshots/sync/sync.go @@ -46,9 +46,9 @@ import ( "github.com/erigontech/erigon-lib/downloader/downloadercfg" "github.com/erigontech/erigon-lib/downloader/snaptype" "github.com/erigontech/erigon-lib/version" + "github.com/erigontech/erigon-p2p/nat" "github.com/erigontech/erigon/cmd/downloader/downloadernat" "github.com/erigontech/erigon/cmd/utils" - "github.com/erigontech/erigon/p2p/nat" "github.com/erigontech/erigon/params" ) diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index f17597d7911..c223d6d0139 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -31,7 +31,6 @@ import ( "time" "github.com/c2h5oh/datasize" - "github.com/erigontech/erigon/txnprovider/shutter/shuttercfg" "github.com/spf13/cobra" "github.com/spf13/pflag" "github.com/urfave/cli/v2" @@ -51,6 +50,10 @@ import ( "github.com/erigontech/erigon-lib/log/v3" "github.com/erigontech/erigon-lib/state" "github.com/erigontech/erigon-lib/types" + p2p "github.com/erigontech/erigon-p2p" + "github.com/erigontech/erigon-p2p/enode" + "github.com/erigontech/erigon-p2p/nat" + "github.com/erigontech/erigon-p2p/netutil" "github.com/erigontech/erigon/cl/clparams" "github.com/erigontech/erigon/cmd/downloader/downloadernat" "github.com/erigontech/erigon/cmd/utils/flags" @@ -59,14 +62,11 @@ import ( "github.com/erigontech/erigon/eth/gasprice/gaspricecfg" "github.com/erigontech/erigon/execution/consensus/ethash/ethashcfg" "github.com/erigontech/erigon/node/nodecfg" - "github.com/erigontech/erigon/p2p" - "github.com/erigontech/erigon/p2p/enode" - "github.com/erigontech/erigon/p2p/nat" - "github.com/erigontech/erigon/p2p/netutil" params2 "github.com/erigontech/erigon/params" "github.com/erigontech/erigon/polygon/heimdall" "github.com/erigontech/erigon/rpc/rpccfg" "github.com/erigontech/erigon/turbo/logging" + "github.com/erigontech/erigon/txnprovider/shutter/shuttercfg" "github.com/erigontech/erigon/txnprovider/txpool/txpoolcfg" ) @@ -1215,7 +1215,7 @@ func GetBootnodesFromFlags(urlsStr, chain string) ([]*enode.Node, error) { } else { urls = params2.BootnodeURLsOfChain(chain) } - return ParseNodesFromURLs(urls) + return enode.ParseNodesFromURLs(urls) } func setStaticPeers(ctx *cli.Context, cfg *p2p.Config) { @@ -1227,7 +1227,7 @@ func setStaticPeers(ctx *cli.Context, cfg *p2p.Config) { urls = params2.StaticPeerURLsOfChain(chain) } - nodes, err := ParseNodesFromURLs(urls) + nodes, err := enode.ParseNodesFromURLs(urls) if err != nil { Fatalf("Option %s: %v", StaticPeersFlag.Name, err) } @@ -1241,7 +1241,7 @@ func setTrustedPeers(ctx *cli.Context, cfg *p2p.Config) { } urls := common.CliString2Array(ctx.String(TrustedPeersFlag.Name)) - trustedNodes, err := ParseNodesFromURLs(urls) + trustedNodes, err := enode.ParseNodesFromURLs(urls) if err != nil { Fatalf("Option %s: %v", TrustedPeersFlag.Name, err) } @@ -1249,21 +1249,6 @@ func setTrustedPeers(ctx *cli.Context, cfg *p2p.Config) { cfg.TrustedNodes = append(cfg.TrustedNodes, trustedNodes...) } -func ParseNodesFromURLs(urls []string) ([]*enode.Node, error) { - nodes := make([]*enode.Node, 0, len(urls)) - for _, url := range urls { - if url == "" { - continue - } - n, err := enode.Parse(enode.ValidSchemes, url) - if err != nil { - return nil, fmt.Errorf("invalid node URL %s: %w", url, err) - } - nodes = append(nodes, n) - } - return nodes, nil -} - // NewP2PConfig // - doesn't setup bootnodes - they will set when genesisHash will know func NewP2PConfig( @@ -1297,31 +1282,33 @@ func NewP2PConfig( } cfg := &p2p.Config{ - ListenAddr: fmt.Sprintf(":%d", port), - MaxPeers: maxPeers, - MaxPendingPeers: maxPendPeers, - NAT: nat.Any(), - NoDiscovery: nodiscover, - PrivateKey: serverKey, - Name: nodeName, - NodeDatabase: enodeDBPath, - AllowedPorts: allowedPorts, - TmpDir: dirs.Tmp, - MetricsEnabled: metricsEnabled, + ListenAddr: fmt.Sprintf(":%d", port), + MaxPeers: maxPeers, + MaxPendingPeers: maxPendPeers, + NAT: nat.Any(), + NoDiscovery: nodiscover, + PrivateKey: serverKey, + Name: nodeName, + NodeDatabase: enodeDBPath, + AllowedPorts: allowedPorts, + TmpDir: dirs.Tmp, + MetricsEnabled: metricsEnabled, + LookupBootnodeURLs: params2.BootnodeURLsByGenesisHash, + LookupDNSNetwork: params2.KnownDNSNetwork, } if netRestrict != "" { cfg.NetRestrict = new(netutil.Netlist) cfg.NetRestrict.Add(netRestrict) } if staticPeers != nil { - staticNodes, err := ParseNodesFromURLs(staticPeers) + staticNodes, err := enode.ParseNodesFromURLs(staticPeers) if err != nil { return nil, fmt.Errorf("bad option %s: %w", StaticPeersFlag.Name, err) } cfg.StaticNodes = staticNodes } if trustedPeers != nil { - trustedNodes, err := ParseNodesFromURLs(trustedPeers) + trustedNodes, err := enode.ParseNodesFromURLs(trustedPeers) if err != nil { return nil, fmt.Errorf("bad option %s: %w", TrustedPeersFlag.Name, err) } diff --git a/core/accessors_metadata.go b/core/accessors_metadata.go index 18c65a66ed6..1ba13252cf7 100644 --- a/core/accessors_metadata.go +++ b/core/accessors_metadata.go @@ -57,31 +57,6 @@ func ReadChainConfig(db kv.Getter, hash common.Hash) (*chain.Config, error) { return &config, nil } -// WriteChainConfig writes the chain config settings to the database. -func WriteChainConfig(db kv.Putter, hash common.Hash, cfg *chain.Config) error { - if cfg == nil { - return nil - } - - if cfg.Bor != nil { - borJSON, err := json.Marshal(cfg.Bor) - if err != nil { - return fmt.Errorf("failed to JSON encode chain config 'bor': %w", err) - } - cfg.BorJSON = borJSON - } - - data, err := json.Marshal(cfg) - if err != nil { - return fmt.Errorf("failed to JSON encode chain config: %w", err) - } - - if err := db.Put(kv.ConfigTable, hash[:], data); err != nil { - return fmt.Errorf("failed to store chain config: %w", err) - } - return nil -} - func WriteGenesisIfNotExist(db kv.RwTx, g *types.Genesis) error { has, err := db.Has(kv.ConfigTable, kv.GenesisKey) if err != nil { diff --git a/core/block_validator_test.go b/core/block_validator_test.go index 64146b41420..8a8bd86ec72 100644 --- a/core/block_validator_test.go +++ b/core/block_validator_test.go @@ -26,13 +26,13 @@ import ( libchain "github.com/erigontech/erigon-lib/chain" "github.com/erigontech/erigon-lib/kv" "github.com/erigontech/erigon-lib/log/v3" + "github.com/erigontech/erigon-lib/testlog" "github.com/erigontech/erigon-lib/types" "github.com/erigontech/erigon/core" "github.com/erigontech/erigon/eth/stagedsync" "github.com/erigontech/erigon/execution/consensus" "github.com/erigontech/erigon/execution/consensus/ethash" "github.com/erigontech/erigon/turbo/stages/mock" - "github.com/erigontech/erigon/turbo/testlog" ) // Tests that simple header verification works, for both good and bad blocks. diff --git a/core/genesis_test.go b/core/genesis_test.go index 6bbe125e56e..62ac07b4d74 100644 --- a/core/genesis_test.go +++ b/core/genesis_test.go @@ -27,6 +27,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/erigontech/erigon-lib/chain" "github.com/erigontech/erigon-lib/chain/networkname" "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/common/datadir" @@ -100,10 +101,10 @@ func TestGenesisBlockRoots(t *testing.T) { block, _, err = core.GenesisToBlock(core.TestGenesisBlock(), datadir.New(t.TempDir()), log.Root()) require.NoError(err) if block.Root() != params.TestGenesisStateRoot { - t.Errorf("wrong Chiado genesis state root, got %v, want %v", block.Root(), params.TestGenesisStateRoot) + t.Errorf("wrong test genesis state root, got %v, want %v", block.Root(), params.TestGenesisStateRoot) } if block.Hash() != params.TestGenesisHash { - t.Errorf("wrong Chiado genesis hash, got %v, want %v", block.Hash(), params.TestGenesisHash) + t.Errorf("wrong test genesis hash, got %v, want %v", block.Hash(), params.TestGenesisHash) } } @@ -141,7 +142,7 @@ func TestAllocConstructor(t *testing.T) { funds := big.NewInt(1000000000) address := common.HexToAddress("0x1000000000000000000000000000000000000001") genSpec := &types.Genesis{ - Config: params.AllProtocolChanges, + Config: chain.AllProtocolChanges, Alloc: types.GenesisAlloc{ address: {Constructor: deploymentCode, Balance: funds}, }, diff --git a/core/genesis_write.go b/core/genesis_write.go index 5516413efde..5dce3d3fe4b 100644 --- a/core/genesis_write.go +++ b/core/genesis_write.go @@ -36,16 +36,13 @@ import ( "github.com/erigontech/erigon-db/rawdb" "github.com/erigontech/erigon-lib/chain" "github.com/erigontech/erigon-lib/chain/networkname" - "github.com/erigontech/erigon-lib/chain/params" "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/common/datadir" - "github.com/erigontech/erigon-lib/common/empty" "github.com/erigontech/erigon-lib/common/hexutil" "github.com/erigontech/erigon-lib/config3" "github.com/erigontech/erigon-lib/crypto" "github.com/erigontech/erigon-lib/kv" "github.com/erigontech/erigon-lib/kv/mdbx" - "github.com/erigontech/erigon-lib/kv/rawdbv3" "github.com/erigontech/erigon-lib/kv/temporal" "github.com/erigontech/erigon-lib/log/v3" state2 "github.com/erigontech/erigon-lib/state" @@ -115,7 +112,7 @@ func configOrDefault(g *types.Genesis, genesisHash common.Hash) *chain.Config { if config != nil { return config } else { - return params2.AllProtocolChanges + return chain.AllProtocolChanges } } @@ -126,7 +123,7 @@ func WriteGenesisBlock(tx kv.RwTx, genesis *types.Genesis, overridePragueTime *b var storedBlock *types.Block if genesis != nil && genesis.Config == nil { - return params2.AllProtocolChanges, nil, types.ErrGenesisNoConfig + return chain.AllProtocolChanges, nil, types.ErrGenesisNoConfig } // Just commit the new block if there is no stored genesis block. storedHash, storedErr := rawdb.ReadCanonicalHash(tx, 0) @@ -189,7 +186,7 @@ func WriteGenesisBlock(tx kv.RwTx, genesis *types.Genesis, overridePragueTime *b } if storedCfg == nil { logger.Warn("Found genesis block without chain config") - err1 := WriteChainConfig(tx, storedHash, newCfg) + err1 := rawdb.WriteChainConfig(tx, storedHash, newCfg) if err1 != nil { return newCfg, nil, err1 } @@ -211,7 +208,7 @@ func WriteGenesisBlock(tx kv.RwTx, genesis *types.Genesis, overridePragueTime *b return newCfg, storedBlock, compatibilityErr } } - if err := WriteChainConfig(tx, storedHash, newCfg); err != nil { + if err := rawdb.WriteChainConfig(tx, storedHash, newCfg); err != nil { return newCfg, nil, err } return newCfg, storedBlock, nil @@ -223,8 +220,7 @@ func WriteGenesisState(g *types.Genesis, tx kv.RwTx, dirs datadir.Dirs, logger l return nil, nil, err } - var stateWriter state.StateWriter - stateWriter = state.NewNoopWriter() + stateWriter := state.NewNoopWriter() if block.Number().Sign() != 0 { return nil, statedb, errors.New("can't commit genesis block with number > 0") @@ -256,41 +252,12 @@ func MustCommitGenesis(g *types.Genesis, db kv.RwDB, dirs datadir.Dirs, logger l // Write writes the block and state of a genesis specification to the database. // The block is committed as the canonical head block. func write(tx kv.RwTx, g *types.Genesis, dirs datadir.Dirs, logger log.Logger) (*types.Block, *state.IntraBlockState, error) { - block, statedb, err2 := WriteGenesisState(g, tx, dirs, logger) - if err2 != nil { - return block, statedb, err2 - } - config := g.Config - if config == nil { - config = params2.AllProtocolChanges - } - if err := config.CheckConfigForkOrder(); err != nil { - return nil, nil, err - } - - if err := rawdb.WriteBlock(tx, block); err != nil { - return nil, nil, err - } - if err := rawdb.WriteTd(tx, block.Hash(), block.NumberU64(), g.Difficulty); err != nil { - return nil, nil, err - } - if err := rawdbv3.TxNums.Append(tx, 0, uint64(block.Transactions().Len()+1)); err != nil { - return nil, nil, err - } - - if err := rawdb.WriteCanonicalHash(tx, block.Hash(), block.NumberU64()); err != nil { - return nil, nil, err - } - - rawdb.WriteHeadBlockHash(tx, block.Hash()) - if err := rawdb.WriteHeadHeaderHash(tx, block.Hash()); err != nil { - return nil, nil, err - } - if err := WriteChainConfig(tx, block.Hash(), config); err != nil { - return nil, nil, err + block, statedb, err := WriteGenesisState(g, tx, dirs, logger) + if err != nil { + return block, statedb, err } - - return block, statedb, nil + err = rawdb.WriteGenesisBesideState(block, tx, g) + return block, statedb, err } // GenesisBlockForTesting creates and writes a block in which addr has the given wei balance. @@ -305,17 +272,6 @@ type GenAccount struct { Balance *big.Int } -func GenesisWithAccounts(db kv.RwDB, accs []GenAccount, dirs datadir.Dirs, logger log.Logger) *types.Block { - g := types.Genesis{Config: chain.TestChainConfig} - allocs := make(map[common.Address]types.GenesisAccount) - for _, acc := range accs { - allocs[acc.Addr] = types.GenesisAccount{Balance: acc.Balance} - } - g.Alloc = allocs - block := MustCommitGenesis(&g, db, dirs, logger) - return block -} - // MainnetGenesisBlock returns the Ethereum main net genesis block. func MainnetGenesisBlock() *types.Genesis { return &types.Genesis{ @@ -462,7 +418,7 @@ func DeveloperGenesisBlock(period uint64, faucet common.Address) *types.Genesis } } -// ToBlock creates the genesis block and writes state of a genesis specification +// GenesisToBlock creates the genesis block and writes state of a genesis specification // to the given database (or discards it if nil). func GenesisToBlock(g *types.Genesis, dirs datadir.Dirs, logger log.Logger) (*types.Block, *state.IntraBlockState, error) { if dirs.SnapDomain == "" { @@ -470,70 +426,7 @@ func GenesisToBlock(g *types.Genesis, dirs datadir.Dirs, logger log.Logger) (*ty } _ = g.Alloc //nil-check - head := &types.Header{ - Number: new(big.Int).SetUint64(g.Number), - Nonce: types.EncodeNonce(g.Nonce), - Time: g.Timestamp, - ParentHash: g.ParentHash, - Extra: g.ExtraData, - GasLimit: g.GasLimit, - GasUsed: g.GasUsed, - Difficulty: g.Difficulty, - MixDigest: g.Mixhash, - Coinbase: g.Coinbase, - BaseFee: g.BaseFee, - BlobGasUsed: g.BlobGasUsed, - ExcessBlobGas: g.ExcessBlobGas, - RequestsHash: g.RequestsHash, - } - if g.AuRaSeal != nil && len(g.AuRaSeal.AuthorityRound.Signature) > 0 { - head.AuRaSeal = g.AuRaSeal.AuthorityRound.Signature - head.AuRaStep = uint64(g.AuRaSeal.AuthorityRound.Step) - } - if g.GasLimit == 0 { - head.GasLimit = params.GenesisGasLimit - } - if g.Difficulty == nil { - head.Difficulty = params.GenesisDifficulty - } - if g.Config != nil && g.Config.IsLondon(0) { - if g.BaseFee != nil { - head.BaseFee = g.BaseFee - } else { - head.BaseFee = new(big.Int).SetUint64(params.InitialBaseFee) - } - } - - var withdrawals []*types.Withdrawal - if g.Config != nil && g.Config.IsShanghai(g.Timestamp) { - withdrawals = []*types.Withdrawal{} - } - - if g.Config != nil && g.Config.IsCancun(g.Timestamp) { - if g.BlobGasUsed != nil { - head.BlobGasUsed = g.BlobGasUsed - } else { - head.BlobGasUsed = new(uint64) - } - if g.ExcessBlobGas != nil { - head.ExcessBlobGas = g.ExcessBlobGas - } else { - head.ExcessBlobGas = new(uint64) - } - if g.ParentBeaconBlockRoot != nil { - head.ParentBeaconBlockRoot = g.ParentBeaconBlockRoot - } else { - head.ParentBeaconBlockRoot = &common.Hash{} - } - } - - if g.Config != nil && g.Config.IsPrague(g.Timestamp) { - if g.RequestsHash != nil { - head.RequestsHash = g.RequestsHash - } else { - head.RequestsHash = &empty.RequestsHash - } - } + head, withdrawals := rawdb.GenesisWithoutStateToBlock(g) var root common.Hash var statedb *state.IntraBlockState // reader behind this statedb is dead at the moment of return, tx is rolled back @@ -542,7 +435,7 @@ func GenesisToBlock(g *types.Genesis, dirs datadir.Dirs, logger log.Logger) (*ty wg, ctx := errgroup.WithContext(ctx) // we may run inside write tx, can't open 2nd write tx in same goroutine wg.Go(func() error { - // some users creaing > 1Gb custome genesis by `erigon init` + // some users creating > 1Gb custome genesis by `erigon init` genesisTmpDB := mdbx.New(kv.TemporaryDB, logger).InMem(dirs.DataDir).MapSize(2 * datasize.GB).GrowthStep(1 * datasize.MB).MustOpen() defer genesisTmpDB.Close() diff --git a/core/state/contracts/gen_changer.go b/core/state/contracts/gen_changer.go index 25e36f8880e..b9ec3a19e9f 100644 --- a/core/state/contracts/gen_changer.go +++ b/core/state/contracts/gen_changer.go @@ -13,7 +13,7 @@ import ( "github.com/erigontech/erigon-lib/abi" "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/types" - "github.com/erigontech/erigon/event" + "github.com/erigontech/erigon-p2p/event" "github.com/erigontech/erigon/execution/abi/bind" ) diff --git a/core/state/contracts/gen_phoenix.go b/core/state/contracts/gen_phoenix.go index a6bc198e45a..afad35bd313 100644 --- a/core/state/contracts/gen_phoenix.go +++ b/core/state/contracts/gen_phoenix.go @@ -13,7 +13,7 @@ import ( "github.com/erigontech/erigon-lib/abi" "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/types" - "github.com/erigontech/erigon/event" + "github.com/erigontech/erigon-p2p/event" "github.com/erigontech/erigon/execution/abi/bind" ) diff --git a/core/state/contracts/gen_poly.go b/core/state/contracts/gen_poly.go index b8aa77b27b4..230647b2944 100644 --- a/core/state/contracts/gen_poly.go +++ b/core/state/contracts/gen_poly.go @@ -13,7 +13,7 @@ import ( "github.com/erigontech/erigon-lib/abi" "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/types" - "github.com/erigontech/erigon/event" + "github.com/erigontech/erigon-p2p/event" "github.com/erigontech/erigon/execution/abi/bind" ) diff --git a/core/state/contracts/gen_revive.go b/core/state/contracts/gen_revive.go index 84132f96c22..32b410ef4fb 100644 --- a/core/state/contracts/gen_revive.go +++ b/core/state/contracts/gen_revive.go @@ -13,7 +13,7 @@ import ( "github.com/erigontech/erigon-lib/abi" "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/types" - "github.com/erigontech/erigon/event" + "github.com/erigontech/erigon-p2p/event" "github.com/erigontech/erigon/execution/abi/bind" ) diff --git a/core/state/contracts/gen_revive2.go b/core/state/contracts/gen_revive2.go index e1ec40072be..73179e46795 100644 --- a/core/state/contracts/gen_revive2.go +++ b/core/state/contracts/gen_revive2.go @@ -13,7 +13,7 @@ import ( "github.com/erigontech/erigon-lib/abi" "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/types" - "github.com/erigontech/erigon/event" + "github.com/erigontech/erigon-p2p/event" "github.com/erigontech/erigon/execution/abi/bind" ) diff --git a/core/state/contracts/gen_selfdestruct.go b/core/state/contracts/gen_selfdestruct.go index 88515a558f1..b2c78da5aff 100644 --- a/core/state/contracts/gen_selfdestruct.go +++ b/core/state/contracts/gen_selfdestruct.go @@ -13,7 +13,7 @@ import ( "github.com/erigontech/erigon-lib/abi" "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/types" - "github.com/erigontech/erigon/event" + "github.com/erigontech/erigon-p2p/event" "github.com/erigontech/erigon/execution/abi/bind" ) diff --git a/core/test/marked_forkable_test.go b/core/test/marked_forkable_test.go index 1ce1e4be037..7f23cb0eeec 100644 --- a/core/test/marked_forkable_test.go +++ b/core/test/marked_forkable_test.go @@ -9,6 +9,9 @@ import ( "testing" "github.com/c2h5oh/datasize" + "github.com/stretchr/testify/require" + + "github.com/erigontech/erigon-db/snaptype" "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/common/background" "github.com/erigontech/erigon-lib/common/datadir" @@ -18,8 +21,6 @@ import ( "github.com/erigontech/erigon-lib/state" ee "github.com/erigontech/erigon-lib/state/entity_extras" "github.com/erigontech/erigon-lib/types" - "github.com/erigontech/erigon/core/snaptype" - "github.com/stretchr/testify/require" ) type Num = state.Num diff --git a/core/vm/gas_table_test.go b/core/vm/gas_table_test.go index cb5e9c7c83c..8e59f801d61 100644 --- a/core/vm/gas_table_test.go +++ b/core/vm/gas_table_test.go @@ -45,7 +45,6 @@ import ( "github.com/erigontech/erigon/core/state" "github.com/erigontech/erigon/core/vm" "github.com/erigontech/erigon/core/vm/evmtypes" - "github.com/erigontech/erigon/params" "github.com/erigontech/erigon/rpc/rpchelper" ) @@ -147,14 +146,14 @@ func TestEIP2200(t *testing.T) { s.SetCode(address, hexutil.MustDecode(tt.input)) s.SetState(address, common.Hash{}, *uint256.NewInt(uint64(tt.original))) - _ = s.CommitBlock(params.AllProtocolChanges.Rules(0, 0), w) + _ = s.CommitBlock(chain.AllProtocolChanges.Rules(0, 0), w) vmctx := evmtypes.BlockContext{ CanTransfer: func(evmtypes.IntraBlockState, common.Address, *uint256.Int) (bool, error) { return true, nil }, Transfer: func(evmtypes.IntraBlockState, common.Address, common.Address, *uint256.Int, bool) error { return nil }, } - vmenv := vm.NewEVM(vmctx, evmtypes.TxContext{}, s, params.AllProtocolChanges, vm.Config{ExtraEips: []int{2200}}) + vmenv := vm.NewEVM(vmctx, evmtypes.TxContext{}, s, chain.AllProtocolChanges, vm.Config{ExtraEips: []int{2200}}) _, gas, err := vmenv.Call(vm.AccountRef(common.Address{}), address, nil, tt.gaspool, new(uint256.Int), false /* bailout */) if !errors.Is(err, tt.failure) { diff --git a/erigon-db/.gitignore b/erigon-db/.gitignore new file mode 100644 index 00000000000..73fd99b31b7 --- /dev/null +++ b/erigon-db/.gitignore @@ -0,0 +1,2 @@ +coverage-test.out +coverage-test-all.out diff --git a/erigon-db/interfaces/services.go b/erigon-db/interfaces/services.go new file mode 100644 index 00000000000..1905b9250d0 --- /dev/null +++ b/erigon-db/interfaces/services.go @@ -0,0 +1,60 @@ +// Copyright 2024 The Erigon Authors +// This file is part of Erigon. +// +// Erigon is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Erigon is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with Erigon. If not, see . + +package interfaces + +import ( + "context" + + "github.com/erigontech/erigon-lib/common" + "github.com/erigontech/erigon-lib/kv" + "github.com/erigontech/erigon-lib/rlp" + "github.com/erigontech/erigon-lib/types" +) + +type BlockReader interface { + BlockByNumber(ctx context.Context, db kv.Tx, number uint64) (*types.Block, error) + BlockByHash(ctx context.Context, db kv.Tx, hash common.Hash) (*types.Block, error) + CurrentBlock(db kv.Tx) (*types.Block, error) + BlockWithSenders(ctx context.Context, tx kv.Getter, hash common.Hash, blockNum uint64) (block *types.Block, senders []common.Address, err error) + IterateFrozenBodies(f func(blockNum, baseTxNum, txCount uint64) error) error +} + +type HeaderReader interface { + Header(ctx context.Context, tx kv.Getter, hash common.Hash, blockNum uint64) (*types.Header, error) + HeaderByNumber(ctx context.Context, tx kv.Getter, blockNum uint64) (*types.Header, error) + HeaderNumber(ctx context.Context, tx kv.Getter, hash common.Hash) (*uint64, error) + HeaderByHash(ctx context.Context, tx kv.Getter, hash common.Hash) (*types.Header, error) + ReadAncestor(db kv.Getter, hash common.Hash, number, ancestor uint64, maxNonCanonical *uint64) (common.Hash, uint64) + + // HeadersRange - TODO: change it to `stream` + HeadersRange(ctx context.Context, walker func(header *types.Header) error) error + Integrity(ctx context.Context) error +} + +type BodyReader interface { + BodyWithTransactions(ctx context.Context, tx kv.Getter, hash common.Hash, blockNum uint64) (body *types.Body, err error) + BodyRlp(ctx context.Context, tx kv.Getter, hash common.Hash, blockNum uint64) (bodyRlp rlp.RawValue, err error) + Body(ctx context.Context, tx kv.Getter, hash common.Hash, blockNum uint64) (body *types.Body, txCount uint32, err error) + CanonicalBodyForStorage(ctx context.Context, tx kv.Getter, blockNum uint64) (body *types.BodyForStorage, err error) + HasSenders(ctx context.Context, tx kv.Getter, hash common.Hash, blockNum uint64) (bool, error) +} + +type HeaderAndBodyReader interface { + BlockReader + BodyReader + HeaderReader +} diff --git a/erigon-db/rawdb/write_genesis.go b/erigon-db/rawdb/write_genesis.go new file mode 100644 index 00000000000..f3422ac7149 --- /dev/null +++ b/erigon-db/rawdb/write_genesis.go @@ -0,0 +1,183 @@ +// Copyright 2018 The go-ethereum Authors +// (original work) +// Copyright 2024 The Erigon Authors +// (modifications) +// This file is part of Erigon. +// +// Erigon is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Erigon is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with Erigon. If not, see . + +package rawdb + +import ( + "context" + "encoding/json" + "fmt" + "math/big" + + "github.com/erigontech/erigon-lib/chain" + "github.com/erigontech/erigon-lib/chain/params" + "github.com/erigontech/erigon-lib/common" + "github.com/erigontech/erigon-lib/common/empty" + "github.com/erigontech/erigon-lib/kv" + "github.com/erigontech/erigon-lib/kv/rawdbv3" + "github.com/erigontech/erigon-lib/types" +) + +// GenesisWithoutStateToBlock creates the genesis block, assuming an empty state. +func GenesisWithoutStateToBlock(g *types.Genesis) (head *types.Header, withdrawals []*types.Withdrawal) { + head = &types.Header{ + Number: new(big.Int).SetUint64(g.Number), + Nonce: types.EncodeNonce(g.Nonce), + Time: g.Timestamp, + ParentHash: g.ParentHash, + Extra: g.ExtraData, + GasLimit: g.GasLimit, + GasUsed: g.GasUsed, + Difficulty: g.Difficulty, + MixDigest: g.Mixhash, + Coinbase: g.Coinbase, + BaseFee: g.BaseFee, + BlobGasUsed: g.BlobGasUsed, + ExcessBlobGas: g.ExcessBlobGas, + RequestsHash: g.RequestsHash, + Root: empty.RootHash, + } + if g.AuRaSeal != nil && len(g.AuRaSeal.AuthorityRound.Signature) > 0 { + head.AuRaSeal = g.AuRaSeal.AuthorityRound.Signature + head.AuRaStep = uint64(g.AuRaSeal.AuthorityRound.Step) + } + if g.GasLimit == 0 { + head.GasLimit = params.GenesisGasLimit + } + if g.Difficulty == nil { + head.Difficulty = params.GenesisDifficulty + } + if g.Config != nil && g.Config.IsLondon(0) { + if g.BaseFee != nil { + head.BaseFee = g.BaseFee + } else { + head.BaseFee = new(big.Int).SetUint64(params.InitialBaseFee) + } + } + + withdrawals = nil + if g.Config != nil && g.Config.IsShanghai(g.Timestamp) { + withdrawals = []*types.Withdrawal{} + } + + if g.Config != nil && g.Config.IsCancun(g.Timestamp) { + if g.BlobGasUsed != nil { + head.BlobGasUsed = g.BlobGasUsed + } else { + head.BlobGasUsed = new(uint64) + } + if g.ExcessBlobGas != nil { + head.ExcessBlobGas = g.ExcessBlobGas + } else { + head.ExcessBlobGas = new(uint64) + } + if g.ParentBeaconBlockRoot != nil { + head.ParentBeaconBlockRoot = g.ParentBeaconBlockRoot + } else { + head.ParentBeaconBlockRoot = &common.Hash{} + } + } + + if g.Config != nil && g.Config.IsPrague(g.Timestamp) { + if g.RequestsHash != nil { + head.RequestsHash = g.RequestsHash + } else { + head.RequestsHash = &empty.RequestsHash + } + } + + return +} + +// WriteChainConfig writes the chain config settings to the database. +func WriteChainConfig(db kv.Putter, hash common.Hash, cfg *chain.Config) error { + if cfg == nil { + return nil + } + + if cfg.Bor != nil { + borJSON, err := json.Marshal(cfg.Bor) + if err != nil { + return fmt.Errorf("failed to JSON encode chain config 'bor': %w", err) + } + cfg.BorJSON = borJSON + } + + data, err := json.Marshal(cfg) + if err != nil { + return fmt.Errorf("failed to JSON encode chain config: %w", err) + } + + if err := db.Put(kv.ConfigTable, hash[:], data); err != nil { + return fmt.Errorf("failed to store chain config: %w", err) + } + return nil +} + +// Write writes the block a genesis specification to the database. +// The block is committed as the canonical head block. +func WriteGenesisBesideState(block *types.Block, tx kv.RwTx, g *types.Genesis) error { + config := g.Config + if config == nil { + config = chain.AllProtocolChanges + } + if err := config.CheckConfigForkOrder(); err != nil { + return err + } + + if err := WriteBlock(tx, block); err != nil { + return err + } + if err := WriteTd(tx, block.Hash(), block.NumberU64(), g.Difficulty); err != nil { + return err + } + if err := rawdbv3.TxNums.Append(tx, 0, uint64(block.Transactions().Len()+1)); err != nil { + return err + } + + if err := WriteCanonicalHash(tx, block.Hash(), block.NumberU64()); err != nil { + return err + } + + WriteHeadBlockHash(tx, block.Hash()) + if err := WriteHeadHeaderHash(tx, block.Hash()); err != nil { + return err + } + return WriteChainConfig(tx, block.Hash(), config) +} + +func MustCommitGenesisWithoutState(g *types.Genesis, db kv.RwDB) *types.Block { + tx, err := db.BeginRw(context.Background()) + if err != nil { + panic(err) + } + defer tx.Rollback() + + header, withdrawals := GenesisWithoutStateToBlock(g) + block := types.NewBlock(header, nil, nil, nil, withdrawals) + err = WriteGenesisBesideState(block, tx, g) + if err != nil { + panic(err) + } + err = tx.Commit() + if err != nil { + panic(err) + } + return block +} diff --git a/core/snaptype/block_types.go b/erigon-db/snaptype/block_types.go similarity index 100% rename from core/snaptype/block_types.go rename to erigon-db/snaptype/block_types.go diff --git a/core/snaptype/block_types_test.go b/erigon-db/snaptype/block_types_test.go similarity index 97% rename from core/snaptype/block_types_test.go rename to erigon-db/snaptype/block_types_test.go index a6508b66682..4e0a7841d42 100644 --- a/core/snaptype/block_types_test.go +++ b/erigon-db/snaptype/block_types_test.go @@ -19,7 +19,7 @@ package snaptype_test import ( "testing" - "github.com/erigontech/erigon/core/snaptype" + "github.com/erigontech/erigon-db/snaptype" ) func TestEnumeration(t *testing.T) { diff --git a/core/snaptype/headers_freezer.go b/erigon-db/snaptype/headers_freezer.go similarity index 100% rename from core/snaptype/headers_freezer.go rename to erigon-db/snaptype/headers_freezer.go diff --git a/erigon-lib/.golangci.yml b/erigon-lib/.golangci.yml index 898f5eedb44..ab56cd0c6fc 100644 --- a/erigon-lib/.golangci.yml +++ b/erigon-lib/.golangci.yml @@ -144,10 +144,6 @@ linters: - gocritic - gosec path: metrics/sample\.go - - linters: - - gocritic - - gosec - path: p2p/simulations paths: - third_party$ - builtin$ diff --git a/erigon-lib/chain/chain_config.go b/erigon-lib/chain/chain_config.go index 803597ac276..356b943c300 100644 --- a/erigon-lib/chain/chain_config.go +++ b/erigon-lib/chain/chain_config.go @@ -127,6 +127,31 @@ var ( LondonBlock: big.NewInt(0), Aura: &AuRaConfig{}, } + + // AllProtocolChanges contains every protocol change (EIPs) introduced + // and accepted by the Ethereum core developers into the main net protocol. + AllProtocolChanges = &Config{ + ChainID: big.NewInt(1337), + Consensus: EtHashConsensus, + HomesteadBlock: big.NewInt(0), + TangerineWhistleBlock: big.NewInt(0), + SpuriousDragonBlock: big.NewInt(0), + ByzantiumBlock: big.NewInt(0), + ConstantinopleBlock: big.NewInt(0), + PetersburgBlock: big.NewInt(0), + IstanbulBlock: big.NewInt(0), + MuirGlacierBlock: big.NewInt(0), + BerlinBlock: big.NewInt(0), + LondonBlock: big.NewInt(0), + ArrowGlacierBlock: big.NewInt(0), + GrayGlacierBlock: big.NewInt(0), + TerminalTotalDifficulty: big.NewInt(0), + TerminalTotalDifficultyPassed: true, + ShanghaiTime: big.NewInt(0), + CancunTime: big.NewInt(0), + PragueTime: big.NewInt(0), + Ethash: new(EthashConfig), + } ) type BlobConfig struct { diff --git a/turbo/testlog/testlog.go b/erigon-lib/testlog/testlog.go similarity index 99% rename from turbo/testlog/testlog.go rename to erigon-lib/testlog/testlog.go index 3fcc6ca79db..5d1efd16d39 100644 --- a/turbo/testlog/testlog.go +++ b/erigon-lib/testlog/testlog.go @@ -29,6 +29,7 @@ import ( // Handler returns a log handler which logs to the unit test log of t. func Handler(t *testing.T, level log.Lvl) log.Handler { + t.Helper() return log.LvlFilterHandler(level, &handler{t, log.TerminalFormat()}) } @@ -65,6 +66,8 @@ func (h *bufHandler) Log(r *log.Record) error { // Logger returns a logger which logs to the unit test log of t. func Logger(t *testing.T, level log.Lvl) log.Logger { + t.Helper() + l := &logger{ t: t, log: log.New(), diff --git a/eth/backend.go b/eth/backend.go index b5615d13320..153a462246a 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -48,6 +48,7 @@ import ( "github.com/erigontech/erigon-db/rawdb" "github.com/erigontech/erigon-db/rawdb/blockio" + snaptype2 "github.com/erigontech/erigon-db/snaptype" "github.com/erigontech/erigon-lib/chain" "github.com/erigontech/erigon-lib/chain/networkname" "github.com/erigontech/erigon-lib/chain/snapcfg" @@ -85,13 +86,16 @@ import ( libstate "github.com/erigontech/erigon-lib/state" "github.com/erigontech/erigon-lib/types" "github.com/erigontech/erigon-lib/wrap" + p2p "github.com/erigontech/erigon-p2p" + "github.com/erigontech/erigon-p2p/enode" + "github.com/erigontech/erigon-p2p/protocols/eth" + "github.com/erigontech/erigon-p2p/sentry" "github.com/erigontech/erigon/cl/clparams" "github.com/erigontech/erigon/cl/persistence/format/snapshot_format/getters" executionclient "github.com/erigontech/erigon/cl/phase1/execution_client" "github.com/erigontech/erigon/cmd/caplin/caplin1" rpcdaemoncli "github.com/erigontech/erigon/cmd/rpcdaemon/cli" "github.com/erigontech/erigon/core" - snaptype2 "github.com/erigontech/erigon/core/snaptype" "github.com/erigontech/erigon/core/vm" "github.com/erigontech/erigon/eth/consensuschain" "github.com/erigontech/erigon/eth/ethconfig" @@ -107,13 +111,9 @@ import ( "github.com/erigontech/erigon/execution/consensus/merge" "github.com/erigontech/erigon/execution/eth1" "github.com/erigontech/erigon/execution/eth1/eth1_chain_reader" + "github.com/erigontech/erigon/execution/sentry_multi_client" "github.com/erigontech/erigon/node" "github.com/erigontech/erigon/node/nodecfg" - "github.com/erigontech/erigon/p2p" - "github.com/erigontech/erigon/p2p/enode" - "github.com/erigontech/erigon/p2p/protocols/eth" - "github.com/erigontech/erigon/p2p/sentry" - "github.com/erigontech/erigon/p2p/sentry/sentry_multi_client" "github.com/erigontech/erigon/params" "github.com/erigontech/erigon/polygon/bor" "github.com/erigontech/erigon/polygon/bor/borcfg" @@ -492,6 +492,8 @@ func New(ctx context.Context, stack *node.Node, config *ethconfig.Config, logger return res } + p2pConfig.LookupBootnodeURLs = params.BootnodeURLsByGenesisHash + p2pConfig.LookupDNSNetwork = params.KnownDNSNetwork p2pConfig.DiscoveryDNS = backend.config.EthDiscoveryURLs listenHost, listenPort, err := splitAddrIntoHostAndPort(p2pConfig.ListenAddr) diff --git a/eth/stagedsync/exec3.go b/eth/stagedsync/exec3.go index 5b43902764c..68f6b93cb0a 100644 --- a/eth/stagedsync/exec3.go +++ b/eth/stagedsync/exec3.go @@ -27,6 +27,7 @@ import ( "sync/atomic" "time" + "github.com/erigontech/erigon-db/interfaces" "github.com/erigontech/erigon-db/rawdb" "github.com/erigontech/erigon-db/rawdb/rawdbhelpers" "github.com/erigontech/erigon-db/rawdb/rawtemporaldb" @@ -48,7 +49,6 @@ import ( "github.com/erigontech/erigon/core/tracing" "github.com/erigontech/erigon/eth/ethconfig/estimate" "github.com/erigontech/erigon/eth/stagedsync/stages" - "github.com/erigontech/erigon/turbo/services" "github.com/erigontech/erigon/turbo/shards" "github.com/erigontech/erigon/turbo/snapshotsync/freezeblocks" ) @@ -966,7 +966,7 @@ func flushAndCheckCommitmentV3(ctx context.Context, header *types.Header, applyT } -func blockWithSenders(ctx context.Context, db kv.RoDB, tx kv.Tx, blockReader services.BlockReader, blockNum uint64) (b *types.Block, err error) { +func blockWithSenders(ctx context.Context, db kv.RoDB, tx kv.Tx, blockReader interfaces.BlockReader, blockNum uint64) (b *types.Block, err error) { if tx == nil { tx, err = db.BeginRo(ctx) if err != nil { diff --git a/eth/stagedsync/stage_polygon_sync.go b/eth/stagedsync/stage_polygon_sync.go index 405adc73728..b12ea9eab0e 100644 --- a/eth/stagedsync/stage_polygon_sync.go +++ b/eth/stagedsync/stage_polygon_sync.go @@ -39,9 +39,9 @@ import ( "github.com/erigontech/erigon-lib/log/v3" "github.com/erigontech/erigon-lib/rlp" "github.com/erigontech/erigon-lib/types" + "github.com/erigontech/erigon-p2p/sentry" "github.com/erigontech/erigon/eth/ethconfig" "github.com/erigontech/erigon/eth/stagedsync/stages" - "github.com/erigontech/erigon/p2p/sentry" "github.com/erigontech/erigon/polygon/bor/borcfg" "github.com/erigontech/erigon/polygon/bor/bordb" "github.com/erigontech/erigon/polygon/bridge" diff --git a/eth/stagedsync/stage_snapshots.go b/eth/stagedsync/stage_snapshots.go index 4e721b24a9f..7f1112a5246 100644 --- a/eth/stagedsync/stage_snapshots.go +++ b/eth/stagedsync/stage_snapshots.go @@ -38,6 +38,7 @@ import ( "github.com/anacrolix/torrent" "golang.org/x/sync/errgroup" + coresnaptype "github.com/erigontech/erigon-db/snaptype" "github.com/erigontech/erigon-lib/chain" "github.com/erigontech/erigon-lib/chain/snapcfg" "github.com/erigontech/erigon-lib/common/datadir" @@ -55,7 +56,6 @@ import ( "github.com/erigontech/erigon-lib/state" state2 "github.com/erigontech/erigon-lib/state" "github.com/erigontech/erigon-lib/state/stats" - coresnaptype "github.com/erigontech/erigon/core/snaptype" "github.com/erigontech/erigon/eth/ethconfig" "github.com/erigontech/erigon/eth/ethconfig/estimate" "github.com/erigontech/erigon/eth/rawdbreset" diff --git a/eth/stagedsync/stagedsynctest/harness.go b/eth/stagedsync/stagedsynctest/harness.go index f0739409f94..b9878c5c032 100644 --- a/eth/stagedsync/stagedsynctest/harness.go +++ b/eth/stagedsync/stagedsynctest/harness.go @@ -31,6 +31,7 @@ import ( "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" + "github.com/erigontech/erigon-db/interfaces" "github.com/erigontech/erigon-db/rawdb" "github.com/erigontech/erigon-lib/chain" "github.com/erigontech/erigon-lib/common" @@ -39,6 +40,7 @@ import ( "github.com/erigontech/erigon-lib/kv/memdb" "github.com/erigontech/erigon-lib/kv/order" "github.com/erigontech/erigon-lib/log/v3" + "github.com/erigontech/erigon-lib/testlog" "github.com/erigontech/erigon-lib/types" "github.com/erigontech/erigon-lib/wrap" "github.com/erigontech/erigon/core" @@ -51,9 +53,7 @@ import ( "github.com/erigontech/erigon/polygon/bor/valset" "github.com/erigontech/erigon/polygon/bridge" "github.com/erigontech/erigon/polygon/heimdall" - "github.com/erigontech/erigon/turbo/services" "github.com/erigontech/erigon/turbo/stages/mock" - "github.com/erigontech/erigon/turbo/testlog" ) func InitHarness(ctx context.Context, t *testing.T, cfg HarnessCfg) Harness { @@ -176,7 +176,7 @@ type Harness struct { borConsensusDB kv.RwDB chainConfig *chain.Config borConfig *borcfg.BorConfig - blockReader services.BlockReader + blockReader interfaces.BlockReader stateSyncStages []*stagedsync.Stage stateSync *stagedsync.Sync miningSyncStages []*stagedsync.Stage diff --git a/eth/tracers/tracers_test.go b/eth/tracers/tracers_test.go index 2cb77f3d19a..7553a5c1c8d 100644 --- a/eth/tracers/tracers_test.go +++ b/eth/tracers/tracers_test.go @@ -29,6 +29,7 @@ import ( "github.com/holiman/uint256" "github.com/stretchr/testify/require" + "github.com/erigontech/erigon-lib/chain" "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/common/hexutil" "github.com/erigontech/erigon-lib/crypto" @@ -36,13 +37,12 @@ import ( "github.com/erigontech/erigon/core" "github.com/erigontech/erigon/core/vm" "github.com/erigontech/erigon/core/vm/evmtypes" + "github.com/erigontech/erigon/eth/tracers" "github.com/erigontech/erigon/execution/consensus" - "github.com/erigontech/erigon/params" "github.com/erigontech/erigon/tests" "github.com/erigontech/erigon/turbo/stages/mock" // Force-load native and js packages, to trigger registration - "github.com/erigontech/erigon/eth/tracers" _ "github.com/erigontech/erigon/eth/tracers/js" _ "github.com/erigontech/erigon/eth/tracers/native" ) @@ -104,7 +104,7 @@ func TestPrestateTracerCreate2(t *testing.T) { tx, err := m.DB.BeginRw(m.Ctx) require.NoError(t, err) defer tx.Rollback() - rules := params.AllProtocolChanges.Rules(context.BlockNumber, context.Time) + rules := chain.AllProtocolChanges.Rules(context.BlockNumber, context.Time) statedb, _ := tests.MakePreState(rules, tx, alloc, context.BlockNumber) // Create the tracer, the EVM environment and run it @@ -112,7 +112,7 @@ func TestPrestateTracerCreate2(t *testing.T) { if err != nil { t.Fatalf("failed to prestate tracer: %v", err) } - evm := vm.NewEVM(context, txContext, statedb, params.AllProtocolChanges, vm.Config{Tracer: tracer.Hooks}) + evm := vm.NewEVM(context, txContext, statedb, chain.AllProtocolChanges, vm.Config{Tracer: tracer.Hooks}) msg, err := txn.AsMessage(*signer, nil, rules) if err != nil { diff --git a/ethstats/ethstats.go b/ethstats/ethstats.go index 909079594a3..015817e7a55 100644 --- a/ethstats/ethstats.go +++ b/ethstats/ethstats.go @@ -42,10 +42,10 @@ import ( "github.com/erigontech/erigon-lib/kv" "github.com/erigontech/erigon-lib/log/v3" "github.com/erigontech/erigon-lib/types" + "github.com/erigontech/erigon-p2p/sentry" "github.com/erigontech/erigon/eth/stagedsync/stages" "github.com/erigontech/erigon/execution/consensus" "github.com/erigontech/erigon/node" - "github.com/erigontech/erigon/p2p/sentry" "github.com/erigontech/erigon/turbo/services" ) diff --git a/execution/abi/bind/backends/simulated.go b/execution/abi/bind/backends/simulated.go index cc934ccb9b9..4b47f91ded0 100644 --- a/execution/abi/bind/backends/simulated.go +++ b/execution/abi/bind/backends/simulated.go @@ -42,12 +42,12 @@ import ( "github.com/erigontech/erigon-lib/kv" "github.com/erigontech/erigon-lib/log/v3" "github.com/erigontech/erigon-lib/types" + "github.com/erigontech/erigon-p2p/event" "github.com/erigontech/erigon/core" "github.com/erigontech/erigon/core/state" "github.com/erigontech/erigon/core/tracing" "github.com/erigontech/erigon/core/vm" "github.com/erigontech/erigon/core/vm/evmtypes" - "github.com/erigontech/erigon/event" "github.com/erigontech/erigon/execution/abi/bind" "github.com/erigontech/erigon/execution/consensus" "github.com/erigontech/erigon/execution/consensus/ethash" diff --git a/execution/abi/bind/base.go b/execution/abi/bind/base.go index 4f48f2f7e57..72f9426fafd 100644 --- a/execution/abi/bind/base.go +++ b/execution/abi/bind/base.go @@ -32,7 +32,7 @@ import ( "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/crypto" "github.com/erigontech/erigon-lib/types" - "github.com/erigontech/erigon/event" + "github.com/erigontech/erigon-p2p/event" ) // SignerFn is a signer function callback when a contract requires a method to diff --git a/execution/abi/bind/template.go b/execution/abi/bind/template.go index 2151d9f3739..7d53613bc88 100644 --- a/execution/abi/bind/template.go +++ b/execution/abi/bind/template.go @@ -101,7 +101,7 @@ import ( "github.com/erigontech/erigon/execution/abi/bind" "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/types" - "github.com/erigontech/erigon/event" + "github.com/erigontech/erigon-p2p/event" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/execution/consensus/aura/auraabi/gen_block_reward.go b/execution/consensus/aura/auraabi/gen_block_reward.go index 7cfe82dcd11..9b9dfddc1ab 100644 --- a/execution/consensus/aura/auraabi/gen_block_reward.go +++ b/execution/consensus/aura/auraabi/gen_block_reward.go @@ -13,7 +13,7 @@ import ( "github.com/erigontech/erigon-lib/abi" "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/types" - "github.com/erigontech/erigon/event" + "github.com/erigontech/erigon-p2p/event" "github.com/erigontech/erigon/execution/abi/bind" ) diff --git a/execution/consensus/aura/auraabi/gen_validator_set.go b/execution/consensus/aura/auraabi/gen_validator_set.go index a02770fe84c..7f91575e78f 100644 --- a/execution/consensus/aura/auraabi/gen_validator_set.go +++ b/execution/consensus/aura/auraabi/gen_validator_set.go @@ -13,7 +13,7 @@ import ( "github.com/erigontech/erigon-lib/abi" "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/types" - "github.com/erigontech/erigon/event" + "github.com/erigontech/erigon-p2p/event" "github.com/erigontech/erigon/execution/abi/bind" ) diff --git a/execution/consensus/clique/snapshot_test.go b/execution/consensus/clique/snapshot_test.go index 1b9c2486da0..290f5d3ba68 100644 --- a/execution/consensus/clique/snapshot_test.go +++ b/execution/consensus/clique/snapshot_test.go @@ -33,13 +33,13 @@ import ( "github.com/erigontech/erigon-lib/kv" "github.com/erigontech/erigon-lib/kv/memdb" "github.com/erigontech/erigon-lib/log/v3" + "github.com/erigontech/erigon-lib/testlog" "github.com/erigontech/erigon-lib/types" "github.com/erigontech/erigon/core" "github.com/erigontech/erigon/eth/stagedsync" "github.com/erigontech/erigon/execution/consensus/clique" "github.com/erigontech/erigon/params" "github.com/erigontech/erigon/turbo/stages/mock" - "github.com/erigontech/erigon/turbo/testlog" ) // testerAccountPool is a pool to maintain currently active tester accounts, diff --git a/execution/consensus/ethash/sealer_test.go b/execution/consensus/ethash/sealer_test.go index 42e95b8f59a..ed2d510bc9c 100644 --- a/execution/consensus/ethash/sealer_test.go +++ b/execution/consensus/ethash/sealer_test.go @@ -32,9 +32,9 @@ import ( "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/log/v3" + "github.com/erigontech/erigon-lib/testlog" "github.com/erigontech/erigon-lib/types" "github.com/erigontech/erigon/execution/consensus/ethash/ethashcfg" - "github.com/erigontech/erigon/turbo/testlog" ) // Tests whether remote HTTP servers are correctly notified of new work. diff --git a/execution/exec3/historical_trace_worker.go b/execution/exec3/historical_trace_worker.go index 88e469d5b61..c65f55d9415 100644 --- a/execution/exec3/historical_trace_worker.go +++ b/execution/exec3/historical_trace_worker.go @@ -26,6 +26,7 @@ import ( "golang.org/x/sync/errgroup" + "github.com/erigontech/erigon-db/interfaces" "github.com/erigontech/erigon-lib/chain" "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/common/datadir" @@ -610,7 +611,7 @@ func CustomTraceMapReduce(fromBlock, toBlock uint64, consumer TraceConsumer, ctx return nil } -func blockWithSenders(ctx context.Context, db kv.RoDB, tx kv.Tx, blockReader services.BlockReader, blockNum uint64) (b *types.Block, err error) { +func blockWithSenders(ctx context.Context, db kv.RoDB, tx kv.Tx, blockReader interfaces.BlockReader, blockNum uint64) (b *types.Block, err error) { select { case <-ctx.Done(): return nil, ctx.Err() diff --git a/execution/exec3/trace_worker.go b/execution/exec3/trace_worker.go index 987990d8bd2..2d4e6d23cf8 100644 --- a/execution/exec3/trace_worker.go +++ b/execution/exec3/trace_worker.go @@ -19,6 +19,7 @@ package exec3 import ( "fmt" + "github.com/erigontech/erigon-db/interfaces" "github.com/erigontech/erigon-lib/chain" "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/kv" @@ -30,7 +31,6 @@ import ( "github.com/erigontech/erigon/core/vm/evmtypes" "github.com/erigontech/erigon/execution/consensus" "github.com/erigontech/erigon/polygon/aa" - "github.com/erigontech/erigon/turbo/services" "github.com/erigontech/erigon/turbo/transactions" ) @@ -47,7 +47,7 @@ type Resetable interface { type TraceWorker struct { stateReader *state.HistoryReaderV3 engine consensus.EngineReader - headerReader services.HeaderReader + headerReader interfaces.HeaderReader tx kv.Getter chainConfig *chain.Config tracer GenericTracer @@ -64,7 +64,7 @@ type TraceWorker struct { vmConfig *vm.Config } -func NewTraceWorker(tx kv.TemporalTx, cc *chain.Config, engine consensus.EngineReader, br services.HeaderReader, tracer GenericTracer) *TraceWorker { +func NewTraceWorker(tx kv.TemporalTx, cc *chain.Config, engine consensus.EngineReader, br interfaces.HeaderReader, tracer GenericTracer) *TraceWorker { stateReader := state.NewHistoryReaderV3() stateReader.SetTx(tx) diff --git a/p2p/sentry/sentry_multi_client/broadcast.go b/execution/sentry_multi_client/broadcast.go similarity index 97% rename from p2p/sentry/sentry_multi_client/broadcast.go rename to execution/sentry_multi_client/broadcast.go index 537e1bf2904..f477b2923b5 100644 --- a/p2p/sentry/sentry_multi_client/broadcast.go +++ b/execution/sentry_multi_client/broadcast.go @@ -29,8 +29,8 @@ import ( "github.com/erigontech/erigon-lib/log/v3" "github.com/erigontech/erigon-lib/rlp" "github.com/erigontech/erigon-lib/types" - "github.com/erigontech/erigon/p2p" - "github.com/erigontech/erigon/p2p/protocols/eth" + p2p "github.com/erigontech/erigon-p2p" + "github.com/erigontech/erigon-p2p/protocols/eth" "github.com/erigontech/erigon/turbo/stages/headerdownload" ) diff --git a/p2p/sentry/sentry_multi_client/sentry_api.go b/execution/sentry_multi_client/sentry_api.go similarity index 98% rename from p2p/sentry/sentry_multi_client/sentry_api.go rename to execution/sentry_multi_client/sentry_api.go index e4f79655c87..42d7bc053ee 100644 --- a/p2p/sentry/sentry_multi_client/sentry_api.go +++ b/execution/sentry_multi_client/sentry_api.go @@ -26,8 +26,8 @@ import ( "github.com/erigontech/erigon-lib/gointerfaces" proto_sentry "github.com/erigontech/erigon-lib/gointerfaces/sentryproto" "github.com/erigontech/erigon-lib/rlp" - "github.com/erigontech/erigon/p2p/protocols/eth" - "github.com/erigontech/erigon/p2p/sentry" + "github.com/erigontech/erigon-p2p/protocols/eth" + "github.com/erigontech/erigon-p2p/sentry" "github.com/erigontech/erigon/turbo/stages/bodydownload" "github.com/erigontech/erigon/turbo/stages/headerdownload" ) diff --git a/p2p/sentry/sentry_multi_client/sentry_multi_client.go b/execution/sentry_multi_client/sentry_multi_client.go similarity index 99% rename from p2p/sentry/sentry_multi_client/sentry_multi_client.go rename to execution/sentry_multi_client/sentry_multi_client.go index 79f4f9015fb..d0d0a76a9ad 100644 --- a/p2p/sentry/sentry_multi_client/sentry_multi_client.go +++ b/execution/sentry_multi_client/sentry_multi_client.go @@ -44,10 +44,10 @@ import ( libsentry "github.com/erigontech/erigon-lib/p2p/sentry" "github.com/erigontech/erigon-lib/rlp" "github.com/erigontech/erigon-lib/types" + "github.com/erigontech/erigon-p2p/protocols/eth" + "github.com/erigontech/erigon-p2p/sentry" "github.com/erigontech/erigon/eth/ethconfig" "github.com/erigontech/erigon/execution/consensus" - "github.com/erigontech/erigon/p2p/protocols/eth" - "github.com/erigontech/erigon/p2p/sentry" "github.com/erigontech/erigon/rpc/jsonrpc/receipts" "github.com/erigontech/erigon/turbo/services" "github.com/erigontech/erigon/turbo/stages/bodydownload" diff --git a/go.mod b/go.mod index a682a2624e7..a7134af0540 100644 --- a/go.mod +++ b/go.mod @@ -7,11 +7,13 @@ toolchain go1.23.6 replace ( github.com/erigontech/erigon-db => ./erigon-db github.com/erigontech/erigon-lib => ./erigon-lib + github.com/erigontech/erigon-p2p => ./p2p ) require ( github.com/erigontech/erigon-db v0.0.0-00010101000000-000000000000 github.com/erigontech/erigon-lib v0.0.0-00010101000000-000000000000 + github.com/erigontech/erigon-p2p v0.0.0-00010101000000-000000000000 ) replace ( @@ -41,7 +43,7 @@ require ( github.com/crate-crypto/go-kzg-4844 v1.1.0 github.com/davecgh/go-spew v1.1.1 github.com/deckarep/golang-set v1.8.0 - github.com/deckarep/golang-set/v2 v2.3.1 + github.com/deckarep/golang-set/v2 v2.8.0 github.com/dop251/goja v0.0.0-20220405120441-9037c2b61cbf github.com/edsrzf/mmap-go v1.2.0 github.com/emicklei/dot v1.6.2 @@ -65,11 +67,8 @@ require ( github.com/hashicorp/golang-lru/v2 v2.0.7 github.com/holiman/uint256 v1.3.2 github.com/huandu/xstrings v1.5.0 - github.com/huin/goupnp v1.3.0 - github.com/jackpal/go-nat-pmp v1.0.2 github.com/jedib0t/go-pretty/v6 v6.5.9 github.com/json-iterator/go v1.1.12 - github.com/julienschmidt/httprouter v1.3.0 github.com/klauspost/compress v1.18.0 github.com/libp2p/go-libp2p v0.37.2 github.com/libp2p/go-libp2p-mplex v0.9.0 @@ -80,7 +79,6 @@ require ( github.com/pelletier/go-toml v1.9.5 github.com/pelletier/go-toml/v2 v2.2.3 github.com/pion/randutil v0.1.0 - github.com/pion/stun v0.6.1 github.com/prysmaticlabs/go-bitfield v0.0.0-20240618144021-706c95b2dd15 github.com/prysmaticlabs/gohashtree v0.0.4-beta github.com/quasilyte/go-ruleguard/dsl v0.3.22 @@ -102,7 +100,6 @@ require ( golang.org/x/net v0.40.0 golang.org/x/sync v0.14.0 golang.org/x/sys v0.33.0 - golang.org/x/time v0.11.0 google.golang.org/grpc v1.72.1 google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.5.1 google.golang.org/protobuf v1.36.6 @@ -128,8 +125,11 @@ require ( github.com/google/uuid v1.6.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-retryablehttp v0.7.7 // indirect + github.com/huin/goupnp v1.3.0 // indirect + github.com/jackpal/go-nat-pmp v1.0.2 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/nyaosorg/go-windows-shortcut v0.0.0-20220529122037-8b0c89bca4c4 // indirect + github.com/pion/stun v0.6.1 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/protolambda/ztyp v0.2.2 // indirect github.com/shoenig/go-m1cpu v0.1.6 // indirect @@ -140,6 +140,7 @@ require ( github.com/yusufpapurcu/wmi v1.2.4 // indirect go.opentelemetry.io/auto/sdk v1.1.0 // indirect go.opentelemetry.io/otel/metric v1.34.0 // indirect + golang.org/x/time v0.11.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20250218202821-56aae31c358a // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a // indirect ) diff --git a/go.sum b/go.sum index 32fef37ea54..553e7f580cc 100644 --- a/go.sum +++ b/go.sum @@ -225,8 +225,8 @@ github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c h1:pFUpOrbxDR github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c/go.mod h1:6UhI8N9EjYm1c2odKpFpAYeR8dsBeM7PtzQhRgxRr9U= github.com/deckarep/golang-set v1.8.0 h1:sk9/l/KqpunDwP7pSjUg0keiOOLEnOBHzykLrsPppp4= github.com/deckarep/golang-set v1.8.0/go.mod h1:5nI87KwE7wgsBU1F4GKAw2Qod7p5kyS383rP6+o6qqo= -github.com/deckarep/golang-set/v2 v2.3.1 h1:vjmkvJt/IV27WXPyYQpAh4bRyWJc5Y435D17XQ9QU5A= -github.com/deckarep/golang-set/v2 v2.3.1/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4= +github.com/deckarep/golang-set/v2 v2.8.0 h1:swm0rlPCmdWn9mESxKOjWk8hXSqoxOp+ZlfuyaAdFlQ= +github.com/deckarep/golang-set/v2 v2.8.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4= github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y= github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 h1:rpfIENRNNilwHwZeG5+P150SMrnNEcHYvcCuK6dPZSg= @@ -514,8 +514,6 @@ github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/X github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= -github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U= -github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= diff --git a/node/migrations/prohibit_new_downloads2.go b/node/migrations/prohibit_new_downloads2.go index 5251e5d68b8..0c4aa045377 100644 --- a/node/migrations/prohibit_new_downloads2.go +++ b/node/migrations/prohibit_new_downloads2.go @@ -23,13 +23,13 @@ import ( "os" "path/filepath" + coresnaptype "github.com/erigontech/erigon-db/snaptype" "github.com/erigontech/erigon-lib/common/datadir" "github.com/erigontech/erigon-lib/common/dir" "github.com/erigontech/erigon-lib/downloader" "github.com/erigontech/erigon-lib/downloader/snaptype" "github.com/erigontech/erigon-lib/kv" "github.com/erigontech/erigon-lib/log/v3" - coresnaptype "github.com/erigontech/erigon/core/snaptype" "github.com/erigontech/erigon/polygon/heimdall" ) diff --git a/node/node_test.go b/node/node_test.go index 0e22c431684..da32c21d892 100644 --- a/node/node_test.go +++ b/node/node_test.go @@ -32,8 +32,8 @@ import ( "github.com/erigontech/erigon-lib/crypto" "github.com/erigontech/erigon-lib/kv" "github.com/erigontech/erigon-lib/log/v3" + p2p "github.com/erigontech/erigon-p2p" "github.com/erigontech/erigon/node/nodecfg" - "github.com/erigontech/erigon/p2p" ) var ( diff --git a/node/nodecfg/config.go b/node/nodecfg/config.go index 8ac0c78a8dd..6beefb40600 100644 --- a/node/nodecfg/config.go +++ b/node/nodecfg/config.go @@ -34,9 +34,9 @@ import ( "github.com/erigontech/erigon-lib/common/paths" "github.com/erigontech/erigon-lib/kv" "github.com/erigontech/erigon-lib/log/v3" + p2p "github.com/erigontech/erigon-p2p" + "github.com/erigontech/erigon-p2p/enode" "github.com/erigontech/erigon/cmd/rpcdaemon/cli/httpcfg" - "github.com/erigontech/erigon/p2p" - "github.com/erigontech/erigon/p2p/enode" "github.com/erigontech/erigon/rpc/rpccfg" ) diff --git a/node/nodecfg/defaults.go b/node/nodecfg/defaults.go index 7dcdf13c163..3c747a18b49 100644 --- a/node/nodecfg/defaults.go +++ b/node/nodecfg/defaults.go @@ -21,9 +21,8 @@ package nodecfg import ( "github.com/erigontech/erigon-lib/direct" - - "github.com/erigontech/erigon/p2p" - "github.com/erigontech/erigon/p2p/nat" + p2p "github.com/erigontech/erigon-p2p" + "github.com/erigontech/erigon-p2p/nat" "github.com/erigontech/erigon/rpc/rpccfg" ) diff --git a/node/rpcstack_test.go b/node/rpcstack_test.go index d7561431cc2..7aa359b030d 100644 --- a/node/rpcstack_test.go +++ b/node/rpcstack_test.go @@ -35,9 +35,9 @@ import ( "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/log/v3" + "github.com/erigontech/erigon-lib/testlog" "github.com/erigontech/erigon/rpc" "github.com/erigontech/erigon/rpc/rpccfg" - "github.com/erigontech/erigon/turbo/testlog" ) // TestCorsHandler makes sure CORS are properly handled on the http server. diff --git a/p2p/.gitignore b/p2p/.gitignore new file mode 100644 index 00000000000..73fd99b31b7 --- /dev/null +++ b/p2p/.gitignore @@ -0,0 +1,2 @@ +coverage-test.out +coverage-test-all.out diff --git a/p2p/Makefile b/p2p/Makefile new file mode 100644 index 00000000000..9e1295a595a --- /dev/null +++ b/p2p/Makefile @@ -0,0 +1,13 @@ +CGO_CXXFLAGS ?= $(shell go env CGO_CXXFLAGS 2>/dev/null) +ifeq ($(CGO_CXXFLAGS),) + CGO_CXXFLAGS += -g + CGO_CXXFLAGS += -O2 +endif + +GOTEST = CGO_CXXFLAGS="$(CGO_CXXFLAGS)" go test -trimpath + +test: + $(GOTEST) -short -coverprofile=coverage-test.out ./... + +test-all: + $(GOTEST) -coverprofile=coverage-test-all.out -race ./... diff --git a/p2p/bootnode_lookup.go b/p2p/bootnode_lookup.go new file mode 100644 index 00000000000..02bf8724776 --- /dev/null +++ b/p2p/bootnode_lookup.go @@ -0,0 +1,26 @@ +// Copyright 2025 The Erigon Authors +// This file is part of Erigon. +// +// Erigon is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Erigon is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with Erigon. If not, see . + +package p2p + +import "github.com/erigontech/erigon-lib/common" + +type LookupBootnodeURLsFunc func(genesis common.Hash) []string + +// LookupDNSNetwork returns the address of a public DNS-based node list for the given +// genesis hash and protocol. See https://github.com/ethereum/discv4-dns-lists for more +// information. +type LookupDNSNetworkFunc func(genesis common.Hash, protocol string) string diff --git a/p2p/dial.go b/p2p/dial.go index 7d5e223d35e..10db849d7b9 100644 --- a/p2p/dial.go +++ b/p2p/dial.go @@ -34,8 +34,8 @@ import ( "github.com/erigontech/erigon-lib/common/debug" "github.com/erigontech/erigon-lib/common/mclock" "github.com/erigontech/erigon-lib/log/v3" - "github.com/erigontech/erigon/p2p/enode" - "github.com/erigontech/erigon/p2p/netutil" + "github.com/erigontech/erigon-p2p/enode" + "github.com/erigontech/erigon-p2p/netutil" ) const ( diff --git a/p2p/dial_test.go b/p2p/dial_test.go index d136bb4332c..4b99167a93b 100644 --- a/p2p/dial_test.go +++ b/p2p/dial_test.go @@ -32,9 +32,9 @@ import ( "github.com/erigontech/erigon-lib/common/mclock" "github.com/erigontech/erigon-lib/log/v3" - "github.com/erigontech/erigon/p2p/enode" - "github.com/erigontech/erigon/p2p/netutil" - "github.com/erigontech/erigon/turbo/testlog" + "github.com/erigontech/erigon-lib/testlog" + "github.com/erigontech/erigon-p2p/enode" + "github.com/erigontech/erigon-p2p/netutil" ) // This test checks that dynamic dials are launched from discovery results. diff --git a/p2p/discover/common.go b/p2p/discover/common.go index f35584c3f39..1c4317ca9f7 100644 --- a/p2p/discover/common.go +++ b/p2p/discover/common.go @@ -28,9 +28,9 @@ import ( "github.com/erigontech/erigon-lib/common/mclock" "github.com/erigontech/erigon-lib/crypto" "github.com/erigontech/erigon-lib/log/v3" - "github.com/erigontech/erigon/p2p/enode" - "github.com/erigontech/erigon/p2p/enr" - "github.com/erigontech/erigon/p2p/netutil" + "github.com/erigontech/erigon-p2p/enode" + "github.com/erigontech/erigon-p2p/enr" + "github.com/erigontech/erigon-p2p/netutil" ) // UDPConn is a network connection on which discovery can operate. diff --git a/p2p/discover/lookup.go b/p2p/discover/lookup.go index fdc3d778cb9..81c6b60323d 100644 --- a/p2p/discover/lookup.go +++ b/p2p/discover/lookup.go @@ -23,7 +23,7 @@ import ( "context" "time" - "github.com/erigontech/erigon/p2p/enode" + "github.com/erigontech/erigon-p2p/enode" ) // lookup performs a network search for nodes close to the given target. It approaches the diff --git a/p2p/discover/lookup_util_test.go b/p2p/discover/lookup_util_test.go index d1fee935ec1..a462ac07a16 100644 --- a/p2p/discover/lookup_util_test.go +++ b/p2p/discover/lookup_util_test.go @@ -28,9 +28,9 @@ import ( "testing" "github.com/erigontech/erigon-lib/crypto" - "github.com/erigontech/erigon/p2p/discover/v4wire" - "github.com/erigontech/erigon/p2p/enode" - "github.com/erigontech/erigon/p2p/enr" + "github.com/erigontech/erigon-p2p/discover/v4wire" + "github.com/erigontech/erigon-p2p/enode" + "github.com/erigontech/erigon-p2p/enr" ) // This is the test network for the Lookup test. diff --git a/p2p/discover/node.go b/p2p/discover/node.go index fc2ba511e41..df840c568f8 100644 --- a/p2p/discover/node.go +++ b/p2p/discover/node.go @@ -23,7 +23,7 @@ import ( "net" "time" - "github.com/erigontech/erigon/p2p/enode" + "github.com/erigontech/erigon-p2p/enode" ) // node represents a host on the network. diff --git a/p2p/discover/table.go b/p2p/discover/table.go index 29e85a111c0..72ddbc9598b 100644 --- a/p2p/discover/table.go +++ b/p2p/discover/table.go @@ -37,11 +37,10 @@ import ( "time" "github.com/erigontech/erigon-lib/common" - "github.com/erigontech/erigon-lib/log/v3" - "github.com/erigontech/erigon-lib/common/debug" - "github.com/erigontech/erigon/p2p/enode" - "github.com/erigontech/erigon/p2p/netutil" + "github.com/erigontech/erigon-lib/log/v3" + "github.com/erigontech/erigon-p2p/enode" + "github.com/erigontech/erigon-p2p/netutil" ) const ( diff --git a/p2p/discover/table_test.go b/p2p/discover/table_test.go index a1ada36ef4d..97b8e72ba6f 100644 --- a/p2p/discover/table_test.go +++ b/p2p/discover/table_test.go @@ -30,9 +30,9 @@ import ( "github.com/erigontech/erigon-lib/crypto" "github.com/erigontech/erigon-lib/log/v3" - "github.com/erigontech/erigon/p2p/enode" - "github.com/erigontech/erigon/p2p/enr" - "github.com/erigontech/erigon/p2p/netutil" + "github.com/erigontech/erigon-p2p/enode" + "github.com/erigontech/erigon-p2p/enr" + "github.com/erigontech/erigon-p2p/netutil" ) func TestTable_pingReplace(t *testing.T) { diff --git a/p2p/discover/table_util_test.go b/p2p/discover/table_util_test.go index 002e79568dc..311b782e141 100644 --- a/p2p/discover/table_util_test.go +++ b/p2p/discover/table_util_test.go @@ -34,8 +34,8 @@ import ( "github.com/erigontech/erigon-lib/crypto" "github.com/erigontech/erigon-lib/log/v3" - "github.com/erigontech/erigon/p2p/enode" - "github.com/erigontech/erigon/p2p/enr" + "github.com/erigontech/erigon-p2p/enode" + "github.com/erigontech/erigon-p2p/enr" ) var nullNode *enode.Node diff --git a/p2p/discover/v4_lookup_test.go b/p2p/discover/v4_lookup_test.go index a38539d0d58..ab5a474ccfe 100644 --- a/p2p/discover/v4_lookup_test.go +++ b/p2p/discover/v4_lookup_test.go @@ -28,8 +28,8 @@ import ( "github.com/erigontech/erigon-lib/crypto" "github.com/erigontech/erigon-lib/log/v3" - "github.com/erigontech/erigon/p2p/discover/v4wire" - "github.com/erigontech/erigon/p2p/enode" + "github.com/erigontech/erigon-p2p/discover/v4wire" + "github.com/erigontech/erigon-p2p/enode" ) func TestUDPv4_Lookup(t *testing.T) { diff --git a/p2p/discover/v4_udp.go b/p2p/discover/v4_udp.go index 803d497afff..23ecb304aed 100644 --- a/p2p/discover/v4_udp.go +++ b/p2p/discover/v4_udp.go @@ -36,9 +36,9 @@ import ( "github.com/erigontech/erigon-lib/common/debug" "github.com/erigontech/erigon-lib/crypto" "github.com/erigontech/erigon-lib/log/v3" - "github.com/erigontech/erigon/p2p/discover/v4wire" - "github.com/erigontech/erigon/p2p/enode" - "github.com/erigontech/erigon/p2p/netutil" + "github.com/erigontech/erigon-p2p/discover/v4wire" + "github.com/erigontech/erigon-p2p/enode" + "github.com/erigontech/erigon-p2p/netutil" ) // Errors diff --git a/p2p/discover/v4_udp_test.go b/p2p/discover/v4_udp_test.go index 5c32873039c..cc89f06779c 100644 --- a/p2p/discover/v4_udp_test.go +++ b/p2p/discover/v4_udp_test.go @@ -35,10 +35,10 @@ import ( "time" "github.com/erigontech/erigon-lib/log/v3" - "github.com/erigontech/erigon/p2p/discover/v4wire" - "github.com/erigontech/erigon/p2p/enode" - "github.com/erigontech/erigon/p2p/enr" - "github.com/erigontech/erigon/turbo/testlog" + "github.com/erigontech/erigon-lib/testlog" + "github.com/erigontech/erigon-p2p/discover/v4wire" + "github.com/erigontech/erigon-p2p/enode" + "github.com/erigontech/erigon-p2p/enr" ) // shared test variables diff --git a/p2p/discover/v4wire/v4wire.go b/p2p/discover/v4wire/v4wire.go index 55d6cb2b41f..685ab83b5b6 100644 --- a/p2p/discover/v4wire/v4wire.go +++ b/p2p/discover/v4wire/v4wire.go @@ -33,7 +33,7 @@ import ( "github.com/erigontech/erigon-lib/common/math" "github.com/erigontech/erigon-lib/crypto" "github.com/erigontech/erigon-lib/rlp" - "github.com/erigontech/erigon/p2p/enr" + "github.com/erigontech/erigon-p2p/enr" ) // RPC packet types diff --git a/p2p/discover/v5_lookup_test.go b/p2p/discover/v5_lookup_test.go index 4db9bd97711..fe06c9355fc 100644 --- a/p2p/discover/v5_lookup_test.go +++ b/p2p/discover/v5_lookup_test.go @@ -24,8 +24,8 @@ import ( "testing" "github.com/erigontech/erigon-lib/log/v3" - "github.com/erigontech/erigon/p2p/discover/v5wire" - "github.com/erigontech/erigon/p2p/enode" + "github.com/erigontech/erigon-p2p/discover/v5wire" + "github.com/erigontech/erigon-p2p/enode" ) // This test checks that lookup works. diff --git a/p2p/discover/v5_udp.go b/p2p/discover/v5_udp.go index 78041cda899..e7d5d65cb15 100644 --- a/p2p/discover/v5_udp.go +++ b/p2p/discover/v5_udp.go @@ -37,10 +37,10 @@ import ( "github.com/erigontech/erigon-lib/common/debug" "github.com/erigontech/erigon-lib/common/mclock" - "github.com/erigontech/erigon/p2p/discover/v5wire" - "github.com/erigontech/erigon/p2p/enode" - "github.com/erigontech/erigon/p2p/enr" - "github.com/erigontech/erigon/p2p/netutil" + "github.com/erigontech/erigon-p2p/discover/v5wire" + "github.com/erigontech/erigon-p2p/enode" + "github.com/erigontech/erigon-p2p/enr" + "github.com/erigontech/erigon-p2p/netutil" ) const ( diff --git a/p2p/discover/v5_udp_integration_test.go b/p2p/discover/v5_udp_integration_test.go index d08576c20fa..20a3f502706 100644 --- a/p2p/discover/v5_udp_integration_test.go +++ b/p2p/discover/v5_udp_integration_test.go @@ -24,7 +24,7 @@ import ( "time" "github.com/erigontech/erigon-lib/log/v3" - "github.com/erigontech/erigon/p2p/discover/v5wire" + "github.com/erigontech/erigon-p2p/discover/v5wire" ) // This test checks that pending calls are re-sent when a handshake happens. diff --git a/p2p/discover/v5_udp_test.go b/p2p/discover/v5_udp_test.go index 595331c834e..dd15a92869a 100644 --- a/p2p/discover/v5_udp_test.go +++ b/p2p/discover/v5_udp_test.go @@ -33,12 +33,11 @@ import ( "time" "github.com/erigontech/erigon-lib/log/v3" - "github.com/erigontech/erigon/turbo/testlog" - "github.com/erigontech/erigon-lib/rlp" - "github.com/erigontech/erigon/p2p/discover/v5wire" - "github.com/erigontech/erigon/p2p/enode" - "github.com/erigontech/erigon/p2p/enr" + "github.com/erigontech/erigon-lib/testlog" + "github.com/erigontech/erigon-p2p/discover/v5wire" + "github.com/erigontech/erigon-p2p/enode" + "github.com/erigontech/erigon-p2p/enr" ) func startLocalhostV5(t *testing.T, cfg Config, logger log.Logger) *UDPv5 { diff --git a/p2p/discover/v5wire/crypto.go b/p2p/discover/v5wire/crypto.go index bed6c46d871..5e933ce0a9b 100644 --- a/p2p/discover/v5wire/crypto.go +++ b/p2p/discover/v5wire/crypto.go @@ -32,7 +32,7 @@ import ( "github.com/erigontech/erigon-lib/common/math" "github.com/erigontech/erigon-lib/crypto" - "github.com/erigontech/erigon/p2p/enode" + "github.com/erigontech/erigon-p2p/enode" ) const ( diff --git a/p2p/discover/v5wire/crypto_test.go b/p2p/discover/v5wire/crypto_test.go index ec459900ef2..a68aca6adef 100644 --- a/p2p/discover/v5wire/crypto_test.go +++ b/p2p/discover/v5wire/crypto_test.go @@ -31,7 +31,7 @@ import ( "github.com/erigontech/erigon-lib/common/hexutil" "github.com/erigontech/erigon-lib/crypto" "github.com/erigontech/erigon-lib/log/v3" - "github.com/erigontech/erigon/p2p/enode" + "github.com/erigontech/erigon-p2p/enode" ) func TestVector_ECDH(t *testing.T) { diff --git a/p2p/discover/v5wire/encoding.go b/p2p/discover/v5wire/encoding.go index 22adbfcb6fe..916e4d7503c 100644 --- a/p2p/discover/v5wire/encoding.go +++ b/p2p/discover/v5wire/encoding.go @@ -34,8 +34,8 @@ import ( "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/common/mclock" "github.com/erigontech/erigon-lib/rlp" - "github.com/erigontech/erigon/p2p/enode" - "github.com/erigontech/erigon/p2p/enr" + "github.com/erigontech/erigon-p2p/enode" + "github.com/erigontech/erigon-p2p/enr" ) // TODO concurrent WHOAREYOU tie-breaker diff --git a/p2p/discover/v5wire/encoding_test.go b/p2p/discover/v5wire/encoding_test.go index 68ba2598af2..c15584fb1b3 100644 --- a/p2p/discover/v5wire/encoding_test.go +++ b/p2p/discover/v5wire/encoding_test.go @@ -40,7 +40,7 @@ import ( "github.com/erigontech/erigon-lib/common/mclock" "github.com/erigontech/erigon-lib/crypto" "github.com/erigontech/erigon-lib/log/v3" - "github.com/erigontech/erigon/p2p/enode" + "github.com/erigontech/erigon-p2p/enode" ) // To regenerate discv5 test vectors, run diff --git a/p2p/discover/v5wire/msg.go b/p2p/discover/v5wire/msg.go index c20a5343c7c..89bdee59647 100644 --- a/p2p/discover/v5wire/msg.go +++ b/p2p/discover/v5wire/msg.go @@ -25,8 +25,8 @@ import ( "github.com/erigontech/erigon-lib/common/mclock" "github.com/erigontech/erigon-lib/rlp" - "github.com/erigontech/erigon/p2p/enode" - "github.com/erigontech/erigon/p2p/enr" + "github.com/erigontech/erigon-p2p/enode" + "github.com/erigontech/erigon-p2p/enr" ) // Packet is implemented by all message types. diff --git a/p2p/discover/v5wire/session.go b/p2p/discover/v5wire/session.go index b7fff118697..e75194c141f 100644 --- a/p2p/discover/v5wire/session.go +++ b/p2p/discover/v5wire/session.go @@ -29,7 +29,7 @@ import ( "github.com/erigontech/erigon-lib/common/mclock" "github.com/erigontech/erigon-lib/crypto" - "github.com/erigontech/erigon/p2p/enode" + "github.com/erigontech/erigon-p2p/enode" ) const handshakeTimeout = time.Second diff --git a/p2p/dnsdisc/client.go b/p2p/dnsdisc/client.go index 0431c481764..b19442e7d27 100644 --- a/p2p/dnsdisc/client.go +++ b/p2p/dnsdisc/client.go @@ -37,8 +37,8 @@ import ( "github.com/erigontech/erigon-lib/common/mclock" "github.com/erigontech/erigon-lib/crypto" "github.com/erigontech/erigon-lib/log/v3" - "github.com/erigontech/erigon/p2p/enode" - "github.com/erigontech/erigon/p2p/enr" + "github.com/erigontech/erigon-p2p/enode" + "github.com/erigontech/erigon-p2p/enr" ) // Client discovers nodes by querying DNS servers. diff --git a/p2p/dnsdisc/client_test.go b/p2p/dnsdisc/client_test.go index 697bb4f7fca..97edeb80311 100644 --- a/p2p/dnsdisc/client_test.go +++ b/p2p/dnsdisc/client_test.go @@ -33,9 +33,9 @@ import ( "github.com/erigontech/erigon-lib/common/mclock" "github.com/erigontech/erigon-lib/crypto" "github.com/erigontech/erigon-lib/log/v3" - "github.com/erigontech/erigon/p2p/enode" - "github.com/erigontech/erigon/p2p/enr" - "github.com/erigontech/erigon/turbo/testlog" + "github.com/erigontech/erigon-lib/testlog" + "github.com/erigontech/erigon-p2p/enode" + "github.com/erigontech/erigon-p2p/enr" ) var signingKeyForTesting, _ = crypto.ToECDSA(hexutil.MustDecode("0xdc599867fc513f8f5e2c2c9c489cde5e71362d1d9ec6e693e0de063236ed1240")) diff --git a/p2p/dnsdisc/sync.go b/p2p/dnsdisc/sync.go index a721c5527b7..de0306bb609 100644 --- a/p2p/dnsdisc/sync.go +++ b/p2p/dnsdisc/sync.go @@ -25,7 +25,7 @@ import ( "time" "github.com/erigontech/erigon-lib/common/mclock" - "github.com/erigontech/erigon/p2p/enode" + "github.com/erigontech/erigon-p2p/enode" ) // This is the number of consecutive leaf requests that may fail before diff --git a/p2p/dnsdisc/tree.go b/p2p/dnsdisc/tree.go index 9389da3965e..5769aed27f3 100644 --- a/p2p/dnsdisc/tree.go +++ b/p2p/dnsdisc/tree.go @@ -34,8 +34,8 @@ import ( "github.com/erigontech/erigon-lib/crypto" "github.com/erigontech/erigon-lib/rlp" - "github.com/erigontech/erigon/p2p/enode" - "github.com/erigontech/erigon/p2p/enr" + "github.com/erigontech/erigon-p2p/enode" + "github.com/erigontech/erigon-p2p/enr" ) // Tree is a merkle tree of node records. diff --git a/p2p/dnsdisc/tree_test.go b/p2p/dnsdisc/tree_test.go index b81a0f33295..97774b6e34a 100644 --- a/p2p/dnsdisc/tree_test.go +++ b/p2p/dnsdisc/tree_test.go @@ -26,8 +26,7 @@ import ( "github.com/davecgh/go-spew/spew" "github.com/erigontech/erigon-lib/common/hexutil" - - "github.com/erigontech/erigon/p2p/enode" + "github.com/erigontech/erigon-p2p/enode" ) func TestParseRoot(t *testing.T) { diff --git a/p2p/enode/idscheme.go b/p2p/enode/idscheme.go index 6c53341305c..b360e04522d 100644 --- a/p2p/enode/idscheme.go +++ b/p2p/enode/idscheme.go @@ -28,8 +28,8 @@ import ( "github.com/erigontech/erigon-lib/crypto" "github.com/erigontech/erigon-lib/rlp" - "github.com/erigontech/erigon/p2p/discover/v4wire" - "github.com/erigontech/erigon/p2p/enr" + "github.com/erigontech/erigon-p2p/discover/v4wire" + "github.com/erigontech/erigon-p2p/enr" ) // List of known secure identity schemes. diff --git a/p2p/enode/idscheme_test.go b/p2p/enode/idscheme_test.go index 0e8ff17b57f..8b1ac26d2d1 100644 --- a/p2p/enode/idscheme_test.go +++ b/p2p/enode/idscheme_test.go @@ -31,7 +31,7 @@ import ( "github.com/erigontech/erigon-lib/crypto" "github.com/erigontech/erigon-lib/rlp" - "github.com/erigontech/erigon/p2p/enr" + "github.com/erigontech/erigon-p2p/enr" ) var ( diff --git a/p2p/enode/iter_test.go b/p2p/enode/iter_test.go index 7b02083add2..492c87563b9 100644 --- a/p2p/enode/iter_test.go +++ b/p2p/enode/iter_test.go @@ -26,7 +26,7 @@ import ( "testing" "time" - "github.com/erigontech/erigon/p2p/enr" + "github.com/erigontech/erigon-p2p/enr" ) func TestReadNodes(t *testing.T) { diff --git a/p2p/enode/localnode.go b/p2p/enode/localnode.go index 51bb52c13bc..d313e05ec36 100644 --- a/p2p/enode/localnode.go +++ b/p2p/enode/localnode.go @@ -30,8 +30,8 @@ import ( "time" "github.com/erigontech/erigon-lib/log/v3" - "github.com/erigontech/erigon/p2p/enr" - "github.com/erigontech/erigon/p2p/netutil" + "github.com/erigontech/erigon-p2p/enr" + "github.com/erigontech/erigon-p2p/netutil" ) const ( diff --git a/p2p/enode/localnode_test.go b/p2p/enode/localnode_test.go index 079eac85821..31ea154178f 100644 --- a/p2p/enode/localnode_test.go +++ b/p2p/enode/localnode_test.go @@ -29,7 +29,7 @@ import ( "github.com/erigontech/erigon-lib/crypto" "github.com/erigontech/erigon-lib/log/v3" - "github.com/erigontech/erigon/p2p/enr" + "github.com/erigontech/erigon-p2p/enr" ) func newLocalNodeForTesting(tmpDir string, logger log.Logger) (*LocalNode, *DB) { diff --git a/p2p/enode/node.go b/p2p/enode/node.go index c74a366ff3f..7d2b03f57ce 100644 --- a/p2p/enode/node.go +++ b/p2p/enode/node.go @@ -30,7 +30,7 @@ import ( "strings" "github.com/erigontech/erigon-lib/rlp" - "github.com/erigontech/erigon/p2p/enr" + "github.com/erigontech/erigon-p2p/enr" ) var errMissingPrefix = errors.New("missing 'enr:' prefix for base64-encoded record") @@ -82,6 +82,21 @@ func Parse(validSchemes enr.IdentityScheme, input string) (*Node, error) { return New(validSchemes, &r) } +func ParseNodesFromURLs(urls []string) ([]*Node, error) { + nodes := make([]*Node, 0, len(urls)) + for _, url := range urls { + if url == "" { + continue + } + n, err := Parse(ValidSchemes, url) + if err != nil { + return nil, fmt.Errorf("invalid node URL %s: %w", url, err) + } + nodes = append(nodes, n) + } + return nodes, nil +} + // ID returns the node identifier. func (n *Node) ID() ID { return n.id diff --git a/p2p/enode/node_test.go b/p2p/enode/node_test.go index 9ae2f0790a8..d1e726cb01d 100644 --- a/p2p/enode/node_test.go +++ b/p2p/enode/node_test.go @@ -30,7 +30,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/erigontech/erigon-lib/rlp" - "github.com/erigontech/erigon/p2p/enr" + "github.com/erigontech/erigon-p2p/enr" ) var pyRecord, _ = hex.DecodeString("f884b8407098ad865b00a582051940cb9cf36836572411a47278783077011599ed5cd16b76f2635f4e234738f30813a89eb9137e3e3df5266e3a1f11df72ecf1145ccb9c01826964827634826970847f00000189736563703235366b31a103ca634cae0d49acb401d8a4c6b6fe8c55b70d115bf400769cc1400f3258cd31388375647082765f") diff --git a/p2p/enode/urlv4.go b/p2p/enode/urlv4.go index a67a6a3c34a..273d7a1d161 100644 --- a/p2p/enode/urlv4.go +++ b/p2p/enode/urlv4.go @@ -30,7 +30,7 @@ import ( "strconv" "github.com/erigontech/erigon-lib/crypto" - "github.com/erigontech/erigon/p2p/enr" + "github.com/erigontech/erigon-p2p/enr" ) var ( diff --git a/p2p/enode/urlv4_test.go b/p2p/enode/urlv4_test.go index 1798ae59b1a..8272115dd2f 100644 --- a/p2p/enode/urlv4_test.go +++ b/p2p/enode/urlv4_test.go @@ -28,7 +28,7 @@ import ( "testing" "github.com/erigontech/erigon-lib/crypto" - "github.com/erigontech/erigon/p2p/enr" + "github.com/erigontech/erigon-p2p/enr" ) func init() { diff --git a/event/example_feed_test.go b/p2p/event/example_feed_test.go similarity index 97% rename from event/example_feed_test.go rename to p2p/event/example_feed_test.go index 6abc64247b2..fa327192fd2 100644 --- a/event/example_feed_test.go +++ b/p2p/event/example_feed_test.go @@ -22,7 +22,7 @@ package event_test import ( "fmt" - "github.com/erigontech/erigon/event" + "github.com/erigontech/erigon-p2p/event" ) func ExampleFeed_acknowledgedEvents() { diff --git a/event/example_scope_test.go b/p2p/event/example_scope_test.go similarity index 98% rename from event/example_scope_test.go rename to p2p/event/example_scope_test.go index 4df5168a9ed..f29bcc854a1 100644 --- a/event/example_scope_test.go +++ b/p2p/event/example_scope_test.go @@ -23,7 +23,7 @@ import ( "fmt" "sync" - "github.com/erigontech/erigon/event" + "github.com/erigontech/erigon-p2p/event" ) // This example demonstrates how SubscriptionScope can be used to control the lifetime of diff --git a/event/example_subscription_test.go b/p2p/event/example_subscription_test.go similarity index 97% rename from event/example_subscription_test.go rename to p2p/event/example_subscription_test.go index 331ecd9f255..6c6e87b5ba3 100644 --- a/event/example_subscription_test.go +++ b/p2p/event/example_subscription_test.go @@ -22,7 +22,7 @@ package event_test import ( "fmt" - "github.com/erigontech/erigon/event" + "github.com/erigontech/erigon-p2p/event" ) func ExampleNewSubscription() { diff --git a/event/feed.go b/p2p/event/feed.go similarity index 100% rename from event/feed.go rename to p2p/event/feed.go diff --git a/event/feed_test.go b/p2p/event/feed_test.go similarity index 100% rename from event/feed_test.go rename to p2p/event/feed_test.go diff --git a/event/subscription.go b/p2p/event/subscription.go similarity index 100% rename from event/subscription.go rename to p2p/event/subscription.go diff --git a/event/subscription_test.go b/p2p/event/subscription_test.go similarity index 100% rename from event/subscription_test.go rename to p2p/event/subscription_test.go diff --git a/p2p/forkid/forkid.go b/p2p/forkid/forkid.go index 598b16b2bb2..e9a1fb0076e 100644 --- a/p2p/forkid/forkid.go +++ b/p2p/forkid/forkid.go @@ -30,10 +30,9 @@ import ( "slices" "strings" + "github.com/erigontech/erigon-lib/chain" "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/log/v3" - - "github.com/erigontech/erigon-lib/chain" ) var ( @@ -68,7 +67,7 @@ func NewIDFromForks(heightForks, timeForks []uint64, genesis common.Hash, headHe hash = checksumUpdate(hash, fork) continue } - return ID{Hash: checksumToBytes(hash), Next: fork} + return ID{Hash: ChecksumToBytes(hash), Next: fork} } var next uint64 for _, fork := range timeForks { @@ -80,7 +79,7 @@ func NewIDFromForks(heightForks, timeForks []uint64, genesis common.Hash, headHe next = fork break } - return ID{Hash: checksumToBytes(hash), Next: next} + return ID{Hash: ChecksumToBytes(hash), Next: next} } func NextForkHashFromForks(heightForks, timeForks []uint64, genesis common.Hash, headHeight, headTime uint64) [4]byte { @@ -89,7 +88,7 @@ func NextForkHashFromForks(heightForks, timeForks []uint64, genesis common.Hash, return id.Hash } else { hash := binary.BigEndian.Uint32(id.Hash[:]) - return checksumToBytes(checksumUpdate(hash, id.Next)) + return ChecksumToBytes(checksumUpdate(hash, id.Next)) } } @@ -119,10 +118,10 @@ func newFilter(heightForks, timeForks []uint64, genesis common.Hash, headHeight, // Calculate the all the valid fork hash and fork next combos sums := make([][4]byte, len(forks)+1) // 0th is the genesis hash := crc32.ChecksumIEEE(genesis[:]) - sums[0] = checksumToBytes(hash) + sums[0] = ChecksumToBytes(hash) for i, fork := range forks { hash = checksumUpdate(hash, fork) - sums[i+1] = checksumToBytes(hash) + sums[i+1] = ChecksumToBytes(hash) } // Add two sentries to simplify the fork checks and don't require special // casing the last one. @@ -203,8 +202,8 @@ func checksumUpdate(hash uint32, fork uint64) uint32 { return crc32.Update(hash, crc32.IEEETable, blob[:]) } -// checksumToBytes converts a uint32 checksum into a [4]byte array. -func checksumToBytes(hash uint32) [4]byte { +// ChecksumToBytes converts a uint32 checksum into a [4]byte array. +func ChecksumToBytes(hash uint32) [4]byte { var blob [4]byte binary.BigEndian.PutUint32(blob[:], hash) return blob diff --git a/p2p/forkid/forkid_test.go b/p2p/forkid/forkid_test.go index edd6e579b9c..122e19060bf 100644 --- a/p2p/forkid/forkid_test.go +++ b/p2p/forkid/forkid_test.go @@ -24,187 +24,11 @@ import ( "math" "testing" - "github.com/erigontech/erigon-lib/chain" "github.com/erigontech/erigon-lib/common" - "github.com/erigontech/erigon-lib/rlp" - "github.com/erigontech/erigon/params" + "github.com/erigontech/erigon-p2p/testutil" ) -// TestCreation tests that different genesis and fork rule combinations result in -// the correct fork ID. -// Forks before Shanghai are triggered by the block number, -// while Shanghai and later forks are triggered by the block time. -func TestCreation(t *testing.T) { - t.Parallel() - type testcase struct { - head uint64 - time uint64 - want ID - } - tests := []struct { - config *chain.Config - genesis common.Hash - cases []testcase - }{ - // Mainnet test cases - { - params.MainnetChainConfig, - params.MainnetGenesisHash, - []testcase{ - {0, 0, ID{Hash: checksumToBytes(0xfc64ec04), Next: 1150000}}, // Unsynced - {1149999, 1457981342, ID{Hash: checksumToBytes(0xfc64ec04), Next: 1150000}}, // Last Frontier block - {1150000, 1457981393, ID{Hash: checksumToBytes(0x97c2c34c), Next: 1920000}}, // First Homestead block - {1919999, 1469020838, ID{Hash: checksumToBytes(0x97c2c34c), Next: 1920000}}, // Last Homestead block - {1920000, 1469020840, ID{Hash: checksumToBytes(0x91d1f948), Next: 2463000}}, // First DAO block - {2462999, 1476796747, ID{Hash: checksumToBytes(0x91d1f948), Next: 2463000}}, // Last DAO block - {2463000, 1476796771, ID{Hash: checksumToBytes(0x7a64da13), Next: 2675000}}, // First Tangerine block - {2674999, 1479831337, ID{Hash: checksumToBytes(0x7a64da13), Next: 2675000}}, // Last Tangerine block - {2675000, 1479831344, ID{Hash: checksumToBytes(0x3edd5b10), Next: 4370000}}, // First Spurious block - {4369999, 1508131303, ID{Hash: checksumToBytes(0x3edd5b10), Next: 4370000}}, // Last Spurious block - {4370000, 1508131331, ID{Hash: checksumToBytes(0xa00bc324), Next: 7280000}}, // First Byzantium block - {7279999, 1551383501, ID{Hash: checksumToBytes(0xa00bc324), Next: 7280000}}, // Last Byzantium block - {7280000, 1551383524, ID{Hash: checksumToBytes(0x668db0af), Next: 9069000}}, // First and last Constantinople, first Petersburg block - {9068999, 1575764708, ID{Hash: checksumToBytes(0x668db0af), Next: 9069000}}, // Last Petersburg block - {9069000, 1575764709, ID{Hash: checksumToBytes(0x879d6e30), Next: 9200000}}, // First Istanbul block - {9199999, 1577953806, ID{Hash: checksumToBytes(0x879d6e30), Next: 9200000}}, // Last Istanbul block - {9200000, 1577953849, ID{Hash: checksumToBytes(0xe029e991), Next: 12244000}}, // First Muir Glacier block - {12243999, 1618481214, ID{Hash: checksumToBytes(0xe029e991), Next: 12244000}}, // Last Muir Glacier block - {12244000, 1618481223, ID{Hash: checksumToBytes(0x0eb440f6), Next: 12965000}}, // First Berlin block - {12964999, 1628166812, ID{Hash: checksumToBytes(0x0eb440f6), Next: 12965000}}, // Last Berlin block - {12965000, 1628166822, ID{Hash: checksumToBytes(0xb715077d), Next: 13773000}}, // First London block - {13772999, 1639079715, ID{Hash: checksumToBytes(0xb715077d), Next: 13773000}}, // Last London block - {13773000, 1639079723, ID{Hash: checksumToBytes(0x20c327fc), Next: 15050000}}, // First Arrow Glacier block - {15049999, 1656586434, ID{Hash: checksumToBytes(0x20c327fc), Next: 15050000}}, // Last Arrow Glacier block - {15050000, 1656586444, ID{Hash: checksumToBytes(0xf0afd0e3), Next: 1681338455}}, // First Gray Glacier block - {17034869, 1681338443, ID{Hash: checksumToBytes(0xf0afd0e3), Next: 1681338455}}, // Last pre-Shanghai block - {17034870, 1681338479, ID{Hash: checksumToBytes(0xdce96c2d), Next: 1710338135}}, // First Shanghai block - {19426586, 1710338123, ID{Hash: checksumToBytes(0xdce96c2d), Next: 1710338135}}, // Last Shanghai block - {19426587, 1710338135, ID{Hash: checksumToBytes(0x9f3d2254), Next: 1746612311}}, // First Cancun block - {22432453, 1746612299, ID{Hash: checksumToBytes(0x9f3d2254), Next: 1746612311}}, // Last Cancun block (approx.) - {22432454, 1746612311, ID{Hash: checksumToBytes(0xc376cf8b), Next: 0}}, // First Prague block (approx.) - {30000000, 1900000000, ID{Hash: checksumToBytes(0xc376cf8b), Next: 0}}, // Future Prague block (mock) - }, - }, - // Sepolia test cases - { - params.SepoliaChainConfig, - params.SepoliaGenesisHash, - []testcase{ - {0, 1633267481, ID{Hash: checksumToBytes(0xfe3366e7), Next: 1735371}}, // Unsynced, last Frontier, Homestead, Tangerine, Spurious, Byzantium, Constantinople, Petersburg, Istanbul, Berlin and first London block - {1735370, 1661130096, ID{Hash: checksumToBytes(0xfe3366e7), Next: 1735371}}, // Last pre-MergeNetsplit block - {1735371, 1661130108, ID{Hash: checksumToBytes(0xb96cbd13), Next: 1677557088}}, // First MergeNetsplit block - {2990907, 1677557076, ID{Hash: checksumToBytes(0xb96cbd13), Next: 1677557088}}, // Last pre-Shanghai block - {2990908, 1677557088, ID{Hash: checksumToBytes(0xf7f9bc08), Next: 1706655072}}, // First Shanghai block - {5187022, 1706655060, ID{Hash: checksumToBytes(0xf7f9bc08), Next: 1706655072}}, // Last Shanghai block - {5187023, 1706655072, ID{Hash: checksumToBytes(0x88cf81d9), Next: 1741159776}}, // First Cancun block - {7844466, 1741159764, ID{Hash: checksumToBytes(0x88cf81d9), Next: 1741159776}}, // Last Cancun block (approx) - {7844467, 1741159776, ID{Hash: checksumToBytes(0xed88b5fd), Next: 0}}, // First Prague block (approx) - {12000000, 1800000000, ID{Hash: checksumToBytes(0xed88b5fd), Next: 0}}, // Future Prague block (mock) - }, - }, - - // Holesky test cases - { - params.HoleskyChainConfig, - params.HoleskyGenesisHash, - []testcase{ - {0, 1696000704, ID{Hash: checksumToBytes(0xfd4f016b), Next: 1707305664}}, // First Shanghai block - {0, 1707305652, ID{Hash: checksumToBytes(0xfd4f016b), Next: 1707305664}}, // Last Shanghai block - {894733, 1707305676, ID{Hash: checksumToBytes(0x9b192ad0), Next: 1740434112}}, // First Cancun block - {3655435, 1740434100, ID{Hash: checksumToBytes(0x9b192ad0), Next: 1740434112}}, // Last Cancun block (approx) - {3655436, 1740434112, ID{Hash: checksumToBytes(0xdfbd9bed), Next: 0}}, // First Prague block (approx) - {8000000, 1800000000, ID{Hash: checksumToBytes(0xdfbd9bed), Next: 0}}, // Future Prague block (mock) - }, - }, - - // Hoodi test cases - { - params.HoodiChainConfig, - params.HoodiGenesisHash, - []testcase{ - {0, 174221200, ID{Hash: checksumToBytes(0xbef71d30), Next: 1742999832}}, // First Cancun block - {50000, 1742999820, ID{Hash: checksumToBytes(0xbef71d30), Next: 1742999832}}, // Last Cancun block (approx) - {50001, 1742999832, ID{Hash: checksumToBytes(0x0929e24e), Next: 0}}, // First Prague block (approx) - {8000000, 1800000000, ID{Hash: checksumToBytes(0x0929e24e), Next: 0}}, // Future Prague block (mock) - }, - }, - // Gnosis test cases - { - params.GnosisChainConfig, - params.GnosisGenesisHash, - []testcase{ - {0, 0, ID{Hash: checksumToBytes(0xf64909b1), Next: 1604400}}, // Unsynced, last Frontier, Homestead, Tangerine, Spurious, Byzantium - {1604399, 1547205885, ID{Hash: checksumToBytes(0xf64909b1), Next: 1604400}}, // Last Byzantium block - {1604400, 1547205890, ID{Hash: checksumToBytes(0xfde2d083), Next: 2508800}}, // First Constantinople block - {2508799, 1551879340, ID{Hash: checksumToBytes(0xfde2d083), Next: 2508800}}, // Last Constantinople block - {2508800, 1551879345, ID{Hash: checksumToBytes(0xfc1d8f2f), Next: 7298030}}, // First Petersburg block - {7298029, 1576134775, ID{Hash: checksumToBytes(0xfc1d8f2f), Next: 7298030}}, // Last Petersburg block - {7298030, 1576134780, ID{Hash: checksumToBytes(0x54d05e6c), Next: 9186425}}, // First Istanbul block - {9186424, 1585729685, ID{Hash: checksumToBytes(0x54d05e6c), Next: 9186425}}, // Last Istanbul block - {9186425, 1585729690, ID{Hash: checksumToBytes(0xb6e6cd81), Next: 16101500}}, // First POSDAO Activation block - {16101499, 1621258420, ID{Hash: checksumToBytes(0xb6e6cd81), Next: 16101500}}, // Last POSDAO Activation block - {16101500, 1621258425, ID{Hash: checksumToBytes(0x069a83d9), Next: 19040000}}, // First Berlin block - {19039999, 1636753575, ID{Hash: checksumToBytes(0x069a83d9), Next: 19040000}}, // Last Berlin block - {19040000, 1636753580, ID{Hash: checksumToBytes(0x018479d3), Next: 1690889660}}, // First London block - {21735000, 1650443255, ID{Hash: checksumToBytes(0x018479d3), Next: 1690889660}}, // First GIP-31 block - {29242931, 1690889650, ID{Hash: checksumToBytes(0x018479d3), Next: 1690889660}}, // Last pre-Shanghai block - {29242932, 1690889660, ID{Hash: checksumToBytes(0x2efe91ba), Next: 1710181820}}, // First Shanghai block - {32880679, 1710181810, ID{Hash: checksumToBytes(0x2efe91ba), Next: 1710181820}}, // Last Shanghai block - {32880680, 1710181820, ID{Hash: checksumToBytes(0x1384dfc1), Next: 1746021820}}, // First Cancun block - {39834364, 1746021815, ID{Hash: checksumToBytes(0x1384dfc1), Next: 1746021820}}, // Last Cancun block (approx) - {39834365, 1746021820, ID{Hash: checksumToBytes(0x2f095d4a), Next: 0}}, // First Prague block (approx) - {50000000, 1800000000, ID{Hash: checksumToBytes(0x2f095d4a), Next: 0}}, // Future Prague block (mock) - }, - }, - // Chiado test cases - { - params.ChiadoChainConfig, - params.ChiadoGenesisHash, - []testcase{ - {0, 0, ID{Hash: checksumToBytes(0x50d39d7b), Next: 1684934220}}, - {4100418, 1684934215, ID{Hash: checksumToBytes(0x50d39d7b), Next: 1684934220}}, // Last pre-Shanghai block - {4100419, 1684934220, ID{Hash: checksumToBytes(0xa15a4252), Next: 1706724940}}, // First Shanghai block - {8021277, 1706724930, ID{Hash: checksumToBytes(0xa15a4252), Next: 1706724940}}, // Last Shanghai block - {8021278, 1706724940, ID{Hash: checksumToBytes(0x5fbc16bc), Next: 1741254220}}, // First Cancun block - {14655798, 1741254215, ID{Hash: checksumToBytes(0x5fbc16bc), Next: 1741254220}}, // Last Cancun block (approx) - {14655799, 1741254220, ID{Hash: checksumToBytes(0x8ba51786), Next: 0}}, // First Prague block (approx) - {20000000, 1800000000, ID{Hash: checksumToBytes(0x8ba51786), Next: 0}}, // Future Prague block (mock) - }, - }, - // Amoy test cases - { - params.AmoyChainConfig, - params.AmoyGenesisHash, - []testcase{ - {0, 0, ID{Hash: checksumToBytes(0xbe06a477), Next: 73100}}, - {73100, 0, ID{Hash: checksumToBytes(0x135d2cd5), Next: 5423600}}, // First London, Jaipur, Delhi, Indore, Agra - }, - }, - // Bor mainnet test cases - { - params.BorMainnetChainConfig, - params.BorMainnetGenesisHash, - []testcase{ - {0, 0, ID{Hash: checksumToBytes(0x0e07e722), Next: 3395000}}, - {3395000, 0, ID{Hash: checksumToBytes(0x27806576), Next: 14750000}}, // First Istanbul block - {14750000, 0, ID{Hash: checksumToBytes(0x66e26adb), Next: 23850000}}, // First Berlin block - {23850000, 0, ID{Hash: checksumToBytes(0x4f2f71cc), Next: 50523000}}, // First London block - {50523000, 0, ID{Hash: checksumToBytes(0xdc08865c), Next: 54876000}}, // First Agra block - {54876000, 0, ID{Hash: checksumToBytes(0xf097bc13), Next: 0}}, // First Napoli block - }, - }, - } - for i, tt := range tests { - for j, ttt := range tt.cases { - heightForks, timeForks := GatherForks(tt.config, 0 /* genesisTime */) - if have := NewIDFromForks(heightForks, timeForks, tt.genesis, ttt.head, ttt.time); have != ttt.want { - t.Errorf("test %d, case %d: fork ID mismatch: have %x, want %x", i, j, have, ttt.want) - } - } - } -} - // TestValidation tests that a local peer correctly validates and accepts a remote // fork ID. func TestValidation(t *testing.T) { @@ -215,70 +39,70 @@ func TestValidation(t *testing.T) { err error }{ // Local is mainnet Petersburg, remote announces the same. No future fork is announced. - {7987396, ID{Hash: checksumToBytes(0x668db0af), Next: 0}, nil}, + {7987396, ID{Hash: ChecksumToBytes(0x668db0af), Next: 0}, nil}, // Local is mainnet Petersburg, remote announces the same. Remote also announces a next fork // at block 0xffffffff, but that is uncertain. - {7987396, ID{Hash: checksumToBytes(0x668db0af), Next: math.MaxUint64}, nil}, + {7987396, ID{Hash: ChecksumToBytes(0x668db0af), Next: math.MaxUint64}, nil}, // Local is mainnet currently in Byzantium only (so it's aware of Petersburg), remote announces // also Byzantium, but it's not yet aware of Petersburg (e.g. non updated node before the fork). // In this case we don't know if Petersburg passed yet or not. - {7279999, ID{Hash: checksumToBytes(0xa00bc324), Next: 0}, nil}, + {7279999, ID{Hash: ChecksumToBytes(0xa00bc324), Next: 0}, nil}, // Local is mainnet currently in Byzantium only (so it's aware of Petersburg), remote announces // also Byzantium, and it's also aware of Petersburg (e.g. updated node before the fork). We // don't know if Petersburg passed yet (will pass) or not. - {7279999, ID{Hash: checksumToBytes(0xa00bc324), Next: 7280000}, nil}, + {7279999, ID{Hash: ChecksumToBytes(0xa00bc324), Next: 7280000}, nil}, // Local is mainnet currently in Byzantium only (so it's aware of Petersburg), remote announces // also Byzantium, and it's also aware of some random fork (e.g. misconfigured Petersburg). As // neither forks passed at neither nodes, they may mismatch, but we still connect for now. - {7279999, ID{Hash: checksumToBytes(0xa00bc324), Next: math.MaxUint64}, nil}, + {7279999, ID{Hash: ChecksumToBytes(0xa00bc324), Next: math.MaxUint64}, nil}, // Local is mainnet Petersburg, remote announces Byzantium + knowledge about Petersburg. Remote // is simply out of sync, accept. - {7987396, ID{Hash: checksumToBytes(0xa00bc324), Next: 7280000}, nil}, + {7987396, ID{Hash: ChecksumToBytes(0xa00bc324), Next: 7280000}, nil}, // Local is mainnet Petersburg, remote announces Spurious + knowledge about Byzantium. Remote // is definitely out of sync. It may or may not need the Petersburg update, we don't know yet. - {7987396, ID{Hash: checksumToBytes(0x3edd5b10), Next: 4370000}, nil}, + {7987396, ID{Hash: ChecksumToBytes(0x3edd5b10), Next: 4370000}, nil}, // Local is mainnet Byzantium, remote announces Petersburg. Local is out of sync, accept. - {7279999, ID{Hash: checksumToBytes(0x668db0af), Next: 0}, nil}, + {7279999, ID{Hash: ChecksumToBytes(0x668db0af), Next: 0}, nil}, // Local is mainnet Spurious, remote announces Byzantium, but is not aware of Petersburg. Local // out of sync. Local also knows about a future fork, but that is uncertain yet. - {4369999, ID{Hash: checksumToBytes(0xa00bc324), Next: 0}, nil}, + {4369999, ID{Hash: ChecksumToBytes(0xa00bc324), Next: 0}, nil}, // Local is mainnet Petersburg. remote announces Byzantium but is not aware of further forks. // Remote needs software update. - {7987396, ID{Hash: checksumToBytes(0xa00bc324), Next: 0}, ErrRemoteStale}, + {7987396, ID{Hash: ChecksumToBytes(0xa00bc324), Next: 0}, ErrRemoteStale}, // Local is mainnet Petersburg, and isn't aware of more forks. Remote announces Petersburg + // 0xffffffff. Local needs software update, reject. - {7987396, ID{Hash: checksumToBytes(0x5cddc0e1), Next: 0}, ErrLocalIncompatibleOrStale}, + {7987396, ID{Hash: ChecksumToBytes(0x5cddc0e1), Next: 0}, ErrLocalIncompatibleOrStale}, // Local is mainnet Byzantium, and is aware of Petersburg. Remote announces Petersburg + // 0xffffffff. Local needs software update, reject. - {7279999, ID{Hash: checksumToBytes(0x5cddc0e1), Next: 0}, ErrLocalIncompatibleOrStale}, + {7279999, ID{Hash: ChecksumToBytes(0x5cddc0e1), Next: 0}, ErrLocalIncompatibleOrStale}, // Local is mainnet Petersburg, remote is Rinkeby Petersburg. - {7987396, ID{Hash: checksumToBytes(0xafec6b27), Next: 0}, ErrLocalIncompatibleOrStale}, + {7987396, ID{Hash: ChecksumToBytes(0xafec6b27), Next: 0}, ErrLocalIncompatibleOrStale}, // Local is mainnet Gray Glacier, far in the future. Remote announces Gopherium (non existing fork) // at some future block 88888888, for itself, but past block for local. Local is incompatible. // // This case detects non-upgraded nodes with majority hash power (typical Ropsten mess). - {88888888, ID{Hash: checksumToBytes(0xf0afd0e3), Next: 88888888}, ErrLocalIncompatibleOrStale}, + {88888888, ID{Hash: ChecksumToBytes(0xf0afd0e3), Next: 88888888}, ErrLocalIncompatibleOrStale}, // Local is mainnet Byzantium. Remote is also in Byzantium, but announces Gopherium (non existing // fork) at block 7279999, before Petersburg. Local is incompatible. - {7279999, ID{Hash: checksumToBytes(0xa00bc324), Next: 7279999}, ErrLocalIncompatibleOrStale}, + {7279999, ID{Hash: ChecksumToBytes(0xa00bc324), Next: 7279999}, ErrLocalIncompatibleOrStale}, } - heightForks, timeForks := GatherForks(params.MainnetChainConfig, 0 /* genesisTime */) + heightForks, timeForks := GatherForks(testutil.PoWMainnetChainConfig, 0 /* genesisTime */) for i, tt := range tests { - filter := newFilter(heightForks, timeForks, params.MainnetGenesisHash, tt.head, 0) + filter := newFilter(heightForks, timeForks, testutil.MainnetGenesisHash, tt.head, 0) if err := filter(tt.id); err != tt.err { t.Errorf("test %d: validation error mismatch: have %v, want %v", i, err, tt.err) } @@ -293,9 +117,9 @@ func TestEncoding(t *testing.T) { id ID want []byte }{ - {ID{Hash: checksumToBytes(0), Next: 0}, common.Hex2Bytes("c6840000000080")}, - {ID{Hash: checksumToBytes(0xdeadbeef), Next: 0xBADDCAFE}, common.Hex2Bytes("ca84deadbeef84baddcafe,")}, - {ID{Hash: checksumToBytes(math.MaxUint32), Next: math.MaxUint64}, common.Hex2Bytes("ce84ffffffff88ffffffffffffffff")}, + {ID{Hash: ChecksumToBytes(0), Next: 0}, common.Hex2Bytes("c6840000000080")}, + {ID{Hash: ChecksumToBytes(0xdeadbeef), Next: 0xBADDCAFE}, common.Hex2Bytes("ca84deadbeef84baddcafe,")}, + {ID{Hash: ChecksumToBytes(math.MaxUint32), Next: math.MaxUint64}, common.Hex2Bytes("ce84ffffffff88ffffffffffffffff")}, } for i, tt := range tests { have, err := rlp.EncodeToBytes(tt.id) diff --git a/p2p/go.mod b/p2p/go.mod new file mode 100644 index 00000000000..452bd38a31b --- /dev/null +++ b/p2p/go.mod @@ -0,0 +1,113 @@ +module github.com/erigontech/erigon-p2p + +go 1.23.0 + +toolchain go1.23.6 + +replace ( + github.com/erigontech/erigon-db => ../erigon-db + github.com/erigontech/erigon-lib => ../erigon-lib +) + +require ( + github.com/erigontech/erigon-db v0.0.0-00010101000000-000000000000 + github.com/erigontech/erigon-lib v0.0.0-00010101000000-000000000000 +) + +replace ( + github.com/anacrolix/torrent => github.com/erigontech/torrent v1.54.3-alpha-1 + github.com/crate-crypto/go-kzg-4844 => github.com/erigontech/go-kzg-4844 v0.0.0-20250130131058-ce13be60bc86 + github.com/holiman/bloomfilter/v2 => github.com/AskAlexSharov/bloomfilter/v2 v2.0.9 +) + +require ( + github.com/c2h5oh/datasize v0.0.0-20231215233829-aa82cc1e6500 + github.com/davecgh/go-spew v1.1.1 + github.com/deckarep/golang-set/v2 v2.8.0 + github.com/erigontech/mdbx-go v0.39.8 + github.com/erigontech/secp256k1 v1.2.0 + github.com/golang/snappy v0.0.1 + github.com/hashicorp/golang-lru/v2 v2.0.7 + github.com/holiman/uint256 v1.3.2 + github.com/huin/goupnp v1.3.0 + github.com/jackpal/go-nat-pmp v1.0.2 + github.com/pion/stun v0.3.5 + github.com/stretchr/testify v1.10.0 + go.uber.org/mock v0.5.0 + golang.org/x/crypto v0.38.0 + golang.org/x/sync v0.14.0 + golang.org/x/time v0.11.0 + google.golang.org/grpc v1.71.1 + google.golang.org/protobuf v1.36.6 +) + +require ( + github.com/RoaringBitmap/roaring/v2 v2.4.5 // indirect + github.com/anacrolix/missinggo v1.3.0 // indirect + github.com/anacrolix/missinggo/v2 v2.7.3 // indirect + github.com/anacrolix/torrent v1.52.6-0.20231201115409-7ea994b6bbd8 // indirect + github.com/benesch/cgosymbolizer v0.0.0-20190515212042-bec6fe6e597b // indirect + github.com/beorn7/perks v1.0.1 // indirect + github.com/bits-and-blooms/bitset v1.20.0 // indirect + github.com/bradfitz/iter v0.0.0-20191230175014-e8f45d346db8 // indirect + github.com/cespare/xxhash/v2 v2.3.0 // indirect + github.com/cilium/ebpf v0.11.0 // indirect + github.com/consensys/bavard v0.1.29 // indirect + github.com/consensys/gnark-crypto v0.17.0 // indirect + github.com/containerd/cgroups/v3 v3.0.3 // indirect + github.com/coreos/go-systemd/v22 v22.5.0 // indirect + github.com/crate-crypto/go-ipa v0.0.0-20221111143132-9aa5d42120bc // indirect + github.com/crate-crypto/go-kzg-4844 v1.1.0 // indirect + github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect + github.com/docker/go-units v0.5.0 // indirect + github.com/edsrzf/mmap-go v1.2.0 // indirect + github.com/elastic/go-freelru v0.16.0 // indirect + github.com/erigontech/erigon-snapshot v1.3.1-0.20250501041114-4a48ac232c83 // indirect + github.com/erigontech/speedtest v0.0.2 // indirect + github.com/gballet/go-verkle v0.0.0-20221121182333-31427a1f2d35 // indirect + github.com/go-ole/go-ole v1.2.6 // indirect + github.com/go-stack/stack v1.8.1 // indirect + github.com/godbus/dbus/v5 v5.0.4 // indirect + github.com/gofrs/flock v0.12.1 // indirect + github.com/google/btree v1.1.3 // indirect + github.com/gorilla/websocket v1.5.3 // indirect + github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect + github.com/holiman/bloomfilter/v2 v2.0.3 // indirect + github.com/huandu/xstrings v1.4.0 // indirect + github.com/ianlancetaylor/cgosymbolizer v0.0.0-20241129212102-9c50ad6b591e // indirect + github.com/klauspost/compress v1.18.0 // indirect + github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect + github.com/mmcloughlin/addchain v0.4.0 // indirect + github.com/mschoch/smat v0.2.0 // indirect + github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect + github.com/nyaosorg/go-windows-shortcut v0.0.0-20220529122037-8b0c89bca4c4 // indirect + github.com/opencontainers/runtime-spec v1.2.0 // indirect + github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect + github.com/pelletier/go-toml/v2 v2.2.3 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect + github.com/prometheus/client_golang v1.21.1 // indirect + github.com/prometheus/client_model v0.6.1 // indirect + github.com/prometheus/common v0.62.0 // indirect + github.com/prometheus/procfs v0.15.1 // indirect + github.com/protolambda/ztyp v0.2.2 // indirect + github.com/shirou/gopsutil/v4 v4.24.8 // indirect + github.com/shoenig/go-m1cpu v0.1.6 // indirect + github.com/sirupsen/logrus v1.9.3 // indirect + github.com/spaolacci/murmur3 v1.1.0 // indirect + github.com/tidwall/btree v1.6.0 // indirect + github.com/tklauser/go-sysconf v0.3.14 // indirect + github.com/tklauser/numcpus v0.8.0 // indirect + github.com/ugorji/go/codec v1.2.12 // indirect + github.com/valyala/fastjson v1.6.4 // indirect + github.com/yusufpapurcu/wmi v1.2.4 // indirect + golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6 // indirect + golang.org/x/net v0.40.0 // indirect + golang.org/x/sys v0.33.0 // indirect + golang.org/x/text v0.25.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect + rsc.io/tmplfunc v0.0.3 // indirect +) diff --git a/p2p/go.sum b/p2p/go.sum new file mode 100644 index 00000000000..32a896594f0 --- /dev/null +++ b/p2p/go.sum @@ -0,0 +1,514 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +crawshaw.io/iox v0.0.0-20181124134642-c51c3df30797/go.mod h1:sXBiorCo8c46JlQV3oXPKINnZ8mcqnye1EkVkqsectk= +crawshaw.io/sqlite v0.3.2/go.mod h1:igAO5JulrQ1DbdZdtVq48mnZUBAPOeFzer7VhDWNtW4= +github.com/AskAlexSharov/bloomfilter/v2 v2.0.9 h1:BuZqNjRlYmcXJIsI7nrIkejYMz9mgFi7ZsNFCbSPpaI= +github.com/AskAlexSharov/bloomfilter/v2 v2.0.9/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/RoaringBitmap/roaring v0.4.7/go.mod h1:8khRDP4HmeXns4xIj9oGrKSz7XTQiJx2zgh7AcNke4w= +github.com/RoaringBitmap/roaring v0.4.17/go.mod h1:D3qVegWTmfCaX4Bl5CrBE9hfrSrrXIr8KVNvRsDi1NI= +github.com/RoaringBitmap/roaring v0.4.23/go.mod h1:D0gp8kJQgE1A4LQ5wFLggQEyvDi06Mq5mKs52e1TwOo= +github.com/RoaringBitmap/roaring/v2 v2.4.5 h1:uGrrMreGjvAtTBobc0g5IrW1D5ldxDQYe2JW2gggRdg= +github.com/RoaringBitmap/roaring/v2 v2.4.5/go.mod h1:FiJcsfkGje/nZBZgCu0ZxCPOKD/hVXDS2dXi7/eUFE0= +github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= +github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= +github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/anacrolix/dht/v2 v2.21.1 h1:s1rKkfLLcmBHKv4v/mtMkIeHIEptzEFiB6xVu54+5/o= +github.com/anacrolix/dht/v2 v2.21.1/go.mod h1:SDGC+sEs1pnO2sJGYuhvIis7T8749dDHNfcjtdH4e3g= +github.com/anacrolix/envpprof v0.0.0-20180404065416-323002cec2fa/go.mod h1:KgHhUaQMc8cC0+cEflSgCFNFbKwi5h54gqtVn8yhP7c= +github.com/anacrolix/envpprof v1.0.0/go.mod h1:KgHhUaQMc8cC0+cEflSgCFNFbKwi5h54gqtVn8yhP7c= +github.com/anacrolix/envpprof v1.1.0/go.mod h1:My7T5oSqVfEn4MD4Meczkw/f5lSIndGAKu/0SM/rkf4= +github.com/anacrolix/log v0.3.0/go.mod h1:lWvLTqzAnCWPJA08T2HCstZi0L1y2Wyvm3FJgwU9jwU= +github.com/anacrolix/log v0.6.0/go.mod h1:lWvLTqzAnCWPJA08T2HCstZi0L1y2Wyvm3FJgwU9jwU= +github.com/anacrolix/missinggo v1.1.0/go.mod h1:MBJu3Sk/k3ZfGYcS7z18gwfu72Ey/xopPFJJbTi5yIo= +github.com/anacrolix/missinggo v1.1.2-0.20190815015349-b888af804467/go.mod h1:MBJu3Sk/k3ZfGYcS7z18gwfu72Ey/xopPFJJbTi5yIo= +github.com/anacrolix/missinggo v1.2.1/go.mod h1:J5cMhif8jPmFoC3+Uvob3OXXNIhOUikzMt+uUjeM21Y= +github.com/anacrolix/missinggo v1.3.0 h1:06HlMsudotL7BAELRZs0yDZ4yVXsHXGi323QBjAVASw= +github.com/anacrolix/missinggo v1.3.0/go.mod h1:bqHm8cE8xr+15uVfMG3BFui/TxyB6//H5fwlq/TeqMc= +github.com/anacrolix/missinggo/perf v1.0.0/go.mod h1:ljAFWkBuzkO12MQclXzZrosP5urunoLS0Cbvb4V0uMQ= +github.com/anacrolix/missinggo/v2 v2.2.0/go.mod h1:o0jgJoYOyaoYQ4E2ZMISVa9c88BbUBVQQW4QeRkNCGY= +github.com/anacrolix/missinggo/v2 v2.5.1/go.mod h1:WEjqh2rmKECd0t1VhQkLGTdIWXO6f6NLjp5GlMZ+6FA= +github.com/anacrolix/missinggo/v2 v2.7.3 h1:Ee//CmZBMadeNiYB/hHo9ly2PFOEZ4Fhsbnug3rDAIE= +github.com/anacrolix/missinggo/v2 v2.7.3/go.mod h1:mIEtp9pgaXqt8VQ3NQxFOod/eQ1H0D1XsZzKUQfwtac= +github.com/anacrolix/multiless v0.3.1-0.20221221005021-2d12701f83f7 h1:lOtCD+LzoD1g7bowhYJNR++uV+FyY5bTZXKwnPex9S8= +github.com/anacrolix/multiless v0.3.1-0.20221221005021-2d12701f83f7/go.mod h1:zJv1JF9AqdZiHwxqPgjuOZDGWER6nyE48WBCi/OOrMM= +github.com/anacrolix/stm v0.2.0/go.mod h1:zoVQRvSiGjGoTmbM0vSLIiaKjWtNPeTvXUSdJQA4hsg= +github.com/anacrolix/tagflag v0.0.0-20180109131632-2146c8d41bf0/go.mod h1:1m2U/K6ZT+JZG0+bdMK6qauP49QT4wE5pmhJXOKKCHw= +github.com/anacrolix/tagflag v1.0.0/go.mod h1:1m2U/K6ZT+JZG0+bdMK6qauP49QT4wE5pmhJXOKKCHw= +github.com/anacrolix/tagflag v1.1.0/go.mod h1:Scxs9CV10NQatSmbyjqmqmeQNwGzlNe0CMUMIxqHIG8= +github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= +github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= +github.com/benbjohnson/immutable v0.2.0/go.mod h1:uc6OHo6PN2++n98KHLxW8ef4W42ylHiQSENghE1ezxI= +github.com/benesch/cgosymbolizer v0.0.0-20190515212042-bec6fe6e597b h1:5JgaFtHFRnOPReItxvhMDXbvuBkjSWE+9glJyF466yw= +github.com/benesch/cgosymbolizer v0.0.0-20190515212042-bec6fe6e597b/go.mod h1:eMD2XUcPsHYbakFEocKrWZp47G0MRJYoC60qFblGjpA= +github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= +github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= +github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= +github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/bits-and-blooms/bitset v1.12.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= +github.com/bits-and-blooms/bitset v1.20.0 h1:2F+rfL86jE2d/bmw7OhqUg2Sj/1rURkBn3MdfoPyRVU= +github.com/bits-and-blooms/bitset v1.20.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= +github.com/bradfitz/iter v0.0.0-20140124041915-454541ec3da2/go.mod h1:PyRFw1Lt2wKX4ZVSQ2mk+PeDa1rxyObEDlApuIsUKuo= +github.com/bradfitz/iter v0.0.0-20190303215204-33e6a9893b0c/go.mod h1:PyRFw1Lt2wKX4ZVSQ2mk+PeDa1rxyObEDlApuIsUKuo= +github.com/bradfitz/iter v0.0.0-20191230175014-e8f45d346db8 h1:GKTyiRCL6zVf5wWaqKnf+7Qs6GbEPfd4iMOitWzXJx8= +github.com/bradfitz/iter v0.0.0-20191230175014-e8f45d346db8/go.mod h1:spo1JLcs67NmW1aVLEgtA8Yy1elc+X8y5SRW1sFW4Og= +github.com/c2h5oh/datasize v0.0.0-20231215233829-aa82cc1e6500 h1:6lhrsTEnloDPXyeZBvSYvQf8u86jbKehZPVDDlkgDl4= +github.com/c2h5oh/datasize v0.0.0-20231215233829-aa82cc1e6500/go.mod h1:S/7n9copUssQ56c7aAgHqftWO4LTf4xY6CGWt8Bc+3M= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= +github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cilium/ebpf v0.11.0 h1:V8gS/bTCCjX9uUnkUFUpPsksM8n1lXBAvHcpiFk1X2Y= +github.com/cilium/ebpf v0.11.0/go.mod h1:WE7CZAnqOL2RouJ4f1uyNhqr2P4CCvXFIqdRDUgWsVs= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/consensys/bavard v0.1.29 h1:fobxIYksIQ+ZSrTJUuQgu+HIJwclrAPcdXqd7H2hh1k= +github.com/consensys/bavard v0.1.29/go.mod h1:k/zVjHHC4B+PQy1Pg7fgvG3ALicQw540Crag8qx+dZs= +github.com/consensys/gnark-crypto v0.17.0 h1:vKDhZMOrySbpZDCvGMOELrHFv/A9mJ7+9I8HEfRZSkI= +github.com/consensys/gnark-crypto v0.17.0/go.mod h1:A2URlMHUT81ifJ0UlLzSlm7TmnE3t7VxEThApdMukJw= +github.com/containerd/cgroups/v3 v3.0.3 h1:S5ByHZ/h9PMe5IOQoN7E+nMc2UcLEM/V48DGDJ9kip0= +github.com/containerd/cgroups/v3 v3.0.3/go.mod h1:8HBe7V3aWGLFPd/k03swSIsGjZhHI2WzJmticMgVuz0= +github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs= +github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= +github.com/crate-crypto/go-ipa v0.0.0-20221111143132-9aa5d42120bc h1:mtR7MuscVeP/s0/ERWA2uSr5QOrRYy1pdvZqG1USfXI= +github.com/crate-crypto/go-ipa v0.0.0-20221111143132-9aa5d42120bc/go.mod h1:gFnFS95y8HstDP6P9pPwzrxOOC5TRDkwbM+ao15ChAI= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/deckarep/golang-set/v2 v2.8.0 h1:swm0rlPCmdWn9mESxKOjWk8hXSqoxOp+ZlfuyaAdFlQ= +github.com/deckarep/golang-set/v2 v2.8.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4= +github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y= +github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 h1:rpfIENRNNilwHwZeG5+P150SMrnNEcHYvcCuK6dPZSg= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= +github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= +github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= +github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE= +github.com/dustin/go-humanize v0.0.0-20180421182945-02af3965c54e/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= +github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= +github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= +github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= +github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= +github.com/edsrzf/mmap-go v1.2.0 h1:hXLYlkbaPzt1SaQk+anYwKSRNhufIDCchSPkUD6dD84= +github.com/edsrzf/mmap-go v1.2.0/go.mod h1:19H/e8pUPLicwkyNgOykDXkJ9F0MHE+Z52B8EIth78Q= +github.com/elastic/go-freelru v0.16.0 h1:gG2HJ1WXN2tNl5/p40JS/l59HjvjRhjyAa+oFTRArYs= +github.com/elastic/go-freelru v0.16.0/go.mod h1:bSdWT4M0lW79K8QbX6XY2heQYSCqD7THoYf82pT/H3I= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/erigontech/erigon-snapshot v1.3.1-0.20250501041114-4a48ac232c83 h1:q/bh24/m3V0FIHdLU+eYwoFtHd1x4khYyHhujDaiWek= +github.com/erigontech/erigon-snapshot v1.3.1-0.20250501041114-4a48ac232c83/go.mod h1:ooHlCl+eEYzebiPu+FP6Q6SpPUeMADn8Jxabv3IKb9M= +github.com/erigontech/go-kzg-4844 v0.0.0-20250130131058-ce13be60bc86 h1:UKcIbFZUGIKzK4aQbkv/dYiOVxZSUuD3zKadhmfwdwU= +github.com/erigontech/go-kzg-4844 v0.0.0-20250130131058-ce13be60bc86/go.mod h1:JolLjpSff1tCCJKaJx4psrlEdlXuJEC996PL3tTAFks= +github.com/erigontech/mdbx-go v0.39.8 h1:Hp2pjywZexBA3EQQSU9KM1nUpHIppMNHbX8OMGc5tlM= +github.com/erigontech/mdbx-go v0.39.8/go.mod h1:tHUS492F5YZvccRqatNdpTDQAaN+Vv4HRARYq89KqeY= +github.com/erigontech/secp256k1 v1.2.0 h1:Q/HCBMdYYT0sh1xPZ9ZYEnU30oNyb/vt715cJhj7n7A= +github.com/erigontech/secp256k1 v1.2.0/go.mod h1:GokhPepsMB+EYDs7I5JZCprxHW6+yfOcJKaKtoZ+Fls= +github.com/erigontech/speedtest v0.0.2 h1:W9Cvky/8AMUtUONwkLA/dZjeQ2XfkBdYfJzvhMZUO+U= +github.com/erigontech/speedtest v0.0.2/go.mod h1:vulsRNiM51BmSTbVtch4FWxKxx53pS2D35lZTtao0bw= +github.com/erigontech/torrent v1.54.3-alpha-1 h1:oyT9YpMr82g566v0STVKW0ZTdX/eun03cW2mKmKuTAQ= +github.com/erigontech/torrent v1.54.3-alpha-1/go.mod h1:QtK2WLdEz1Iy1Dh/325UltdHU0nA1xujh2rN6aov6y0= +github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= +github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/gballet/go-verkle v0.0.0-20221121182333-31427a1f2d35 h1:I8QswD9gf3VEpr7bpepKKOm7ChxFITIG+oc1I5/S0no= +github.com/gballet/go-verkle v0.0.0-20221121182333-31427a1f2d35/go.mod h1:DMDd04jjQgdynaAwbEgiRERIGpC8fDjx0+y06an7Psg= +github.com/glycerine/go-unsnap-stream v0.0.0-20180323001048-9f0cb55181dd/go.mod h1:/20jfyN9Y5QPEAprSgKAUr+glWDY39ZiUEAYOEv5dsE= +github.com/glycerine/go-unsnap-stream v0.0.0-20181221182339-f9677308dec2/go.mod h1:/20jfyN9Y5QPEAprSgKAUr+glWDY39ZiUEAYOEv5dsE= +github.com/glycerine/go-unsnap-stream v0.0.0-20190901134440-81cf024a9e0a/go.mod h1:/20jfyN9Y5QPEAprSgKAUr+glWDY39ZiUEAYOEv5dsE= +github.com/glycerine/goconvey v0.0.0-20180728074245-46e3a41ad493/go.mod h1:Ogl1Tioa0aV7gstGFO7KhffUsb9M4ydbEbbxpcEDc24= +github.com/glycerine/goconvey v0.0.0-20190315024820-982ee783a72e/go.mod h1:Ogl1Tioa0aV7gstGFO7KhffUsb9M4ydbEbbxpcEDc24= +github.com/glycerine/goconvey v0.0.0-20190410193231-58a59202ab31/go.mod h1:Ogl1Tioa0aV7gstGFO7KhffUsb9M4ydbEbbxpcEDc24= +github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= +github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= +github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= +github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= +github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= +github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= +github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/go-stack/stack v1.8.1 h1:ntEHSVwIt7PNXNpgPmVfMrNhLtgjlmnZha2kOpuRiDw= +github.com/go-stack/stack v1.8.1/go.mod h1:dcoOX6HbPZSZptuspn9bctJ+N/CnF5gGygcUP3XYfe4= +github.com/go-test/deep v1.1.1 h1:0r/53hagsehfO4bzD2Pgr/+RgHqhmf+k1Bpse2cTu1U= +github.com/go-test/deep v1.1.1/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE= +github.com/godbus/dbus/v5 v5.0.4 h1:9349emZab16e7zQvpmsbtjc18ykshndd8y2PG3sgJbA= +github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/gofrs/flock v0.12.1 h1:MTLVXXHf8ekldpJk3AKicLij9MdwOWkZ+a/jHHZby9E= +github.com/gofrs/flock v0.12.1/go.mod h1:9zxTsyu5xtJ9DK+1tFZyibEV7y3uwDxPPfbxeeHCoD0= +github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= +github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4= +github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/google/btree v0.0.0-20180124185431-e89373fe6b4a/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/btree v1.1.3 h1:CVpQJjYgC4VbzxeGVHfvZrv1ctoYCAI8vbl07Fcxlyg= +github.com/google/btree v1.1.3/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/gopherjs/gopherjs v0.0.0-20190309154008-847fc94819f9/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/gopherjs/gopherjs v0.0.0-20190910122728-9d188e94fb99/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= +github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= +github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg= +github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 h1:UH//fgunKIs4JdUbpDl1VZCDaL56wXCB/5+wF6uHfaI= +github.com/grpc-ecosystem/go-grpc-middleware v1.4.0/go.mod h1:g5qyo/la0ALbONm6Vbp88Yd8NsDy6rZz+RcrMPxvld8= +github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k= +github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= +github.com/holiman/uint256 v1.2.0/go.mod h1:y4ga/t+u+Xwd7CpDgZESaRcWy0I7XMlTMA25ApIH5Jw= +github.com/holiman/uint256 v1.3.2 h1:a9EgMPSC1AAaj1SZL5zIQD3WbwTuHrMGOerLjGmM/TA= +github.com/holiman/uint256 v1.3.2/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E= +github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/huandu/xstrings v1.0.0/go.mod h1:4qWG/gcEcfX4z/mBDHJ++3ReCw9ibxbsNJbcucJdbSo= +github.com/huandu/xstrings v1.2.0/go.mod h1:DvyZB1rfVYsBIigL8HwpZgxHwXozlTgGqn63UyNX5k4= +github.com/huandu/xstrings v1.3.1/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= +github.com/huandu/xstrings v1.4.0 h1:D17IlohoQq4UcpqD7fDk80P7l+lwAmlFaBHgOipl2FU= +github.com/huandu/xstrings v1.4.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= +github.com/huin/goupnp v1.3.0 h1:UvLUlWDNpoUdYzb2TCn+MuTWtcjXKSza2n6CBdQ0xXc= +github.com/huin/goupnp v1.3.0/go.mod h1:gnGPsThkYa7bFi/KWmEysQRf48l2dvR5bxr2OFckNX8= +github.com/ianlancetaylor/cgosymbolizer v0.0.0-20241129212102-9c50ad6b591e h1:8AnObPi8WmIgjwcidUxaREhXMSpyUJeeSrIkZTXdabw= +github.com/ianlancetaylor/cgosymbolizer v0.0.0-20241129212102-9c50ad6b591e/go.mod h1:DvXTE/K/RtHehxU8/GtDs4vFtfw64jJ3PaCnFri8CRg= +github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= +github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= +github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= +github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= +github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo= +github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= +github.com/leanovate/gopter v0.2.11 h1:vRjThO1EKPb/1NsDXuDrzldR28RLkBflWYcU9CvzWu4= +github.com/leanovate/gopter v0.2.11/go.mod h1:aK3tzZP/C+p1m3SPRE4SYZFGP7jjkuSI4f7Xvpt0S9c= +github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4= +github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I= +github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/mmcloughlin/addchain v0.4.0 h1:SobOdjm2xLj1KkXN5/n0xTIWyZA2+s99UCY1iPfkHRY= +github.com/mmcloughlin/addchain v0.4.0/go.mod h1:A86O+tHqZLMNO4w6ZZ4FlVQEadcoqkyU72HC5wJ4RlU= +github.com/mmcloughlin/profile v0.1.1/go.mod h1:IhHD7q1ooxgwTgjxQYkACGA77oFTDdFVejUS1/tS/qU= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/mschoch/smat v0.0.0-20160514031455-90eadee771ae/go.mod h1:qAyveg+e4CE+eKJXWVjKXM4ck2QobLqTDytGJbLLhJg= +github.com/mschoch/smat v0.2.0 h1:8imxQsjDm8yFEAVBe7azKmKSgzSkZXDuKkSq9374khM= +github.com/mschoch/smat v0.2.0/go.mod h1:kc9mz7DoBKqDyiRL7VZN8KvXQMWeTaVnttLRXOlotKw= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= +github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/nyaosorg/go-windows-shortcut v0.0.0-20220529122037-8b0c89bca4c4 h1:+3bXHpIl3RiBuPKlqeCZZeShGHC9RFhR/P2OJfOLRyA= +github.com/nyaosorg/go-windows-shortcut v0.0.0-20220529122037-8b0c89bca4c4/go.mod h1:9YR30vCq/4djj0WO7AvLm48YvNs7M094LWRieEFDE4A= +github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/opencontainers/runtime-spec v1.2.0 h1:z97+pHb3uELt/yiAWD691HNHQIF07bE7dzrbT927iTk= +github.com/opencontainers/runtime-spec v1.2.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= +github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= +github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw= +github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 h1:onHthvaw9LFnH4t2DcNVpwGmV9E1BkGknEliJkfwQj0= +github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58/go.mod h1:DXv8WO4yhMYhSNPKjeNKa5WY9YCIEBRbNzFFPJbWO6Y= +github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M= +github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc= +github.com/philhofer/fwd v1.0.0/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU= +github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= +github.com/pion/stun v0.3.5 h1:uLUCBCkQby4S1cf6CGuR9QrVOKcvUwFeemaC865QHDg= +github.com/pion/stun v0.3.5/go.mod h1:gDMim+47EeEtfWogA37n6qXZS88L5V6LqFcf+DZA2UA= +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF4JjgDlrVEn3C11VoGHZN7m8qihwgMEtzYw= +github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE= +github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= +github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs= +github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= +github.com/prometheus/client_golang v1.5.1/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= +github.com/prometheus/client_golang v1.21.1 h1:DOvXXTqVzvkIewV/CDPFdejpMCGeMcbGCQ8YOmu+Ibk= +github.com/prometheus/client_golang v1.21.1/go.mod h1:U9NM32ykUErtVBxdvD3zfi+EuFkkaBvMb09mIfe0Zgg= +github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= +github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= +github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= +github.com/prometheus/common v0.62.0 h1:xasJaQlnWAeyHdUBeGjXmutelfJHWMRr+Fg4QszZ2Io= +github.com/prometheus/common v0.62.0/go.mod h1:vyBcEuLSvWos9B1+CyL7JZ2up+uFzXhkqml0W5zIY1I= +github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= +github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= +github.com/prometheus/procfs v0.0.11/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= +github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= +github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= +github.com/protolambda/ztyp v0.2.2 h1:rVcL3vBu9W/aV646zF6caLS/dyn9BN8NYiuJzicLNyY= +github.com/protolambda/ztyp v0.2.2/go.mod h1:9bYgKGqg3wJqT9ac1gI2hnVb0STQq7p/1lapqrqY1dU= +github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= +github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII= +github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o= +github.com/ryszard/goskiplist v0.0.0-20150312221310-2dfbae5fcf46/go.mod h1:uAQ5PCi+MFsC7HjREoAz1BU+Mq60+05gifQSsHSDG/8= +github.com/shirou/gopsutil/v4 v4.24.8 h1:pVQjIenQkIhqO81mwTaXjTzOMT7d3TZkf43PlVFHENI= +github.com/shirou/gopsutil/v4 v4.24.8/go.mod h1:wE0OrJtj4dG+hYkxqDH3QiBICdKSf04/npcvLLc/oRg= +github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM= +github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ= +github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU= +github.com/shoenig/test v0.6.4/go.mod h1:byHiCGXqrVaflBLAMq/srcZIHynQPQgeyvkvXnjqq0k= +github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= +github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= +github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= +github.com/smartystreets/assertions v0.0.0-20190215210624-980c5ac6f3ac/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= +github.com/smartystreets/goconvey v0.0.0-20181108003508-044398e4856c/go.mod h1:XDJAKZRPZ1CvBcN2aX5YOUTYGHki24fSF0Iv48Ibg0s= +github.com/smartystreets/goconvey v0.0.0-20190306220146-200a235640ff/go.mod h1:KSQcGKpxUMHk3nbYzs/tIBAM2iDooCn0BmttHOJEbLs= +github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= +github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.2.1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/tidwall/btree v1.6.0 h1:LDZfKfQIBHGHWSwckhXI0RPSXzlo+KYdjK7FWSqOzzg= +github.com/tidwall/btree v1.6.0/go.mod h1:twD9XRA5jj9VUQGELzDO4HPQTNJsoWWfYEL+EUQ2cKY= +github.com/tinylib/msgp v1.0.2/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE= +github.com/tinylib/msgp v1.1.0/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE= +github.com/tinylib/msgp v1.1.2/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE= +github.com/tklauser/go-sysconf v0.3.14 h1:g5vzr9iPFFz24v2KZXs/pvpvh8/V9Fw6vQK5ZZb78yU= +github.com/tklauser/go-sysconf v0.3.14/go.mod h1:1ym4lWMLUOhuBOPGtRcJm7tEGX4SCYNEEEtghGG/8uY= +github.com/tklauser/numcpus v0.8.0 h1:Mx4Wwe/FjZLeQsK/6kt2EOepwwSl7SmJrK5bV/dXYgY= +github.com/tklauser/numcpus v0.8.0/go.mod h1:ZJZlAY+dmR4eut8epnzf0u/VwodKmryxR8txiloSqBE= +github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE= +github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= +github.com/valyala/fastjson v1.6.4 h1:uAUNq9Z6ymTgGhcm0UynUAB6tlbakBrz6CQFax3BXVQ= +github.com/valyala/fastjson v1.6.4/go.mod h1:CLCAqky6SMuOcxStkYQvblddUtoRxhYMGLrsQns1aXY= +github.com/willf/bitset v1.1.9/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4= +github.com/willf/bitset v1.1.10/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0= +github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= +go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= +go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= +go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= +go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= +go.opentelemetry.io/otel v1.34.0 h1:zRLXxLCgL1WyKsPVrgbSdMN4c0FMkDAskSTQP+0hdUY= +go.opentelemetry.io/otel v1.34.0/go.mod h1:OWFPOQ+h4G8xpyjgqo4SxJYdDQ/qmRH+wivy7zzx9oI= +go.opentelemetry.io/otel/metric v1.34.0 h1:+eTR3U0MyfWjRDhmFMxe2SsW64QrZ84AOhvqS7Y+PoQ= +go.opentelemetry.io/otel/metric v1.34.0/go.mod h1:CEDrp0fy2D0MvkXE+dPV7cMi8tWZwX3dmaIhwPOaqHE= +go.opentelemetry.io/otel/sdk v1.34.0 h1:95zS4k/2GOy069d321O8jWgYsW3MzVV+KuSPKp7Wr1A= +go.opentelemetry.io/otel/sdk v1.34.0/go.mod h1:0e/pNiaMAqaykJGKbi+tSjWfNNHMTxoC9qANsCzbyxU= +go.opentelemetry.io/otel/sdk/metric v1.34.0 h1:5CeK9ujjbFVL5c1PhLuStg1wxA7vQv7ce1EK0Gyvahk= +go.opentelemetry.io/otel/sdk/metric v1.34.0/go.mod h1:jQ/r8Ze28zRKoNRdkjCZxfs6YvBTG1+YIqyFVFYec5w= +go.opentelemetry.io/otel/trace v1.34.0 h1:+ouXS2V8Rd4hp4580a8q23bg0azF2nI8cqLYnC8mh/k= +go.opentelemetry.io/otel/trace v1.34.0/go.mod h1:Svm7lSjQD7kG7KJ/MUHPVXSDGz2OX4h0M2jHBhmSfRE= +go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= +go.uber.org/mock v0.5.0 h1:KAMbZvZPyBPWgD14IrIQ38QCyjwpvVVV6K/bHl1IwQU= +go.uber.org/mock v0.5.0/go.mod h1:ge71pBPLYDk7QIi1LupWxdAykm7KIEFchiOqd6z7qMM= +go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= +go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.38.0 h1:jt+WWG8IZlBnVbomuhg2Mdq0+BBQaHbtqHEFEigjUV8= +golang.org/x/crypto v0.38.0/go.mod h1:MvrbAqul58NNYPKnOra203SB9vpuZW0e+RRZV+Ggqjw= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6 h1:y5zboxd6LQAqYIhHnB48p0ByQ/GnQx2BE33L8BOHQkI= +golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6/go.mod h1:U6Lno4MTRCDY+Ba7aCcauB9T60gsv5s4ralQzP72ZoQ= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY= +golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.14.0 h1:woo0S4Yywslg6hp4eUFjTVOyKt0RookbpAHG4c1HmhQ= +golang.org/x/sync v0.14.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200413165638-669c56c373c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20211020174200-9d6173849985/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw= +golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4= +golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA= +golang.org/x/time v0.11.0 h1:/bpjEDfN9tkoN/ryeYHnv5hcMlc8ncjMcM4XBk5NWV0= +golang.org/x/time v0.11.0/go.mod h1:CDIdPxbZBQxdj6cxyCIdrNogrJKMJ7pr37NYpMcMDSg= +golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f h1:OxYkA3wjPsZyBylwymxSHa7ViiW1Sml4ToBrncvFehI= +google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f/go.mod h1:+2Yz8+CLJbIfL9z73EW45avw8Lmge3xVElCP9zEKi50= +google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= +google.golang.org/grpc v1.71.1 h1:ffsFWr7ygTUscGPI0KKK6TLrGz0476KUvvsbqWK0rPI= +google.golang.org/grpc v1.71.1/go.mod h1:H0GRtasmQOh9LkFoCPDu3ZrwUtD1YGE+b2vYBYd/8Ec= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY= +google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY= +gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +rsc.io/tmplfunc v0.0.3 h1:53XFQh69AfOa8Tw0Jm7t+GV7KZhOi6jzsCzTtKbMvzU= +rsc.io/tmplfunc v0.0.3/go.mod h1:AG3sTPzElb1Io3Yg4voV9AGZJuleGAwaVRxL9M49PhA= diff --git a/p2p/message.go b/p2p/message.go index 81f57a1ff07..cb7aeb80262 100644 --- a/p2p/message.go +++ b/p2p/message.go @@ -30,8 +30,8 @@ import ( "github.com/erigontech/erigon-lib/common/debug" "github.com/erigontech/erigon-lib/rlp" - "github.com/erigontech/erigon/event" - "github.com/erigontech/erigon/p2p/enode" + "github.com/erigontech/erigon-p2p/enode" + "github.com/erigontech/erigon-p2p/event" ) // Msg defines the structure of a p2p message. diff --git a/p2p/peer.go b/p2p/peer.go index 5aae476f05f..7707f5aaeab 100644 --- a/p2p/peer.go +++ b/p2p/peer.go @@ -30,15 +30,14 @@ import ( "sync" "time" - "github.com/erigontech/erigon-lib/log/v3" - "github.com/erigontech/erigon-lib/common/debug" "github.com/erigontech/erigon-lib/common/mclock" + "github.com/erigontech/erigon-lib/log/v3" "github.com/erigontech/erigon-lib/metrics" "github.com/erigontech/erigon-lib/rlp" - "github.com/erigontech/erigon/event" - "github.com/erigontech/erigon/p2p/enode" - "github.com/erigontech/erigon/p2p/enr" + "github.com/erigontech/erigon-p2p/enode" + "github.com/erigontech/erigon-p2p/enr" + "github.com/erigontech/erigon-p2p/event" ) var ( diff --git a/p2p/peer_test.go b/p2p/peer_test.go index 0c4cd0c7535..d83085aa988 100644 --- a/p2p/peer_test.go +++ b/p2p/peer_test.go @@ -33,8 +33,8 @@ import ( "github.com/erigontech/erigon-lib/log/v3" - "github.com/erigontech/erigon/p2p/enode" - "github.com/erigontech/erigon/p2p/enr" + "github.com/erigontech/erigon-p2p/enode" + "github.com/erigontech/erigon-p2p/enr" ) var discard = Protocol{ diff --git a/p2p/simulations/pipes/pipes.go b/p2p/pipes/pipes.go similarity index 100% rename from p2p/simulations/pipes/pipes.go rename to p2p/pipes/pipes.go diff --git a/p2p/protocol.go b/p2p/protocol.go index 9a16a69c9d4..36cbed69fa3 100644 --- a/p2p/protocol.go +++ b/p2p/protocol.go @@ -22,8 +22,8 @@ package p2p import ( "fmt" - "github.com/erigontech/erigon/p2p/enode" - "github.com/erigontech/erigon/p2p/enr" + "github.com/erigontech/erigon-p2p/enode" + "github.com/erigontech/erigon-p2p/enr" ) // Protocol represents a P2P subprotocol implementation. diff --git a/p2p/protocols/eth/discovery.go b/p2p/protocols/eth/discovery.go index 0840cd4057c..508f83e181a 100644 --- a/p2p/protocols/eth/discovery.go +++ b/p2p/protocols/eth/discovery.go @@ -24,8 +24,8 @@ import ( "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/rlp" - "github.com/erigontech/erigon/p2p/enr" - "github.com/erigontech/erigon/p2p/forkid" + "github.com/erigontech/erigon-p2p/enr" + "github.com/erigontech/erigon-p2p/forkid" ) // enrEntry is the ENR entry which advertises `eth` protocol on the discovery. diff --git a/p2p/protocols/eth/handlers.go b/p2p/protocols/eth/handlers.go index 5198fabea53..701cde5f32d 100644 --- a/p2p/protocols/eth/handlers.go +++ b/p2p/protocols/eth/handlers.go @@ -23,6 +23,7 @@ import ( "context" "fmt" + "github.com/erigontech/erigon-db/interfaces" "github.com/erigontech/erigon-db/rawdb" "github.com/erigontech/erigon-lib/chain" "github.com/erigontech/erigon-lib/common" @@ -31,10 +32,9 @@ import ( "github.com/erigontech/erigon-lib/log/v3" "github.com/erigontech/erigon-lib/rlp" "github.com/erigontech/erigon-lib/types" - "github.com/erigontech/erigon/turbo/services" ) -func AnswerGetBlockHeadersQuery(db kv.Tx, query *GetBlockHeadersPacket, blockReader services.HeaderAndCanonicalReader) ([]*types.Header, error) { +func AnswerGetBlockHeadersQuery(db kv.Tx, query *GetBlockHeadersPacket, blockReader interfaces.HeaderReader) ([]*types.Header, error) { hashMode := query.Origin.Hash != (common.Hash{}) first := true maxNonCanonical := uint64(100) @@ -143,7 +143,7 @@ func AnswerGetBlockHeadersQuery(db kv.Tx, query *GetBlockHeadersPacket, blockRea return headers, nil } -func AnswerGetBlockBodiesQuery(db kv.Tx, query GetBlockBodiesPacket, blockReader services.FullBlockReader) []rlp.RawValue { //nolint:unparam +func AnswerGetBlockBodiesQuery(db kv.Tx, query GetBlockBodiesPacket, blockReader interfaces.HeaderAndBodyReader) []rlp.RawValue { //nolint:unparam // Gather blocks until the fetch or network limits is reached var bytes int bodies := make([]rlp.RawValue, 0, len(query)) @@ -214,7 +214,7 @@ func AnswerGetReceiptsQueryCacheOnly(ctx context.Context, receiptsGetter Receipt }, needMore, nil } -func AnswerGetReceiptsQuery(ctx context.Context, cfg *chain.Config, receiptsGetter ReceiptsGetter, br services.FullBlockReader, db kv.TemporalTx, query GetReceiptsPacket, cachedReceipts *cachedReceipts) ([]rlp.RawValue, error) { //nolint:unparam +func AnswerGetReceiptsQuery(ctx context.Context, cfg *chain.Config, receiptsGetter ReceiptsGetter, br interfaces.HeaderAndBodyReader, db kv.TemporalTx, query GetReceiptsPacket, cachedReceipts *cachedReceipts) ([]rlp.RawValue, error) { //nolint:unparam // Gather state data until the fetch or network limits is reached var ( bytes int diff --git a/p2p/protocols/eth/protocol.go b/p2p/protocols/eth/protocol.go index 1625f2d6f5b..2847d5bee5b 100644 --- a/p2p/protocols/eth/protocol.go +++ b/p2p/protocols/eth/protocol.go @@ -29,7 +29,7 @@ import ( proto_sentry "github.com/erigontech/erigon-lib/gointerfaces/sentryproto" "github.com/erigontech/erigon-lib/rlp" "github.com/erigontech/erigon-lib/types" - "github.com/erigontech/erigon/p2p/forkid" + "github.com/erigontech/erigon-p2p/forkid" ) var ProtocolToString = map[uint]string{ diff --git a/p2p/rlpx/rlpx_test.go b/p2p/rlpx/rlpx_test.go index be116c7cd49..f45eed244f9 100644 --- a/p2p/rlpx/rlpx_test.go +++ b/p2p/rlpx/rlpx_test.go @@ -37,7 +37,7 @@ import ( "github.com/erigontech/erigon-lib/crypto" "github.com/erigontech/erigon-lib/crypto/ecies" "github.com/erigontech/erigon-lib/rlp" - "github.com/erigontech/erigon/p2p/simulations/pipes" + "github.com/erigontech/erigon-p2p/pipes" ) type message struct { diff --git a/p2p/sentry/eth_handshake.go b/p2p/sentry/eth_handshake.go index e6edbbd59f1..b4bb0559f80 100644 --- a/p2p/sentry/eth_handshake.go +++ b/p2p/sentry/eth_handshake.go @@ -21,9 +21,9 @@ import ( "github.com/erigontech/erigon-lib/gointerfaces" proto_sentry "github.com/erigontech/erigon-lib/gointerfaces/sentryproto" - "github.com/erigontech/erigon/p2p" - "github.com/erigontech/erigon/p2p/forkid" - "github.com/erigontech/erigon/p2p/protocols/eth" + p2p "github.com/erigontech/erigon-p2p" + "github.com/erigontech/erigon-p2p/forkid" + "github.com/erigontech/erigon-p2p/protocols/eth" ) func readAndValidatePeerStatusMessage( diff --git a/p2p/sentry/eth_handshake_test.go b/p2p/sentry/eth_handshake_test.go index dab4a660a0f..688b4210cc3 100644 --- a/p2p/sentry/eth_handshake_test.go +++ b/p2p/sentry/eth_handshake_test.go @@ -27,29 +27,29 @@ import ( "github.com/erigontech/erigon-lib/direct" "github.com/erigontech/erigon-lib/gointerfaces" proto_sentry "github.com/erigontech/erigon-lib/gointerfaces/sentryproto" - "github.com/erigontech/erigon/p2p/forkid" - "github.com/erigontech/erigon/p2p/protocols/eth" - "github.com/erigontech/erigon/params" + "github.com/erigontech/erigon-p2p/forkid" + "github.com/erigontech/erigon-p2p/protocols/eth" + "github.com/erigontech/erigon-p2p/testutil" ) func TestCheckPeerStatusCompatibility(t *testing.T) { var version uint = direct.ETH67 - networkID := params.MainnetChainConfig.ChainID.Uint64() - heightForks, timeForks := forkid.GatherForks(params.MainnetChainConfig, 0 /* genesisTime */) + networkID := testutil.PoWMainnetChainConfig.ChainID.Uint64() + heightForks, timeForks := forkid.GatherForks(testutil.PoWMainnetChainConfig, 0 /* genesisTime */) goodReply := eth.StatusPacket{ ProtocolVersion: uint32(version), NetworkID: networkID, TD: big.NewInt(0), Head: common.Hash{}, - Genesis: params.MainnetGenesisHash, - ForkID: forkid.NewIDFromForks(heightForks, timeForks, params.MainnetGenesisHash, 0, 0), + Genesis: testutil.MainnetGenesisHash, + ForkID: forkid.NewIDFromForks(heightForks, timeForks, testutil.MainnetGenesisHash, 0, 0), } status := proto_sentry.StatusData{ NetworkId: networkID, TotalDifficulty: gointerfaces.ConvertUint256IntToH256(new(uint256.Int)), BestHash: nil, ForkData: &proto_sentry.Forks{ - Genesis: gointerfaces.ConvertHashToH256(params.MainnetGenesisHash), + Genesis: gointerfaces.ConvertHashToH256(testutil.MainnetGenesisHash), HeightForks: heightForks, TimeForks: timeForks, }, diff --git a/p2p/sentry/sentry_grpc_server.go b/p2p/sentry/sentry_grpc_server.go index a2eea1ea116..a749b54f60b 100644 --- a/p2p/sentry/sentry_grpc_server.go +++ b/p2p/sentry/sentry_grpc_server.go @@ -52,13 +52,11 @@ import ( proto_types "github.com/erigontech/erigon-lib/gointerfaces/typesproto" "github.com/erigontech/erigon-lib/log/v3" "github.com/erigontech/erigon-lib/rlp" - "github.com/erigontech/erigon/cmd/utils" - "github.com/erigontech/erigon/p2p" - "github.com/erigontech/erigon/p2p/dnsdisc" - "github.com/erigontech/erigon/p2p/enode" - "github.com/erigontech/erigon/p2p/forkid" - "github.com/erigontech/erigon/p2p/protocols/eth" - "github.com/erigontech/erigon/params" + p2p "github.com/erigontech/erigon-p2p" + "github.com/erigontech/erigon-p2p/dnsdisc" + "github.com/erigontech/erigon-p2p/enode" + "github.com/erigontech/erigon-p2p/forkid" + "github.com/erigontech/erigon-p2p/protocols/eth" ) const ( @@ -278,15 +276,11 @@ func makeP2PServer( genesisHash common.Hash, protocols []p2p.Protocol, ) (*p2p.Server, error) { - var urls []string - chainConfig := params.ChainConfigByGenesisHash(genesisHash) - if chainConfig != nil { - urls = params.BootnodeURLsOfChain(chainConfig.ChainName) - } if len(p2pConfig.BootstrapNodes) == 0 { - bootstrapNodes, err := utils.ParseNodesFromURLs(urls) + urls := p2pConfig.LookupBootnodeURLs(genesisHash) + bootstrapNodes, err := enode.ParseNodesFromURLs(urls) if err != nil { - return nil, fmt.Errorf("bad option %s: %w", utils.BootnodesFlag.Name, err) + return nil, fmt.Errorf("bad bootnodes option: %w", err) } p2pConfig.BootstrapNodes = bootstrapNodes p2pConfig.BootstrapNodesV5 = bootstrapNodes @@ -1006,7 +1000,7 @@ func (ss *GrpcServer) HandShake(context.Context, *emptypb.Empty) (*proto_sentry. func (ss *GrpcServer) startP2PServer(genesisHash common.Hash) (*p2p.Server, error) { if !ss.p2p.NoDiscovery { if len(ss.p2p.DiscoveryDNS) == 0 { - if url := params.KnownDNSNetwork(genesisHash, "all"); url != "" { + if url := ss.p2p.LookupDNSNetwork(genesisHash, "all"); url != "" { ss.p2p.DiscoveryDNS = []string{url} } @@ -1139,8 +1133,7 @@ func (ss *GrpcServer) PeerById(_ context.Context, req *proto_sentry.PeerByIdRequ return &proto_sentry.PeerByIdReply{Peer: rpcPeer}, nil } -// setupDiscovery creates the node discovery source for the `eth` and `snap` -// protocols. +// setupDiscovery creates the node discovery source for the `eth` protocol. func setupDiscovery(urls []string) (enode.Iterator, error) { if len(urls) == 0 { return nil, nil diff --git a/p2p/sentry/sentry_grpc_server_test.go b/p2p/sentry/sentry_grpc_server_test.go index d33b76a9a0f..0cf4217567b 100644 --- a/p2p/sentry/sentry_grpc_server_test.go +++ b/p2p/sentry/sentry_grpc_server_test.go @@ -34,11 +34,9 @@ import ( proto_sentry "github.com/erigontech/erigon-lib/gointerfaces/sentryproto" "github.com/erigontech/erigon-lib/kv" "github.com/erigontech/erigon-lib/kv/temporal/temporaltest" - "github.com/erigontech/erigon-lib/log/v3" "github.com/erigontech/erigon-lib/types" - "github.com/erigontech/erigon/core" - "github.com/erigontech/erigon/p2p" - "github.com/erigontech/erigon/p2p/forkid" + p2p "github.com/erigontech/erigon-p2p" + "github.com/erigontech/erigon-p2p/forkid" ) func testSentryServer(db kv.Getter, genesis *types.Genesis, genesisHash common.Hash) *GrpcServer { @@ -105,8 +103,8 @@ func testForkIDSplit(t *testing.T, protocol uint) { gspecNoFork = &types.Genesis{Config: configNoFork} gspecProFork = &types.Genesis{Config: configProFork} - genesisNoFork = core.MustCommitGenesis(gspecNoFork, dbNoFork, datadir.New(t.TempDir()), log.Root()) - genesisProFork = core.MustCommitGenesis(gspecProFork, dbProFork, datadir.New(t.TempDir()), log.Root()) + genesisNoFork = rawdb.MustCommitGenesisWithoutState(gspecNoFork, dbNoFork) + genesisProFork = rawdb.MustCommitGenesisWithoutState(gspecProFork, dbProFork) ) var s1, s2 *GrpcServer @@ -184,6 +182,15 @@ func testForkIDSplit(t *testing.T, protocol uint) { } } +func emptyBootnodeURL(genesis common.Hash) []string { + return []string{} + +} + +func mainnetDNSNetwork(genesis common.Hash, protocol string) string { + return "enrtree://AKA3AM6LPBYEUDMVNU3BSVQJ5AD45Y7YPOHJLEF6W26QOE4VTUDPE@" + protocol + ".mainnet.ethdisco.net" +} + func TestSentryServerImpl_SetStatusInitPanic(t *testing.T) { defer func() { if r := recover(); r != nil { @@ -194,8 +201,8 @@ func TestSentryServerImpl_SetStatusInitPanic(t *testing.T) { configNoFork := &chain.Config{HomesteadBlock: big.NewInt(1), ChainID: big.NewInt(1)} dbNoFork := temporaltest.NewTestDB(t, datadir.New(t.TempDir())) gspecNoFork := &types.Genesis{Config: configNoFork} - genesisNoFork := core.MustCommitGenesis(gspecNoFork, dbNoFork, datadir.New(t.TempDir()), log.Root()) - ss := &GrpcServer{p2p: &p2p.Config{}} + genesisNoFork := rawdb.MustCommitGenesisWithoutState(gspecNoFork, dbNoFork) + ss := &GrpcServer{p2p: &p2p.Config{LookupBootnodeURLs: emptyBootnodeURL, LookupDNSNetwork: mainnetDNSNetwork}} _, err := ss.SetStatus(context.Background(), &proto_sentry.StatusData{ ForkData: &proto_sentry.Forks{Genesis: gointerfaces.ConvertHashToH256(genesisNoFork.Hash())}, diff --git a/p2p/sentry/sentrymultiplexer_test.go b/p2p/sentry/sentrymultiplexer_test.go index a84ee77d5f5..5408b7266cd 100644 --- a/p2p/sentry/sentrymultiplexer_test.go +++ b/p2p/sentry/sentrymultiplexer_test.go @@ -11,17 +11,19 @@ import ( "sync" "testing" + "github.com/stretchr/testify/require" + "go.uber.org/mock/gomock" + "google.golang.org/grpc" + "google.golang.org/protobuf/types/known/emptypb" + + "github.com/erigontech/secp256k1" + "github.com/erigontech/erigon-lib/direct" "github.com/erigontech/erigon-lib/gointerfaces" "github.com/erigontech/erigon-lib/gointerfaces/sentryproto" "github.com/erigontech/erigon-lib/gointerfaces/typesproto" "github.com/erigontech/erigon-lib/p2p/sentry" - "github.com/erigontech/erigon/p2p/enode" - "github.com/erigontech/secp256k1" - "github.com/stretchr/testify/require" - "go.uber.org/mock/gomock" - "google.golang.org/grpc" - "google.golang.org/protobuf/types/known/emptypb" + "github.com/erigontech/erigon-p2p/enode" ) func newClient(ctrl *gomock.Controller, i int, caps []string) *direct.MockSentryClient { diff --git a/p2p/sentry/simulator/sentry_simulator.go b/p2p/sentry/simulator/sentry_simulator.go deleted file mode 100644 index 66af931a56b..00000000000 --- a/p2p/sentry/simulator/sentry_simulator.go +++ /dev/null @@ -1,445 +0,0 @@ -// Copyright 2024 The Erigon Authors -// This file is part of Erigon. -// -// Erigon is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Erigon is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with Erigon. If not, see . - -package simulator - -import ( - "bytes" - "context" - "errors" - "fmt" - "path/filepath" - - "google.golang.org/protobuf/types/known/emptypb" - - "github.com/erigontech/erigon-lib/chain/snapcfg" - "github.com/erigontech/erigon-lib/common" - "github.com/erigontech/erigon-lib/crypto" - "github.com/erigontech/erigon-lib/downloader/snaptype" - "github.com/erigontech/erigon-lib/gointerfaces" - isentry "github.com/erigontech/erigon-lib/gointerfaces/sentryproto" - types "github.com/erigontech/erigon-lib/gointerfaces/typesproto" - "github.com/erigontech/erigon-lib/log/v3" - "github.com/erigontech/erigon-lib/rlp" - coretypes "github.com/erigontech/erigon-lib/types" - "github.com/erigontech/erigon-lib/version" - "github.com/erigontech/erigon/cmd/snapshots/sync" - coresnaptype "github.com/erigontech/erigon/core/snaptype" - "github.com/erigontech/erigon/eth/ethconfig" - "github.com/erigontech/erigon/p2p" - "github.com/erigontech/erigon/p2p/discover/v4wire" - "github.com/erigontech/erigon/p2p/enode" - "github.com/erigontech/erigon/p2p/protocols/eth" - "github.com/erigontech/erigon/p2p/sentry" - "github.com/erigontech/erigon/turbo/snapshotsync" - "github.com/erigontech/erigon/turbo/snapshotsync/freezeblocks" -) - -type server struct { - isentry.UnimplementedSentryServer - ctx context.Context - peers map[[64]byte]*p2p.Peer - messageReceivers map[isentry.MessageId][]isentry.Sentry_MessagesServer - logger log.Logger - knownSnapshots *freezeblocks.RoSnapshots - activeSnapshots *freezeblocks.RoSnapshots - blockReader *freezeblocks.BlockReader - downloader *sync.TorrentClient - chain string -} - -func newPeer(name string, caps []p2p.Cap) (*p2p.Peer, error) { - key, err := crypto.GenerateKey() - - if err != nil { - return nil, err - } - - return p2p.NewPeer(enode.PubkeyToIDV4(&key.PublicKey), v4wire.EncodePubkey(&key.PublicKey), name, caps, true), nil -} - -func NewSentry(ctx context.Context, chain string, snapshotLocation string, peerCount int, logger log.Logger) (isentry.SentryServer, error) { - peers := map[[64]byte]*p2p.Peer{} - - for i := 0; i < peerCount; i++ { - peer, err := newPeer(fmt.Sprint("peer-", i), nil) - - if err != nil { - return nil, err - } - peers[peer.Pubkey()] = peer - } - - cfg := snapcfg.KnownCfg(chain) - torrentDir := filepath.Join(snapshotLocation, "torrents", chain) - - freezeCfg := ethconfig.Defaults.Snapshot - freezeCfg.NoDownloader = true - freezeCfg.ProduceE2 = false - freezeCfg.ProduceE3 = false - freezeCfg.ChainName = chain - knownSnapshots := freezeblocks.NewRoSnapshots(freezeCfg, "", 0, logger) - - files := make([]string, 0, len(cfg.Preverified)) - - for _, item := range cfg.Preverified { - files = append(files, item.Name) - } - - knownSnapshots.InitSegments(files) - - //s.knownSnapshots.OpenList([]string{ent2.Name()}, false) - activeSnapshots := freezeblocks.NewRoSnapshots(freezeCfg, torrentDir, 0, logger) - - if err := activeSnapshots.OpenFolder(); err != nil { - return nil, err - } - - config := sync.NewDefaultTorrentClientConfig(chain, snapshotLocation, logger) - downloader, err := sync.NewTorrentClient(ctx, config) - - if err != nil { - return nil, err - } - - s := &server{ - ctx: ctx, - peers: peers, - messageReceivers: map[isentry.MessageId][]isentry.Sentry_MessagesServer{}, - knownSnapshots: knownSnapshots, - activeSnapshots: activeSnapshots, - blockReader: freezeblocks.NewBlockReader(activeSnapshots, nil, nil, nil), - logger: logger, - downloader: downloader, - chain: chain, - } - - go func() { - <-ctx.Done() - s.Close() - }() - - return s, nil -} - -func (s *server) Close() { - _ = s.downloader.Close() - s.activeSnapshots.Close() -} - -func (s *server) NodeInfo(context.Context, *emptypb.Empty) (*types.NodeInfoReply, error) { - return nil, errors.New("TODO") -} - -func (s *server) PeerById(ctx context.Context, in *isentry.PeerByIdRequest) (*isentry.PeerByIdReply, error) { - peerId := sentry.ConvertH512ToPeerID(in.PeerId) - - peer, ok := s.peers[peerId] - - if !ok { - return nil, errors.New("unknown peer") - } - - info := peer.Info() - - return &isentry.PeerByIdReply{ - Peer: &types.PeerInfo{ - Id: info.ID, - Name: info.Name, - Enode: info.Enode, - Enr: info.ENR, - Caps: info.Caps, - ConnLocalAddr: info.Network.LocalAddress, - ConnRemoteAddr: info.Network.RemoteAddress, - ConnIsInbound: info.Network.Inbound, - ConnIsTrusted: info.Network.Trusted, - ConnIsStatic: info.Network.Static, - }, - }, nil -} - -func (s *server) PeerCount(context.Context, *isentry.PeerCountRequest) (*isentry.PeerCountReply, error) { - return &isentry.PeerCountReply{Count: uint64(len(s.peers))}, nil -} - -func (s *server) PeerEvents(*isentry.PeerEventsRequest, isentry.Sentry_PeerEventsServer) error { - return errors.New("TODO") -} - -func (s *server) PeerMinBlock(context.Context, *isentry.PeerMinBlockRequest) (*emptypb.Empty, error) { - return nil, errors.New("TODO") -} - -func (s *server) Peers(context.Context, *emptypb.Empty) (*isentry.PeersReply, error) { - reply := &isentry.PeersReply{} - - for _, peer := range s.peers { - info := peer.Info() - - reply.Peers = append(reply.Peers, - &types.PeerInfo{ - Id: info.ID, - Name: info.Name, - Enode: info.Enode, - Enr: info.ENR, - Caps: info.Caps, - ConnLocalAddr: info.Network.LocalAddress, - ConnRemoteAddr: info.Network.RemoteAddress, - ConnIsInbound: info.Network.Inbound, - ConnIsTrusted: info.Network.Trusted, - ConnIsStatic: info.Network.Static, - }) - } - - return reply, nil -} - -func (s *server) SendMessageById(ctx context.Context, in *isentry.SendMessageByIdRequest) (*isentry.SentPeers, error) { - peerId := sentry.ConvertH512ToPeerID(in.PeerId) - - if err := s.sendMessageById(ctx, peerId, in.Data); err != nil { - return nil, err - } - - return &isentry.SentPeers{ - Peers: []*types.H512{in.PeerId}, - }, nil -} - -func (s *server) sendMessageById(ctx context.Context, peerId [64]byte, messageData *isentry.OutboundMessageData) error { - peer, ok := s.peers[peerId] - - if !ok { - return errors.New("unknown peer") - } - - switch messageData.Id { - case isentry.MessageId_GET_BLOCK_HEADERS_66: - packet := ð.GetBlockHeadersPacket66{} - if err := rlp.DecodeBytes(messageData.Data, packet); err != nil { - return fmt.Errorf("failed to decode packet: %w", err) - } - - go s.processGetBlockHeaders(ctx, peer, packet.RequestId, packet.GetBlockHeadersPacket) - - default: - return fmt.Errorf("unhandled message id: %s", messageData.Id) - } - - return nil -} - -func (s *server) SendMessageByMinBlock(ctx context.Context, request *isentry.SendMessageByMinBlockRequest) (*isentry.SentPeers, error) { - return s.UnimplementedSentryServer.SendMessageByMinBlock(ctx, request) -} - -func (s *server) SendMessageToAll(ctx context.Context, data *isentry.OutboundMessageData) (*isentry.SentPeers, error) { - sentPeers := &isentry.SentPeers{} - - for _, peer := range s.peers { - peerKey := peer.Pubkey() - - if err := s.sendMessageById(ctx, peerKey, data); err != nil { - return sentPeers, err - } - - sentPeers.Peers = append(sentPeers.Peers, gointerfaces.ConvertBytesToH512(peerKey[:])) - } - - return sentPeers, nil -} - -func (s *server) SendMessageToRandomPeers(ctx context.Context, request *isentry.SendMessageToRandomPeersRequest) (*isentry.SentPeers, error) { - sentPeers := &isentry.SentPeers{} - - var i uint64 - - for _, peer := range s.peers { - peerKey := peer.Pubkey() - - if err := s.sendMessageById(ctx, peerKey, request.Data); err != nil { - return sentPeers, err - } - - sentPeers.Peers = append(sentPeers.Peers, gointerfaces.ConvertBytesToH512(peerKey[:])) - - i++ - - if i == request.MaxPeers { - break - } - } - - return sentPeers, nil - -} - -func (s *server) Messages(request *isentry.MessagesRequest, receiver isentry.Sentry_MessagesServer) error { - for _, messageId := range request.Ids { - receivers := s.messageReceivers[messageId] - s.messageReceivers[messageId] = append(receivers, receiver) - } - - <-s.ctx.Done() - - return nil -} - -func (s *server) processGetBlockHeaders(ctx context.Context, peer *p2p.Peer, requestId uint64, request *eth.GetBlockHeadersPacket) { - r66 := s.messageReceivers[isentry.MessageId_BLOCK_HEADERS_66] - - if len(r66) > 0 { - - peerKey := peer.Pubkey() - peerId := gointerfaces.ConvertBytesToH512(peerKey[:]) - - headers, err := s.getHeaders(ctx, request.Origin, request.Amount, request.Skip, request.Reverse) - - if err != nil { - s.logger.Warn("Can't get headers", "error", err) - return - } - - var data bytes.Buffer - - err = rlp.Encode(&data, ð.BlockHeadersPacket66{ - RequestId: requestId, - BlockHeadersPacket: headers, - }) - - if err != nil { - fmt.Printf("Error (move to logger): %s", err) - return - } - - for _, receiver := range r66 { - receiver.Send(&isentry.InboundMessage{ - Id: isentry.MessageId_BLOCK_HEADERS_66, - Data: data.Bytes(), - PeerId: peerId, - }) - } - } -} - -func (s *server) getHeaders(ctx context.Context, origin eth.HashOrNumber, amount uint64, skip uint64, reverse bool) (eth.BlockHeadersPacket, error) { - - var headers eth.BlockHeadersPacket - - var next uint64 - - nextBlockNum := func(blockNum uint64) uint64 { - inc := uint64(1) - - if skip != 0 { - inc = skip - } - - if reverse { - return blockNum - inc - } else { - return blockNum + inc - } - } - - if origin.Hash != (common.Hash{}) { - header, err := s.getHeaderByHash(ctx, origin.Hash) - - if err != nil { - return nil, err - } - - headers = append(headers, header) - - next = nextBlockNum(header.Number.Uint64()) - } else { - header, err := s.getHeader(ctx, origin.Number) - - if err != nil { - return nil, err - } - - headers = append(headers, header) - - next = nextBlockNum(header.Number.Uint64()) - } - - for len(headers) < int(amount) { - header, err := s.getHeader(ctx, next) - - if err != nil { - return nil, err - } - - headers = append(headers, header) - - next = nextBlockNum(header.Number.Uint64()) - } - - return headers, nil -} - -func (s *server) getHeader(ctx context.Context, blockNum uint64) (*coretypes.Header, error) { - header, err := s.blockReader.Header(ctx, nil, common.Hash{}, blockNum) - - if err != nil { - return nil, err - } - - if header == nil { - view := s.knownSnapshots.View() - defer view.Close() - - if seg, ok := view.HeadersSegment(blockNum); ok { - if err := s.downloadHeaders(ctx, seg); err != nil { - return nil, err - } - } - - s.activeSnapshots.OpenSegments([]snaptype.Type{coresnaptype.Headers}, true) - - header, err = s.blockReader.Header(ctx, nil, common.Hash{}, blockNum) - - if err != nil { - return nil, err - } - } - - return header, nil -} - -func (s *server) getHeaderByHash(ctx context.Context, hash common.Hash) (*coretypes.Header, error) { - return s.blockReader.HeaderByHash(ctx, nil, hash) -} - -func (s *server) downloadHeaders(ctx context.Context, header *snapshotsync.VisibleSegment) error { - fileName := snaptype.SegmentFileName(version.ZeroVersion, header.From(), header.To(), coresnaptype.Enums.Headers) - session := sync.NewTorrentSession(s.downloader, s.chain) - - s.logger.Info("Downloading", "file", fileName) - - err := session.Download(ctx, fileName) - - if err != nil { - return fmt.Errorf("can't download %s: %w", fileName, err) - } - - s.logger.Info("Indexing", "file", fileName) - - info, _, _ := snaptype.ParseFileName(session.LocalFsRoot(), fileName) - - return coresnaptype.Headers.BuildIndexes(ctx, info, nil, nil, session.LocalFsRoot(), nil, log.LvlDebug, s.logger) -} diff --git a/p2p/sentry/simulator/simulator_test.go b/p2p/sentry/simulator/simulator_test.go deleted file mode 100644 index c3acdce21b1..00000000000 --- a/p2p/sentry/simulator/simulator_test.go +++ /dev/null @@ -1,137 +0,0 @@ -// Copyright 2024 The Erigon Authors -// This file is part of Erigon. -// -// Erigon is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Erigon is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with Erigon. If not, see . - -package simulator_test - -import ( - "bytes" - "context" - "testing" - - "github.com/erigontech/erigon-lib/direct" - "github.com/erigontech/erigon-lib/gointerfaces/sentryproto" - "github.com/erigontech/erigon-lib/log/v3" - "github.com/erigontech/erigon-lib/rlp" - "github.com/erigontech/erigon/p2p/protocols/eth" - "github.com/erigontech/erigon/p2p/sentry/simulator" -) - -func TestSimulatorStart(t *testing.T) { - t.Skip("For now, this test is intended for manual runs only as it downloads snapshots and takes too long") - - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - - logger := log.New() - // logger.SetHandler(log.StdoutHandler) - dataDir := t.TempDir() - - sim, err := simulator.NewSentry(ctx, "amoy", dataDir, 1, logger) - if err != nil { - t.Fatal(err) - } - - simClient := direct.NewSentryClientDirect(66, sim) - - peerCount, err := simClient.PeerCount(ctx, &sentryproto.PeerCountRequest{}) - if err != nil { - t.Fatal(err) - } - - if peerCount.Count != 1 { - t.Fatal("Invalid response count: expected:", 1, "got:", peerCount.Count) - } - - receiver, err := simClient.Messages(ctx, &sentryproto.MessagesRequest{ - Ids: []sentryproto.MessageId{sentryproto.MessageId_BLOCK_HEADERS_66}, - }) - - if err != nil { - t.Fatal(err) - } - - getHeaders66 := ð.GetBlockHeadersPacket66{ - RequestId: 1, - GetBlockHeadersPacket: ð.GetBlockHeadersPacket{ - Origin: eth.HashOrNumber{Number: 10}, - Amount: 10, - }, - } - - var data bytes.Buffer - - err = rlp.Encode(&data, getHeaders66) - - if err != nil { - t.Fatal(err) - } - - peers, err := simClient.SendMessageToAll(ctx, &sentryproto.OutboundMessageData{ - Id: sentryproto.MessageId_GET_BLOCK_HEADERS_66, - Data: data.Bytes(), - }) - - if err != nil { - t.Fatal(err) - } - - if len(peers.Peers) != int(peerCount.Count) { - t.Fatal("Unexpected peer count expected:", peerCount.Count, len(peers.Peers)) - } - - message, err := receiver.Recv() - - if err != nil { - t.Fatal(err) - } - - if message.Id != sentryproto.MessageId_BLOCK_HEADERS_66 { - t.Fatal("unexpected message id expected:", sentryproto.MessageId_BLOCK_HEADERS_66, "got:", message.Id) - } - - var expectedPeer bool - - for _, peer := range peers.Peers { - if message.PeerId.String() == peer.String() { - expectedPeer = true - break - } - } - - if !expectedPeer { - t.Fatal("message received from unexpected peer:", message.PeerId) - } - - packet := ð.BlockHeadersPacket66{} - - if err := rlp.DecodeBytes(message.Data, packet); err != nil { - t.Fatal("failed to decode packet:", err) - } - - if len(packet.BlockHeadersPacket) != 10 { - t.Fatal("unexpected header count: expected:", 10, "got:", len(packet.BlockHeadersPacket)) - } - - blockNum := uint64(10) - - for _, header := range packet.BlockHeadersPacket { - if header.Number.Uint64() != blockNum { - t.Fatal("unexpected block number: expected:", blockNum, "got:", header.Number) - } - - blockNum++ - } -} diff --git a/p2p/sentry/status_data_provider.go b/p2p/sentry/status_data_provider.go index cbc53803b5a..d615c760dd1 100644 --- a/p2p/sentry/status_data_provider.go +++ b/p2p/sentry/status_data_provider.go @@ -32,7 +32,7 @@ import ( "github.com/erigontech/erigon-lib/kv" "github.com/erigontech/erigon-lib/log/v3" "github.com/erigontech/erigon-lib/types" - "github.com/erigontech/erigon/p2p/forkid" + "github.com/erigontech/erigon-p2p/forkid" ) var ErrNoHead = errors.New("ReadChainHead: ReadCurrentHeader error") diff --git a/p2p/server.go b/p2p/server.go index 4ee2b38267a..e72397a5c58 100644 --- a/p2p/server.go +++ b/p2p/server.go @@ -41,12 +41,12 @@ import ( "github.com/erigontech/erigon-lib/common/mclock" "github.com/erigontech/erigon-lib/crypto" "github.com/erigontech/erigon-lib/log/v3" - "github.com/erigontech/erigon/event" - "github.com/erigontech/erigon/p2p/discover" - "github.com/erigontech/erigon/p2p/enode" - "github.com/erigontech/erigon/p2p/enr" - "github.com/erigontech/erigon/p2p/nat" - "github.com/erigontech/erigon/p2p/netutil" + "github.com/erigontech/erigon-p2p/discover" + "github.com/erigontech/erigon-p2p/enode" + "github.com/erigontech/erigon-p2p/enr" + "github.com/erigontech/erigon-p2p/event" + "github.com/erigontech/erigon-p2p/nat" + "github.com/erigontech/erigon-p2p/netutil" ) const ( @@ -115,6 +115,8 @@ type Config struct { // protocol. BootstrapNodesV5 []*enode.Node `toml:",omitempty"` + LookupBootnodeURLs LookupBootnodeURLsFunc + // Static nodes are used as pre-configured connections which are always // maintained and re-connected on disconnects. StaticNodes []*enode.Node @@ -181,6 +183,8 @@ type Config struct { MetricsEnabled bool DiscoveryDNS []string + + LookupDNSNetwork LookupDNSNetworkFunc } func (config *Config) ListenPort() int { diff --git a/p2p/server_test.go b/p2p/server_test.go index 49a3cf8bc2f..7343a7d9461 100644 --- a/p2p/server_test.go +++ b/p2p/server_test.go @@ -34,9 +34,9 @@ import ( "github.com/erigontech/erigon-lib/crypto" "github.com/erigontech/erigon-lib/log/v3" - "github.com/erigontech/erigon/p2p/enode" - "github.com/erigontech/erigon/p2p/enr" - "github.com/erigontech/erigon/p2p/rlpx" + "github.com/erigontech/erigon-p2p/enode" + "github.com/erigontech/erigon-p2p/enr" + "github.com/erigontech/erigon-p2p/rlpx" ) type testTransport struct { diff --git a/p2p/simulations/README.md b/p2p/simulations/README.md deleted file mode 100644 index ea67cd8aaa5..00000000000 --- a/p2p/simulations/README.md +++ /dev/null @@ -1,169 +0,0 @@ -# devp2p Simulations - -The `p2p/simulations` package implements a simulation framework which supports -creating a collection of devp2p nodes, connecting them together to form a -simulation network, performing simulation actions in that network and then -extracting useful information. - -## Nodes - -Each node in a simulation network runs multiple services by wrapping a collection -of objects which implement the `node.Service` interface meaning they: - -* can be started and stopped -* run p2p protocols -* expose RPC APIs - -This means that any object which implements the `node.Service` interface can be -used to run a node in the simulation. - -## Services - -Before running a simulation, a set of service initializers must be registered -which can then be used to run nodes in the network. - -A service initializer is a function with the following signature: - -```go -func(ctx *adapters.ServiceContext) (node.Service, error) -``` - -These initializers should be registered by calling the `adapters.RegisterServices` -function in an `init()` hook: - -```go -func init() { - adapters.RegisterServices(adapters.Services{ - "service1": initService1, - "service2": initService2, - }) -} -``` - -## Node Adapters - -The simulation framework includes multiple "node adapters" which are -responsible for creating an environment in which a node runs. - -### SimAdapter - -The `SimAdapter` runs nodes in-memory, connecting them using an in-memory, -synchronous `net.Pipe` and connecting to their RPC server using an in-memory -`rpc.Client`. - -### ExecAdapter - -The `ExecAdapter` runs nodes as child processes of the running simulation. - -It does this by executing the binary which is running the simulation but -setting `argv[0]` (i.e. the program name) to `p2p-node` which is then -detected by an init hook in the child process which runs the `node.Service` -using the devp2p node stack rather than executing `main()`. - -The nodes listen for devp2p connections and WebSocket RPC clients on random -localhost ports. - -## Network - -A simulation network is created with an ID and default service (which is used -if a node is created without an explicit service), exposes methods for -creating, starting, stopping, connecting and disconnecting nodes, and emits -events when certain actions occur. - -### Events - -A simulation network emits the following events: - -* node event - when nodes are created / started / stopped -* connection event - when nodes are connected / disconnected -* message event - when a protocol message is sent between two nodes - -The events have a "control" flag which when set indicates that the event is the -outcome of a controlled simulation action (e.g. creating a node or explicitly -connecting two nodes together). - -This is in contrast to a non-control event, otherwise called a "live" event, -which is the outcome of something happening in the network as a result of a -control event (e.g. a node actually started up or a connection was actually -established between two nodes). - -Live events are detected by the simulation network by subscribing to node peer -events via RPC when the nodes start up. - -## Testing Framework - -The `Simulation` type can be used in tests to perform actions in a simulation -network and then wait for expectations to be met. - -With a running simulation network, the `Simulation.Run` method can be called -with a `Step` which has the following fields: - -* `Action` - a function which performs some action in the network - -* `Expect` - an expectation function which returns whether or not a - given node meets the expectation - -* `Trigger` - a channel which receives node IDs which then trigger a check - of the expectation function to be performed against that node - -As a concrete example, consider a simulated network of Ethereum nodes. An -`Action` could be the sending of a transaction, `Expect` it being included in -a block, and `Trigger` a check for every block that is mined. - -On return, the `Simulation.Run` method returns a `StepResult` which can be used -to determine if all nodes met the expectation, how long it took them to meet -the expectation and what network events were emitted during the step run. - -## HTTP API - -The simulation framework includes an HTTP API which can be used to control the -simulation. - -The API is initialised with a particular node adapter and has the following -endpoints: - -``` -GET / Get network information -POST /start Start all nodes in the network -POST /stop Stop all nodes in the network -GET /events Stream network events -GET /snapshot Take a network snapshot -POST /snapshot Load a network snapshot -POST /nodes Create a node -GET /nodes Get all nodes in the network -GET /nodes/:nodeid Get node information -POST /nodes/:nodeid/start Start a node -POST /nodes/:nodeid/stop Stop a node -POST /nodes/:nodeid/conn/:peerid Connect two nodes -DELETE /nodes/:nodeid/conn/:peerid Disconnect two nodes -GET /nodes/:nodeid/rpc Make RPC requests to a node via WebSocket -``` - -For convenience, `nodeid` in the URL can be the name of a node rather than its -ID. - -## Command line client - -`p2psim` is a command line client for the HTTP API, located in -`cmd/p2psim`. - -It provides the following commands: - -``` -p2psim show -p2psim events [--current] [--filter=FILTER] -p2psim snapshot -p2psim load -p2psim node create [--name=NAME] [--services=SERVICES] [--key=KEY] -p2psim node list -p2psim node show -p2psim node start -p2psim node stop -p2psim node connect -p2psim node disconnect -p2psim node rpc [] [--subscribe] -``` - -## Example - -See [p2p/simulations/examples/README.md](examples/README.md). diff --git a/p2p/simulations/adapters/inproc_test.go b/p2p/simulations/adapters/inproc_test.go deleted file mode 100644 index 0e933f40b38..00000000000 --- a/p2p/simulations/adapters/inproc_test.go +++ /dev/null @@ -1,205 +0,0 @@ -// Copyright 2018 The go-ethereum Authors -// (original work) -// Copyright 2024 The Erigon Authors -// (modifications) -// This file is part of Erigon. -// -// Erigon is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Erigon is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with Erigon. If not, see . - -package adapters - -import ( - "bytes" - "encoding/binary" - "fmt" - "sync" - "testing" - - "github.com/erigontech/erigon/p2p/simulations/pipes" -) - -func TestTCPPipe(t *testing.T) { - c1, c2, err := pipes.TCPPipe() - if err != nil { - t.Fatal(err) - } - - msgs := 50 - size := 1024 - for i := 0; i < msgs; i++ { - msg := make([]byte, size) - binary.PutUvarint(msg, uint64(i)) - if _, err := c1.Write(msg); err != nil { - t.Fatal(err) - } - } - - for i := 0; i < msgs; i++ { - msg := make([]byte, size) - binary.PutUvarint(msg, uint64(i)) - out := make([]byte, size) - if _, err := c2.Read(out); err != nil { - t.Fatal(err) - } - if !bytes.Equal(msg, out) { - t.Fatalf("expected %#v, got %#v", msg, out) - } - } -} - -func TestTCPPipeBidirections(t *testing.T) { - c1, c2, err := pipes.TCPPipe() - if err != nil { - t.Fatal(err) - } - - msgs := 50 - size := 7 - for i := 0; i < msgs; i++ { - msg := []byte(fmt.Sprintf("ping %02d", i)) - if _, err := c1.Write(msg); err != nil { - t.Fatal(err) - } - } - - for i := 0; i < msgs; i++ { - expected := []byte(fmt.Sprintf("ping %02d", i)) - out := make([]byte, size) - if _, err := c2.Read(out); err != nil { - t.Fatal(err) - } - - if !bytes.Equal(expected, out) { - t.Fatalf("expected %#v, got %#v", out, expected) - } else { - msg := []byte(fmt.Sprintf("pong %02d", i)) - if _, err := c2.Write(msg); err != nil { - t.Fatal(err) - } - } - } - - for i := 0; i < msgs; i++ { - expected := []byte(fmt.Sprintf("pong %02d", i)) - out := make([]byte, size) - if _, err := c1.Read(out); err != nil { - t.Fatal(err) - } - if !bytes.Equal(expected, out) { - t.Fatalf("expected %#v, got %#v", out, expected) - } - } -} - -func TestNetPipe(t *testing.T) { - c1, c2, err := pipes.NetPipe() - if err != nil { - t.Fatal(err) - } - - msgs := 50 - size := 1024 - var wg sync.WaitGroup - defer wg.Wait() - - // netPipe is blocking, so writes are emitted asynchronously - wg.Add(1) - go func() { - defer wg.Done() - - for i := 0; i < msgs; i++ { - msg := make([]byte, size) - binary.PutUvarint(msg, uint64(i)) - if _, err := c1.Write(msg); err != nil { - t.Error(err) - } - } - }() - - for i := 0; i < msgs; i++ { - msg := make([]byte, size) - binary.PutUvarint(msg, uint64(i)) - out := make([]byte, size) - if _, err := c2.Read(out); err != nil { - t.Error(err) - } - if !bytes.Equal(msg, out) { - t.Errorf("expected %#v, got %#v", msg, out) - } - } -} - -func TestNetPipeBidirections(t *testing.T) { - c1, c2, err := pipes.NetPipe() - if err != nil { - t.Fatal(err) - } - - msgs := 1000 - size := 8 - pingTemplate := "ping %03d" - pongTemplate := "pong %03d" - var wg sync.WaitGroup - defer wg.Wait() - - // netPipe is blocking, so writes are emitted asynchronously - wg.Add(1) - go func() { - defer wg.Done() - - for i := 0; i < msgs; i++ { - msg := []byte(fmt.Sprintf(pingTemplate, i)) - if _, err := c1.Write(msg); err != nil { - t.Error(err) - } - } - }() - - // netPipe is blocking, so reads for pong are emitted asynchronously - wg.Add(1) - go func() { - defer wg.Done() - - for i := 0; i < msgs; i++ { - expected := []byte(fmt.Sprintf(pongTemplate, i)) - out := make([]byte, size) - if _, err := c1.Read(out); err != nil { - t.Error(err) - } - if !bytes.Equal(expected, out) { - t.Errorf("expected %#v, got %#v", expected, out) - } - } - }() - - // expect to read pings, and respond with pongs to the alternate connection - for i := 0; i < msgs; i++ { - expected := []byte(fmt.Sprintf(pingTemplate, i)) - - out := make([]byte, size) - _, err := c2.Read(out) - if err != nil { - t.Fatal(err) - } - - if !bytes.Equal(expected, out) { - t.Errorf("expected %#v, got %#v", expected, out) - } else { - msg := []byte(fmt.Sprintf(pongTemplate, i)) - if _, err := c2.Write(msg); err != nil { - t.Fatal(err) - } - } - } -} diff --git a/p2p/simulations/adapters/types.go b/p2p/simulations/adapters/types.go deleted file mode 100644 index 9a981b7f81c..00000000000 --- a/p2p/simulations/adapters/types.go +++ /dev/null @@ -1,290 +0,0 @@ -// Copyright 2017 The go-ethereum Authors -// (original work) -// Copyright 2024 The Erigon Authors -// (modifications) -// This file is part of Erigon. -// -// Erigon is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Erigon is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with Erigon. If not, see . - -package adapters - -import ( - "crypto/ecdsa" - "encoding/hex" - "encoding/json" - "fmt" - "net" - "strconv" - - "github.com/gorilla/websocket" - - "github.com/erigontech/erigon-lib/crypto" - "github.com/erigontech/erigon-lib/log/v3" - "github.com/erigontech/erigon/node" - "github.com/erigontech/erigon/p2p" - "github.com/erigontech/erigon/p2p/enode" - "github.com/erigontech/erigon/p2p/enr" - "github.com/erigontech/erigon/rpc" -) - -// Node represents a node in a simulation network which is created by a -// NodeAdapter, for example: -// -// * SimNode - An in-memory node -// * ExecNode - A child process node -// * DockerNode - A Docker container node -type Node interface { - // Addr returns the node's address (e.g. an Enode URL) - Addr() []byte - - // Client returns the RPC client which is created once the node is - // up and running - Client() (*rpc.Client, error) - - // ServeRPC serves RPC requests over the given connection - ServeRPC(*websocket.Conn) error - - // Start starts the node with the given snapshots - Start(snapshots map[string][]byte) error - - // Stop stops the node - Stop() error - - // NodeInfo returns information about the node - NodeInfo() *p2p.NodeInfo - - // Snapshots creates snapshots of the running services - Snapshots() (map[string][]byte, error) -} - -// NodeAdapter is used to create Nodes in a simulation network -type NodeAdapter interface { - // Name returns the name of the adapter for logging purposes - Name() string - - // NewNode creates a new node with the given configuration - NewNode(config *NodeConfig) (Node, error) -} - -// NodeConfig is the configuration used to start a node in a simulation -// network -type NodeConfig struct { - // ID is the node's ID which is used to identify the node in the - // simulation network - ID enode.ID - - // PrivateKey is the node's private key which is used by the devp2p - // stack to encrypt communications - PrivateKey *ecdsa.PrivateKey - - // Enable peer events for Msgs - EnableMsgEvents bool - - // Name is a human friendly name for the node like "node01" - Name string - - // Use an existing database instead of a temporary one if non-empty - DataDir string - - // Lifecycles are the names of the service lifecycles which should be run when - // starting the node (for SimNodes it should be the names of service lifecycles - // contained in SimAdapter.lifecycles, for other nodes it should be - // service lifecycles registered by calling the RegisterLifecycle function) - Lifecycles []string - - // Properties are the names of the properties this node should hold - // within running services (e.g. "bootnode", "lightnode" or any custom values) - // These values need to be checked and acted upon by node Services - Properties []string - - // Enode - node *enode.Node - - // ENR Record with entries to overwrite - Record enr.Record - - // function to sanction or prevent suggesting a peer - Reachable func(id enode.ID) bool - - Port uint16 - - // LogFile is the log file name of the p2p node at runtime. - // - // The default value is empty so that the default log writer - // is the system standard output. - LogFile string - - // LogVerbosity is the log verbosity of the p2p node at runtime. - // - // The default verbosity is INFO. - LogVerbosity log.Lvl -} - -// nodeConfigJSON is used to encode and decode NodeConfig as JSON by encoding -// all fields as strings -type nodeConfigJSON struct { - ID string `json:"id"` - PrivateKey string `json:"private_key"` - Name string `json:"name"` - Lifecycles []string `json:"lifecycles"` - Properties []string `json:"properties"` - EnableMsgEvents bool `json:"enable_msg_events"` - Port uint16 `json:"port"` - LogFile string `json:"logfile"` - LogVerbosity int `json:"log_verbosity"` -} - -// MarshalJSON implements the json.Marshaler interface by encoding the config -// fields as strings -func (n *NodeConfig) MarshalJSON() ([]byte, error) { - confJSON := nodeConfigJSON{ - ID: n.ID.String(), - Name: n.Name, - Lifecycles: n.Lifecycles, - Properties: n.Properties, - Port: n.Port, - EnableMsgEvents: n.EnableMsgEvents, - LogFile: n.LogFile, - LogVerbosity: int(n.LogVerbosity), - } - if n.PrivateKey != nil { - confJSON.PrivateKey = hex.EncodeToString(crypto.FromECDSA(n.PrivateKey)) - } - return json.Marshal(confJSON) -} - -// UnmarshalJSON implements the json.Unmarshaler interface by decoding the json -// string values into the config fields -func (n *NodeConfig) UnmarshalJSON(data []byte) error { - var confJSON nodeConfigJSON - if err := json.Unmarshal(data, &confJSON); err != nil { - return err - } - - if confJSON.ID != "" { - if err := n.ID.UnmarshalText([]byte(confJSON.ID)); err != nil { - return err - } - } - - if confJSON.PrivateKey != "" { - key, err := hex.DecodeString(confJSON.PrivateKey) - if err != nil { - return err - } - privKey, err := crypto.ToECDSA(key) - if err != nil { - return err - } - n.PrivateKey = privKey - } - - n.Name = confJSON.Name - n.Lifecycles = confJSON.Lifecycles - n.Properties = confJSON.Properties - n.Port = confJSON.Port - n.EnableMsgEvents = confJSON.EnableMsgEvents - n.LogFile = confJSON.LogFile - n.LogVerbosity = log.Lvl(confJSON.LogVerbosity) - - return nil -} - -// Node returns the node descriptor represented by the config. -func (n *NodeConfig) Node() *enode.Node { - return n.node -} - -// RandomNodeConfig returns node configuration with a randomly generated ID and -// PrivateKey -func RandomNodeConfig() *NodeConfig { - prvkey, err := crypto.GenerateKey() - if err != nil { - panic("unable to generate key") - } - - port, err := assignTCPPort() - if err != nil { - panic("unable to assign tcp port") - } - - enodeId := enode.PubkeyToIDV4(&prvkey.PublicKey) - return &NodeConfig{ - PrivateKey: prvkey, - ID: enodeId, - Name: "node_" + enodeId.String(), - Port: port, - EnableMsgEvents: true, - LogVerbosity: log.LvlInfo, - } -} - -func assignTCPPort() (uint16, error) { - l, err := net.Listen("tcp", "127.0.0.1:0") - if err != nil { - return 0, err - } - l.Close() - _, port, err := net.SplitHostPort(l.Addr().String()) - if err != nil { - return 0, err - } - p, err := strconv.ParseInt(port, 10, 32) - if err != nil { - return 0, err - } - return uint16(p), nil -} - -// ServiceContext is a collection of options and methods which can be utilised -// when starting services -type ServiceContext struct { - RPCDialer - - Config *NodeConfig - Snapshot []byte -} - -// RPCDialer is used when initialising services which need to connect to -// other nodes in the network (for example a simulated Swarm node which needs -// to connect to a Geth node to resolve ENS names) -type RPCDialer interface { - DialRPC(id enode.ID) (*rpc.Client, error) -} - -// LifecycleConstructor allows a Lifecycle to be constructed during node start-up. -// While the service-specific package usually takes care of Lifecycle creation and registration, -// for testing purposes, it is useful to be able to construct a Lifecycle on spot. -type LifecycleConstructor func(ctx *ServiceContext, stack *node.Node) (node.Lifecycle, error) - -// LifecycleConstructors stores LifecycleConstructor functions to call during node start-up. -type LifecycleConstructors map[string]LifecycleConstructor - -// lifecycleConstructorFuncs is a map of registered services which are used to boot devp2p -// nodes -var lifecycleConstructorFuncs = make(LifecycleConstructors) - -// RegisterLifecycles registers the given Services which can then be used to -// start devp2p nodes using either the Exec or Docker adapters. -// -// It should be called in an init function so that it has the opportunity to -// execute the services before main() is called. -func RegisterLifecycles(lifecycles LifecycleConstructors) { - for name, f := range lifecycles { - if _, exists := lifecycleConstructorFuncs[name]; exists { - panic(fmt.Sprintf("node service already exists: %q", name)) - } - lifecycleConstructorFuncs[name] = f - } -} diff --git a/p2p/simulations/connect.go b/p2p/simulations/connect.go deleted file mode 100644 index b2bd41a8c06..00000000000 --- a/p2p/simulations/connect.go +++ /dev/null @@ -1,156 +0,0 @@ -// Copyright 2018 The go-ethereum Authors -// (original work) -// Copyright 2024 The Erigon Authors -// (modifications) -// This file is part of Erigon. -// -// Erigon is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Erigon is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with Erigon. If not, see . - -package simulations - -import ( - "errors" - "strings" - - "github.com/erigontech/erigon/p2p/enode" -) - -var ( - ErrNodeNotFound = errors.New("node not found") -) - -// ConnectToLastNode connects the node with provided NodeID -// to the last node that is up, and avoiding connection to self. -// It is useful when constructing a chain network topology -// when Network adds and removes nodes dynamically. -func (net *Network) ConnectToLastNode(id enode.ID) (err error) { - net.lock.Lock() - defer net.lock.Unlock() - - ids := net.getUpNodeIDs() - l := len(ids) - if l < 2 { - return nil - } - last := ids[l-1] - if last == id { - last = ids[l-2] - } - return net.connectNotConnected(last, id) -} - -// ConnectToRandomNode connects the node with provided NodeID -// to a random node that is up. -func (net *Network) ConnectToRandomNode(id enode.ID) (err error) { - net.lock.Lock() - defer net.lock.Unlock() - - selected := net.getRandomUpNode(id) - if selected == nil { - return ErrNodeNotFound - } - return net.connectNotConnected(selected.ID(), id) -} - -// ConnectNodesFull connects all nodes one to another. -// It provides a complete connectivity in the network -// which should be rarely needed. -func (net *Network) ConnectNodesFull(ids []enode.ID) (err error) { - net.lock.Lock() - defer net.lock.Unlock() - - if ids == nil { - ids = net.getUpNodeIDs() - } - for i, lid := range ids { - for _, rid := range ids[i+1:] { - if err = net.connectNotConnected(lid, rid); err != nil { - return err - } - } - } - return nil -} - -// ConnectNodesChain connects all nodes in a chain topology. -// If ids argument is nil, all nodes that are up will be connected. -func (net *Network) ConnectNodesChain(ids []enode.ID) (err error) { - net.lock.Lock() - defer net.lock.Unlock() - - return net.connectNodesChain(ids) -} - -func (net *Network) connectNodesChain(ids []enode.ID) (err error) { - if ids == nil { - ids = net.getUpNodeIDs() - } - l := len(ids) - for i := 0; i < l-1; i++ { - if err := net.connectNotConnected(ids[i], ids[i+1]); err != nil { - return err - } - } - return nil -} - -// ConnectNodesRing connects all nodes in a ring topology. -// If ids argument is nil, all nodes that are up will be connected. -func (net *Network) ConnectNodesRing(ids []enode.ID) (err error) { - net.lock.Lock() - defer net.lock.Unlock() - - if ids == nil { - ids = net.getUpNodeIDs() - } - l := len(ids) - if l < 2 { - return nil - } - if err := net.connectNodesChain(ids); err != nil { - return err - } - return net.connectNotConnected(ids[l-1], ids[0]) -} - -// ConnectNodesStar connects all nodes into a star topology -// If ids argument is nil, all nodes that are up will be connected. -func (net *Network) ConnectNodesStar(ids []enode.ID, center enode.ID) (err error) { - net.lock.Lock() - defer net.lock.Unlock() - - if ids == nil { - ids = net.getUpNodeIDs() - } - for _, id := range ids { - if center == id { - continue - } - if err := net.connectNotConnected(center, id); err != nil { - return err - } - } - return nil -} - -func (net *Network) connectNotConnected(oneID, otherID enode.ID) error { - return ignoreAlreadyConnectedErr(net.connect(oneID, otherID)) -} - -func ignoreAlreadyConnectedErr(err error) error { - if err == nil || strings.Contains(err.Error(), "already connected") { - return nil - } - return err -} diff --git a/p2p/simulations/events.go b/p2p/simulations/events.go deleted file mode 100644 index 4be7b591aed..00000000000 --- a/p2p/simulations/events.go +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright 2017 The go-ethereum Authors -// (original work) -// Copyright 2024 The Erigon Authors -// (modifications) -// This file is part of Erigon. -// -// Erigon is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Erigon is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with Erigon. If not, see . - -package simulations - -import ( - "fmt" - "time" -) - -// EventType is the type of event emitted by a simulation network -type EventType string - -const ( - // EventTypeNode is the type of event emitted when a node is either - // created, started or stopped - EventTypeNode EventType = "node" - - // EventTypeConn is the type of event emitted when a connection is - // is either established or dropped between two nodes - EventTypeConn EventType = "conn" - - // EventTypeMsg is the type of event emitted when a p2p message it - // sent between two nodes - EventTypeMsg EventType = "msg" -) - -// Event is an event emitted by a simulation network -type Event struct { - // Type is the type of the event - Type EventType `json:"type"` - - // Time is the time the event happened - Time time.Time `json:"time"` - - // Control indicates whether the event is the result of a controlled - // action in the network - Control bool `json:"control"` - - // Node is set if the type is EventTypeNode - Node *Node `json:"node,omitempty"` - - // Conn is set if the type is EventTypeConn - Conn *Conn `json:"conn,omitempty"` - - // Msg is set if the type is EventTypeMsg - Msg *Msg `json:"msg,omitempty"` - - //Optionally provide data (currently for simulation frontends only) - Data interface{} `json:"data"` -} - -// NewEvent creates a new event for the given object which should be either a -// Node, Conn or Msg. -// -// The object is copied so that the event represents the state of the object -// when NewEvent is called. -func NewEvent(v interface{}) *Event { - event := &Event{Time: time.Now()} - switch v := v.(type) { - case *Node: - event.Type = EventTypeNode - event.Node = v.copy() - case *Conn: - event.Type = EventTypeConn - conn := *v - event.Conn = &conn - case *Msg: - event.Type = EventTypeMsg - msg := *v - event.Msg = &msg - default: - panic(fmt.Sprintf("invalid event type: %T", v)) - } - return event -} - -// ControlEvent creates a new control event -func ControlEvent(v interface{}) *Event { - event := NewEvent(v) - event.Control = true - return event -} - -// String returns the string representation of the event -func (e *Event) String() string { - switch e.Type { - case EventTypeNode: - return fmt.Sprintf(" id: %s up: %t", e.Node.ID().TerminalString(), e.Node.Up()) - case EventTypeConn: - return fmt.Sprintf(" nodes: %s->%s up: %t", e.Conn.One.TerminalString(), e.Conn.Other.TerminalString(), e.Conn.Up) - case EventTypeMsg: - return fmt.Sprintf(" nodes: %s->%s proto: %s, code: %d, received: %t", e.Msg.One.TerminalString(), e.Msg.Other.TerminalString(), e.Msg.Protocol, e.Msg.Code, e.Msg.Received) - default: - return "" - } -} diff --git a/p2p/simulations/examples/README.md b/p2p/simulations/examples/README.md deleted file mode 100644 index 822a48dcb6e..00000000000 --- a/p2p/simulations/examples/README.md +++ /dev/null @@ -1,39 +0,0 @@ -# devp2p simulation examples - -## ping-pong - -`ping-pong.go` implements a simulation network which contains nodes running a -simple "ping-pong" protocol where nodes send a ping message to all their -connected peers every 10s and receive pong messages in return. - -To run the simulation, run `go run ping-pong.go` in one terminal to start the -simulation API and `./ping-pong.sh` in another to start and connect the nodes: - -``` -$ go run ping-pong.go -INFO [08-15|13:53:49] using sim adapter -INFO [08-15|13:53:49] starting simulation server on 0.0.0.0:8888... -``` - -``` -$ ./ping-pong.sh ----> 13:58:12 creating 10 nodes -Created node01 -Started node01 -... -Created node10 -Started node10 ----> 13:58:13 connecting node01 to all other nodes -Connected node01 to node02 -... -Connected node01 to node10 ----> 13:58:14 done -``` - -Use the `--adapter` flag to choose the adapter type: - -``` -$ go run ping-pong.go --adapter exec -INFO [08-15|14:01:14] using exec adapter tmpdir=/var/folders/k6/wpsgfg4n23ddbc6f5cnw5qg00000gn/T/p2p-example992833779 -INFO [08-15|14:01:14] starting simulation server on 0.0.0.0:8888... -``` diff --git a/p2p/simulations/http.go b/p2p/simulations/http.go deleted file mode 100644 index 07861bcaf3c..00000000000 --- a/p2p/simulations/http.go +++ /dev/null @@ -1,750 +0,0 @@ -// Copyright 2017 The go-ethereum Authors -// (original work) -// Copyright 2024 The Erigon Authors -// (modifications) -// This file is part of Erigon. -// -// Erigon is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Erigon is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with Erigon. If not, see . - -package simulations - -import ( - "bufio" - "bytes" - "context" - "encoding/json" - "fmt" - "io" - "net/http" - "strconv" - "strings" - "sync" - - "github.com/erigontech/erigon/event" - "github.com/erigontech/erigon/p2p" - "github.com/erigontech/erigon/p2p/enode" - "github.com/erigontech/erigon/p2p/simulations/adapters" - "github.com/erigontech/erigon/rpc" - - "github.com/gorilla/websocket" - "github.com/julienschmidt/httprouter" - - "github.com/erigontech/erigon-lib/log/v3" -) - -// DefaultClient is the default simulation API client which expects the API -// to be running at http://localhost:8888 -var DefaultClient = NewClient("http://localhost:8888", log.New()) - -// Client is a client for the simulation HTTP API which supports creating -// and managing simulation networks -type Client struct { - URL string - - client *http.Client - logger log.Logger -} - -// NewClient returns a new simulation API client -func NewClient(url string, logger log.Logger) *Client { - return &Client{ - URL: url, - client: http.DefaultClient, - logger: logger, - } -} - -// GetNetwork returns details of the network -func (c *Client) GetNetwork() (*Network, error) { - network := &Network{} - return network, c.Get("/", network) -} - -// StartNetwork starts all existing nodes in the simulation network -func (c *Client) StartNetwork() error { - return c.Post("/start", nil, nil) -} - -// StopNetwork stops all existing nodes in a simulation network -func (c *Client) StopNetwork() error { - return c.Post("/stop", nil, nil) -} - -// CreateSnapshot creates a network snapshot -func (c *Client) CreateSnapshot() (*Snapshot, error) { - snap := &Snapshot{} - return snap, c.Get("/snapshot", snap) -} - -// LoadSnapshot loads a snapshot into the network -func (c *Client) LoadSnapshot(snap *Snapshot) error { - return c.Post("/snapshot", snap, nil) -} - -// SubscribeOpts is a collection of options to use when subscribing to network -// events -type SubscribeOpts struct { - // Current instructs the server to send events for existing nodes and - // connections first - Current bool - - // Filter instructs the server to only send a subset of message events - Filter string -} - -// SubscribeNetwork subscribes to network events which are sent from the server -// as a server-sent-events stream, optionally receiving events for existing -// nodes and connections and filtering message events -func (c *Client) SubscribeNetwork(events chan *Event, opts SubscribeOpts) (event.Subscription, error) { - url := fmt.Sprintf("%s/events?current=%t&filter=%s", c.URL, opts.Current, opts.Filter) - req, err := http.NewRequest("GET", url, nil) - if err != nil { - return nil, err - } - req.Header.Set("Accept", "text/event-stream") - res, err := c.client.Do(req) - if err != nil { - return nil, err - } - if res.StatusCode != http.StatusOK { - response, _ := io.ReadAll(res.Body) - res.Body.Close() - return nil, fmt.Errorf("unexpected HTTP status: %s: %s", res.Status, response) - } - - // define a producer function to pass to event.Subscription - // which reads server-sent events from res.Body and sends - // them to the events channel - producer := func(stop <-chan struct{}) error { - defer res.Body.Close() - - // read lines from res.Body in a goroutine so that we are - // always reading from the stop channel - lines := make(chan string) - errC := make(chan error, 1) - go func() { - s := bufio.NewScanner(res.Body) - for s.Scan() { - select { - case lines <- s.Text(): - case <-stop: - return - } - } - errC <- s.Err() - }() - - // detect any lines which start with "data:", decode the data - // into an event and send it to the events channel - for { - select { - case line := <-lines: - if !strings.HasPrefix(line, "data:") { - continue - } - data := strings.TrimSpace(strings.TrimPrefix(line, "data:")) - event := &Event{} - if err := json.Unmarshal([]byte(data), event); err != nil { - return fmt.Errorf("error decoding SSE event: %s", err) - } - select { - case events <- event: - case <-stop: - return nil - } - case err := <-errC: - return err - case <-stop: - return nil - } - } - } - - return event.NewSubscription(producer), nil -} - -// GetNodes returns all nodes which exist in the network -func (c *Client) GetNodes() ([]*p2p.NodeInfo, error) { - var nodes []*p2p.NodeInfo - return nodes, c.Get("/nodes", &nodes) -} - -// CreateNode creates a node in the network using the given configuration -func (c *Client) CreateNode(config *adapters.NodeConfig) (*p2p.NodeInfo, error) { - node := &p2p.NodeInfo{} - return node, c.Post("/nodes", config, node) -} - -// GetNode returns details of a node -func (c *Client) GetNode(nodeID string) (*p2p.NodeInfo, error) { - node := &p2p.NodeInfo{} - return node, c.Get("/nodes/"+nodeID, node) -} - -// StartNode starts a node -func (c *Client) StartNode(nodeID string) error { - return c.Post(fmt.Sprintf("/nodes/%s/start", nodeID), nil, nil) -} - -// StopNode stops a node -func (c *Client) StopNode(nodeID string) error { - return c.Post(fmt.Sprintf("/nodes/%s/stop", nodeID), nil, nil) -} - -// ConnectNode connects a node to a peer node -func (c *Client) ConnectNode(nodeID, peerID string) error { - return c.Post(fmt.Sprintf("/nodes/%s/conn/%s", nodeID, peerID), nil, nil) -} - -// DisconnectNode disconnects a node from a peer node -func (c *Client) DisconnectNode(nodeID, peerID string) error { - return c.Delete(fmt.Sprintf("/nodes/%s/conn/%s", nodeID, peerID)) -} - -// RPCClient returns an RPC client connected to a node -func (c *Client) RPCClient(ctx context.Context, nodeID string) (*rpc.Client, error) { - baseURL := strings.Replace(c.URL, "http", "ws", 1) - return rpc.DialWebsocket(ctx, fmt.Sprintf("%s/nodes/%s/rpc", baseURL, nodeID), "", c.logger) -} - -// Get performs a HTTP GET request decoding the resulting JSON response -// into "out" -func (c *Client) Get(path string, out interface{}) error { - return c.Send("GET", path, nil, out) -} - -// Post performs a HTTP POST request sending "in" as the JSON body and -// decoding the resulting JSON response into "out" -func (c *Client) Post(path string, in, out interface{}) error { - return c.Send("POST", path, in, out) -} - -// Delete performs a HTTP DELETE request -func (c *Client) Delete(path string) error { - return c.Send("DELETE", path, nil, nil) -} - -// Send performs a HTTP request, sending "in" as the JSON request body and -// decoding the JSON response into "out" -func (c *Client) Send(method, path string, in, out interface{}) error { - var body []byte - if in != nil { - var err error - body, err = json.Marshal(in) - if err != nil { - return err - } - } - req, err := http.NewRequest(method, c.URL+path, bytes.NewReader(body)) - if err != nil { - return err - } - req.Header.Set("Content-Type", "application/json") - req.Header.Set("Accept", "application/json") - res, err := c.client.Do(req) - if err != nil { - return err - } - defer res.Body.Close() - if res.StatusCode != http.StatusOK && res.StatusCode != http.StatusCreated { - response, _ := io.ReadAll(res.Body) - return fmt.Errorf("unexpected HTTP status: %s: %s", res.Status, response) - } - if out != nil { - if err := json.NewDecoder(res.Body).Decode(out); err != nil { - return err - } - } - return nil -} - -// Server is an HTTP server providing an API to manage a simulation network -type Server struct { - router *httprouter.Router - network *Network - mockerStop chan struct{} // when set, stops the current mocker - mockerMtx sync.Mutex // synchronises access to the mockerStop field -} - -// NewServer returns a new simulation API server -func NewServer(network *Network) *Server { - s := &Server{ - router: httprouter.New(), - network: network, - } - - s.OPTIONS("/", s.Options) - s.GET("/", s.GetNetwork) - s.POST("/start", s.StartNetwork) - s.POST("/stop", s.StopNetwork) - s.POST("/mocker/start", s.StartMocker) - s.POST("/mocker/stop", s.StopMocker) - s.GET("/mocker", s.GetMockers) - s.POST("/reset", s.ResetNetwork) - s.GET("/events", s.StreamNetworkEvents) - s.GET("/snapshot", s.CreateSnapshot) - s.POST("/snapshot", s.LoadSnapshot) - s.POST("/nodes", s.CreateNode) - s.GET("/nodes", s.GetNodes) - s.GET("/nodes/:nodeid", s.GetNode) - s.POST("/nodes/:nodeid/start", s.StartNode) - s.POST("/nodes/:nodeid/stop", s.StopNode) - s.POST("/nodes/:nodeid/conn/:peerid", s.ConnectNode) - s.DELETE("/nodes/:nodeid/conn/:peerid", s.DisconnectNode) - s.GET("/nodes/:nodeid/rpc", s.NodeRPC) - - return s -} - -// GetNetwork returns details of the network -func (s *Server) GetNetwork(w http.ResponseWriter, req *http.Request) { - s.JSON(w, http.StatusOK, s.network) -} - -// StartNetwork starts all nodes in the network -func (s *Server) StartNetwork(w http.ResponseWriter, req *http.Request) { - if err := s.network.StartAll(); err != nil { - http.Error(w, err.Error(), http.StatusInternalServerError) - return - } - - w.WriteHeader(http.StatusOK) -} - -// StopNetwork stops all nodes in the network -func (s *Server) StopNetwork(w http.ResponseWriter, req *http.Request) { - if err := s.network.StopAll(); err != nil { - http.Error(w, err.Error(), http.StatusInternalServerError) - return - } - - w.WriteHeader(http.StatusOK) -} - -// StartMocker starts the mocker node simulation -func (s *Server) StartMocker(w http.ResponseWriter, req *http.Request) { - s.mockerMtx.Lock() - defer s.mockerMtx.Unlock() - if s.mockerStop != nil { - http.Error(w, "mocker already running", http.StatusInternalServerError) - return - } - mockerType := req.FormValue("mocker-type") - mockerFn := LookupMocker(mockerType) - if mockerFn == nil { - http.Error(w, fmt.Sprintf("unknown mocker type %q", mockerType), http.StatusBadRequest) - return - } - nodeCount, err := strconv.Atoi(req.FormValue("node-count")) - if err != nil { - http.Error(w, "invalid node-count provided", http.StatusBadRequest) - return - } - s.mockerStop = make(chan struct{}) - go mockerFn(s.network, s.mockerStop, nodeCount) - - w.WriteHeader(http.StatusOK) -} - -// StopMocker stops the mocker node simulation -func (s *Server) StopMocker(w http.ResponseWriter, req *http.Request) { - s.mockerMtx.Lock() - defer s.mockerMtx.Unlock() - if s.mockerStop == nil { - http.Error(w, "stop channel not initialized", http.StatusInternalServerError) - return - } - close(s.mockerStop) - s.mockerStop = nil - - w.WriteHeader(http.StatusOK) -} - -// GetMockerList returns a list of available mockers -func (s *Server) GetMockers(w http.ResponseWriter, req *http.Request) { - - list := GetMockerList() - s.JSON(w, http.StatusOK, list) -} - -// ResetNetwork resets all properties of a network to its initial (empty) state -func (s *Server) ResetNetwork(w http.ResponseWriter, req *http.Request) { - s.network.Reset() - - w.WriteHeader(http.StatusOK) -} - -// StreamNetworkEvents streams network events as a server-sent-events stream -func (s *Server) StreamNetworkEvents(w http.ResponseWriter, req *http.Request) { - events := make(chan *Event) - sub := s.network.events.Subscribe(events) - defer sub.Unsubscribe() - - // write writes the given event and data to the stream like: - // - // event: - // data: - // - write := func(event, data string) { - fmt.Fprintf(w, "event: %s\n", event) - fmt.Fprintf(w, "data: %s\n\n", data) - if fw, ok := w.(http.Flusher); ok { - fw.Flush() - } - } - writeEvent := func(event *Event) error { - data, err := json.Marshal(event) - if err != nil { - return err - } - write("network", string(data)) - return nil - } - writeErr := func(err error) { - write("error", err.Error()) - } - - // check if filtering has been requested - var filters MsgFilters - if filterParam := req.URL.Query().Get("filter"); filterParam != "" { - var err error - filters, err = NewMsgFilters(filterParam) - if err != nil { - http.Error(w, err.Error(), http.StatusBadRequest) - return - } - } - - w.Header().Set("Content-Type", "text/event-stream; charset=utf-8") - w.WriteHeader(http.StatusOK) - fmt.Fprintf(w, "\n\n") - if fw, ok := w.(http.Flusher); ok { - fw.Flush() - } - - // optionally send the existing nodes and connections - if req.URL.Query().Get("current") == "true" { - snap, err := s.network.Snapshot() - if err != nil { - writeErr(err) - return - } - for _, node := range snap.Nodes { - event := NewEvent(&node.Node) - if err := writeEvent(event); err != nil { - writeErr(err) - return - } - } - for _, conn := range snap.Conns { - conn := conn - event := NewEvent(&conn) - if err := writeEvent(event); err != nil { - writeErr(err) - return - } - } - } - - clientGone := req.Context().Done() - for { - select { - case event := <-events: - // only send message events which match the filters - if event.Msg != nil && !filters.Match(event.Msg) { - continue - } - if err := writeEvent(event); err != nil { - writeErr(err) - return - } - case <-clientGone: - return - } - } -} - -// NewMsgFilters constructs a collection of message filters from a URL query -// parameter. -// -// The parameter is expected to be a dash-separated list of individual filters, -// each having the format ':', where is the name of a -// protocol and is a comma-separated list of message codes. -// -// A message code of '*' or '-1' is considered a wildcard and matches any code. -func NewMsgFilters(filterParam string) (MsgFilters, error) { - filters := make(MsgFilters) - for _, filter := range strings.Split(filterParam, "-") { - protoCodes := strings.SplitN(filter, ":", 2) - if len(protoCodes) != 2 || protoCodes[0] == "" || protoCodes[1] == "" { - return nil, fmt.Errorf("invalid message filter: %s", filter) - } - proto := protoCodes[0] - for _, code := range strings.Split(protoCodes[1], ",") { - if code == "*" || code == "-1" { - filters[MsgFilter{Proto: proto, Code: -1}] = struct{}{} - continue - } - n, err := strconv.ParseUint(code, 10, 64) - if err != nil { - return nil, fmt.Errorf("invalid message code: %s", code) - } - filters[MsgFilter{Proto: proto, Code: int64(n)}] = struct{}{} - } - } - return filters, nil -} - -// MsgFilters is a collection of filters which are used to filter message -// events -type MsgFilters map[MsgFilter]struct{} - -// Match checks if the given message matches any of the filters -func (m MsgFilters) Match(msg *Msg) bool { - // check if there is a wildcard filter for the message's protocol - if _, ok := m[MsgFilter{Proto: msg.Protocol, Code: -1}]; ok { - return true - } - - // check if there is a filter for the message's protocol and code - if _, ok := m[MsgFilter{Proto: msg.Protocol, Code: int64(msg.Code)}]; ok { - return true - } - - return false -} - -// MsgFilter is used to filter message events based on protocol and message -// code -type MsgFilter struct { - // Proto is matched against a message's protocol - Proto string - - // Code is matched against a message's code, with -1 matching all codes - Code int64 -} - -// CreateSnapshot creates a network snapshot -func (s *Server) CreateSnapshot(w http.ResponseWriter, req *http.Request) { - snap, err := s.network.Snapshot() - if err != nil { - http.Error(w, err.Error(), http.StatusInternalServerError) - return - } - - s.JSON(w, http.StatusOK, snap) -} - -// LoadSnapshot loads a snapshot into the network -func (s *Server) LoadSnapshot(w http.ResponseWriter, req *http.Request) { - snap := &Snapshot{} - if err := json.NewDecoder(req.Body).Decode(snap); err != nil { - http.Error(w, err.Error(), http.StatusBadRequest) - return - } - - if err := s.network.Load(snap); err != nil { - http.Error(w, err.Error(), http.StatusInternalServerError) - return - } - - s.JSON(w, http.StatusOK, s.network) -} - -// CreateNode creates a node in the network using the given configuration -func (s *Server) CreateNode(w http.ResponseWriter, req *http.Request) { - config := &adapters.NodeConfig{} - - err := json.NewDecoder(req.Body).Decode(config) - if err != nil && err != io.EOF { - http.Error(w, err.Error(), http.StatusBadRequest) - return - } - - node, err := s.network.NewNodeWithConfig(config) - if err != nil { - http.Error(w, err.Error(), http.StatusInternalServerError) - return - } - - s.JSON(w, http.StatusCreated, node.NodeInfo()) -} - -// GetNodes returns all nodes which exist in the network -func (s *Server) GetNodes(w http.ResponseWriter, req *http.Request) { - nodes := s.network.GetNodes() - - infos := make([]*p2p.NodeInfo, len(nodes)) - for i, node := range nodes { - infos[i] = node.NodeInfo() - } - - s.JSON(w, http.StatusOK, infos) -} - -// GetNode returns details of a node -func (s *Server) GetNode(w http.ResponseWriter, req *http.Request) { - node := req.Context().Value("node").(*Node) - - s.JSON(w, http.StatusOK, node.NodeInfo()) -} - -// StartNode starts a node -func (s *Server) StartNode(w http.ResponseWriter, req *http.Request) { - node := req.Context().Value("node").(*Node) - - if err := s.network.Start(node.ID()); err != nil { - http.Error(w, err.Error(), http.StatusInternalServerError) - return - } - - s.JSON(w, http.StatusOK, node.NodeInfo()) -} - -// StopNode stops a node -func (s *Server) StopNode(w http.ResponseWriter, req *http.Request) { - node := req.Context().Value("node").(*Node) - - if err := s.network.Stop(node.ID()); err != nil { - http.Error(w, err.Error(), http.StatusInternalServerError) - return - } - - s.JSON(w, http.StatusOK, node.NodeInfo()) -} - -// ConnectNode connects a node to a peer node -func (s *Server) ConnectNode(w http.ResponseWriter, req *http.Request) { - node := req.Context().Value("node").(*Node) - peer := req.Context().Value("peer").(*Node) - - if err := s.network.Connect(node.ID(), peer.ID()); err != nil { - http.Error(w, err.Error(), http.StatusInternalServerError) - return - } - - s.JSON(w, http.StatusOK, node.NodeInfo()) -} - -// DisconnectNode disconnects a node from a peer node -func (s *Server) DisconnectNode(w http.ResponseWriter, req *http.Request) { - node := req.Context().Value("node").(*Node) - peer := req.Context().Value("peer").(*Node) - - if err := s.network.Disconnect(node.ID(), peer.ID()); err != nil { - http.Error(w, err.Error(), http.StatusInternalServerError) - return - } - - s.JSON(w, http.StatusOK, node.NodeInfo()) -} - -// Options responds to the OPTIONS HTTP method by returning a 200 OK response -// with the "Access-Control-Allow-Headers" header set to "Content-Type" -func (s *Server) Options(w http.ResponseWriter, req *http.Request) { - w.Header().Set("Access-Control-Allow-Headers", "Content-Type") - w.WriteHeader(http.StatusOK) -} - -var wsUpgrade = websocket.Upgrader{ - CheckOrigin: func(*http.Request) bool { return true }, -} - -// NodeRPC forwards RPC requests to a node in the network via a WebSocket -// connection -func (s *Server) NodeRPC(w http.ResponseWriter, req *http.Request) { - conn, err := wsUpgrade.Upgrade(w, req, nil) - if err != nil { - return - } - defer conn.Close() - node := req.Context().Value("node").(*Node) - node.ServeRPC(conn) -} - -// ServeHTTP implements the http.Handler interface by delegating to the -// underlying httprouter.Router -func (s *Server) ServeHTTP(w http.ResponseWriter, req *http.Request) { - s.router.ServeHTTP(w, req) -} - -// GET registers a handler for GET requests to a particular path -func (s *Server) GET(path string, handle http.HandlerFunc) { - s.router.GET(path, s.wrapHandler(handle)) -} - -// POST registers a handler for POST requests to a particular path -func (s *Server) POST(path string, handle http.HandlerFunc) { - s.router.POST(path, s.wrapHandler(handle)) -} - -// DELETE registers a handler for DELETE requests to a particular path -func (s *Server) DELETE(path string, handle http.HandlerFunc) { - s.router.DELETE(path, s.wrapHandler(handle)) -} - -// OPTIONS registers a handler for OPTIONS requests to a particular path -func (s *Server) OPTIONS(path string, handle http.HandlerFunc) { - s.router.OPTIONS("/*path", s.wrapHandler(handle)) -} - -// JSON sends "data" as a JSON HTTP response -func (s *Server) JSON(w http.ResponseWriter, status int, data interface{}) { - w.Header().Set("Content-Type", "application/json") - w.WriteHeader(status) - json.NewEncoder(w).Encode(data) -} - -// wrapHandler returns an httprouter.Handle which wraps an http.HandlerFunc by -// populating request.Context with any objects from the URL params -func (s *Server) wrapHandler(handler http.HandlerFunc) httprouter.Handle { - return func(w http.ResponseWriter, req *http.Request, params httprouter.Params) { - w.Header().Set("Access-Control-Allow-Origin", "*") - w.Header().Set("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS") - - ctx := req.Context() - - if id := params.ByName("nodeid"); id != "" { - var nodeID enode.ID - var node *Node - if nodeID.UnmarshalText([]byte(id)) == nil { - node = s.network.GetNode(nodeID) - } else { - node = s.network.GetNodeByName(id) - } - if node == nil { - http.NotFound(w, req) - return - } - ctx = context.WithValue(ctx, "node", node) - } - - if id := params.ByName("peerid"); id != "" { - var peerID enode.ID - var peer *Node - if peerID.UnmarshalText([]byte(id)) == nil { - peer = s.network.GetNode(peerID) - } else { - peer = s.network.GetNodeByName(id) - } - if peer == nil { - http.NotFound(w, req) - return - } - ctx = context.WithValue(ctx, "peer", peer) - } - - handler(w, req.WithContext(ctx)) - } -} diff --git a/p2p/simulations/mocker.go b/p2p/simulations/mocker.go deleted file mode 100644 index b9105f3b8fa..00000000000 --- a/p2p/simulations/mocker.go +++ /dev/null @@ -1,203 +0,0 @@ -// Copyright 2017 The go-ethereum Authors -// (original work) -// Copyright 2024 The Erigon Authors -// (modifications) -// This file is part of Erigon. -// -// Erigon is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Erigon is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with Erigon. If not, see . - -// Package simulations simulates p2p networks. -// A mocker simulates starting and stopping real nodes in a network. -package simulations - -import ( - "fmt" - "math/rand" - "sync" - "time" - - "github.com/erigontech/erigon-lib/log/v3" - "github.com/erigontech/erigon/p2p/enode" - "github.com/erigontech/erigon/p2p/simulations/adapters" -) - -// a map of mocker names to its function -var mockerList = map[string]func(net *Network, quit chan struct{}, nodeCount int){ - "startStop": startStop, - "probabilistic": probabilistic, - "boot": boot, -} - -// Lookup a mocker by its name, returns the mockerFn -func LookupMocker(mockerType string) func(net *Network, quit chan struct{}, nodeCount int) { - return mockerList[mockerType] -} - -// Get a list of mockers (keys of the map) -// Useful for frontend to build available mocker selection -func GetMockerList() []string { - list := make([]string, 0, len(mockerList)) - for k := range mockerList { - list = append(list, k) - } - return list -} - -// The boot mockerFn only connects the node in a ring and doesn't do anything else -func boot(net *Network, quit chan struct{}, nodeCount int) { - _, err := connectNodesInRing(net, nodeCount) - if err != nil { - panic("Could not startup node network for mocker") - } -} - -// The startStop mockerFn stops and starts nodes in a defined period (ticker) -func startStop(net *Network, quit chan struct{}, nodeCount int) { - nodes, err := connectNodesInRing(net, nodeCount) - if err != nil { - panic("Could not startup node network for mocker") - } - tick := time.NewTicker(10 * time.Second) - defer tick.Stop() - for { - select { - case <-quit: - log.Info("Terminating simulation loop") - return - case <-tick.C: - id := nodes[rand.Intn(len(nodes))] - log.Info("stopping node", "id", id) - if err := net.Stop(id); err != nil { - log.Error("Error stopping node", "id", id, "err", err) - return - } - - select { - case <-quit: - log.Info("Terminating simulation loop ...") - return - case <-time.After(3 * time.Second): - } - - log.Trace("Starting node ...", "id", id) - if err := net.Start(id); err != nil { - log.Error("error starting node", "id", id, "err", err) - return - } - } - } -} - -// The probabilistic mocker func has a more probabilistic pattern -// (the implementation could probably be improved): -// nodes are connected in a ring, then a varying number of random nodes is selected, -// mocker then stops and starts them in random intervals, and continues the loop -func probabilistic(net *Network, quit chan struct{}, nodeCount int) { - nodes, err := connectNodesInRing(net, nodeCount) - if err != nil { - select { - case <-quit: - //error may be due to abortion of mocking; so the quit channel is closed - return - default: - panic("Could not startup node network for mocker") - } - } - for { - select { - case <-quit: - log.Info("Terminating simulation loop") - return - default: - } - var lowid, highid int - var wg sync.WaitGroup - randWait := time.Duration(rand.Intn(5000)+1000) * time.Millisecond - rand1 := rand.Intn(nodeCount - 1) - rand2 := rand.Intn(nodeCount - 1) - if rand1 < rand2 { - lowid = rand1 - highid = rand2 - } else if rand1 > rand2 { - highid = rand1 - lowid = rand2 - } else { - if rand1 == 0 { - rand2 = 9 - } else if rand1 == 9 { - rand1 = 0 - } - lowid = rand1 - highid = rand2 - } - var steps = highid - lowid - wg.Add(steps) - for i := lowid; i < highid; i++ { - select { - case <-quit: - log.Info("Terminating simulation loop") - return - case <-time.After(randWait): - } - log.Trace(fmt.Sprintf("Node %v shutting down ...", nodes[i])) - err := net.Stop(nodes[i]) - if err != nil { - log.Error("Error stopping node", "node", nodes[i]) - wg.Done() - continue - } - go func(id enode.ID) { - time.Sleep(randWait) - err := net.Start(id) - if err != nil { - log.Error("Error starting node", "node", id) - } - wg.Done() - }(nodes[i]) - } - wg.Wait() - } - -} - -// connect nodeCount number of nodes in a ring -func connectNodesInRing(net *Network, nodeCount int) ([]enode.ID, error) { - ids := make([]enode.ID, nodeCount) - for i := 0; i < nodeCount; i++ { - conf := adapters.RandomNodeConfig() - node, err := net.NewNodeWithConfig(conf) - if err != nil { - log.Error("Error creating a node!", "err", err) - return nil, err - } - ids[i] = node.ID() - } - - for _, id := range ids { - if err := net.Start(id); err != nil { - log.Error("Error starting a node!", "err", err) - return nil, err - } - log.Trace(fmt.Sprintf("Node %v starting up", id)) - } - for i, id := range ids { - peerID := ids[(i+1)%len(ids)] - if err := net.Connect(id, peerID); err != nil { - log.Error("Error connecting a node to a peer!", "err", err) - return nil, err - } - } - - return ids, nil -} diff --git a/p2p/simulations/network.go b/p2p/simulations/network.go deleted file mode 100644 index d3b217a109d..00000000000 --- a/p2p/simulations/network.go +++ /dev/null @@ -1,1104 +0,0 @@ -// Copyright 2017 The go-ethereum Authors -// (original work) -// Copyright 2024 The Erigon Authors -// (modifications) -// This file is part of Erigon. -// -// Erigon is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Erigon is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with Erigon. If not, see . - -package simulations - -import ( - "bytes" - "context" - "encoding/json" - "errors" - "fmt" - "io" - "math/rand" - "sync" - "time" - - "github.com/erigontech/erigon-lib/log/v3" - "github.com/erigontech/erigon/event" - "github.com/erigontech/erigon/p2p" - "github.com/erigontech/erigon/p2p/enode" - "github.com/erigontech/erigon/p2p/simulations/adapters" -) - -var DialBanTimeout = 200 * time.Millisecond - -// NetworkConfig defines configuration options for starting a Network -type NetworkConfig struct { - ID string `json:"id"` - DefaultService string `json:"default_service,omitempty"` -} - -// Network models a p2p simulation network which consists of a collection of -// simulated nodes and the connections which exist between them. -// -// The Network has a single NodeAdapter which is responsible for actually -// starting nodes and connecting them together. -// -// The Network emits events when nodes are started and stopped, when they are -// connected and disconnected, and also when messages are sent between nodes. -type Network struct { - NetworkConfig - - Nodes []*Node `json:"nodes"` - nodeMap map[enode.ID]int - - // Maps a node property string to node indexes of all nodes that hold this property - propertyMap map[string][]int - - Conns []*Conn `json:"conns"` - connMap map[string]int - - nodeAdapter adapters.NodeAdapter - events event.Feed - lock sync.RWMutex - quitc chan struct{} -} - -// NewNetwork returns a Network which uses the given NodeAdapter and NetworkConfig -func NewNetwork(nodeAdapter adapters.NodeAdapter, conf *NetworkConfig) *Network { - return &Network{ - NetworkConfig: *conf, - nodeAdapter: nodeAdapter, - nodeMap: make(map[enode.ID]int), - propertyMap: make(map[string][]int), - connMap: make(map[string]int), - quitc: make(chan struct{}), - } -} - -// Events returns the output event feed of the Network. -func (net *Network) Events() *event.Feed { - return &net.events -} - -// NewNodeWithConfig adds a new node to the network with the given config, -// returning an error if a node with the same ID or name already exists -func (net *Network) NewNodeWithConfig(conf *adapters.NodeConfig) (*Node, error) { - net.lock.Lock() - defer net.lock.Unlock() - - if conf.Reachable == nil { - conf.Reachable = func(otherID enode.ID) bool { - _, err := net.InitConn(conf.ID, otherID) - if err != nil && bytes.Compare(conf.ID.Bytes(), otherID.Bytes()) < 0 { - return false - } - return true - } - } - - // check the node doesn't already exist - if node := net.getNode(conf.ID); node != nil { - return nil, fmt.Errorf("node with ID %q already exists", conf.ID) - } - if node := net.getNodeByName(conf.Name); node != nil { - return nil, fmt.Errorf("node with name %q already exists", conf.Name) - } - - // if no services are configured, use the default service - if len(conf.Lifecycles) == 0 { - conf.Lifecycles = []string{net.DefaultService} - } - - // use the NodeAdapter to create the node - adapterNode, err := net.nodeAdapter.NewNode(conf) - if err != nil { - return nil, err - } - node := newNode(adapterNode, conf, false) - log.Trace("Node created", "id", conf.ID) - - nodeIndex := len(net.Nodes) - net.nodeMap[conf.ID] = nodeIndex - net.Nodes = append(net.Nodes, node) - - // Register any node properties with the network-level propertyMap - for _, property := range conf.Properties { - net.propertyMap[property] = append(net.propertyMap[property], nodeIndex) - } - - // emit a "control" event - net.events.Send(ControlEvent(node)) - - return node, nil -} - -// Config returns the network configuration -func (net *Network) Config() *NetworkConfig { - return &net.NetworkConfig -} - -// StartAll starts all nodes in the network -func (net *Network) StartAll() error { - for _, node := range net.Nodes { - if node.Up() { - continue - } - if err := net.Start(node.ID()); err != nil { - return err - } - } - return nil -} - -// StopAll stops all nodes in the network -func (net *Network) StopAll() error { - for _, node := range net.Nodes { - if !node.Up() { - continue - } - if err := net.Stop(node.ID()); err != nil { - return err - } - } - return nil -} - -// Start starts the node with the given ID -func (net *Network) Start(id enode.ID) error { - return net.startWithSnapshots(id, nil) -} - -// startWithSnapshots starts the node with the given ID using the give -// snapshots -func (net *Network) startWithSnapshots(id enode.ID, snapshots map[string][]byte) error { - net.lock.Lock() - defer net.lock.Unlock() - - node := net.getNode(id) - if node == nil { - return fmt.Errorf("node %v does not exist", id) - } - if node.Up() { - return fmt.Errorf("node %v already up", id) - } - log.Trace("Starting node", "id", id, "adapter", net.nodeAdapter.Name()) - if err := node.Start(snapshots); err != nil { - log.Warn("Node startup failed", "id", id, "err", err) - return err - } - node.SetUp(true) - log.Info("Started node", "id", id) - ev := NewEvent(node) - net.events.Send(ev) - - // subscribe to peer events - client, err := node.Client() - if err != nil { - return fmt.Errorf("error getting rpc client for node %v: %w", id, err) - } - events := make(chan *p2p.PeerEvent) - sub, err := client.Subscribe(context.Background(), "admin", events, "peerEvents") - if err != nil { - return fmt.Errorf("error getting peer events for node %v: %w", id, err) - } - go net.watchPeerEvents(id, events, sub) - return nil -} - -// watchPeerEvents reads peer events from the given channel and emits -// corresponding network events -func (net *Network) watchPeerEvents(id enode.ID, events chan *p2p.PeerEvent, sub event.Subscription) { - defer func() { - sub.Unsubscribe() - - // assume the node is now down - net.lock.Lock() - defer net.lock.Unlock() - - node := net.getNode(id) - if node == nil { - return - } - node.SetUp(false) - ev := NewEvent(node) - net.events.Send(ev) - }() - for { - select { - case event, ok := <-events: - if !ok { - return - } - peer := event.Peer - switch event.Type { - - case p2p.PeerEventTypeAdd: - net.DidConnect(id, peer) - - case p2p.PeerEventTypeDrop: - net.DidDisconnect(id, peer) - - case p2p.PeerEventTypeMsgSend: - net.DidSend(id, peer, event.Protocol, *event.MsgCode) - - case p2p.PeerEventTypeMsgRecv: - net.DidReceive(peer, id, event.Protocol, *event.MsgCode) - - } - - case err := <-sub.Err(): - if err != nil { - log.Error("Error in peer event subscription", "id", id, "err", err) - } - return - } - } -} - -// Stop stops the node with the given ID -func (net *Network) Stop(id enode.ID) error { - // IMPORTANT: node.Stop() must NOT be called under net.lock as - // node.Reachable() closure has a reference to the network and - // calls net.InitConn() what also locks the network. => DEADLOCK - // That holds until the following ticket is not resolved: - - var err error - - node, err := func() (*Node, error) { - net.lock.Lock() - defer net.lock.Unlock() - - node := net.getNode(id) - if node == nil { - return nil, fmt.Errorf("node %v does not exist", id) - } - if !node.Up() { - return nil, fmt.Errorf("node %v already down", id) - } - node.SetUp(false) - return node, nil - }() - if err != nil { - return err - } - - err = node.Stop() // must be called without net.lock - - net.lock.Lock() - defer net.lock.Unlock() - - if err != nil { - node.SetUp(true) - return err - } - log.Info("Stopped node", "id", id, "err", err) - ev := ControlEvent(node) - net.events.Send(ev) - return nil -} - -// Connect connects two nodes together by calling the "admin_addPeer" RPC -// method on the "one" node so that it connects to the "other" node -func (net *Network) Connect(oneID, otherID enode.ID) error { - net.lock.Lock() - defer net.lock.Unlock() - return net.connect(oneID, otherID) -} - -func (net *Network) connect(oneID, otherID enode.ID) error { - log.Trace("Connecting nodes with addPeer", "id", oneID, "other", otherID) - conn, err := net.initConn(oneID, otherID) - if err != nil { - return err - } - client, err := conn.one.Client() - if err != nil { - return err - } - net.events.Send(ControlEvent(conn)) - return client.Call(nil, "admin_addPeer", string(conn.other.Addr())) -} - -// Disconnect disconnects two nodes by calling the "admin_removePeer" RPC -// method on the "one" node so that it disconnects from the "other" node -func (net *Network) Disconnect(oneID, otherID enode.ID) error { - conn := net.GetConn(oneID, otherID) - if conn == nil { - return fmt.Errorf("connection between %v and %v does not exist", oneID, otherID) - } - if !conn.Up { - return fmt.Errorf("%v and %v already disconnected", oneID, otherID) - } - client, err := conn.one.Client() - if err != nil { - return err - } - net.events.Send(ControlEvent(conn)) - return client.Call(nil, "admin_removePeer", string(conn.other.Addr())) -} - -// DidConnect tracks the fact that the "one" node connected to the "other" node -func (net *Network) DidConnect(one, other enode.ID) error { - net.lock.Lock() - defer net.lock.Unlock() - conn, err := net.getOrCreateConn(one, other) - if err != nil { - return fmt.Errorf("connection between %v and %v does not exist", one, other) - } - if conn.Up { - return fmt.Errorf("%v and %v already connected", one, other) - } - conn.Up = true - net.events.Send(NewEvent(conn)) - return nil -} - -// DidDisconnect tracks the fact that the "one" node disconnected from the -// "other" node -func (net *Network) DidDisconnect(one, other enode.ID) error { - net.lock.Lock() - defer net.lock.Unlock() - conn := net.getConn(one, other) - if conn == nil { - return fmt.Errorf("connection between %v and %v does not exist", one, other) - } - if !conn.Up { - return fmt.Errorf("%v and %v already disconnected", one, other) - } - conn.Up = false - conn.initiated = time.Now().Add(-DialBanTimeout) - net.events.Send(NewEvent(conn)) - return nil -} - -// DidSend tracks the fact that "sender" sent a message to "receiver" -func (net *Network) DidSend(sender, receiver enode.ID, proto string, code uint64) error { - msg := &Msg{ - One: sender, - Other: receiver, - Protocol: proto, - Code: code, - Received: false, - } - net.events.Send(NewEvent(msg)) - return nil -} - -// DidReceive tracks the fact that "receiver" received a message from "sender" -func (net *Network) DidReceive(sender, receiver enode.ID, proto string, code uint64) error { - msg := &Msg{ - One: sender, - Other: receiver, - Protocol: proto, - Code: code, - Received: true, - } - net.events.Send(NewEvent(msg)) - return nil -} - -// GetNode gets the node with the given ID, returning nil if the node does not -// exist -func (net *Network) GetNode(id enode.ID) *Node { - net.lock.RLock() - defer net.lock.RUnlock() - return net.getNode(id) -} - -func (net *Network) getNode(id enode.ID) *Node { - i, found := net.nodeMap[id] - if !found { - return nil - } - return net.Nodes[i] -} - -// GetNodeByName gets the node with the given name, returning nil if the node does -// not exist -func (net *Network) GetNodeByName(name string) *Node { - net.lock.RLock() - defer net.lock.RUnlock() - return net.getNodeByName(name) -} - -func (net *Network) getNodeByName(name string) *Node { - for _, node := range net.Nodes { - if node.Config.Name == name { - return node - } - } - return nil -} - -// GetNodeIDs returns the IDs of all existing nodes -// Nodes can optionally be excluded by specifying their enode.ID. -func (net *Network) GetNodeIDs(excludeIDs ...enode.ID) []enode.ID { - net.lock.RLock() - defer net.lock.RUnlock() - - return net.getNodeIDs(excludeIDs) -} - -func (net *Network) getNodeIDs(excludeIDs []enode.ID) []enode.ID { - // Get all current nodeIDs - nodeIDs := make([]enode.ID, 0, len(net.nodeMap)) - for id := range net.nodeMap { - nodeIDs = append(nodeIDs, id) - } - - if len(excludeIDs) > 0 { - // Return the difference of nodeIDs and excludeIDs - return filterIDs(nodeIDs, excludeIDs) - } - return nodeIDs -} - -// GetNodes returns the existing nodes. -// Nodes can optionally be excluded by specifying their enode.ID. -func (net *Network) GetNodes(excludeIDs ...enode.ID) []*Node { - net.lock.RLock() - defer net.lock.RUnlock() - - return net.getNodes(excludeIDs) -} - -func (net *Network) getNodes(excludeIDs []enode.ID) []*Node { - if len(excludeIDs) > 0 { - nodeIDs := net.getNodeIDs(excludeIDs) - return net.getNodesByID(nodeIDs) - } - return net.Nodes -} - -// GetNodesByID returns existing nodes with the given enode.IDs. -// If a node doesn't exist with a given enode.ID, it is ignored. -func (net *Network) GetNodesByID(nodeIDs []enode.ID) []*Node { - net.lock.RLock() - defer net.lock.RUnlock() - - return net.getNodesByID(nodeIDs) -} - -func (net *Network) getNodesByID(nodeIDs []enode.ID) []*Node { - nodes := make([]*Node, 0, len(nodeIDs)) - for _, id := range nodeIDs { - node := net.getNode(id) - if node != nil { - nodes = append(nodes, node) - } - } - - return nodes -} - -// GetNodesByProperty returns existing nodes that have the given property string registered in their NodeConfig -func (net *Network) GetNodesByProperty(property string) []*Node { - net.lock.RLock() - defer net.lock.RUnlock() - - return net.getNodesByProperty(property) -} - -func (net *Network) getNodesByProperty(property string) []*Node { - nodes := make([]*Node, 0, len(net.propertyMap[property])) - for _, nodeIndex := range net.propertyMap[property] { - nodes = append(nodes, net.Nodes[nodeIndex]) - } - - return nodes -} - -// GetNodeIDsByProperty returns existing node's enode IDs that have the given property string registered in the NodeConfig -func (net *Network) GetNodeIDsByProperty(property string) []enode.ID { - net.lock.RLock() - defer net.lock.RUnlock() - - return net.getNodeIDsByProperty(property) -} - -func (net *Network) getNodeIDsByProperty(property string) []enode.ID { - nodeIDs := make([]enode.ID, 0, len(net.propertyMap[property])) - for _, nodeIndex := range net.propertyMap[property] { - node := net.Nodes[nodeIndex] - nodeIDs = append(nodeIDs, node.ID()) - } - - return nodeIDs -} - -// GetRandomUpNode returns a random node on the network, which is running. -func (net *Network) GetRandomUpNode(excludeIDs ...enode.ID) *Node { - net.lock.RLock() - defer net.lock.RUnlock() - return net.getRandomUpNode(excludeIDs...) -} - -// GetRandomUpNode returns a random node on the network, which is running. -func (net *Network) getRandomUpNode(excludeIDs ...enode.ID) *Node { - return net.getRandomNode(net.getUpNodeIDs(), excludeIDs) -} - -func (net *Network) getUpNodeIDs() (ids []enode.ID) { - for _, node := range net.Nodes { - if node.Up() { - ids = append(ids, node.ID()) - } - } - return ids -} - -// GetRandomDownNode returns a random node on the network, which is stopped. -func (net *Network) GetRandomDownNode(excludeIDs ...enode.ID) *Node { - net.lock.RLock() - defer net.lock.RUnlock() - return net.getRandomNode(net.getDownNodeIDs(), excludeIDs) -} - -func (net *Network) getDownNodeIDs() (ids []enode.ID) { - for _, node := range net.Nodes { - if !node.Up() { - ids = append(ids, node.ID()) - } - } - return ids -} - -// GetRandomNode returns a random node on the network, regardless of whether it is running or not -func (net *Network) GetRandomNode(excludeIDs ...enode.ID) *Node { - net.lock.RLock() - defer net.lock.RUnlock() - return net.getRandomNode(net.getNodeIDs(nil), excludeIDs) // no need to exclude twice -} - -func (net *Network) getRandomNode(ids []enode.ID, excludeIDs []enode.ID) *Node { - filtered := filterIDs(ids, excludeIDs) - - l := len(filtered) - if l == 0 { - return nil - } - return net.getNode(filtered[rand.Intn(l)]) -} - -func filterIDs(ids []enode.ID, excludeIDs []enode.ID) []enode.ID { - exclude := make(map[enode.ID]bool) - for _, id := range excludeIDs { - exclude[id] = true - } - var filtered []enode.ID - for _, id := range ids { - if _, found := exclude[id]; !found { - filtered = append(filtered, id) - } - } - return filtered -} - -// GetConn returns the connection which exists between "one" and "other" -// regardless of which node initiated the connection -func (net *Network) GetConn(oneID, otherID enode.ID) *Conn { - net.lock.RLock() - defer net.lock.RUnlock() - return net.getConn(oneID, otherID) -} - -// GetOrCreateConn is like GetConn but creates the connection if it doesn't -// already exist -func (net *Network) GetOrCreateConn(oneID, otherID enode.ID) (*Conn, error) { - net.lock.Lock() - defer net.lock.Unlock() - return net.getOrCreateConn(oneID, otherID) -} - -func (net *Network) getOrCreateConn(oneID, otherID enode.ID) (*Conn, error) { - if conn := net.getConn(oneID, otherID); conn != nil { - return conn, nil - } - - one := net.getNode(oneID) - if one == nil { - return nil, fmt.Errorf("node %v does not exist", oneID) - } - other := net.getNode(otherID) - if other == nil { - return nil, fmt.Errorf("node %v does not exist", otherID) - } - conn := &Conn{ - One: oneID, - Other: otherID, - one: one, - other: other, - } - label := ConnLabel(oneID, otherID) - net.connMap[label] = len(net.Conns) - net.Conns = append(net.Conns, conn) - return conn, nil -} - -func (net *Network) getConn(oneID, otherID enode.ID) *Conn { - label := ConnLabel(oneID, otherID) - i, found := net.connMap[label] - if !found { - return nil - } - return net.Conns[i] -} - -// InitConn(one, other) retrieves the connection model for the connection between -// peers one and other, or creates a new one if it does not exist -// the order of nodes does not matter, i.e., Conn(i,j) == Conn(j, i) -// it checks if the connection is already up, and if the nodes are running -// NOTE: -// it also checks whether there has been recent attempt to connect the peers -// this is cheating as the simulation is used as an oracle and know about -// remote peers attempt to connect to a node which will then not initiate the connection -func (net *Network) InitConn(oneID, otherID enode.ID) (*Conn, error) { - net.lock.Lock() - defer net.lock.Unlock() - return net.initConn(oneID, otherID) -} - -func (net *Network) initConn(oneID, otherID enode.ID) (*Conn, error) { - if oneID == otherID { - return nil, fmt.Errorf("refusing to connect to self %v", oneID) - } - conn, err := net.getOrCreateConn(oneID, otherID) - if err != nil { - return nil, err - } - if conn.Up { - return nil, fmt.Errorf("%v and %v already connected", oneID, otherID) - } - if time.Since(conn.initiated) < DialBanTimeout { - return nil, fmt.Errorf("connection between %v and %v recently attempted", oneID, otherID) - } - - err = conn.nodesUp() - if err != nil { - log.Trace("Nodes not up", "err", err) - return nil, fmt.Errorf("nodes not up: %v", err) - } - log.Trace("Connection initiated", "id", oneID, "other", otherID) - conn.initiated = time.Now() - return conn, nil -} - -// Shutdown stops all nodes in the network and closes the quit channel -func (net *Network) Shutdown() { - for _, node := range net.Nodes { - log.Trace("Stopping node", "id", node.ID()) - if err := node.Stop(); err != nil { - log.Warn("Can't stop node", "id", node.ID(), "err", err) - } - // If the node has the close method, call it. - if closer, ok := node.Node.(io.Closer); ok { - if err := closer.Close(); err != nil { - log.Warn("Can't close node", "id", node.ID(), "err", err) - } - } - } - close(net.quitc) -} - -// Reset resets all network properties: -// empties the nodes and the connection list -func (net *Network) Reset() { - net.lock.Lock() - defer net.lock.Unlock() - - //re-initialize the maps - net.connMap = make(map[string]int) - net.nodeMap = make(map[enode.ID]int) - net.propertyMap = make(map[string][]int) - - net.Nodes = nil - net.Conns = nil -} - -// Node is a wrapper around adapters.Node which is used to track the status -// of a node in the network -type Node struct { - adapters.Node `json:"-"` - - // Config if the config used to created the node - Config *adapters.NodeConfig `json:"config"` - - // up tracks whether or not the node is running - up bool - upMu *sync.RWMutex -} - -func newNode(an adapters.Node, ac *adapters.NodeConfig, up bool) *Node { - return &Node{Node: an, Config: ac, up: up, upMu: new(sync.RWMutex)} -} - -func (n *Node) copy() *Node { - configCpy := *n.Config - return newNode(n.Node, &configCpy, n.Up()) -} - -// Up returns whether the node is currently up (online) -func (n *Node) Up() bool { - n.upMu.RLock() - defer n.upMu.RUnlock() - return n.up -} - -// SetUp sets the up (online) status of the nodes with the given value -func (n *Node) SetUp(up bool) { - n.upMu.Lock() - defer n.upMu.Unlock() - n.up = up -} - -// ID returns the ID of the node -func (n *Node) ID() enode.ID { - return n.Config.ID -} - -// String returns a log-friendly string -func (n *Node) String() string { - return fmt.Sprintf("Node %v", n.ID().TerminalString()) -} - -// NodeInfo returns information about the node -func (n *Node) NodeInfo() *p2p.NodeInfo { - // avoid a panic if the node is not started yet - if n.Node == nil { - return nil - } - info := n.Node.NodeInfo() - info.Name = n.Config.Name - return info -} - -// MarshalJSON implements the json.Marshaler interface so that the encoded -// JSON includes the NodeInfo -func (n *Node) MarshalJSON() ([]byte, error) { - return json.Marshal(struct { - Info *p2p.NodeInfo `json:"info,omitempty"` - Config *adapters.NodeConfig `json:"config,omitempty"` - Up bool `json:"up"` - }{ - Info: n.NodeInfo(), - Config: n.Config, - Up: n.Up(), - }) -} - -// UnmarshalJSON implements json.Unmarshaler interface so that we don't lose Node.up -// status. IMPORTANT: The implementation is incomplete; we lose p2p.NodeInfo. -func (n *Node) UnmarshalJSON(raw []byte) error { - // TODO: How should we turn back NodeInfo into n.Node? - // Ticket: https://github.com/ethersphere/go-ethereum/issues/1177 - var node struct { - Config *adapters.NodeConfig `json:"config,omitempty"` - Up bool `json:"up"` - } - if err := json.Unmarshal(raw, &node); err != nil { - return err - } - *n = *newNode(nil, node.Config, node.Up) - return nil -} - -// Conn represents a connection between two nodes in the network -type Conn struct { - // One is the node which initiated the connection - One enode.ID `json:"one"` - - // Other is the node which the connection was made to - Other enode.ID `json:"other"` - - // Up tracks whether or not the connection is active - Up bool `json:"up"` - // Registers when the connection was grabbed to dial - initiated time.Time - - one *Node - other *Node -} - -// nodesUp returns whether both nodes are currently up -func (c *Conn) nodesUp() error { - if !c.one.Up() { - return fmt.Errorf("one %v is not up", c.One) - } - if !c.other.Up() { - return fmt.Errorf("other %v is not up", c.Other) - } - return nil -} - -// String returns a log-friendly string -func (c *Conn) String() string { - return fmt.Sprintf("Conn %v->%v", c.One.TerminalString(), c.Other.TerminalString()) -} - -// Msg represents a p2p message sent between two nodes in the network -type Msg struct { - One enode.ID `json:"one"` - Other enode.ID `json:"other"` - Protocol string `json:"protocol"` - Code uint64 `json:"code"` - Received bool `json:"received"` -} - -// String returns a log-friendly string -func (m *Msg) String() string { - return fmt.Sprintf("Msg(%d) %v->%v", m.Code, m.One.TerminalString(), m.Other.TerminalString()) -} - -// ConnLabel generates a deterministic string which represents a connection -// between two nodes, used to compare if two connections are between the same -// nodes -func ConnLabel(source, target enode.ID) string { - var first, second enode.ID - if bytes.Compare(source.Bytes(), target.Bytes()) > 0 { - first = target - second = source - } else { - first = source - second = target - } - return fmt.Sprintf("%v-%v", first, second) -} - -// Snapshot represents the state of a network at a single point in time and can -// be used to restore the state of a network -type Snapshot struct { - Nodes []NodeSnapshot `json:"nodes,omitempty"` - Conns []Conn `json:"conns,omitempty"` -} - -// NodeSnapshot represents the state of a node in the network -type NodeSnapshot struct { - Node Node `json:"node,omitempty"` - - // Snapshots is arbitrary data gathered from calling node.Snapshots() - Snapshots map[string][]byte `json:"snapshots,omitempty"` -} - -// Snapshot creates a network snapshot -func (net *Network) Snapshot() (*Snapshot, error) { - return net.snapshot(nil, nil) -} - -func (net *Network) SnapshotWithServices(addServices []string, removeServices []string) (*Snapshot, error) { - return net.snapshot(addServices, removeServices) -} - -func (net *Network) snapshot(addServices []string, removeServices []string) (*Snapshot, error) { - net.lock.Lock() - defer net.lock.Unlock() - snap := &Snapshot{ - Nodes: make([]NodeSnapshot, len(net.Nodes)), - } - for i, node := range net.Nodes { - snap.Nodes[i] = NodeSnapshot{Node: *node.copy()} - if !node.Up() { - continue - } - snapshots, err := node.Snapshots() - if err != nil { - return nil, err - } - snap.Nodes[i].Snapshots = snapshots - for _, addSvc := range addServices { - haveSvc := false - for _, svc := range snap.Nodes[i].Node.Config.Lifecycles { - if svc == addSvc { - haveSvc = true - break - } - } - if !haveSvc { - snap.Nodes[i].Node.Config.Lifecycles = append(snap.Nodes[i].Node.Config.Lifecycles, addSvc) - } - } - if len(removeServices) > 0 { - var cleanedServices []string - for _, svc := range snap.Nodes[i].Node.Config.Lifecycles { - haveSvc := false - for _, rmSvc := range removeServices { - if rmSvc == svc { - haveSvc = true - break - } - } - if !haveSvc { - cleanedServices = append(cleanedServices, svc) - } - - } - snap.Nodes[i].Node.Config.Lifecycles = cleanedServices - } - } - for _, conn := range net.Conns { - if conn.Up { - snap.Conns = append(snap.Conns, *conn) - } - } - return snap, nil -} - -// longrunning tests may need a longer timeout -var snapshotLoadTimeout = 900 * time.Second - -// Load loads a network snapshot -func (net *Network) Load(snap *Snapshot) error { - // Start nodes. - for _, n := range snap.Nodes { - if _, err := net.NewNodeWithConfig(n.Node.Config); err != nil { - return err - } - if !n.Node.Up() { - continue - } - if err := net.startWithSnapshots(n.Node.Config.ID, n.Snapshots); err != nil { - return err - } - } - - // Prepare connection events counter. - allConnected := make(chan struct{}) // closed when all connections are established - done := make(chan struct{}) // ensures that the event loop goroutine is terminated - defer close(done) - - // Subscribe to event channel. - // It needs to be done outside of the event loop goroutine (created below) - // to ensure that the event channel is blocking before connect calls are made. - events := make(chan *Event) - sub := net.Events().Subscribe(events) - defer sub.Unsubscribe() - - go func() { - // Expected number of connections. - total := len(snap.Conns) - // Set of all established connections from the snapshot, not other connections. - // Key array element 0 is the connection One field value, and element 1 connection Other field. - connections := make(map[[2]enode.ID]struct{}, total) - - for { - select { - case e := <-events: - // Ignore control events as they do not represent - // connect or disconnect (Up) state change. - if e.Control { - continue - } - // Detect only connection events. - if e.Type != EventTypeConn { - continue - } - connection := [2]enode.ID{e.Conn.One, e.Conn.Other} - // Nodes are still not connected or have been disconnected. - if !e.Conn.Up { - // Delete the connection from the set of established connections. - // This will prevent false positive in case disconnections happen. - delete(connections, connection) - log.Warn("load snapshot: unexpected disconnection", "one", e.Conn.One, "other", e.Conn.Other) - continue - } - // Check that the connection is from the snapshot. - for _, conn := range snap.Conns { - if conn.One == e.Conn.One && conn.Other == e.Conn.Other { - // Add the connection to the set of established connections. - connections[connection] = struct{}{} - if len(connections) == total { - // Signal that all nodes are connected. - close(allConnected) - return - } - - break - } - } - case <-done: - // Load function returned, terminate this goroutine. - return - } - } - }() - - // Start connecting. - for _, conn := range snap.Conns { - - if !net.GetNode(conn.One).Up() || !net.GetNode(conn.Other).Up() { - //in this case, at least one of the nodes of a connection is not up, - //so it would result in the snapshot `Load` to fail - continue - } - if err := net.Connect(conn.One, conn.Other); err != nil { - return err - } - } - - select { - // Wait until all connections from the snapshot are established. - case <-allConnected: - // Make sure that we do not wait forever. - case <-time.After(snapshotLoadTimeout): - return errors.New("snapshot connections not established") - } - return nil -} - -// Subscribe reads control events from a channel and executes them -func (net *Network) Subscribe(events chan *Event) { - for { - select { - case event, ok := <-events: - if !ok { - return - } - if event.Control { - net.executeControlEvent(event) - } - case <-net.quitc: - return - } - } -} - -func (net *Network) executeControlEvent(event *Event) { - log.Trace("Executing control event", "type", event.Type, "event", event) - switch event.Type { - case EventTypeNode: - if err := net.executeNodeEvent(event); err != nil { - log.Error("Error executing node event", "event", event, "err", err) - } - case EventTypeConn: - if err := net.executeConnEvent(event); err != nil { - log.Error("Error executing conn event", "event", event, "err", err) - } - case EventTypeMsg: - log.Warn("Ignoring control msg event") - } -} - -func (net *Network) executeNodeEvent(e *Event) error { - if !e.Node.Up() { - return net.Stop(e.Node.ID()) - } - - if _, err := net.NewNodeWithConfig(e.Node.Config); err != nil { - return err - } - return net.Start(e.Node.ID()) -} - -func (net *Network) executeConnEvent(e *Event) error { - if e.Conn.Up { - return net.Connect(e.Conn.One, e.Conn.Other) - } - return net.Disconnect(e.Conn.One, e.Conn.Other) -} diff --git a/p2p/simulations/simulation.go b/p2p/simulations/simulation.go deleted file mode 100644 index ac73524e27e..00000000000 --- a/p2p/simulations/simulation.go +++ /dev/null @@ -1,160 +0,0 @@ -// Copyright 2017 The go-ethereum Authors -// (original work) -// Copyright 2024 The Erigon Authors -// (modifications) -// This file is part of Erigon. -// -// Erigon is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Erigon is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with Erigon. If not, see . - -package simulations - -import ( - "context" - "time" - - "github.com/erigontech/erigon/p2p/enode" -) - -// Simulation provides a framework for running actions in a simulated network -// and then waiting for expectations to be met -type Simulation struct { - network *Network -} - -// NewSimulation returns a new simulation which runs in the given network -func NewSimulation(network *Network) *Simulation { - return &Simulation{ - network: network, - } -} - -// Run performs a step of the simulation by performing the step's action and -// then waiting for the step's expectation to be met -func (s *Simulation) Run(ctx context.Context, step *Step) (result *StepResult) { - result = newStepResult() - - result.StartedAt = time.Now() - defer func() { result.FinishedAt = time.Now() }() - - // watch network events for the duration of the step - stop := s.watchNetwork(result) - defer stop() - - // perform the action - if err := step.Action(ctx); err != nil { - result.Error = err - return - } - - // wait for all node expectations to either pass, error or timeout - nodes := make(map[enode.ID]struct{}, len(step.Expect.Nodes)) - for _, id := range step.Expect.Nodes { - nodes[id] = struct{}{} - } - for len(result.Passes) < len(nodes) { - select { - case id := <-step.Trigger: - // skip if we aren't checking the node - if _, ok := nodes[id]; !ok { - continue - } - - // skip if the node has already passed - if _, ok := result.Passes[id]; ok { - continue - } - - // run the node expectation check - pass, err := step.Expect.Check(ctx, id) - if err != nil { - result.Error = err - return - } - if pass { - result.Passes[id] = time.Now() - } - case <-ctx.Done(): - result.Error = ctx.Err() - return - } - } - - return -} - -func (s *Simulation) watchNetwork(result *StepResult) func() { - stop := make(chan struct{}) - done := make(chan struct{}) - events := make(chan *Event) - sub := s.network.Events().Subscribe(events) - go func() { - defer close(done) - defer sub.Unsubscribe() - for { - select { - case event := <-events: - result.NetworkEvents = append(result.NetworkEvents, event) - case <-stop: - return - } - } - }() - return func() { - close(stop) - <-done - } -} - -type Step struct { - // Action is the action to perform for this step - Action func(context.Context) error - - // Trigger is a channel which receives node ids and triggers an - // expectation check for that node - Trigger chan enode.ID - - // Expect is the expectation to wait for when performing this step - Expect *Expectation -} - -type Expectation struct { - // Nodes is a list of nodes to check - Nodes []enode.ID - - // Check checks whether a given node meets the expectation - Check func(context.Context, enode.ID) (bool, error) -} - -func newStepResult() *StepResult { - return &StepResult{ - Passes: make(map[enode.ID]time.Time), - } -} - -type StepResult struct { - // Error is the error encountered whilst running the step - Error error - - // StartedAt is the time the step started - StartedAt time.Time - - // FinishedAt is the time the step finished - FinishedAt time.Time - - // Passes are the timestamps of the successful node expectations - Passes map[enode.ID]time.Time - - // NetworkEvents are the network events which occurred during the step - NetworkEvents []*Event -} diff --git a/p2p/simulations/test.go b/p2p/simulations/test.go deleted file mode 100644 index 06393353ec4..00000000000 --- a/p2p/simulations/test.go +++ /dev/null @@ -1,153 +0,0 @@ -// Copyright 2018 The go-ethereum Authors -// (original work) -// Copyright 2024 The Erigon Authors -// (modifications) -// This file is part of Erigon. -// -// Erigon is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Erigon is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with Erigon. If not, see . - -package simulations - -import ( - "testing" - - "github.com/erigontech/erigon/p2p" - "github.com/erigontech/erigon/p2p/enode" - "github.com/erigontech/erigon/p2p/enr" - "github.com/erigontech/erigon/rpc" -) - -// NoopService is the service that does not do anything -// but implements node.Service interface. -type NoopService struct { - c map[enode.ID]chan struct{} -} - -func NewNoopService(ackC map[enode.ID]chan struct{}) *NoopService { - return &NoopService{ - c: ackC, - } -} - -func (t *NoopService) Protocols() []p2p.Protocol { - return []p2p.Protocol{ - { - Name: "noop", - Version: 666, - Length: 0, - Run: func(peer *p2p.Peer, rw p2p.MsgReadWriter) *p2p.PeerError { - if t.c != nil { - t.c[peer.ID()] = make(chan struct{}) - close(t.c[peer.ID()]) - } - rw.ReadMsg() - return nil - }, - NodeInfo: func() interface{} { - return struct{}{} - }, - PeerInfo: func(peerID [64]byte) interface{} { - return struct{}{} - }, - Attributes: []enr.Entry{}, - }, - } -} - -func (t *NoopService) APIs() []rpc.API { - return []rpc.API{} -} - -func (t *NoopService) Start() error { - return nil -} - -func (t *NoopService) Stop() error { - return nil -} - -func VerifyRing(t *testing.T, net *Network, ids []enode.ID) { - t.Helper() - n := len(ids) - for i := 0; i < n; i++ { - for j := i + 1; j < n; j++ { - c := net.GetConn(ids[i], ids[j]) - if i == j-1 || (i == 0 && j == n-1) { - if c == nil { - t.Errorf("nodes %v and %v are not connected, but they should be", i, j) - } - } else { - if c != nil { - t.Errorf("nodes %v and %v are connected, but they should not be", i, j) - } - } - } - } -} - -func VerifyChain(t *testing.T, net *Network, ids []enode.ID) { - t.Helper() - n := len(ids) - for i := 0; i < n; i++ { - for j := i + 1; j < n; j++ { - c := net.GetConn(ids[i], ids[j]) - if i == j-1 { - if c == nil { - t.Errorf("nodes %v and %v are not connected, but they should be", i, j) - } - } else { - if c != nil { - t.Errorf("nodes %v and %v are connected, but they should not be", i, j) - } - } - } - } -} - -func VerifyFull(t *testing.T, net *Network, ids []enode.ID) { - t.Helper() - n := len(ids) - var connections int - for i, lid := range ids { - for _, rid := range ids[i+1:] { - if net.GetConn(lid, rid) != nil { - connections++ - } - } - } - - want := n * (n - 1) / 2 - if connections != want { - t.Errorf("wrong number of connections, got: %v, want: %v", connections, want) - } -} - -func VerifyStar(t *testing.T, net *Network, ids []enode.ID, centerIndex int) { - t.Helper() - n := len(ids) - for i := 0; i < n; i++ { - for j := i + 1; j < n; j++ { - c := net.GetConn(ids[i], ids[j]) - if i == centerIndex || j == centerIndex { - if c == nil { - t.Errorf("nodes %v and %v are not connected, but they should be", i, j) - } - } else { - if c != nil { - t.Errorf("nodes %v and %v are connected, but they should not be", i, j) - } - } - } - } -} diff --git a/p2p/testutil/testutil.go b/p2p/testutil/testutil.go new file mode 100644 index 00000000000..745fed60cea --- /dev/null +++ b/p2p/testutil/testutil.go @@ -0,0 +1,46 @@ +// Copyright 2025 The Erigon Authors +// This file is part of Erigon. +// +// Erigon is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Erigon is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with Erigon. If not, see . + +package testutil + +import ( + "math/big" + + "github.com/erigontech/erigon-lib/chain" + "github.com/erigontech/erigon-lib/common" +) + +var ( + PoWMainnetChainConfig = &chain.Config{ + ChainID: big.NewInt(1), + HomesteadBlock: big.NewInt(1150000), + DAOForkBlock: big.NewInt(1920000), + TangerineWhistleBlock: big.NewInt(2463000), + SpuriousDragonBlock: big.NewInt(2675000), + ByzantiumBlock: big.NewInt(4370000), + ConstantinopleBlock: big.NewInt(7280000), + PetersburgBlock: big.NewInt(7280000), + IstanbulBlock: big.NewInt(9069000), + MuirGlacierBlock: big.NewInt(9200000), + BerlinBlock: big.NewInt(12244000), + LondonBlock: big.NewInt(12965000), + ArrowGlacierBlock: big.NewInt(13773000), + GrayGlacierBlock: big.NewInt(15050000), + Ethash: new(chain.EthashConfig), + } + + MainnetGenesisHash = common.HexToHash("0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3") +) diff --git a/p2p/transport.go b/p2p/transport.go index d3c4bb8f0d4..1ff161c9d20 100644 --- a/p2p/transport.go +++ b/p2p/transport.go @@ -33,7 +33,7 @@ import ( "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/common/bitutil" "github.com/erigontech/erigon-lib/rlp" - "github.com/erigontech/erigon/p2p/rlpx" + "github.com/erigontech/erigon-p2p/rlpx" ) const ( diff --git a/p2p/transport_test.go b/p2p/transport_test.go index 48c186da6b4..f874f62b9fa 100644 --- a/p2p/transport_test.go +++ b/p2p/transport_test.go @@ -30,7 +30,7 @@ import ( "github.com/erigontech/erigon-lib/crypto" "github.com/erigontech/erigon-lib/rlp" - "github.com/erigontech/erigon/p2p/simulations/pipes" + "github.com/erigontech/erigon-p2p/pipes" ) func TestProtocolHandshake(t *testing.T) { diff --git a/params/bootnodes.go b/params/bootnodes.go index 2c30603dee9..18887cef2d2 100644 --- a/params/bootnodes.go +++ b/params/bootnodes.go @@ -151,6 +151,29 @@ func KnownDNSNetwork(genesis common.Hash, protocol string) string { return dnsPrefix + protocol + "." + net + ".ethdisco.net" } +func BootnodeURLsByGenesisHash(genesis common.Hash) []string { + switch genesis { + case MainnetGenesisHash: + return MainnetBootnodes + case HoleskyGenesisHash: + return HoleskyBootnodes + case HoodiGenesisHash: + return HoodiBootnodes + case SepoliaGenesisHash: + return SepoliaBootnodes + case AmoyGenesisHash: + return AmoyBootnodes + case BorMainnetGenesisHash: + return BorMainnetBootnodes + case GnosisGenesisHash: + return GnosisBootnodes + case ChiadoGenesisHash: + return ChiadoBootnodes + default: + return []string{} + } +} + func BootnodeURLsOfChain(chain string) []string { switch chain { case networkname.Mainnet: diff --git a/params/config.go b/params/config.go index 8522bdb9803..6d9d1009c2a 100644 --- a/params/config.go +++ b/params/config.go @@ -96,31 +96,6 @@ var ( // HoodiChainConfig contains the chain parameters to run a node on the Hoodi test network. HoodiChainConfig = readChainSpec("chainspecs/hoodi.json") - // AllProtocolChanges contains every protocol change (EIPs) introduced - // and accepted by the Ethereum core developers into the main net protocol. - AllProtocolChanges = &chain.Config{ - ChainID: big.NewInt(1337), - Consensus: chain.EtHashConsensus, - HomesteadBlock: big.NewInt(0), - TangerineWhistleBlock: big.NewInt(0), - SpuriousDragonBlock: big.NewInt(0), - ByzantiumBlock: big.NewInt(0), - ConstantinopleBlock: big.NewInt(0), - PetersburgBlock: big.NewInt(0), - IstanbulBlock: big.NewInt(0), - MuirGlacierBlock: big.NewInt(0), - BerlinBlock: big.NewInt(0), - LondonBlock: big.NewInt(0), - ArrowGlacierBlock: big.NewInt(0), - GrayGlacierBlock: big.NewInt(0), - TerminalTotalDifficulty: big.NewInt(0), - TerminalTotalDifficultyPassed: true, - ShanghaiTime: big.NewInt(0), - CancunTime: big.NewInt(0), - PragueTime: big.NewInt(0), - Ethash: new(chain.EthashConfig), - } - // AllCliqueProtocolChanges contains every protocol change (EIPs) introduced // and accepted by the Ethereum core developers into the Clique consensus. AllCliqueProtocolChanges = &chain.Config{ diff --git a/params/config_test.go b/params/config_test.go index d58503e45f6..bcf0badf455 100644 --- a/params/config_test.go +++ b/params/config_test.go @@ -38,8 +38,8 @@ func TestCheckCompatible(t *testing.T) { wantErr *chain.ConfigCompatError } tests := []test{ - {stored: AllProtocolChanges, new: AllProtocolChanges, head: 0, wantErr: nil}, - {stored: AllProtocolChanges, new: AllProtocolChanges, head: 100, wantErr: nil}, + {stored: chain.AllProtocolChanges, new: chain.AllProtocolChanges, head: 0, wantErr: nil}, + {stored: chain.AllProtocolChanges, new: chain.AllProtocolChanges, head: 100, wantErr: nil}, { stored: &chain.Config{TangerineWhistleBlock: big.NewInt(10)}, new: &chain.Config{TangerineWhistleBlock: big.NewInt(20)}, @@ -47,7 +47,7 @@ func TestCheckCompatible(t *testing.T) { wantErr: nil, }, { - stored: AllProtocolChanges, + stored: chain.AllProtocolChanges, new: &chain.Config{HomesteadBlock: nil}, head: 3, wantErr: &chain.ConfigCompatError{ @@ -58,7 +58,7 @@ func TestCheckCompatible(t *testing.T) { }, }, { - stored: AllProtocolChanges, + stored: chain.AllProtocolChanges, new: &chain.Config{HomesteadBlock: big.NewInt(1)}, head: 3, wantErr: &chain.ConfigCompatError{ diff --git a/params/forkid_test.go b/params/forkid_test.go new file mode 100644 index 00000000000..b78aafea807 --- /dev/null +++ b/params/forkid_test.go @@ -0,0 +1,203 @@ +// Copyright 2019 The go-ethereum Authors +// (original work) +// Copyright 2024 The Erigon Authors +// (modifications) +// This file is part of Erigon. +// +// Erigon is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Erigon is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with Erigon. If not, see . + +package params_test + +import ( + "testing" + + "github.com/erigontech/erigon-lib/chain" + "github.com/erigontech/erigon-lib/common" + "github.com/erigontech/erigon-p2p/forkid" + "github.com/erigontech/erigon/params" +) + +// TestCreation tests that different genesis and fork rule combinations result in +// the correct fork ID. +// Forks before Shanghai are triggered by the block number, +// while Shanghai and later forks are triggered by the block time. +func TestCreation(t *testing.T) { + t.Parallel() + type testcase struct { + head uint64 + time uint64 + want forkid.ID + } + tests := []struct { + config *chain.Config + genesis common.Hash + cases []testcase + }{ + // Mainnet test cases + { + params.MainnetChainConfig, + params.MainnetGenesisHash, + []testcase{ + {0, 0, forkid.ID{Hash: forkid.ChecksumToBytes(0xfc64ec04), Next: 1150000}}, // Unsynced + {1149999, 1457981342, forkid.ID{Hash: forkid.ChecksumToBytes(0xfc64ec04), Next: 1150000}}, // Last Frontier block + {1150000, 1457981393, forkid.ID{Hash: forkid.ChecksumToBytes(0x97c2c34c), Next: 1920000}}, // First Homestead block + {1919999, 1469020838, forkid.ID{Hash: forkid.ChecksumToBytes(0x97c2c34c), Next: 1920000}}, // Last Homestead block + {1920000, 1469020840, forkid.ID{Hash: forkid.ChecksumToBytes(0x91d1f948), Next: 2463000}}, // First DAO block + {2462999, 1476796747, forkid.ID{Hash: forkid.ChecksumToBytes(0x91d1f948), Next: 2463000}}, // Last DAO block + {2463000, 1476796771, forkid.ID{Hash: forkid.ChecksumToBytes(0x7a64da13), Next: 2675000}}, // First Tangerine block + {2674999, 1479831337, forkid.ID{Hash: forkid.ChecksumToBytes(0x7a64da13), Next: 2675000}}, // Last Tangerine block + {2675000, 1479831344, forkid.ID{Hash: forkid.ChecksumToBytes(0x3edd5b10), Next: 4370000}}, // First Spurious block + {4369999, 1508131303, forkid.ID{Hash: forkid.ChecksumToBytes(0x3edd5b10), Next: 4370000}}, // Last Spurious block + {4370000, 1508131331, forkid.ID{Hash: forkid.ChecksumToBytes(0xa00bc324), Next: 7280000}}, // First Byzantium block + {7279999, 1551383501, forkid.ID{Hash: forkid.ChecksumToBytes(0xa00bc324), Next: 7280000}}, // Last Byzantium block + {7280000, 1551383524, forkid.ID{Hash: forkid.ChecksumToBytes(0x668db0af), Next: 9069000}}, // First and last Constantinople, first Petersburg block + {9068999, 1575764708, forkid.ID{Hash: forkid.ChecksumToBytes(0x668db0af), Next: 9069000}}, // Last Petersburg block + {9069000, 1575764709, forkid.ID{Hash: forkid.ChecksumToBytes(0x879d6e30), Next: 9200000}}, // First Istanbul block + {9199999, 1577953806, forkid.ID{Hash: forkid.ChecksumToBytes(0x879d6e30), Next: 9200000}}, // Last Istanbul block + {9200000, 1577953849, forkid.ID{Hash: forkid.ChecksumToBytes(0xe029e991), Next: 12244000}}, // First Muir Glacier block + {12243999, 1618481214, forkid.ID{Hash: forkid.ChecksumToBytes(0xe029e991), Next: 12244000}}, // Last Muir Glacier block + {12244000, 1618481223, forkid.ID{Hash: forkid.ChecksumToBytes(0x0eb440f6), Next: 12965000}}, // First Berlin block + {12964999, 1628166812, forkid.ID{Hash: forkid.ChecksumToBytes(0x0eb440f6), Next: 12965000}}, // Last Berlin block + {12965000, 1628166822, forkid.ID{Hash: forkid.ChecksumToBytes(0xb715077d), Next: 13773000}}, // First London block + {13772999, 1639079715, forkid.ID{Hash: forkid.ChecksumToBytes(0xb715077d), Next: 13773000}}, // Last London block + {13773000, 1639079723, forkid.ID{Hash: forkid.ChecksumToBytes(0x20c327fc), Next: 15050000}}, // First Arrow Glacier block + {15049999, 1656586434, forkid.ID{Hash: forkid.ChecksumToBytes(0x20c327fc), Next: 15050000}}, // Last Arrow Glacier block + {15050000, 1656586444, forkid.ID{Hash: forkid.ChecksumToBytes(0xf0afd0e3), Next: 1681338455}}, // First Gray Glacier block + {17034869, 1681338443, forkid.ID{Hash: forkid.ChecksumToBytes(0xf0afd0e3), Next: 1681338455}}, // Last pre-Shanghai block + {17034870, 1681338479, forkid.ID{Hash: forkid.ChecksumToBytes(0xdce96c2d), Next: 1710338135}}, // First Shanghai block + {19426586, 1710338123, forkid.ID{Hash: forkid.ChecksumToBytes(0xdce96c2d), Next: 1710338135}}, // Last Shanghai block + {19426587, 1710338135, forkid.ID{Hash: forkid.ChecksumToBytes(0x9f3d2254), Next: 1746612311}}, // First Cancun block + {22432453, 1746612299, forkid.ID{Hash: forkid.ChecksumToBytes(0x9f3d2254), Next: 1746612311}}, // Last Cancun block (approx.) + {22432454, 1746612311, forkid.ID{Hash: forkid.ChecksumToBytes(0xc376cf8b), Next: 0}}, // First Prague block (approx.) + {30000000, 1900000000, forkid.ID{Hash: forkid.ChecksumToBytes(0xc376cf8b), Next: 0}}, // Future Prague block (mock) + }, + }, + // Sepolia test cases + { + params.SepoliaChainConfig, + params.SepoliaGenesisHash, + []testcase{ + {0, 1633267481, forkid.ID{Hash: forkid.ChecksumToBytes(0xfe3366e7), Next: 1735371}}, // Unsynced, last Frontier, Homestead, Tangerine, Spurious, Byzantium, Constantinople, Petersburg, Istanbul, Berlin and first London block + {1735370, 1661130096, forkid.ID{Hash: forkid.ChecksumToBytes(0xfe3366e7), Next: 1735371}}, // Last pre-MergeNetsplit block + {1735371, 1661130108, forkid.ID{Hash: forkid.ChecksumToBytes(0xb96cbd13), Next: 1677557088}}, // First MergeNetsplit block + {2990907, 1677557076, forkid.ID{Hash: forkid.ChecksumToBytes(0xb96cbd13), Next: 1677557088}}, // Last pre-Shanghai block + {2990908, 1677557088, forkid.ID{Hash: forkid.ChecksumToBytes(0xf7f9bc08), Next: 1706655072}}, // First Shanghai block + {5187022, 1706655060, forkid.ID{Hash: forkid.ChecksumToBytes(0xf7f9bc08), Next: 1706655072}}, // Last Shanghai block + {5187023, 1706655072, forkid.ID{Hash: forkid.ChecksumToBytes(0x88cf81d9), Next: 1741159776}}, // First Cancun block + {7844466, 1741159764, forkid.ID{Hash: forkid.ChecksumToBytes(0x88cf81d9), Next: 1741159776}}, // Last Cancun block (approx) + {7844467, 1741159776, forkid.ID{Hash: forkid.ChecksumToBytes(0xed88b5fd), Next: 0}}, // First Prague block (approx) + {12000000, 1800000000, forkid.ID{Hash: forkid.ChecksumToBytes(0xed88b5fd), Next: 0}}, // Future Prague block (mock) + }, + }, + + // Holesky test cases + { + params.HoleskyChainConfig, + params.HoleskyGenesisHash, + []testcase{ + {0, 1696000704, forkid.ID{Hash: forkid.ChecksumToBytes(0xfd4f016b), Next: 1707305664}}, // First Shanghai block + {0, 1707305652, forkid.ID{Hash: forkid.ChecksumToBytes(0xfd4f016b), Next: 1707305664}}, // Last Shanghai block + {894733, 1707305676, forkid.ID{Hash: forkid.ChecksumToBytes(0x9b192ad0), Next: 1740434112}}, // First Cancun block + {3655435, 1740434100, forkid.ID{Hash: forkid.ChecksumToBytes(0x9b192ad0), Next: 1740434112}}, // Last Cancun block (approx) + {3655436, 1740434112, forkid.ID{Hash: forkid.ChecksumToBytes(0xdfbd9bed), Next: 0}}, // First Prague block (approx) + {8000000, 1800000000, forkid.ID{Hash: forkid.ChecksumToBytes(0xdfbd9bed), Next: 0}}, // Future Prague block (mock) + }, + }, + + // Hoodi test cases + { + params.HoodiChainConfig, + params.HoodiGenesisHash, + []testcase{ + {0, 174221200, forkid.ID{Hash: forkid.ChecksumToBytes(0xbef71d30), Next: 1742999832}}, // First Cancun block + {50000, 1742999820, forkid.ID{Hash: forkid.ChecksumToBytes(0xbef71d30), Next: 1742999832}}, // Last Cancun block (approx) + {50001, 1742999832, forkid.ID{Hash: forkid.ChecksumToBytes(0x0929e24e), Next: 0}}, // First Prague block (approx) + {8000000, 1800000000, forkid.ID{Hash: forkid.ChecksumToBytes(0x0929e24e), Next: 0}}, // Future Prague block (mock) + }, + }, + // Gnosis test cases + { + params.GnosisChainConfig, + params.GnosisGenesisHash, + []testcase{ + {0, 0, forkid.ID{Hash: forkid.ChecksumToBytes(0xf64909b1), Next: 1604400}}, // Unsynced, last Frontier, Homestead, Tangerine, Spurious, Byzantium + {1604399, 1547205885, forkid.ID{Hash: forkid.ChecksumToBytes(0xf64909b1), Next: 1604400}}, // Last Byzantium block + {1604400, 1547205890, forkid.ID{Hash: forkid.ChecksumToBytes(0xfde2d083), Next: 2508800}}, // First Constantinople block + {2508799, 1551879340, forkid.ID{Hash: forkid.ChecksumToBytes(0xfde2d083), Next: 2508800}}, // Last Constantinople block + {2508800, 1551879345, forkid.ID{Hash: forkid.ChecksumToBytes(0xfc1d8f2f), Next: 7298030}}, // First Petersburg block + {7298029, 1576134775, forkid.ID{Hash: forkid.ChecksumToBytes(0xfc1d8f2f), Next: 7298030}}, // Last Petersburg block + {7298030, 1576134780, forkid.ID{Hash: forkid.ChecksumToBytes(0x54d05e6c), Next: 9186425}}, // First Istanbul block + {9186424, 1585729685, forkid.ID{Hash: forkid.ChecksumToBytes(0x54d05e6c), Next: 9186425}}, // Last Istanbul block + {9186425, 1585729690, forkid.ID{Hash: forkid.ChecksumToBytes(0xb6e6cd81), Next: 16101500}}, // First POSDAO Activation block + {16101499, 1621258420, forkid.ID{Hash: forkid.ChecksumToBytes(0xb6e6cd81), Next: 16101500}}, // Last POSDAO Activation block + {16101500, 1621258425, forkid.ID{Hash: forkid.ChecksumToBytes(0x069a83d9), Next: 19040000}}, // First Berlin block + {19039999, 1636753575, forkid.ID{Hash: forkid.ChecksumToBytes(0x069a83d9), Next: 19040000}}, // Last Berlin block + {19040000, 1636753580, forkid.ID{Hash: forkid.ChecksumToBytes(0x018479d3), Next: 1690889660}}, // First London block + {21735000, 1650443255, forkid.ID{Hash: forkid.ChecksumToBytes(0x018479d3), Next: 1690889660}}, // First GIP-31 block + {29242931, 1690889650, forkid.ID{Hash: forkid.ChecksumToBytes(0x018479d3), Next: 1690889660}}, // Last pre-Shanghai block + {29242932, 1690889660, forkid.ID{Hash: forkid.ChecksumToBytes(0x2efe91ba), Next: 1710181820}}, // First Shanghai block + {32880679, 1710181810, forkid.ID{Hash: forkid.ChecksumToBytes(0x2efe91ba), Next: 1710181820}}, // Last Shanghai block + {32880680, 1710181820, forkid.ID{Hash: forkid.ChecksumToBytes(0x1384dfc1), Next: 1746021820}}, // First Cancun block + {39834364, 1746021815, forkid.ID{Hash: forkid.ChecksumToBytes(0x1384dfc1), Next: 1746021820}}, // Last Cancun block (approx) + {39834365, 1746021820, forkid.ID{Hash: forkid.ChecksumToBytes(0x2f095d4a), Next: 0}}, // First Prague block (approx) + {50000000, 1800000000, forkid.ID{Hash: forkid.ChecksumToBytes(0x2f095d4a), Next: 0}}, // Future Prague block (mock) + }, + }, + // Chiado test cases + { + params.ChiadoChainConfig, + params.ChiadoGenesisHash, + []testcase{ + {0, 0, forkid.ID{Hash: forkid.ChecksumToBytes(0x50d39d7b), Next: 1684934220}}, + {4100418, 1684934215, forkid.ID{Hash: forkid.ChecksumToBytes(0x50d39d7b), Next: 1684934220}}, // Last pre-Shanghai block + {4100419, 1684934220, forkid.ID{Hash: forkid.ChecksumToBytes(0xa15a4252), Next: 1706724940}}, // First Shanghai block + {8021277, 1706724930, forkid.ID{Hash: forkid.ChecksumToBytes(0xa15a4252), Next: 1706724940}}, // Last Shanghai block + {8021278, 1706724940, forkid.ID{Hash: forkid.ChecksumToBytes(0x5fbc16bc), Next: 1741254220}}, // First Cancun block + {14655798, 1741254215, forkid.ID{Hash: forkid.ChecksumToBytes(0x5fbc16bc), Next: 1741254220}}, // Last Cancun block (approx) + {14655799, 1741254220, forkid.ID{Hash: forkid.ChecksumToBytes(0x8ba51786), Next: 0}}, // First Prague block (approx) + {20000000, 1800000000, forkid.ID{Hash: forkid.ChecksumToBytes(0x8ba51786), Next: 0}}, // Future Prague block (mock) + }, + }, + // Amoy test cases + { + params.AmoyChainConfig, + params.AmoyGenesisHash, + []testcase{ + {0, 0, forkid.ID{Hash: forkid.ChecksumToBytes(0xbe06a477), Next: 73100}}, + {73100, 0, forkid.ID{Hash: forkid.ChecksumToBytes(0x135d2cd5), Next: 5423600}}, // First London, Jaipur, Delhi, Indore, Agra + }, + }, + // Bor mainnet test cases + { + params.BorMainnetChainConfig, + params.BorMainnetGenesisHash, + []testcase{ + {0, 0, forkid.ID{Hash: forkid.ChecksumToBytes(0x0e07e722), Next: 3395000}}, + {3395000, 0, forkid.ID{Hash: forkid.ChecksumToBytes(0x27806576), Next: 14750000}}, // First Istanbul block + {14750000, 0, forkid.ID{Hash: forkid.ChecksumToBytes(0x66e26adb), Next: 23850000}}, // First Berlin block + {23850000, 0, forkid.ID{Hash: forkid.ChecksumToBytes(0x4f2f71cc), Next: 50523000}}, // First London block + {50523000, 0, forkid.ID{Hash: forkid.ChecksumToBytes(0xdc08865c), Next: 54876000}}, // First Agra block + {54876000, 0, forkid.ID{Hash: forkid.ChecksumToBytes(0xf097bc13), Next: 0}}, // First Napoli block + }, + }, + } + for i, tt := range tests { + for j, ttt := range tt.cases { + heightForks, timeForks := forkid.GatherForks(tt.config, 0 /* genesisTime */) + if have := forkid.NewIDFromForks(heightForks, timeForks, tt.genesis, ttt.head, ttt.time); have != ttt.want { + t.Errorf("test %d, case %d: fork ID mismatch: have %x, want %x", i, j, have, ttt.want) + } + } + } +} diff --git a/polygon/bor/bor_test.go b/polygon/bor/bor_test.go index 78dee1d3204..c7ab907cb0d 100644 --- a/polygon/bor/bor_test.go +++ b/polygon/bor/bor_test.go @@ -37,9 +37,9 @@ import ( "github.com/erigontech/erigon-lib/log/v3" "github.com/erigontech/erigon-lib/rlp" "github.com/erigontech/erigon-lib/types" + "github.com/erigontech/erigon-p2p/protocols/eth" "github.com/erigontech/erigon/core" "github.com/erigontech/erigon/execution/consensus" - "github.com/erigontech/erigon/p2p/protocols/eth" "github.com/erigontech/erigon/params" "github.com/erigontech/erigon/polygon/bor" "github.com/erigontech/erigon/polygon/bor/borabi" diff --git a/polygon/bor/finality/whitelist.go b/polygon/bor/finality/whitelist.go index 259e1125147..de88f15ce99 100644 --- a/polygon/bor/finality/whitelist.go +++ b/polygon/bor/finality/whitelist.go @@ -22,20 +22,19 @@ import ( "fmt" "time" - "github.com/erigontech/erigon-lib/log/v3" - + "github.com/erigontech/erigon-db/interfaces" "github.com/erigontech/erigon-lib/kv" + "github.com/erigontech/erigon-lib/log/v3" "github.com/erigontech/erigon/polygon/bor/finality/flags" "github.com/erigontech/erigon/polygon/bor/finality/whitelist" "github.com/erigontech/erigon/polygon/heimdall" - "github.com/erigontech/erigon/turbo/services" ) type config struct { heimdall heimdall.Client borDB kv.RwDB chainDB kv.RwDB - blockReader services.BlockReader + blockReader interfaces.BlockReader logger log.Logger borAPI BorAPI closeCh chan struct{} @@ -45,7 +44,7 @@ type BorAPI interface { GetRootHash(start uint64, end uint64) (string, error) } -func Whitelist(heimdall heimdall.Client, borDB kv.RwDB, chainDB kv.RwDB, blockReader services.BlockReader, logger log.Logger, borAPI BorAPI, closeCh chan struct{}) { +func Whitelist(heimdall heimdall.Client, borDB kv.RwDB, chainDB kv.RwDB, blockReader interfaces.BlockReader, logger log.Logger, borAPI BorAPI, closeCh chan struct{}) { if !flags.Milestone { return } diff --git a/polygon/bridge/service_test.go b/polygon/bridge/service_test.go index 2573f52a2e0..7c488938762 100644 --- a/polygon/bridge/service_test.go +++ b/polygon/bridge/service_test.go @@ -29,10 +29,10 @@ import ( "github.com/erigontech/erigon-lib/common/hexutil" "github.com/erigontech/erigon-lib/log/v3" + "github.com/erigontech/erigon-lib/testlog" "github.com/erigontech/erigon-lib/types" "github.com/erigontech/erigon/polygon/bor/borcfg" "github.com/erigontech/erigon/polygon/heimdall" - "github.com/erigontech/erigon/turbo/testlog" ) var defaultBorConfig = borcfg.BorConfig{ diff --git a/polygon/heimdall/client_http_test.go b/polygon/heimdall/client_http_test.go index 85abe327ce0..acf56cf3bf4 100644 --- a/polygon/heimdall/client_http_test.go +++ b/polygon/heimdall/client_http_test.go @@ -27,8 +27,7 @@ import ( "go.uber.org/mock/gomock" "github.com/erigontech/erigon-lib/log/v3" - - "github.com/erigontech/erigon/turbo/testlog" + "github.com/erigontech/erigon-lib/testlog" ) type emptyBodyReadCloser struct{} diff --git a/polygon/heimdall/scraper_test.go b/polygon/heimdall/scraper_test.go index 8e127feee87..6ed11b628e0 100644 --- a/polygon/heimdall/scraper_test.go +++ b/polygon/heimdall/scraper_test.go @@ -11,7 +11,7 @@ import ( "golang.org/x/sync/errgroup" "github.com/erigontech/erigon-lib/log/v3" - "github.com/erigontech/erigon/turbo/testlog" + "github.com/erigontech/erigon-lib/testlog" ) func TestScrapper_Run_TransientErr(t *testing.T) { diff --git a/polygon/heimdall/service_test.go b/polygon/heimdall/service_test.go index 2898bac4dc7..540f40eb1e4 100644 --- a/polygon/heimdall/service_test.go +++ b/polygon/heimdall/service_test.go @@ -38,9 +38,9 @@ import ( "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/common/dir" "github.com/erigontech/erigon-lib/log/v3" + "github.com/erigontech/erigon-lib/testlog" "github.com/erigontech/erigon/params" "github.com/erigontech/erigon/polygon/bor/borcfg" - "github.com/erigontech/erigon/turbo/testlog" ) func TestServiceWithAmoyData(t *testing.T) { diff --git a/polygon/heimdall/types.go b/polygon/heimdall/types.go index 8c5091bf9fc..617406caf60 100644 --- a/polygon/heimdall/types.go +++ b/polygon/heimdall/types.go @@ -28,6 +28,7 @@ import ( "time" "github.com/erigontech/erigon-db/rawdb" + coresnaptype "github.com/erigontech/erigon-db/snaptype" "github.com/erigontech/erigon-lib/chain" "github.com/erigontech/erigon-lib/chain/networkname" "github.com/erigontech/erigon-lib/chain/snapcfg" @@ -42,8 +43,6 @@ import ( "github.com/erigontech/erigon-lib/recsplit" "github.com/erigontech/erigon-lib/seg" "github.com/erigontech/erigon-lib/version" - coresnaptype "github.com/erigontech/erigon/core/snaptype" - bortypes "github.com/erigontech/erigon/polygon/bor/types" ) diff --git a/polygon/p2p/fetcher_base.go b/polygon/p2p/fetcher_base.go index 682ca99c10d..87c25e372ed 100644 --- a/polygon/p2p/fetcher_base.go +++ b/polygon/p2p/fetcher_base.go @@ -30,7 +30,7 @@ import ( "github.com/erigontech/erigon-lib/common/generics" "github.com/erigontech/erigon-lib/log/v3" "github.com/erigontech/erigon-lib/types" - "github.com/erigontech/erigon/p2p/protocols/eth" + "github.com/erigontech/erigon-p2p/protocols/eth" ) func NewFetcher(logger log.Logger, ml *MessageListener, ms *MessageSender, opts ...FetcherOption) *FetcherBase { diff --git a/polygon/p2p/fetcher_base_test.go b/polygon/p2p/fetcher_base_test.go index af92babe3de..3489e2f302c 100644 --- a/polygon/p2p/fetcher_base_test.go +++ b/polygon/p2p/fetcher_base_test.go @@ -36,9 +36,9 @@ import ( "github.com/erigontech/erigon-lib/log/v3" "github.com/erigontech/erigon-lib/p2p/sentry" "github.com/erigontech/erigon-lib/rlp" + "github.com/erigontech/erigon-lib/testlog" "github.com/erigontech/erigon-lib/types" - "github.com/erigontech/erigon/p2p/protocols/eth" - "github.com/erigontech/erigon/turbo/testlog" + "github.com/erigontech/erigon-p2p/protocols/eth" ) func TestFetcherFetchHeaders(t *testing.T) { diff --git a/polygon/p2p/message_listener.go b/polygon/p2p/message_listener.go index fe255399603..feef5769740 100644 --- a/polygon/p2p/message_listener.go +++ b/polygon/p2p/message_listener.go @@ -28,7 +28,7 @@ import ( "github.com/erigontech/erigon-lib/log/v3" "github.com/erigontech/erigon-lib/p2p/sentry" "github.com/erigontech/erigon-lib/rlp" - "github.com/erigontech/erigon/p2p/protocols/eth" + "github.com/erigontech/erigon-p2p/protocols/eth" ) type DecodedInboundMessage[TPacket any] struct { diff --git a/polygon/p2p/message_listener_test.go b/polygon/p2p/message_listener_test.go index dc02cb410e4..2e04f6050bd 100644 --- a/polygon/p2p/message_listener_test.go +++ b/polygon/p2p/message_listener_test.go @@ -37,9 +37,9 @@ import ( "github.com/erigontech/erigon-lib/log/v3" "github.com/erigontech/erigon-lib/p2p/sentry" "github.com/erigontech/erigon-lib/rlp" + "github.com/erigontech/erigon-lib/testlog" "github.com/erigontech/erigon-lib/types" - "github.com/erigontech/erigon/p2p/protocols/eth" - "github.com/erigontech/erigon/turbo/testlog" + "github.com/erigontech/erigon-p2p/protocols/eth" ) func TestMessageListenerRegisterBlockHeadersObserver(t *testing.T) { diff --git a/polygon/p2p/message_sender.go b/polygon/p2p/message_sender.go index 9ae12403008..64ec87135b8 100644 --- a/polygon/p2p/message_sender.go +++ b/polygon/p2p/message_sender.go @@ -24,7 +24,7 @@ import ( "github.com/erigontech/erigon-lib/gointerfaces/sentryproto" "github.com/erigontech/erigon-lib/p2p/sentry" "github.com/erigontech/erigon-lib/rlp" - "github.com/erigontech/erigon/p2p/protocols/eth" + "github.com/erigontech/erigon-p2p/protocols/eth" ) var ErrPeerNotFound = errors.New("peer not found") diff --git a/polygon/p2p/message_sender_test.go b/polygon/p2p/message_sender_test.go index 1126682ad5c..4623966a598 100644 --- a/polygon/p2p/message_sender_test.go +++ b/polygon/p2p/message_sender_test.go @@ -31,7 +31,7 @@ import ( erigonlibtypes "github.com/erigontech/erigon-lib/gointerfaces/typesproto" "github.com/erigontech/erigon-lib/rlp" "github.com/erigontech/erigon-lib/types" - "github.com/erigontech/erigon/p2p/protocols/eth" + "github.com/erigontech/erigon-p2p/protocols/eth" ) func TestMessageSenderSendGetBlockHeaders(t *testing.T) { diff --git a/polygon/p2p/peer_event_registrar.go b/polygon/p2p/peer_event_registrar.go index b644d7a1bcf..4d810955f30 100644 --- a/polygon/p2p/peer_event_registrar.go +++ b/polygon/p2p/peer_event_registrar.go @@ -19,7 +19,7 @@ package p2p import ( "github.com/erigontech/erigon-lib/event" "github.com/erigontech/erigon-lib/gointerfaces/sentryproto" - "github.com/erigontech/erigon/p2p/protocols/eth" + "github.com/erigontech/erigon-p2p/protocols/eth" ) //go:generate mockgen -typed=true -source=./peer_event_registrar.go -destination=./peer_event_registrar_mock.go -package=p2p diff --git a/polygon/p2p/peer_event_registrar_mock.go b/polygon/p2p/peer_event_registrar_mock.go index 9854d86a086..dc1d709e42e 100644 --- a/polygon/p2p/peer_event_registrar_mock.go +++ b/polygon/p2p/peer_event_registrar_mock.go @@ -14,7 +14,7 @@ import ( event "github.com/erigontech/erigon-lib/event" sentryproto "github.com/erigontech/erigon-lib/gointerfaces/sentryproto" - eth "github.com/erigontech/erigon/p2p/protocols/eth" + eth "github.com/erigontech/erigon-p2p/protocols/eth" gomock "go.uber.org/mock/gomock" ) diff --git a/polygon/p2p/peer_id.go b/polygon/p2p/peer_id.go index 907f012359e..55e5bfe92dc 100644 --- a/polygon/p2p/peer_id.go +++ b/polygon/p2p/peer_id.go @@ -23,7 +23,7 @@ import ( "github.com/erigontech/erigon-lib/crypto" "github.com/erigontech/erigon-lib/gointerfaces" "github.com/erigontech/erigon-lib/gointerfaces/typesproto" - "github.com/erigontech/erigon/p2p/enode" + "github.com/erigontech/erigon-p2p/enode" ) func PeerIdFromH512(h512 *typesproto.H512) *PeerId { diff --git a/polygon/p2p/peer_tracker.go b/polygon/p2p/peer_tracker.go index 2770cceaa67..83662e82431 100644 --- a/polygon/p2p/peer_tracker.go +++ b/polygon/p2p/peer_tracker.go @@ -27,7 +27,7 @@ import ( "github.com/erigontech/erigon-lib/event" "github.com/erigontech/erigon-lib/gointerfaces/sentryproto" "github.com/erigontech/erigon-lib/log/v3" - "github.com/erigontech/erigon/p2p/protocols/eth" + "github.com/erigontech/erigon-p2p/protocols/eth" ) func NewPeerTracker( diff --git a/polygon/p2p/peer_tracker_test.go b/polygon/p2p/peer_tracker_test.go index 924cb2ab5ee..7cea50b7e38 100644 --- a/polygon/p2p/peer_tracker_test.go +++ b/polygon/p2p/peer_tracker_test.go @@ -33,9 +33,9 @@ import ( "github.com/erigontech/erigon-lib/gointerfaces/sentryproto" "github.com/erigontech/erigon-lib/gointerfaces/typesproto" "github.com/erigontech/erigon-lib/log/v3" + "github.com/erigontech/erigon-lib/testlog" "github.com/erigontech/erigon-lib/types" - "github.com/erigontech/erigon/p2p/protocols/eth" - "github.com/erigontech/erigon/turbo/testlog" + "github.com/erigontech/erigon-p2p/protocols/eth" ) func TestPeerTracker(t *testing.T) { diff --git a/polygon/p2p/publisher.go b/polygon/p2p/publisher.go index c265a2d45f0..0c9e11c601e 100644 --- a/polygon/p2p/publisher.go +++ b/polygon/p2p/publisher.go @@ -27,7 +27,7 @@ import ( "github.com/erigontech/erigon-lib/log/v3" "github.com/erigontech/erigon-lib/types" - "github.com/erigontech/erigon/p2p/protocols/eth" + "github.com/erigontech/erigon-p2p/protocols/eth" ) func NewPublisher(logger log.Logger, messageSender *MessageSender, peerTracker *PeerTracker) *Publisher { diff --git a/polygon/p2p/publisher_test.go b/polygon/p2p/publisher_test.go index 30437a4eaf9..b93c12073e5 100644 --- a/polygon/p2p/publisher_test.go +++ b/polygon/p2p/publisher_test.go @@ -35,9 +35,9 @@ import ( "github.com/erigontech/erigon-lib/gointerfaces/sentryproto" "github.com/erigontech/erigon-lib/gointerfaces/typesproto" "github.com/erigontech/erigon-lib/log/v3" + "github.com/erigontech/erigon-lib/testlog" "github.com/erigontech/erigon-lib/types" - "github.com/erigontech/erigon/p2p/protocols/eth" - "github.com/erigontech/erigon/turbo/testlog" + "github.com/erigontech/erigon-p2p/protocols/eth" ) func TestPublisher(t *testing.T) { diff --git a/polygon/p2p/service.go b/polygon/p2p/service.go index 6dd6c0b5ef3..5d0c7e5b413 100644 --- a/polygon/p2p/service.go +++ b/polygon/p2p/service.go @@ -29,7 +29,7 @@ import ( "github.com/erigontech/erigon-lib/log/v3" "github.com/erigontech/erigon-lib/p2p/sentry" "github.com/erigontech/erigon-lib/types" - "github.com/erigontech/erigon/p2p/protocols/eth" + "github.com/erigontech/erigon-p2p/protocols/eth" ) func NewService(logger log.Logger, maxPeers int, sc sentryproto.SentryClient, sdf sentry.StatusDataFactory) *Service { diff --git a/polygon/sync/block_downloader_test.go b/polygon/sync/block_downloader_test.go index 59b0be51e02..d9c9165a9b7 100644 --- a/polygon/sync/block_downloader_test.go +++ b/polygon/sync/block_downloader_test.go @@ -31,10 +31,10 @@ import ( "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/log/v3" + "github.com/erigontech/erigon-lib/testlog" "github.com/erigontech/erigon-lib/types" "github.com/erigontech/erigon/polygon/heimdall" "github.com/erigontech/erigon/polygon/p2p" - "github.com/erigontech/erigon/turbo/testlog" ) func newBlockDownloaderTest(t *testing.T) *blockDownloaderTest { diff --git a/polygon/sync/service.go b/polygon/sync/service.go index 4a2536feb75..6524b2d6a21 100644 --- a/polygon/sync/service.go +++ b/polygon/sync/service.go @@ -29,8 +29,8 @@ import ( "github.com/erigontech/erigon-lib/gointerfaces/executionproto" "github.com/erigontech/erigon-lib/gointerfaces/sentryproto" "github.com/erigontech/erigon-lib/log/v3" + "github.com/erigontech/erigon-p2p/sentry" "github.com/erigontech/erigon/eth/ethconfig" - "github.com/erigontech/erigon/p2p/sentry" "github.com/erigontech/erigon/polygon/bor/borcfg" "github.com/erigontech/erigon/polygon/bridge" "github.com/erigontech/erigon/polygon/heimdall" diff --git a/polygon/sync/tip_events.go b/polygon/sync/tip_events.go index dc7034dedf2..4d95d8826cd 100644 --- a/polygon/sync/tip_events.go +++ b/polygon/sync/tip_events.go @@ -27,7 +27,7 @@ import ( "github.com/erigontech/erigon-lib/event" "github.com/erigontech/erigon-lib/log/v3" "github.com/erigontech/erigon-lib/types" - "github.com/erigontech/erigon/p2p/protocols/eth" + "github.com/erigontech/erigon-p2p/protocols/eth" "github.com/erigontech/erigon/polygon/heimdall" "github.com/erigontech/erigon/polygon/p2p" ) diff --git a/polygon/sync/tip_events_test.go b/polygon/sync/tip_events_test.go index ffe76fa2b29..60697cc8923 100644 --- a/polygon/sync/tip_events_test.go +++ b/polygon/sync/tip_events_test.go @@ -26,8 +26,8 @@ import ( "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/log/v3" + "github.com/erigontech/erigon-lib/testlog" "github.com/erigontech/erigon/polygon/p2p" - "github.com/erigontech/erigon/turbo/testlog" ) func TestBlockEventsSpamGuard(t *testing.T) { diff --git a/rpc/contracts/direct_backend.go b/rpc/contracts/direct_backend.go index e67a05e819c..c9e845cdc4d 100644 --- a/rpc/contracts/direct_backend.go +++ b/rpc/contracts/direct_backend.go @@ -26,8 +26,8 @@ import ( "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/common/hexutil" "github.com/erigontech/erigon-lib/types" + "github.com/erigontech/erigon-p2p/event" "github.com/erigontech/erigon/eth/filters" - "github.com/erigontech/erigon/event" "github.com/erigontech/erigon/execution/abi/bind" "github.com/erigontech/erigon/rpc" "github.com/erigontech/erigon/rpc/ethapi" diff --git a/rpc/ipc.go b/rpc/ipc.go index c35d6ead73a..cca4f7e2db6 100644 --- a/rpc/ipc.go +++ b/rpc/ipc.go @@ -23,7 +23,7 @@ import ( "net" "github.com/erigontech/erigon-lib/log/v3" - "github.com/erigontech/erigon/p2p/netutil" + "github.com/erigontech/erigon-p2p/netutil" ) // ServeListener accepts connections on l, serving JSON-RPC on them. diff --git a/rpc/jsonrpc/admin_api.go b/rpc/jsonrpc/admin_api.go index 25a98737d88..31c3d5a6b87 100644 --- a/rpc/jsonrpc/admin_api.go +++ b/rpc/jsonrpc/admin_api.go @@ -22,7 +22,7 @@ import ( "fmt" remote "github.com/erigontech/erigon-lib/gointerfaces/remoteproto" - "github.com/erigontech/erigon/p2p" + p2p "github.com/erigontech/erigon-p2p" "github.com/erigontech/erigon/rpc/rpchelper" ) diff --git a/rpc/jsonrpc/contracts/gen_poly.go b/rpc/jsonrpc/contracts/gen_poly.go index 07ca4aa63c7..c414c0f07b2 100644 --- a/rpc/jsonrpc/contracts/gen_poly.go +++ b/rpc/jsonrpc/contracts/gen_poly.go @@ -13,7 +13,7 @@ import ( "github.com/erigontech/erigon-lib/abi" "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/types" - "github.com/erigontech/erigon/event" + "github.com/erigontech/erigon-p2p/event" "github.com/erigontech/erigon/execution/abi/bind" ) diff --git a/rpc/jsonrpc/contracts/gen_token.go b/rpc/jsonrpc/contracts/gen_token.go index ab5fa202363..f34321e08a1 100644 --- a/rpc/jsonrpc/contracts/gen_token.go +++ b/rpc/jsonrpc/contracts/gen_token.go @@ -13,7 +13,7 @@ import ( "github.com/erigontech/erigon-lib/abi" "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/types" - "github.com/erigontech/erigon/event" + "github.com/erigontech/erigon-p2p/event" "github.com/erigontech/erigon/execution/abi/bind" ) diff --git a/rpc/jsonrpc/erigon_api.go b/rpc/jsonrpc/erigon_api.go index faef0459133..cf8c94348b1 100644 --- a/rpc/jsonrpc/erigon_api.go +++ b/rpc/jsonrpc/erigon_api.go @@ -23,8 +23,8 @@ import ( "github.com/erigontech/erigon-lib/common/hexutil" "github.com/erigontech/erigon-lib/kv" "github.com/erigontech/erigon-lib/types" + p2p "github.com/erigontech/erigon-p2p" "github.com/erigontech/erigon/eth/filters" - "github.com/erigontech/erigon/p2p" "github.com/erigontech/erigon/rpc" "github.com/erigontech/erigon/rpc/rpchelper" ) diff --git a/rpc/jsonrpc/erigon_nodeInfo.go b/rpc/jsonrpc/erigon_nodeInfo.go index 35d61a32829..f3ff007fb8d 100644 --- a/rpc/jsonrpc/erigon_nodeInfo.go +++ b/rpc/jsonrpc/erigon_nodeInfo.go @@ -19,7 +19,7 @@ package jsonrpc import ( "context" - "github.com/erigontech/erigon/p2p" + p2p "github.com/erigontech/erigon-p2p" ) const ( diff --git a/rpc/jsonrpc/erigon_system.go b/rpc/jsonrpc/erigon_system.go index 44d0f3e8fcd..643425b086c 100644 --- a/rpc/jsonrpc/erigon_system.go +++ b/rpc/jsonrpc/erigon_system.go @@ -22,7 +22,7 @@ import ( "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/common/hexutil" - "github.com/erigontech/erigon/p2p/forkid" + "github.com/erigontech/erigon-p2p/forkid" borfinality "github.com/erigontech/erigon/polygon/bor/finality" "github.com/erigontech/erigon/polygon/bor/finality/whitelist" "github.com/erigontech/erigon/rpc" diff --git a/rpc/jsonrpc/eth_subscribe_test.go b/rpc/jsonrpc/eth_subscribe_test.go index 8cfb45cfa7a..427011f9bc9 100644 --- a/rpc/jsonrpc/eth_subscribe_test.go +++ b/rpc/jsonrpc/eth_subscribe_test.go @@ -29,10 +29,10 @@ import ( "github.com/erigontech/erigon-lib/log/v3" "github.com/erigontech/erigon-lib/rlp" "github.com/erigontech/erigon-lib/wrap" + "github.com/erigontech/erigon-p2p/protocols/eth" "github.com/erigontech/erigon/cmd/rpcdaemon/rpcservices" "github.com/erigontech/erigon/core" "github.com/erigontech/erigon/execution/builder" - "github.com/erigontech/erigon/p2p/protocols/eth" "github.com/erigontech/erigon/rpc/rpchelper" "github.com/erigontech/erigon/turbo/privateapi" "github.com/erigontech/erigon/turbo/stages" diff --git a/p2p/protocols/eth/handler_test.go b/rpc/jsonrpc/receipts/handler_test.go similarity index 99% rename from p2p/protocols/eth/handler_test.go rename to rpc/jsonrpc/receipts/handler_test.go index 369f1f378d5..439eaaef21e 100644 --- a/p2p/protocols/eth/handler_test.go +++ b/rpc/jsonrpc/receipts/handler_test.go @@ -17,7 +17,7 @@ // You should have received a copy of the GNU Lesser General Public License // along with Erigon. If not, see . -package eth_test +package receipts_test import ( "math" @@ -36,8 +36,8 @@ import ( sentry "github.com/erigontech/erigon-lib/gointerfaces/sentryproto" "github.com/erigontech/erigon-lib/rlp" "github.com/erigontech/erigon-lib/types" + "github.com/erigontech/erigon-p2p/protocols/eth" "github.com/erigontech/erigon/core" - "github.com/erigontech/erigon/p2p/protocols/eth" "github.com/erigontech/erigon/rpc/jsonrpc/receipts" "github.com/erigontech/erigon/turbo/stages/mock" ) diff --git a/rpc/jsonrpc/send_transaction_test.go b/rpc/jsonrpc/send_transaction_test.go index f0dbbb02970..dd48f7f748e 100644 --- a/rpc/jsonrpc/send_transaction_test.go +++ b/rpc/jsonrpc/send_transaction_test.go @@ -37,10 +37,10 @@ import ( "github.com/erigontech/erigon-lib/rlp" "github.com/erigontech/erigon-lib/types" "github.com/erigontech/erigon-lib/wrap" + "github.com/erigontech/erigon-p2p/protocols/eth" "github.com/erigontech/erigon/cmd/rpcdaemon/rpcdaemontest" "github.com/erigontech/erigon/core" "github.com/erigontech/erigon/eth/ethconfig" - "github.com/erigontech/erigon/p2p/protocols/eth" "github.com/erigontech/erigon/rpc/jsonrpc" "github.com/erigontech/erigon/rpc/rpccfg" "github.com/erigontech/erigon/rpc/rpchelper" diff --git a/rpc/requests/admin.go b/rpc/requests/admin.go index 7c3b0da8444..454437486e4 100644 --- a/rpc/requests/admin.go +++ b/rpc/requests/admin.go @@ -19,7 +19,7 @@ package requests import ( "context" - "github.com/erigontech/erigon/p2p" + p2p "github.com/erigontech/erigon-p2p" ) func (reqGen *requestGenerator) AdminNodeInfo() (p2p.NodeInfo, error) { diff --git a/rpc/requests/nopgenerator.go b/rpc/requests/nopgenerator.go index 98074fcff82..a0a03c222ba 100644 --- a/rpc/requests/nopgenerator.go +++ b/rpc/requests/nopgenerator.go @@ -25,7 +25,7 @@ import ( "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/common/hexutil" "github.com/erigontech/erigon-lib/types" - "github.com/erigontech/erigon/p2p" + p2p "github.com/erigontech/erigon-p2p" "github.com/erigontech/erigon/rpc" "github.com/erigontech/erigon/rpc/ethapi" ) diff --git a/rpc/requests/request_generator.go b/rpc/requests/request_generator.go index bd70e84eb76..3a7164889b1 100644 --- a/rpc/requests/request_generator.go +++ b/rpc/requests/request_generator.go @@ -36,8 +36,8 @@ import ( "github.com/erigontech/erigon-lib/common/hexutil" "github.com/erigontech/erigon-lib/log/v3" "github.com/erigontech/erigon-lib/types" + p2p "github.com/erigontech/erigon-p2p" "github.com/erigontech/erigon/cmd/devnet/devnetutils" - "github.com/erigontech/erigon/p2p" "github.com/erigontech/erigon/rpc" "github.com/erigontech/erigon/rpc/ethapi" ) diff --git a/rpc/rpchelper/interface.go b/rpc/rpchelper/interface.go index 7a9ed583d71..e098b9b83d7 100644 --- a/rpc/rpchelper/interface.go +++ b/rpc/rpchelper/interface.go @@ -24,7 +24,7 @@ import ( remote "github.com/erigontech/erigon-lib/gointerfaces/remoteproto" "github.com/erigontech/erigon-lib/kv" "github.com/erigontech/erigon-lib/types" - "github.com/erigontech/erigon/p2p" + p2p "github.com/erigontech/erigon-p2p" ) // ApiBackend - interface which must be used by API layer diff --git a/sonar-project.properties b/sonar-project.properties index bec58cc61a2..ed91231a6db 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -18,7 +18,7 @@ sonar.exclusions=\ sonar.tests=. sonar.test.inclusions=**/*_test.go,tests/** -sonar.go.coverage.reportPaths=coverage-test-all.out,erigon-lib/coverage-test-all.out,erigon-db/coverage-test-all.out +sonar.go.coverage.reportPaths=coverage-test-all.out,erigon-lib/coverage-test-all.out,erigon-db/coverage-test-all.out,p2p/coverage-test-all.out # The only way to get an accurate analysis of C/C++/Objective-C files is # by using the SonarSource build-wrapper and setting the property "sonar.cfamily.build-wrapper-output" diff --git a/tests/bor/helper/miner.go b/tests/bor/helper/miner.go index 4facbc76575..51ac0015427 100644 --- a/tests/bor/helper/miner.go +++ b/tests/bor/helper/miner.go @@ -17,13 +17,13 @@ import ( "github.com/erigontech/erigon-lib/downloader/downloadercfg" "github.com/erigontech/erigon-lib/log/v3" "github.com/erigontech/erigon-lib/types" + p2p "github.com/erigontech/erigon-p2p" + "github.com/erigontech/erigon-p2p/nat" "github.com/erigontech/erigon/cmd/utils" "github.com/erigontech/erigon/eth" "github.com/erigontech/erigon/eth/ethconfig" "github.com/erigontech/erigon/node" "github.com/erigontech/erigon/node/nodecfg" - "github.com/erigontech/erigon/p2p" - "github.com/erigontech/erigon/p2p/nat" "github.com/erigontech/erigon/params" "github.com/erigontech/erigon/polygon/bor/borcfg" "github.com/erigontech/erigon/txnprovider/txpool/txpoolcfg" diff --git a/tests/bor/mining_test.go b/tests/bor/mining_test.go index 4e2ff804a4c..22905411f54 100644 --- a/tests/bor/mining_test.go +++ b/tests/bor/mining_test.go @@ -39,11 +39,11 @@ import ( "github.com/erigontech/erigon-lib/gointerfaces/remoteproto" "github.com/erigontech/erigon-lib/gointerfaces/txpoolproto" "github.com/erigontech/erigon-lib/log/v3" + "github.com/erigontech/erigon-lib/testlog" "github.com/erigontech/erigon-lib/types" "github.com/erigontech/erigon/eth" "github.com/erigontech/erigon/node" "github.com/erigontech/erigon/tests/bor/helper" - "github.com/erigontech/erigon/turbo/testlog" ) const ( diff --git a/tests/contracts/gen_selfDestructor.go b/tests/contracts/gen_selfDestructor.go index 4bb38ed6d63..80ff4fe8c1f 100644 --- a/tests/contracts/gen_selfDestructor.go +++ b/tests/contracts/gen_selfDestructor.go @@ -13,7 +13,7 @@ import ( "github.com/erigontech/erigon-lib/abi" "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/types" - "github.com/erigontech/erigon/event" + "github.com/erigontech/erigon-p2p/event" "github.com/erigontech/erigon/execution/abi/bind" ) diff --git a/tests/contracts/gen_testcontract.go b/tests/contracts/gen_testcontract.go index ebd6a71781d..a71dbe06f5e 100644 --- a/tests/contracts/gen_testcontract.go +++ b/tests/contracts/gen_testcontract.go @@ -13,7 +13,7 @@ import ( "github.com/erigontech/erigon-lib/abi" "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/types" - "github.com/erigontech/erigon/event" + "github.com/erigontech/erigon-p2p/event" "github.com/erigontech/erigon/execution/abi/bind" ) diff --git a/tests/txpool/helper/p2p_client.go b/tests/txpool/helper/p2p_client.go index 64ebe922ea1..da932f8aeab 100644 --- a/tests/txpool/helper/p2p_client.go +++ b/tests/txpool/helper/p2p_client.go @@ -16,11 +16,12 @@ import ( "github.com/erigontech/erigon-lib/gointerfaces" "github.com/erigontech/erigon-lib/gointerfaces/sentryproto" "github.com/erigontech/erigon-lib/log/v3" - "github.com/erigontech/erigon/cmd/utils" - "github.com/erigontech/erigon/p2p" - "github.com/erigontech/erigon/p2p/nat" - "github.com/erigontech/erigon/p2p/protocols/eth" - "github.com/erigontech/erigon/p2p/sentry" + p2p "github.com/erigontech/erigon-p2p" + "github.com/erigontech/erigon-p2p/enode" + "github.com/erigontech/erigon-p2p/nat" + "github.com/erigontech/erigon-p2p/protocols/eth" + "github.com/erigontech/erigon-p2p/sentry" + "github.com/erigontech/erigon/params" ) var ( @@ -51,16 +52,17 @@ func (p *p2pClient) Connect() (<-chan TxMessage, <-chan error, error) { } cfg := &p2p.Config{ - ListenAddr: ":30307", - AllowedPorts: []uint{30303, 30304, 30305, 30306, 30307}, - ProtocolVersion: []uint{direct.ETH68, direct.ETH67}, - MaxPeers: 32, - MaxPendingPeers: 1000, - NAT: nat.Any(), - NoDiscovery: true, - Name: "p2p-mock", - NodeDatabase: "dev/nodes/eth67", - PrivateKey: privateKey, + ListenAddr: ":30307", + AllowedPorts: []uint{30303, 30304, 30305, 30306, 30307}, + ProtocolVersion: []uint{direct.ETH68, direct.ETH67}, + MaxPeers: 32, + MaxPendingPeers: 1000, + NAT: nat.Any(), + NoDiscovery: true, + Name: "p2p-mock", + NodeDatabase: "dev/nodes/eth67", + PrivateKey: privateKey, + LookupBootnodeURLs: params.BootnodeURLsByGenesisHash, } r, err := http.Post(p.adminRPC, "application/json", strings.NewReader( @@ -88,7 +90,7 @@ func (p *p2pClient) Connect() (<-chan TxMessage, <-chan error, error) { return nil, nil, err } - if cfg.StaticNodes, err = utils.ParseNodesFromURLs([]string{resp.Result.Enode}); err != nil { + if cfg.StaticNodes, err = enode.ParseNodesFromURLs([]string{resp.Result.Enode}); err != nil { return nil, nil, err } diff --git a/turbo/app/snapshots_cmd.go b/turbo/app/snapshots_cmd.go index bf5213feb11..2b8ec1dd6fa 100644 --- a/turbo/app/snapshots_cmd.go +++ b/turbo/app/snapshots_cmd.go @@ -40,6 +40,7 @@ import ( "golang.org/x/sync/semaphore" "github.com/erigontech/erigon-db/rawdb/blockio" + coresnaptype "github.com/erigontech/erigon-db/snaptype" "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/common/compress" "github.com/erigontech/erigon-lib/common/datadir" @@ -65,7 +66,6 @@ import ( "github.com/erigontech/erigon/cl/clparams" "github.com/erigontech/erigon/cmd/hack/tool/fromdb" "github.com/erigontech/erigon/cmd/utils" - coresnaptype "github.com/erigontech/erigon/core/snaptype" "github.com/erigontech/erigon/diagnostics" "github.com/erigontech/erigon/eth/ethconfig" "github.com/erigontech/erigon/eth/ethconfig/estimate" diff --git a/turbo/app/squeeze_cmd.go b/turbo/app/squeeze_cmd.go index c621c5f1c89..a5eeb7dd8d2 100644 --- a/turbo/app/squeeze_cmd.go +++ b/turbo/app/squeeze_cmd.go @@ -26,6 +26,7 @@ import ( "github.com/urfave/cli/v2" + snaptype2 "github.com/erigontech/erigon-db/snaptype" "github.com/erigontech/erigon-lib/common/datadir" "github.com/erigontech/erigon-lib/common/dir" "github.com/erigontech/erigon-lib/config3" @@ -35,7 +36,6 @@ import ( "github.com/erigontech/erigon-lib/state" "github.com/erigontech/erigon/cmd/hack/tool/fromdb" "github.com/erigontech/erigon/cmd/utils" - snaptype2 "github.com/erigontech/erigon/core/snaptype" "github.com/erigontech/erigon/eth/ethconfig" "github.com/erigontech/erigon/eth/ethconfig/estimate" "github.com/erigontech/erigon/turbo/debug" diff --git a/turbo/engineapi/engine_server_test.go b/turbo/engineapi/engine_server_test.go index e05afec127b..998f0c31acb 100644 --- a/turbo/engineapi/engine_server_test.go +++ b/turbo/engineapi/engine_server_test.go @@ -34,12 +34,12 @@ import ( "github.com/erigontech/erigon-lib/rlp" "github.com/erigontech/erigon-lib/types" "github.com/erigontech/erigon-lib/wrap" + "github.com/erigontech/erigon-p2p/protocols/eth" "github.com/erigontech/erigon/cmd/rpcdaemon/cli/httpcfg" "github.com/erigontech/erigon/cmd/rpcdaemon/rpcdaemontest" "github.com/erigontech/erigon/cmd/rpcdaemon/rpcservices" "github.com/erigontech/erigon/core" "github.com/erigontech/erigon/eth/ethconfig" - "github.com/erigontech/erigon/p2p/protocols/eth" "github.com/erigontech/erigon/rpc/jsonrpc" "github.com/erigontech/erigon/rpc/rpccfg" "github.com/erigontech/erigon/rpc/rpchelper" diff --git a/turbo/mock/txpool.go b/turbo/mock/txpool.go index 7793713841b..c7d377af61e 100644 --- a/turbo/mock/txpool.go +++ b/turbo/mock/txpool.go @@ -22,8 +22,8 @@ import ( "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/types" + "github.com/erigontech/erigon-p2p/event" "github.com/erigontech/erigon/core" - "github.com/erigontech/erigon/event" ) // TestTxPool is a mock transaction pool that blindly accepts all transactions. diff --git a/turbo/services/interfaces.go b/turbo/services/interfaces.go index 9bf7d488c07..364190d667e 100644 --- a/turbo/services/interfaces.go +++ b/turbo/services/interfaces.go @@ -19,11 +19,11 @@ package services import ( "context" - "github.com/erigontech/erigon-lib/log/v3" - + "github.com/erigontech/erigon-db/interfaces" "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/downloader/snaptype" "github.com/erigontech/erigon-lib/kv" + "github.com/erigontech/erigon-lib/log/v3" "github.com/erigontech/erigon-lib/rlp" "github.com/erigontech/erigon-lib/types" "github.com/erigontech/erigon/eth/ethconfig" @@ -35,26 +35,6 @@ type All struct { BlockReader FullBlockReader } -type BlockReader interface { - BlockByNumber(ctx context.Context, db kv.Tx, number uint64) (*types.Block, error) - BlockByHash(ctx context.Context, db kv.Tx, hash common.Hash) (*types.Block, error) - CurrentBlock(db kv.Tx) (*types.Block, error) - BlockWithSenders(ctx context.Context, tx kv.Getter, hash common.Hash, blockNum uint64) (block *types.Block, senders []common.Address, err error) - IterateFrozenBodies(f func(blockNum, baseTxNum, txCount uint64) error) error -} - -type HeaderReader interface { - Header(ctx context.Context, tx kv.Getter, hash common.Hash, blockNum uint64) (*types.Header, error) - HeaderByNumber(ctx context.Context, tx kv.Getter, blockNum uint64) (*types.Header, error) - HeaderNumber(ctx context.Context, tx kv.Getter, hash common.Hash) (*uint64, error) - HeaderByHash(ctx context.Context, tx kv.Getter, hash common.Hash) (*types.Header, error) - ReadAncestor(db kv.Getter, hash common.Hash, number, ancestor uint64, maxNonCanonical *uint64) (common.Hash, uint64) - - // HeadersRange - TODO: change it to `stream` - HeadersRange(ctx context.Context, walker func(header *types.Header) error) error - Integrity(ctx context.Context) error -} - type BorEventReader interface { LastEventId(ctx context.Context, tx kv.Tx) (uint64, bool, error) EventLookup(ctx context.Context, tx kv.Tx, txnHash common.Hash) (uint64, bool, error) @@ -86,14 +66,6 @@ type CanonicalReader interface { BadHeaderNumber(ctx context.Context, tx kv.Getter, hash common.Hash) (blockHeight *uint64, err error) } -type BodyReader interface { - BodyWithTransactions(ctx context.Context, tx kv.Getter, hash common.Hash, blockNum uint64) (body *types.Body, err error) - BodyRlp(ctx context.Context, tx kv.Getter, hash common.Hash, blockNum uint64) (bodyRlp rlp.RawValue, err error) - Body(ctx context.Context, tx kv.Getter, hash common.Hash, blockNum uint64) (body *types.Body, txCount uint32, err error) - CanonicalBodyForStorage(ctx context.Context, tx kv.Getter, blockNum uint64) (body *types.BodyForStorage, err error) - HasSenders(ctx context.Context, tx kv.Getter, hash common.Hash, blockNum uint64) (bool, error) -} - type TxnReader interface { TxnLookup(ctx context.Context, tx kv.Getter, txnHash common.Hash) (blockNum uint64, txNum uint64, ok bool, err error) TxnByIdxInBlock(ctx context.Context, tx kv.Getter, blockNum uint64, i int) (txn types.Transaction, err error) @@ -102,19 +74,19 @@ type TxnReader interface { } type HeaderAndCanonicalReader interface { - HeaderReader + interfaces.HeaderReader CanonicalReader } type BlockAndTxnReader interface { - BlockReader + interfaces.BlockReader TxnReader } type FullBlockReader interface { - BlockReader - BodyReader - HeaderReader + interfaces.BlockReader + interfaces.BodyReader + interfaces.HeaderReader BorEventReader BorSpanReader BorMilestoneReader diff --git a/turbo/silkworm/snapshots_repository.go b/turbo/silkworm/snapshots_repository.go index 4a6adbd5360..63fe572ea78 100644 --- a/turbo/silkworm/snapshots_repository.go +++ b/turbo/silkworm/snapshots_repository.go @@ -8,12 +8,12 @@ import ( silkworm_go "github.com/erigontech/silkworm-go" + coresnaptype "github.com/erigontech/erigon-db/snaptype" "github.com/erigontech/erigon-lib/kv" "github.com/erigontech/erigon-lib/log/v3" "github.com/erigontech/erigon-lib/recsplit" "github.com/erigontech/erigon-lib/seg" "github.com/erigontech/erigon-lib/state" - coresnaptype "github.com/erigontech/erigon/core/snaptype" "github.com/erigontech/erigon/turbo/snapshotsync/freezeblocks" ) diff --git a/turbo/snapshotsync/freezeblocks/block_reader.go b/turbo/snapshotsync/freezeblocks/block_reader.go index d686c4822b9..6618d04a6e0 100644 --- a/turbo/snapshotsync/freezeblocks/block_reader.go +++ b/turbo/snapshotsync/freezeblocks/block_reader.go @@ -25,6 +25,7 @@ import ( "time" "github.com/erigontech/erigon-db/rawdb" + coresnaptype "github.com/erigontech/erigon-db/snaptype" "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/common/dbg" "github.com/erigontech/erigon-lib/downloader/snaptype" @@ -37,7 +38,6 @@ import ( "github.com/erigontech/erigon-lib/recsplit" "github.com/erigontech/erigon-lib/rlp" "github.com/erigontech/erigon-lib/types" - coresnaptype "github.com/erigontech/erigon/core/snaptype" "github.com/erigontech/erigon/eth/ethconfig" "github.com/erigontech/erigon/polygon/bridge" "github.com/erigontech/erigon/polygon/heimdall" diff --git a/turbo/snapshotsync/freezeblocks/block_reader_test.go b/turbo/snapshotsync/freezeblocks/block_reader_test.go index fb2781282d5..69c4e6b2517 100644 --- a/turbo/snapshotsync/freezeblocks/block_reader_test.go +++ b/turbo/snapshotsync/freezeblocks/block_reader_test.go @@ -26,18 +26,18 @@ import ( "github.com/stretchr/testify/require" + coresnaptype "github.com/erigontech/erigon-db/snaptype" "github.com/erigontech/erigon-lib/chain/networkname" "github.com/erigontech/erigon-lib/common/length" "github.com/erigontech/erigon-lib/downloader/snaptype" "github.com/erigontech/erigon-lib/log/v3" "github.com/erigontech/erigon-lib/recsplit" "github.com/erigontech/erigon-lib/seg" + "github.com/erigontech/erigon-lib/testlog" "github.com/erigontech/erigon-lib/version" - coresnaptype "github.com/erigontech/erigon/core/snaptype" "github.com/erigontech/erigon/eth/ethconfig" "github.com/erigontech/erigon/polygon/bridge" "github.com/erigontech/erigon/polygon/heimdall" - "github.com/erigontech/erigon/turbo/testlog" ) func TestBlockReaderLastFrozenSpanIdWhenSegmentFilesArePresent(t *testing.T) { diff --git a/turbo/snapshotsync/freezeblocks/block_snapshots.go b/turbo/snapshotsync/freezeblocks/block_snapshots.go index 5d8dbcf6445..16389a74cc6 100644 --- a/turbo/snapshotsync/freezeblocks/block_snapshots.go +++ b/turbo/snapshotsync/freezeblocks/block_snapshots.go @@ -36,6 +36,7 @@ import ( "github.com/erigontech/erigon-db/rawdb" "github.com/erigontech/erigon-db/rawdb/blockio" + coresnaptype "github.com/erigontech/erigon-db/snaptype" "github.com/erigontech/erigon-lib/chain" "github.com/erigontech/erigon-lib/chain/snapcfg" "github.com/erigontech/erigon-lib/common" @@ -53,7 +54,6 @@ import ( "github.com/erigontech/erigon-lib/rlp" "github.com/erigontech/erigon-lib/seg" "github.com/erigontech/erigon-lib/types" - coresnaptype "github.com/erigontech/erigon/core/snaptype" "github.com/erigontech/erigon/eth/ethconfig" "github.com/erigontech/erigon/eth/ethconfig/estimate" "github.com/erigontech/erigon/eth/stagedsync/stages" diff --git a/turbo/snapshotsync/merger.go b/turbo/snapshotsync/merger.go index a081f8d842e..da26f049bef 100644 --- a/turbo/snapshotsync/merger.go +++ b/turbo/snapshotsync/merger.go @@ -10,6 +10,7 @@ import ( "strings" "time" + coresnaptype "github.com/erigontech/erigon-db/snaptype" "github.com/erigontech/erigon-lib/chain" "github.com/erigontech/erigon-lib/chain/snapcfg" "github.com/erigontech/erigon-lib/common/background" @@ -17,7 +18,6 @@ import ( "github.com/erigontech/erigon-lib/kv" "github.com/erigontech/erigon-lib/log/v3" "github.com/erigontech/erigon-lib/seg" - coresnaptype "github.com/erigontech/erigon/core/snaptype" ) type Merger struct { diff --git a/turbo/snapshotsync/snapshots.go b/turbo/snapshotsync/snapshots.go index 1e5221f7d82..a2e35c51398 100644 --- a/turbo/snapshotsync/snapshots.go +++ b/turbo/snapshotsync/snapshots.go @@ -32,6 +32,7 @@ import ( "github.com/tidwall/btree" "golang.org/x/sync/errgroup" + coresnaptype "github.com/erigontech/erigon-db/snaptype" "github.com/erigontech/erigon-lib/chain" "github.com/erigontech/erigon-lib/chain/snapcfg" common2 "github.com/erigontech/erigon-lib/common" @@ -43,7 +44,6 @@ import ( "github.com/erigontech/erigon-lib/log/v3" "github.com/erigontech/erigon-lib/recsplit" "github.com/erigontech/erigon-lib/seg" - coresnaptype "github.com/erigontech/erigon/core/snaptype" "github.com/erigontech/erigon/eth/ethconfig" "github.com/erigontech/erigon/eth/ethconfig/estimate" ) diff --git a/turbo/snapshotsync/snapshots_test.go b/turbo/snapshotsync/snapshots_test.go index 9c043a52480..ce8983f4610 100644 --- a/turbo/snapshotsync/snapshots_test.go +++ b/turbo/snapshotsync/snapshots_test.go @@ -26,6 +26,7 @@ import ( "github.com/stretchr/testify/require" + coresnaptype "github.com/erigontech/erigon-db/snaptype" "github.com/erigontech/erigon-lib/chain/networkname" "github.com/erigontech/erigon-lib/chain/snapcfg" "github.com/erigontech/erigon-lib/common/math" @@ -33,12 +34,10 @@ import ( "github.com/erigontech/erigon-lib/log/v3" "github.com/erigontech/erigon-lib/recsplit" "github.com/erigontech/erigon-lib/seg" + "github.com/erigontech/erigon-lib/testlog" "github.com/erigontech/erigon-lib/version" - - coresnaptype "github.com/erigontech/erigon/core/snaptype" "github.com/erigontech/erigon/eth/ethconfig" "github.com/erigontech/erigon/params" - "github.com/erigontech/erigon/turbo/testlog" ) func createTestSegmentFile(t *testing.T, from, to uint64, name snaptype.Enum, dir string, ver snaptype.Version, logger log.Logger) { diff --git a/turbo/snapshotsync/snapshotsync.go b/turbo/snapshotsync/snapshotsync.go index e2c7022165d..fcfeda69f71 100644 --- a/turbo/snapshotsync/snapshotsync.go +++ b/turbo/snapshotsync/snapshotsync.go @@ -26,6 +26,9 @@ import ( "strings" "time" + "google.golang.org/grpc" + + coresnaptype "github.com/erigontech/erigon-db/snaptype" "github.com/erigontech/erigon-lib/chain" "github.com/erigontech/erigon-lib/chain/snapcfg" "github.com/erigontech/erigon-lib/common/datadir" @@ -38,9 +41,6 @@ import ( "github.com/erigontech/erigon-lib/kv/rawdbv3" "github.com/erigontech/erigon-lib/log/v3" "github.com/erigontech/erigon-lib/state" - "google.golang.org/grpc" - - coresnaptype "github.com/erigontech/erigon/core/snaptype" "github.com/erigontech/erigon/eth/ethconfig" ) diff --git a/turbo/stages/blockchain_test.go b/turbo/stages/blockchain_test.go index d84c78883ad..404cc2932e0 100644 --- a/turbo/stages/blockchain_test.go +++ b/turbo/stages/blockchain_test.go @@ -47,11 +47,11 @@ import ( "github.com/erigontech/erigon-lib/log/v3" "github.com/erigontech/erigon-lib/rlp" "github.com/erigontech/erigon-lib/types" + "github.com/erigontech/erigon-p2p/protocols/eth" "github.com/erigontech/erigon/core" "github.com/erigontech/erigon/core/state" "github.com/erigontech/erigon/core/vm" "github.com/erigontech/erigon/execution/consensus/ethash" - "github.com/erigontech/erigon/p2p/protocols/eth" params2 "github.com/erigontech/erigon/params" "github.com/erigontech/erigon/turbo/stages/mock" ) diff --git a/turbo/stages/chain_makers_test.go b/turbo/stages/chain_makers_test.go index 61f263cb982..f9b82f674da 100644 --- a/turbo/stages/chain_makers_test.go +++ b/turbo/stages/chain_makers_test.go @@ -34,9 +34,9 @@ import ( "github.com/erigontech/erigon-lib/log/v3" "github.com/erigontech/erigon-lib/rlp" "github.com/erigontech/erigon-lib/types" + "github.com/erigontech/erigon-p2p/protocols/eth" "github.com/erigontech/erigon/core" "github.com/erigontech/erigon/core/state" - "github.com/erigontech/erigon/p2p/protocols/eth" "github.com/erigontech/erigon/turbo/stages/mock" ) diff --git a/turbo/stages/genesis_test.go b/turbo/stages/genesis_test.go index 1c104470d32..f7c10a24778 100644 --- a/turbo/stages/genesis_test.go +++ b/turbo/stages/genesis_test.go @@ -71,7 +71,7 @@ func TestSetupGenesis(t *testing.T) { return core.CommitGenesisBlock(db, new(types.Genesis), datadir.New(tmpdir), logger) }, wantErr: types.ErrGenesisNoConfig, - wantConfig: params.AllProtocolChanges, + wantConfig: chain.AllProtocolChanges, }, { name: "no block in DB, genesis == nil", diff --git a/turbo/stages/headerdownload/header_algo_test.go b/turbo/stages/headerdownload/header_algo_test.go index 75930c07840..b14426b0222 100644 --- a/turbo/stages/headerdownload/header_algo_test.go +++ b/turbo/stages/headerdownload/header_algo_test.go @@ -22,11 +22,11 @@ import ( "math/big" "testing" + "github.com/erigontech/erigon-lib/chain" "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/crypto" "github.com/erigontech/erigon-lib/rlp" "github.com/erigontech/erigon-lib/types" - "github.com/erigontech/erigon/params" "github.com/erigontech/erigon/turbo/stages/headerdownload" "github.com/erigontech/erigon/turbo/stages/mock" ) @@ -36,7 +36,7 @@ func TestSideChainInsert(t *testing.T) { funds := big.NewInt(1000000000) key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") address := crypto.PubkeyToAddress(key.PublicKey) - chainConfig := params.AllProtocolChanges + chainConfig := chain.AllProtocolChanges gspec := &types.Genesis{ Config: chainConfig, Alloc: types.GenesisAlloc{ diff --git a/turbo/stages/headerdownload/header_algos.go b/turbo/stages/headerdownload/header_algos.go index c3220d46bdc..6b0929f3a51 100644 --- a/turbo/stages/headerdownload/header_algos.go +++ b/turbo/stages/headerdownload/header_algos.go @@ -32,6 +32,7 @@ import ( "strings" "time" + "github.com/erigontech/erigon-db/interfaces" "github.com/erigontech/erigon-db/rawdb" "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/common/dbg" @@ -833,7 +834,7 @@ func (hd *HeaderDownload) addHeaderAsLink(h ChainSegmentHeader, persisted bool) return link } -func (hi *HeaderInserter) NewFeedHeaderFunc(db kv.StatelessRwTx, headerReader services.HeaderReader) FeedHeaderFunc { +func (hi *HeaderInserter) NewFeedHeaderFunc(db kv.StatelessRwTx, headerReader interfaces.HeaderReader) FeedHeaderFunc { return func(header *types.Header, headerRaw []byte, hash common.Hash, blockHeight uint64) (*big.Int, error) { return hi.FeedHeaderPoW(db, headerReader, header, headerRaw, hash, blockHeight) } @@ -905,7 +906,7 @@ func (hi *HeaderInserter) ForkingPoint(db kv.StatelessRwTx, header, parent *type return } -func (hi *HeaderInserter) FeedHeaderPoW(db kv.StatelessRwTx, headerReader services.HeaderReader, header *types.Header, headerRaw []byte, hash common.Hash, blockHeight uint64) (td *big.Int, err error) { +func (hi *HeaderInserter) FeedHeaderPoW(db kv.StatelessRwTx, headerReader interfaces.HeaderReader, header *types.Header, headerRaw []byte, hash common.Hash, blockHeight uint64) (td *big.Int, err error) { if hash == hi.prevHash { // Skip duplicates return nil, nil diff --git a/turbo/stages/mock/mock_sentry.go b/turbo/stages/mock/mock_sentry.go index 49046f2a74e..3c7b58bcba1 100644 --- a/turbo/stages/mock/mock_sentry.go +++ b/turbo/stages/mock/mock_sentry.go @@ -58,6 +58,9 @@ import ( "github.com/erigontech/erigon-lib/rlp" "github.com/erigontech/erigon-lib/types" "github.com/erigontech/erigon-lib/wrap" + p2p "github.com/erigontech/erigon-p2p" + "github.com/erigontech/erigon-p2p/protocols/eth" + "github.com/erigontech/erigon-p2p/sentry" "github.com/erigontech/erigon/core" "github.com/erigontech/erigon/core/state" "github.com/erigontech/erigon/core/vm" @@ -73,11 +76,7 @@ import ( "github.com/erigontech/erigon/execution/consensus/ethash" "github.com/erigontech/erigon/execution/eth1" "github.com/erigontech/erigon/execution/eth1/eth1_chain_reader" - "github.com/erigontech/erigon/p2p" - "github.com/erigontech/erigon/p2p/protocols/eth" - "github.com/erigontech/erigon/p2p/sentry" - "github.com/erigontech/erigon/p2p/sentry/sentry_multi_client" - "github.com/erigontech/erigon/params" + "github.com/erigontech/erigon/execution/sentry_multi_client" "github.com/erigontech/erigon/polygon/bor" "github.com/erigontech/erigon/polygon/bridge" "github.com/erigontech/erigon/polygon/heimdall" @@ -652,7 +651,7 @@ func MockWithTxPoolCancun(t *testing.T) *MockSentry { funds := big.NewInt(1 * common.Ether) key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") address := crypto.PubkeyToAddress(key.PublicKey) - chainConfig := params.AllProtocolChanges + chainConfig := chain.AllProtocolChanges gspec := &types.Genesis{ Config: chainConfig, Alloc: types.GenesisAlloc{ @@ -668,7 +667,7 @@ func MockWithZeroTTD(t *testing.T, withPosDownloader bool) *MockSentry { funds := big.NewInt(1 * common.Ether) key, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") address := crypto.PubkeyToAddress(key.PublicKey) - chainConfig := params.AllProtocolChanges + chainConfig := chain.AllProtocolChanges chainConfig.TerminalTotalDifficulty = common.Big0 gspec := &types.Genesis{ Config: chainConfig, diff --git a/turbo/stages/mock/sentry_mock_test.go b/turbo/stages/mock/sentry_mock_test.go index 753de2eeb1d..24d67ac8fd9 100644 --- a/turbo/stages/mock/sentry_mock_test.go +++ b/turbo/stages/mock/sentry_mock_test.go @@ -31,8 +31,8 @@ import ( "github.com/erigontech/erigon-lib/rlp" "github.com/erigontech/erigon-lib/types" "github.com/erigontech/erigon-lib/wrap" + "github.com/erigontech/erigon-p2p/protocols/eth" "github.com/erigontech/erigon/core" - "github.com/erigontech/erigon/p2p/protocols/eth" "github.com/erigontech/erigon/turbo/stages" "github.com/erigontech/erigon/turbo/stages/mock" ) diff --git a/turbo/stages/stageloop.go b/turbo/stages/stageloop.go index 7a454c32a6a..2e27217db2a 100644 --- a/turbo/stages/stageloop.go +++ b/turbo/stages/stageloop.go @@ -41,6 +41,8 @@ import ( "github.com/erigontech/erigon-lib/state" "github.com/erigontech/erigon-lib/types" "github.com/erigontech/erigon-lib/wrap" + p2p "github.com/erigontech/erigon-p2p" + "github.com/erigontech/erigon-p2p/sentry" "github.com/erigontech/erigon/core/tracing" "github.com/erigontech/erigon/core/vm" "github.com/erigontech/erigon/eth/ethconfig" @@ -49,9 +51,7 @@ import ( "github.com/erigontech/erigon/eth/tracers" "github.com/erigontech/erigon/execution/consensus" "github.com/erigontech/erigon/execution/consensus/misc" - "github.com/erigontech/erigon/p2p" - "github.com/erigontech/erigon/p2p/sentry" - "github.com/erigontech/erigon/p2p/sentry/sentry_multi_client" + "github.com/erigontech/erigon/execution/sentry_multi_client" "github.com/erigontech/erigon/polygon/bor" "github.com/erigontech/erigon/polygon/bridge" "github.com/erigontech/erigon/polygon/heimdall" diff --git a/turbo/transactions/call.go b/turbo/transactions/call.go index 0122fa7da90..f203a1d846b 100644 --- a/turbo/transactions/call.go +++ b/turbo/transactions/call.go @@ -24,6 +24,7 @@ import ( "github.com/holiman/uint256" + "github.com/erigontech/erigon-db/interfaces" "github.com/erigontech/erigon-lib/chain" "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/kv" @@ -36,7 +37,6 @@ import ( "github.com/erigontech/erigon/execution/consensus" "github.com/erigontech/erigon/rpc" ethapi2 "github.com/erigontech/erigon/rpc/ethapi" - "github.com/erigontech/erigon/turbo/services" ) func DoCall( @@ -50,7 +50,7 @@ func DoCall( gasCap uint64, chainConfig *chain.Config, stateReader state.StateReader, - headerReader services.HeaderReader, + headerReader interfaces.HeaderReader, callTimeout time.Duration, ) (*evmtypes.ExecutionResult, error) { // todo: Pending state is only known by the miner @@ -122,12 +122,12 @@ func DoCall( } func NewEVMBlockContext(engine consensus.EngineReader, header *types.Header, requireCanonical bool, tx kv.Getter, - headerReader services.HeaderReader, config *chain.Config) evmtypes.BlockContext { + headerReader interfaces.HeaderReader, config *chain.Config) evmtypes.BlockContext { blockHashFunc := MakeHeaderGetter(requireCanonical, tx, headerReader) return core.NewEVMBlockContext(header, blockHashFunc, engine, nil /* author */, config) } -func MakeHeaderGetter(requireCanonical bool, tx kv.Getter, headerReader services.HeaderReader) func(uint64) common.Hash { +func MakeHeaderGetter(requireCanonical bool, tx kv.Getter, headerReader interfaces.HeaderReader) func(uint64) common.Hash { return func(n uint64) common.Hash { h, err := headerReader.HeaderByNumber(context.Background(), tx, n) if err != nil { @@ -209,7 +209,7 @@ func NewReusableCaller( gasCap uint64, blockNrOrHash rpc.BlockNumberOrHash, tx kv.Tx, - headerReader services.HeaderReader, + headerReader interfaces.HeaderReader, chainConfig *chain.Config, callTimeout time.Duration, ) (*ReusableCaller, error) { diff --git a/turbo/transactions/tracing.go b/turbo/transactions/tracing.go index 32313d45e5a..d8e4bdb1f76 100644 --- a/turbo/transactions/tracing.go +++ b/turbo/transactions/tracing.go @@ -26,6 +26,7 @@ import ( jsoniter "github.com/json-iterator/go" + "github.com/erigontech/erigon-db/interfaces" "github.com/erigontech/erigon-lib/chain" "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/kv" @@ -40,7 +41,6 @@ import ( "github.com/erigontech/erigon/eth/tracers/logger" "github.com/erigontech/erigon/execution/consensus" "github.com/erigontech/erigon/rpc/rpchelper" - "github.com/erigontech/erigon/turbo/services" ) type BlockGetter interface { @@ -53,7 +53,7 @@ type BlockGetter interface { // ComputeBlockContext returns the execution environment of a certain block. func ComputeBlockContext(ctx context.Context, engine consensus.EngineReader, header *types.Header, cfg *chain.Config, - headerReader services.HeaderReader, txNumsReader rawdbv3.TxNumsReader, dbtx kv.TemporalTx, + headerReader interfaces.HeaderReader, txNumsReader rawdbv3.TxNumsReader, dbtx kv.TemporalTx, txIndex int) (*state.IntraBlockState, evmtypes.BlockContext, state.StateReader, *chain.Rules, *types.Signer, error) { reader, err := rpchelper.CreateHistoryStateReader(dbtx, txNumsReader, header.Number.Uint64(), txIndex, cfg.ChainName) if err != nil { diff --git a/txnprovider/shutter/block_building_integration_test.go b/txnprovider/shutter/block_building_integration_test.go index d1a24aa2e51..9f706c35d8c 100644 --- a/txnprovider/shutter/block_building_integration_test.go +++ b/txnprovider/shutter/block_building_integration_test.go @@ -41,7 +41,9 @@ import ( "github.com/erigontech/erigon-lib/direct" "github.com/erigontech/erigon-lib/kv" "github.com/erigontech/erigon-lib/log/v3" + "github.com/erigontech/erigon-lib/testlog" "github.com/erigontech/erigon-lib/types" + p2p "github.com/erigontech/erigon-p2p" "github.com/erigontech/erigon/cmd/rpcdaemon/cli" "github.com/erigontech/erigon/cmd/rpcdaemon/cli/httpcfg" "github.com/erigontech/erigon/core" @@ -49,12 +51,10 @@ import ( "github.com/erigontech/erigon/eth/ethconfig" "github.com/erigontech/erigon/node" "github.com/erigontech/erigon/node/nodecfg" - "github.com/erigontech/erigon/p2p" "github.com/erigontech/erigon/params" "github.com/erigontech/erigon/rpc/contracts" "github.com/erigontech/erigon/rpc/requests" "github.com/erigontech/erigon/turbo/engineapi" - "github.com/erigontech/erigon/turbo/testlog" "github.com/erigontech/erigon/txnprovider/shutter" "github.com/erigontech/erigon/txnprovider/shutter/internal/testhelpers" "github.com/erigontech/erigon/txnprovider/shutter/shuttercfg" diff --git a/txnprovider/shutter/block_tracker_test.go b/txnprovider/shutter/block_tracker_test.go index 52c98f4ba5b..4c3ffea8251 100644 --- a/txnprovider/shutter/block_tracker_test.go +++ b/txnprovider/shutter/block_tracker_test.go @@ -26,7 +26,7 @@ import ( "github.com/erigontech/erigon-lib/gointerfaces/remoteproto" "github.com/erigontech/erigon-lib/log/v3" - "github.com/erigontech/erigon/turbo/testlog" + "github.com/erigontech/erigon-lib/testlog" "github.com/erigontech/erigon/txnprovider/shutter" "github.com/erigontech/erigon/txnprovider/shutter/internal/testhelpers" ) diff --git a/txnprovider/shutter/decryption_keys_validator_test.go b/txnprovider/shutter/decryption_keys_validator_test.go index d4d3fd3a67e..01cd32cded8 100644 --- a/txnprovider/shutter/decryption_keys_validator_test.go +++ b/txnprovider/shutter/decryption_keys_validator_test.go @@ -21,15 +21,15 @@ import ( "math" "testing" - "github.com/erigontech/erigon/txnprovider/shutter/shuttercfg" pubsub "github.com/libp2p/go-libp2p-pubsub" "github.com/stretchr/testify/require" "github.com/erigontech/erigon-lib/log/v3" - "github.com/erigontech/erigon/turbo/testlog" + "github.com/erigontech/erigon-lib/testlog" "github.com/erigontech/erigon/txnprovider/shutter" shutterproto "github.com/erigontech/erigon/txnprovider/shutter/internal/proto" "github.com/erigontech/erigon/txnprovider/shutter/internal/testhelpers" + "github.com/erigontech/erigon/txnprovider/shutter/shuttercfg" ) func TestDecryptionKeysValidators(t *testing.T) { diff --git a/txnprovider/shutter/internal/contracts/gen_key_broadcast_contract.go b/txnprovider/shutter/internal/contracts/gen_key_broadcast_contract.go index 5f18fd1728e..d1a0ed0f1ce 100644 --- a/txnprovider/shutter/internal/contracts/gen_key_broadcast_contract.go +++ b/txnprovider/shutter/internal/contracts/gen_key_broadcast_contract.go @@ -13,7 +13,7 @@ import ( "github.com/erigontech/erigon-lib/abi" "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/types" - "github.com/erigontech/erigon/event" + "github.com/erigontech/erigon-p2p/event" "github.com/erigontech/erigon/execution/abi/bind" ) diff --git a/txnprovider/shutter/internal/contracts/gen_keyper_set.go b/txnprovider/shutter/internal/contracts/gen_keyper_set.go index b4868964372..3c85e8de0e3 100644 --- a/txnprovider/shutter/internal/contracts/gen_keyper_set.go +++ b/txnprovider/shutter/internal/contracts/gen_keyper_set.go @@ -13,7 +13,7 @@ import ( "github.com/erigontech/erigon-lib/abi" "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/types" - "github.com/erigontech/erigon/event" + "github.com/erigontech/erigon-p2p/event" "github.com/erigontech/erigon/execution/abi/bind" ) diff --git a/txnprovider/shutter/internal/contracts/gen_keyper_set_manager.go b/txnprovider/shutter/internal/contracts/gen_keyper_set_manager.go index 9f49e3ad86f..4318314266e 100644 --- a/txnprovider/shutter/internal/contracts/gen_keyper_set_manager.go +++ b/txnprovider/shutter/internal/contracts/gen_keyper_set_manager.go @@ -13,7 +13,7 @@ import ( "github.com/erigontech/erigon-lib/abi" "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/types" - "github.com/erigontech/erigon/event" + "github.com/erigontech/erigon-p2p/event" "github.com/erigontech/erigon/execution/abi/bind" ) diff --git a/txnprovider/shutter/internal/contracts/gen_sequencer.go b/txnprovider/shutter/internal/contracts/gen_sequencer.go index bf659333dc8..c589f12e7a2 100644 --- a/txnprovider/shutter/internal/contracts/gen_sequencer.go +++ b/txnprovider/shutter/internal/contracts/gen_sequencer.go @@ -13,7 +13,7 @@ import ( "github.com/erigontech/erigon-lib/abi" "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/types" - "github.com/erigontech/erigon/event" + "github.com/erigontech/erigon-p2p/event" "github.com/erigontech/erigon/execution/abi/bind" ) diff --git a/txnprovider/shutter/internal/contracts/gen_validator_registry.go b/txnprovider/shutter/internal/contracts/gen_validator_registry.go index 4d94c66b0d0..d26022ebd5f 100644 --- a/txnprovider/shutter/internal/contracts/gen_validator_registry.go +++ b/txnprovider/shutter/internal/contracts/gen_validator_registry.go @@ -13,7 +13,7 @@ import ( "github.com/erigontech/erigon-lib/abi" "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/types" - "github.com/erigontech/erigon/event" + "github.com/erigontech/erigon-p2p/event" "github.com/erigontech/erigon/execution/abi/bind" )