Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge geth 1.13.3 #284

Merged
merged 110 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
766272f
params: begin v1.13.1 release cycle
karalabe Sep 12, 2023
43df612
internal, log: remove code for old unsupported go-versions (#28090)
holiman Sep 13, 2023
8d38b1f
core/rawdb: skip pathdb state inspection in hashdb mode (#28108)
karalabe Sep 13, 2023
8b6cf12
metrics: refactor metrics (#28035)
holiman Sep 13, 2023
eb74389
cmd/geth: rename the protocols field in the metrics gague (#28102)
karalabe Sep 13, 2023
b9b99a1
eth: abort on api operations not available in pbss-mode (#28104)
s1na Sep 14, 2023
d9fbb71
cmd/geth, internal/flags, go.mod: colorize cli help, support env vars…
karalabe Sep 14, 2023
636c64c
build: upgrade -dlgo version to Go 1.21.1 (#28113)
sandakersmann Sep 14, 2023
86bc2cd
internal/flags: fix linter
karalabe Sep 14, 2023
8514d66
graphql: add 4844 blob fields (#27963)
jsvisa Sep 14, 2023
ee65462
internal/flags: fix loading env vars for custom flags (#28117)
karalabe Sep 14, 2023
909dd4a
rlp/rlpgen: remove build tag (#28106)
fjl Sep 14, 2023
65a17c0
metrics: add support for enabling metrics from env vars (#28118)
karalabe Sep 14, 2023
48fdb79
core/state: check err for iter.Error in fastDeleteStorage (#28122)
darioush Sep 15, 2023
4fa3db4
eth/downloader: prevent pivot moves after state commit (#28126)
karalabe Sep 15, 2023
16cd1a7
cmd/geth, internal/flags: print envvar config source and bad names (#…
karalabe Sep 15, 2023
9a9db3d
eth/catalyst: fix engine API (#28135)
rjl493456442 Sep 17, 2023
2177193
internal/ethapi: correctly calculate effective gas price (#28130)
cam-schultz Sep 17, 2023
52234eb
internal/flags: fix typo (#28133)
phenix3443 Sep 17, 2023
d8a351b
params: fix typo in comment (#28129)
phenix3443 Sep 17, 2023
c53b0fe
core, eth/downloader: fix genesis state missing due to state sync (#2…
rjl493456442 Sep 17, 2023
3f40e65
params: release Geth v1.13.1
karalabe Sep 17, 2023
90d5bd8
params: begin Geth v1.13.2 release cycle
karalabe Sep 17, 2023
e9f78db
cmd/evm: fix some issues with the evm run command (#28109)
fjl Sep 19, 2023
ef76afa
core/rawdb: fix typo in comment (#28140)
jsvisa Sep 19, 2023
4b748b7
eth: fix typo in comment (#28146)
bnovil Sep 19, 2023
41a0ad9
cmd/devp2p: use bootnodes as crawl input (#28139)
jsvisa Sep 19, 2023
30d5d7c
go.mod: use existing version of karalabe/usb (#28127)
holiman Sep 19, 2023
7ed5bc0
trie: add getter for preimage store in trie.Database (#28155)
gballet Sep 19, 2023
5c6f4b9
cmd/utils: fix typo in comment (#28159)
phenix3443 Sep 19, 2023
5b9cbe3
cmd/clef: suppress fsnotify error if keydir not exists (#28160)
jsvisa Sep 20, 2023
545f4c5
core/rawdb: no need to run truncateFile for readonly mode (#28145)
jsvisa Sep 21, 2023
4773dcb
trie: remove internal nodes between shortNode and child in path mode …
rjl493456442 Sep 22, 2023
03c2176
trie/triedb/pathdb: improve error log (#28177)
rjl493456442 Sep 22, 2023
83f3fc2
core/state/snapshot: be very noisy if the generator hits a trie error…
karalabe Sep 22, 2023
d135baf
cmd/geth: print progress logs when iterating large contracts too (#28…
karalabe Sep 22, 2023
f1b2ec0
core/rawdb: use readonly file lock in readonly mode (#28180)
jsvisa Sep 22, 2023
82ec555
cmd: add state.scheme to the database flag group for local flag handl…
karalabe Sep 22, 2023
323542a
core, params: update Holesky testnet to relaunched spec (#28191)
karalabe Sep 25, 2023
d051ea5
params: update hash for Holesky relaunch (#28192)
karalabe Sep 25, 2023
c2cfe35
core/bloombits: fix deadlock when matcher session hits an error (#28184)
msmania Sep 25, 2023
1fa3362
core/forkid: add forkid test for holesky (#28193)
MariusVanDerWijden Sep 25, 2023
c3742a9
internal/debug: add --log.rotate to the logging category (#28190)
fjl Sep 25, 2023
3d297fc
cmd/geth: ensure db is closed before exit (#28150)
jsvisa Sep 25, 2023
f6f64cc
cmd/utils: fix bootnodes config priority (#28095)
buddh0 Sep 25, 2023
4985d83
ethclient: fix BlockReceipts parameter encoding (#28087)
kandrianov Sep 25, 2023
4de89e9
core/vm: minor code formatting (#28199)
hzysvilla Sep 26, 2023
4021910
eth/downloader: typo in comment (#28196)
phenix3443 Sep 26, 2023
2b7bc2c
eth/fetcher: allow underpriced transactions in after timeout (#28097)
MariusVanDerWijden Sep 26, 2023
adb9b31
internal/ethapi: eth_call block parameter is optional (#28165)
s1na Sep 26, 2023
b85c183
eth/downloader: remove header rollback mechanism (#28147)
rjl493456442 Sep 26, 2023
614804b
core/txpool: fix typos (#28208)
bnovil Sep 27, 2023
a081130
core/txpool: fix typos (#28213)
0xbstn Sep 28, 2023
73f5bcb
core, accounts, eth, trie: handle genesis state missing (#28171)
rjl493456442 Sep 28, 2023
dc34fe8
params: release Geth v1.13.2
karalabe Sep 28, 2023
3dc45a3
params: begin v1.13.3 release cycle
karalabe Sep 28, 2023
37a2d91
params: update 4788 beacon roots contract addr (#28205)
lightclient Sep 28, 2023
46c850a
internal/ethapi: compact db missing key starts with 0xff (#28207)
jsvisa Sep 28, 2023
b9450bf
core, eth: typos and some code formatting (#28201)
phenix3443 Sep 28, 2023
f988b23
ethdb, internal/ethapi: support exposing Pebble stats too, beside Lev…
karalabe Sep 28, 2023
1f6e639
core: fix typos (#28218)
0xbstn Sep 29, 2023
0ded110
core: infer blobGasUsed in chain maker (#28212)
s1na Sep 29, 2023
c5ff839
core/state: small trie prefetcher nits (#28183)
aaronbuchwald Sep 29, 2023
1f9d672
common: remove address.Hash footgun (#28228)
karalabe Sep 29, 2023
22dcb7a
ethdb/pebble: upgrade pebble to master (aa077af62593) (#28070)
rjl493456442 Sep 29, 2023
966e50b
ethdb/pebble: luv you linter
karalabe Sep 29, 2023
a408e37
eth/catalyst: add validation error in new paylaod hash mismatch (#28226)
lightclient Sep 29, 2023
7b6ff52
cmd, eth: switch the dev synctarget to hash from block (#28209)
karalabe Sep 29, 2023
c39cbc1
core: implement BLOBBASEFEE opcode (0x4a) (#28098)
MariusVanDerWijden Oct 2, 2023
705a51e
eth, rpc: add configurable option for wsMessageSizeLimit (#27801)
tylerni7 Oct 3, 2023
07dec7a
cmd/evm: cancun-updates for b11r and t8n -tools (#28195)
lightclient Oct 3, 2023
339a4cf
core: fix typos (#28238)
0xbstn Oct 3, 2023
2091ebd
trie: fix benchmark by ensuring key immutability (#28221)
DeVil2O Oct 3, 2023
7963c4e
rpc: fix erroneous error-message in test (#28227)
hyunchel Oct 3, 2023
bc6d184
cmd/devp2p, eth: drop eth/66 (#28239)
karalabe Oct 3, 2023
a8a9c8e
core, eth, miner: start propagating and consuming blob txs (#28243)
karalabe Oct 4, 2023
95b0555
eth: when snap is complaining for missing eth, be verbose about the d…
karalabe Oct 4, 2023
052355f
cmd/evm/internal/t8ntoo: tiny bugfix for difficulty field (#28245)
tactical-retreat Oct 4, 2023
4e1e373
core/txpool/legacypool: fix typo (#28258)
hyunchel Oct 7, 2023
0832679
trie: refactor stacktrie (#28233)
holiman Oct 10, 2023
fa6107c
core: fix typos (#28255)
0xbstn Oct 10, 2023
db9afae
eth, params: fix typos (#28286)
hyunchel Oct 10, 2023
6b1e4f4
all: move light.NodeSet to trienode.ProofSet (#28287)
holiman Oct 10, 2023
6505297
trie: fix a typo, use correct docstrings (#28302)
bnovil Oct 10, 2023
8afbcf4
eth: enforce announcement metadatas and drop peers violating the prot…
karalabe Oct 10, 2023
5e43ed0
git: ignore tests/spec-tests folder (#28254)
lightclient Oct 10, 2023
2c007cf
accounts/abi/bind/backend: use requested header for gas prices and ga…
karalabe Oct 10, 2023
8976a0c
trie: remove owner and binary marshaling from stacktrie (#28291)
holiman Oct 11, 2023
7776a32
ethdb/pebble: add level file metrics (#28271)
rjl493456442 Oct 11, 2023
a6deb2d
eth/fetcher: throttle tx fetches to 128KB responses (#28304)
karalabe Oct 11, 2023
13d1d42
eth/fetcher: fix typo
karalabe Oct 11, 2023
eeb5dc3
cmd, core: resolve scheme from a read-write database (#28313)
rjl493456442 Oct 11, 2023
0004c6b
accounts, cmd: fix typos (#28300)
vuittont60 Oct 11, 2023
d2c0bed
cmd/geth: fix failing test (#28322)
holiman Oct 12, 2023
0d45d72
params: release Geth v.1.13.3
karalabe Oct 12, 2023
ff3bbcc
Merge branch 'metrics-merge'
joshuacolvin0 Jan 24, 2024
6a1f508
update sliding time window for new geth metrics
joshuacolvin0 Jan 24, 2024
9f6dbf5
Merge upstream commit #28135
tsahee Jan 25, 2024
addac58
Merge upstream commit #28124
tsahee Jan 25, 2024
022ddb9
Merge tag 'v1.13.1' into merge-1.13.3
tsahee Jan 25, 2024
6460f6e
Merge upstream PR 28180
tsahee Jan 25, 2024
02ecac8
Merge upstream PR 28165
tsahee Jan 25, 2024
ed35443
Merge upstream PR #28171
tsahee Jan 25, 2024
208af57
Merge tag 'v1.13.2' into merge-1.13.3
tsahee Jan 25, 2024
efaca34
Merge upstream PR 28098
tsahee Jan 25, 2024
3ece0e0
Merge upstream PR 28238
tsahee Jan 25, 2024
1c7cc5a
Merge tag 'v1.13.3' into merge-1.13.3
tsahee Jan 25, 2024
85f420d
Merge remote-tracking branch 'origin/master' into merge-1.13.3
tsahee Jan 25, 2024
e5ecb9d
update github actions and use go 1.20
tsahee Jan 25, 2024
18a471f
Cleanup function ordering
joshuacolvin0 Jan 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: true

- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: 1.19
go-version: 1.20.x

- name: Test
run: make test
Expand All @@ -27,12 +29,14 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: true

- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: 1.19
go-version: 1.20.x

- name: Test
run: make lint
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,6 @@ profile.cov
/dashboard/assets/package-lock.json

**/yarn-error.log
logs/
logs/

tests/spec-tests/
24 changes: 11 additions & 13 deletions accounts/abi/bind/backends/simulated.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ func (b *SimulatedBackend) CodeAt(ctx context.Context, contract common.Address,
if err != nil {
return nil, err
}

return stateDB.GetCode(contract), nil
}

Expand All @@ -212,7 +211,6 @@ func (b *SimulatedBackend) BalanceAt(ctx context.Context, contract common.Addres
if err != nil {
return nil, err
}

return stateDB.GetBalance(contract), nil
}

Expand All @@ -225,7 +223,6 @@ func (b *SimulatedBackend) NonceAt(ctx context.Context, contract common.Address,
if err != nil {
return 0, err
}

return stateDB.GetNonce(contract), nil
}

Expand All @@ -238,7 +235,6 @@ func (b *SimulatedBackend) StorageAt(ctx context.Context, contract common.Addres
if err != nil {
return nil, err
}

val := stateDB.GetState(contract, key)
return val[:], nil
}
Expand Down Expand Up @@ -610,8 +606,7 @@ func (b *SimulatedBackend) callContract(ctx context.Context, call ethereum.CallM
if call.GasPrice != nil && (call.GasFeeCap != nil || call.GasTipCap != nil) {
return nil, errors.New("both gasPrice and (maxFeePerGas or maxPriorityFeePerGas) specified")
}
head := b.blockchain.CurrentHeader()
if !b.blockchain.Config().IsLondon(head.Number) {
if !b.blockchain.Config().IsLondon(header.Number) {
// If there's no basefee, then it must be a non-1559 execution
if call.GasPrice == nil {
call.GasPrice = new(big.Int)
Expand All @@ -633,13 +628,13 @@ func (b *SimulatedBackend) callContract(ctx context.Context, call ethereum.CallM
// Backfill the legacy gasPrice for EVM execution, unless we're all zeroes
call.GasPrice = new(big.Int)
if call.GasFeeCap.BitLen() > 0 || call.GasTipCap.BitLen() > 0 {
call.GasPrice = math.BigMin(new(big.Int).Add(call.GasTipCap, head.BaseFee), call.GasFeeCap)
call.GasPrice = math.BigMin(new(big.Int).Add(call.GasTipCap, header.BaseFee), call.GasFeeCap)
}
}
}
// Ensure message is initialized properly.
if call.Gas == 0 {
call.Gas = 50000000
call.Gas = 10 * header.GasLimit
}
if call.Value == nil {
call.Value = new(big.Int)
Expand Down Expand Up @@ -700,8 +695,10 @@ func (b *SimulatedBackend) SendTransaction(ctx context.Context, tx *types.Transa
}
block.AddTxWithChain(b.blockchain, tx)
})
stateDB, _ := b.blockchain.State()

stateDB, err := b.blockchain.State()
if err != nil {
return err
}
b.pendingBlock = blocks[0]
b.pendingState, _ = state.New(b.pendingBlock.Root(), stateDB.Database(), nil)
b.pendingReceipts = receipts[0]
Expand Down Expand Up @@ -821,11 +818,12 @@ func (b *SimulatedBackend) AdjustTime(adjustment time.Duration) error {
blocks, _ := core.GenerateChain(b.config, block, ethash.NewFaker(), b.database, 1, func(number int, block *core.BlockGen) {
block.OffsetTime(int64(adjustment.Seconds()))
})
stateDB, _ := b.blockchain.State()

stateDB, err := b.blockchain.State()
if err != nil {
return err
}
b.pendingBlock = blocks[0]
b.pendingState, _ = state.New(b.pendingBlock.Root(), stateDB.Database(), nil)

return nil
}

Expand Down
2 changes: 1 addition & 1 deletion accounts/abi/bind/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ func (c *BoundContract) createLegacyTx(opts *TransactOpts, contract *common.Addr
}

func (c *BoundContract) estimateGasLimit(opts *TransactOpts, contract *common.Address, input []byte, gasPrice, gasTipCap, gasFeeCap, value *big.Int) (uint64, error) {
if contract != nil && (contract.Hash().Big().BitLen() > 16) {
if contract != nil && (contract.Big().BitLen() > 16) {
// Gas estimation cannot succeed without code for method invocations, unless precompile.
if code, err := c.transactor.PendingCodeAt(ensureContext(opts.Context), c.address); err != nil {
return 0, err
Expand Down
5 changes: 4 additions & 1 deletion accounts/keystore/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package keystore

import (
"os"
"time"

"github.com/ethereum/go-ethereum/log"
Expand Down Expand Up @@ -77,7 +78,9 @@ func (w *watcher) loop() {
}
defer watcher.Close()
if err := watcher.Add(w.ac.keydir); err != nil {
logger.Warn("Failed to watch keystore folder", "err", err)
if !os.IsNotExist(err) {
logger.Warn("Failed to watch keystore folder", "err", err)
}
return
}

Expand Down
2 changes: 1 addition & 1 deletion accounts/scwallet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

## Preparing the smartcard

**WARNING: FOILLOWING THESE INSTRUCTIONS WILL DESTROY THE MASTER KEY ON YOUR CARD. ONLY PROCEED IF NO FUNDS ARE ASSOCIATED WITH THESE ACCOUNTS**
**WARNING: FOLLOWING THESE INSTRUCTIONS WILL DESTROY THE MASTER KEY ON YOUR CARD. ONLY PROCEED IF NO FUNDS ARE ASSOCIATED WITH THESE ACCOUNTS**

You can use status' [keycard-cli](https://github.com/status-im/keycard-cli) and you should get _at least_ version 2.1.1 of their [smartcard application](https://github.com/status-im/status-keycard/releases/download/2.2.1/keycard_v2.2.1.cap)

Expand Down
28 changes: 14 additions & 14 deletions build/checksums.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@
24bac679f3a2d8240d8e08e7f6a70b70c2dabf673317d924cf1d1887b9fe1f81 fixtures.tar.gz

# https://go.dev/dl/
818d46ede85682dd551ad378ef37a4d247006f12ec59b5b755601d2ce114369a go1.21.0.src.tar.gz
b314de9f704ab122c077d2ec8e67e3670affe8865479d1f01991e7ac55d65e70 go1.21.0.darwin-amd64.tar.gz
3aca44de55c5e098de2f406e98aba328898b05d509a2e2a356416faacf2c4566 go1.21.0.darwin-arm64.tar.gz
312a0065714a50862af714e7a5b3fbbd70fe68f905ffb9bcc56d42eadf6bffab go1.21.0.freebsd-386.tar.gz
b8eaa36654625df799654f77f4af0ea7bd9e5e760ebe86e68fe7c484748ae995 go1.21.0.freebsd-amd64.tar.gz
0e6f378d9b072fab0a3d9ff4d5e990d98487d47252dba8160015a61e6bd0bcba go1.21.0.linux-386.tar.gz
d0398903a16ba2232b389fb31032ddf57cac34efda306a0eebac34f0965a0742 go1.21.0.linux-amd64.tar.gz
f3d4548edf9b22f26bbd49720350bbfe59d75b7090a1a2bff1afad8214febaf3 go1.21.0.linux-arm64.tar.gz
e377a0004957c8c560a3ff99601bce612330a3d95ba3b0a2ae144165fc87deb1 go1.21.0.linux-armv6l.tar.gz
e938ffc81d8ebe5efc179240960ba22da6a841ff05d5cab7ce2547112b14a47f go1.21.0.linux-ppc64le.tar.gz
be7338df8e5d5472dfa307b0df2b446d85d001b0a2a3cdb1a14048d751b70481 go1.21.0.linux-s390x.tar.gz
af920fbb74fc3d173118dc3cc35f02a709c1de642700e92a91a7d16981df3fec go1.21.0.windows-386.zip
732121e64e0ecb07c77fdf6cc1bc5ce7b242c2d40d4ac29021ad4c64a08731f6 go1.21.0.windows-amd64.zip
41342f5a0f8c083b14c68bde738ddcd313a4f53a5854bfdfab47f0e88247de12 go1.21.0.windows-arm64.zip
bfa36bf75e9a1e9cbbdb9abcf9d1707e479bd3a07880a8ae3564caee5711cb99 go1.21.1.src.tar.gz
809f5b0ef4f7dcdd5f51e9630a5b2e5a1006f22a047126d61560cdc365678a19 go1.21.1.darwin-amd64.tar.gz
ffd40391a1e995855488b008ad9326ff8c2e81803a6e80894401003bae47fcf1 go1.21.1.darwin-arm64.tar.gz
9919a9a4dc82371aba3da5b7c830bcb6249fc1502cd26d959eb340a60e41ee01 go1.21.1.freebsd-386.tar.gz
2571f10f6047e04d87c1f5986a05e5e8f7b511faf98803ef12b66d563845d2a1 go1.21.1.freebsd-amd64.tar.gz
b93850666cdadbd696a986cf7b03111fe99db8c34a9aaa113d7c96d0081e1901 go1.21.1.linux-386.tar.gz
b3075ae1ce5dab85f89bc7905d1632de23ca196bd8336afd93fa97434cfa55ae go1.21.1.linux-amd64.tar.gz
7da1a3936a928fd0b2602ed4f3ef535b8cd1990f1503b8d3e1acc0fa0759c967 go1.21.1.linux-arm64.tar.gz
f3716a43f59ae69999841d6007b42c9e286e8d8ce470656fb3e70d7be2d7ca85 go1.21.1.linux-armv6l.tar.gz
eddf018206f8a5589bda75252b72716d26611efebabdca5d0083ec15e9e41ab7 go1.21.1.linux-ppc64le.tar.gz
a83b3e8eb4dbf76294e773055eb51397510ff4d612a247bad9903560267bba6d go1.21.1.linux-s390x.tar.gz
170256c820f466f29d64876f25f4dfa4029ed9902a0a9095d8bd603aecf4d83b go1.21.1.windows-386.zip
10a4f5b63215d11d1770453733dbcbf024f3f74872f84e28d7ea59f0250316c6 go1.21.1.windows-amd64.zip
41135ce6e0ced4bc1e459cb96bd4090c9dc2062e24179c3f337d855af9b560ef go1.21.1.windows-arm64.zip

# https://github.com/golangci/golangci-lint/releases
fba08acc4027f69f07cef48fbff70b8a7ecdfaa1c2aba9ad3fb31d60d9f5d4bc golangci-lint-1.51.1-darwin-amd64.tar.gz
Expand Down
2 changes: 1 addition & 1 deletion build/ci.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ var (
// This is the version of Go that will be downloaded by
//
// go run ci.go install -dlgo
dlgoVersion = "1.21.0"
dlgoVersion = "1.21.1"

// This is the version of Go that will be used to bootstrap the PPA builder.
//
Expand Down
12 changes: 10 additions & 2 deletions cmd/devp2p/crawl.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package main

import (
"errors"
"sync"
"sync/atomic"
"time"
Expand Down Expand Up @@ -51,7 +52,14 @@ type resolver interface {
RequestENR(*enode.Node) (*enode.Node, error)
}

func newCrawler(input nodeSet, disc resolver, iters ...enode.Iterator) *crawler {
func newCrawler(input nodeSet, bootnodes []*enode.Node, disc resolver, iters ...enode.Iterator) (*crawler, error) {
if len(input) == 0 {
input.add(bootnodes...)
}
if len(input) == 0 {
return nil, errors.New("no input nodes to start crawling")
}

c := &crawler{
input: input,
output: make(nodeSet, len(input)),
Expand All @@ -67,7 +75,7 @@ func newCrawler(input nodeSet, disc resolver, iters ...enode.Iterator) *crawler
for id, n := range input {
c.output[id] = n
}
return c
return c, nil
}

func (c *crawler) run(timeout time.Duration, nthreads int) nodeSet {
Expand Down
29 changes: 18 additions & 11 deletions cmd/devp2p/discv4cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ var discoveryNodeFlags = []cli.Flag{

func discv4Ping(ctx *cli.Context) error {
n := getNodeArg(ctx)
disc := startV4(ctx)
disc, _ := startV4(ctx)
defer disc.Close()

start := time.Now()
Expand All @@ -156,7 +156,7 @@ func discv4Ping(ctx *cli.Context) error {

func discv4RequestRecord(ctx *cli.Context) error {
n := getNodeArg(ctx)
disc := startV4(ctx)
disc, _ := startV4(ctx)
defer disc.Close()

respN, err := disc.RequestENR(n)
Expand All @@ -169,7 +169,7 @@ func discv4RequestRecord(ctx *cli.Context) error {

func discv4Resolve(ctx *cli.Context) error {
n := getNodeArg(ctx)
disc := startV4(ctx)
disc, _ := startV4(ctx)
defer disc.Close()

fmt.Println(disc.Resolve(n).String())
Expand All @@ -196,10 +196,13 @@ func discv4ResolveJSON(ctx *cli.Context) error {
nodeargs = append(nodeargs, n)
}

// Run the crawler.
disc := startV4(ctx)
disc, config := startV4(ctx)
defer disc.Close()
c := newCrawler(inputSet, disc, enode.IterNodes(nodeargs))

c, err := newCrawler(inputSet, config.Bootnodes, disc, enode.IterNodes(nodeargs))
if err != nil {
return err
}
c.revalidateInterval = 0
output := c.run(0, 1)
writeNodesJSON(nodesFile, output)
Expand All @@ -211,14 +214,18 @@ func discv4Crawl(ctx *cli.Context) error {
return errors.New("need nodes file as argument")
}
nodesFile := ctx.Args().First()
var inputSet nodeSet
inputSet := make(nodeSet)
if common.FileExist(nodesFile) {
inputSet = loadNodesJSON(nodesFile)
}

disc := startV4(ctx)
disc, config := startV4(ctx)
defer disc.Close()
c := newCrawler(inputSet, disc, disc.RandomNodes())

c, err := newCrawler(inputSet, config.Bootnodes, disc, disc.RandomNodes())
if err != nil {
return err
}
c.revalidateInterval = 10 * time.Minute
output := c.run(ctx.Duration(crawlTimeoutFlag.Name), ctx.Int(crawlParallelismFlag.Name))
writeNodesJSON(nodesFile, output)
Expand All @@ -238,14 +245,14 @@ func discv4Test(ctx *cli.Context) error {
}

// startV4 starts an ephemeral discovery V4 node.
func startV4(ctx *cli.Context) *discover.UDPv4 {
func startV4(ctx *cli.Context) (*discover.UDPv4, discover.Config) {
ln, config := makeDiscoveryConfig(ctx)
socket := listen(ctx, ln)
disc, err := discover.ListenV4(socket, ln, config)
if err != nil {
exit(err)
}
return disc
return disc, config
}

func makeDiscoveryConfig(ctx *cli.Context) (*enode.LocalNode, discover.Config) {
Expand Down
20 changes: 12 additions & 8 deletions cmd/devp2p/discv5cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ var (

func discv5Ping(ctx *cli.Context) error {
n := getNodeArg(ctx)
disc := startV5(ctx)
disc, _ := startV5(ctx)
defer disc.Close()

fmt.Println(disc.Ping(n))
Expand All @@ -90,7 +90,7 @@ func discv5Ping(ctx *cli.Context) error {

func discv5Resolve(ctx *cli.Context) error {
n := getNodeArg(ctx)
disc := startV5(ctx)
disc, _ := startV5(ctx)
defer disc.Close()

fmt.Println(disc.Resolve(n))
Expand All @@ -102,14 +102,18 @@ func discv5Crawl(ctx *cli.Context) error {
return errors.New("need nodes file as argument")
}
nodesFile := ctx.Args().First()
var inputSet nodeSet
inputSet := make(nodeSet)
if common.FileExist(nodesFile) {
inputSet = loadNodesJSON(nodesFile)
}

disc := startV5(ctx)
disc, config := startV5(ctx)
defer disc.Close()
c := newCrawler(inputSet, disc, disc.RandomNodes())

c, err := newCrawler(inputSet, config.Bootnodes, disc, disc.RandomNodes())
if err != nil {
return err
}
c.revalidateInterval = 10 * time.Minute
output := c.run(ctx.Duration(crawlTimeoutFlag.Name), ctx.Int(crawlParallelismFlag.Name))
writeNodesJSON(nodesFile, output)
Expand All @@ -127,20 +131,20 @@ func discv5Test(ctx *cli.Context) error {
}

func discv5Listen(ctx *cli.Context) error {
disc := startV5(ctx)
disc, _ := startV5(ctx)
defer disc.Close()

fmt.Println(disc.Self())
select {}
}

// startV5 starts an ephemeral discovery v5 node.
func startV5(ctx *cli.Context) *discover.UDPv5 {
func startV5(ctx *cli.Context) (*discover.UDPv5, discover.Config) {
ln, config := makeDiscoveryConfig(ctx)
socket := listen(ctx, ln)
disc, err := discover.ListenV5(socket, ln, config)
if err != nil {
exit(err)
}
return disc
return disc, config
}
Loading
Loading