Page MenuHomePhabricator

Add -overridednsseed for testing DNS seed behavior
ClosedPublic

Authored by jasonbcox on Dec 14 2020, 18:31.

Details

Reviewers
deadalnix
Group Reviewers
Restricted Project
Commits
rABC45d5037db635: Add -overridednsseed for testing DNS seed behavior
Summary

This makes it easier to test both the node fetching seeds
from a particular seeder and a seeder fetching peers from a particular node.

Test Plan
ninja check

Test node fetching seeds from a specific seeder:

bitcoind -overridednsseed=seed.bitcoinabc.org

Should see this in the logs:

2020-12-14T18:01:03Z Loading addresses from DNS seed seed.bitcoinabc.org
2020-12-14T18:01:03Z 24 addresses found from DNS seeds

Test seeder fetching peers from a specific node:

./bitcoind
./bitcoin-seeder -host=localhost -ns=localhost -port=8888 -mbox=noemail@bitcoinabc.org -wipeban -wipeignore -overridednsseed=localhost

After some time, the seeder should report many peers:

[20-12-14 10:29:17] 0/482 available (4 tried in 8s, 147 new, 331 active), 0 banned; 0 DNS requests, 0 db queries

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

The cppcheck issue appears to be a bug in cppcheck. Fabien has confirmed this lint error does not appear in a newer version.

deadalnix requested changes to this revision.Dec 15 2020, 02:32
deadalnix added a subscriber: deadalnix.
deadalnix added inline comments.
src/chainparams.cpp
75 ↗(On Diff #26370)

The proper way to do this is to check if the arg is set.

This revision now requires changes to proceed.Dec 15 2020, 02:32
  • Fixed checking if the arg is set
  • Added another sanity checking test case
deadalnix requested changes to this revision.Jan 2 2021, 20:42
deadalnix added inline comments.
src/chainparams.cpp
75 ↗(On Diff #26418)

I think this returns a reference to something that is past its lifetime.

This revision now requires changes to proceed.Jan 2 2021, 20:42
  • Rename DNSSeeds -> GetRandomizedDNSSeeds
  • Make the currently node-specific randomization logic available to the seeder
  • Doing the above also incidentally makes better use of the vector copy that I introduced in this patch.
src/seeder/main.cpp
467 ↗(On Diff #26618)

I'm aware this will copy on each loop. Not doing so eliminates any potential benefit from the randomization. This operation only occurs occasionally (see the sleep below), so the cost is minimal.

deadalnix requested changes to this revision.Jan 8 2021, 11:03
deadalnix added inline comments.
src/chainparams.h
88 ↗(On Diff #26618)

This does not belong in the chain params. Make it a free function and keep the params dumb.

This revision now requires changes to proceed.Jan 8 2021, 11:03

Separated out GetRandomizedDNSSeeds into its own files. Over time, these new files can house the
DNS seed related logic and constants that currently reside in the net.h/cpp mess.

This revision is now accepted and ready to land.Apr 3 2021, 20:39