Repository navigation
feat: with no peer, dial a seed of the network at random, and only its answers that the internet routes to (#44) - #90
Merged
Merged
Conversation
…s answers that the internet routes to (#44)
…cap of a seed in `dial_order` (#44) - A timeout of the `x9.<seed>` lookup ends the dial. The resolver does not answer, so a lookup of the seed itself only waits `LOOKUP_TIMEOUT` again. A failed lookup or no address still looks up the seed itself. The match names each `LookupError`, so a new error needs a choice here. - The doc of `Destination::Seed` and the README say that a failed lookup also gives the lookup of the seed itself. Before, they said only "no address". - `lookup` gives the iterator of the resolver, and not a `Vec`. `name_order` and `seed_order` take at most their count max of it, so a lookup with many answers does not copy them all. - `dial_order` asserts `before.len() < count_max` after the `pop`. `connect_first` checks only `ADDRESSES_COUNT_MAX`, so before, no check held the cap of 32 for a seed. - `is_routable` is now `is_reserved`, with no `!` on its 8 and 6 terms. `seed_order` keeps an address that is not reserved. `is_benchmarking` uses a range, as `is_shared` does.
…iler checks it against `ADDRESSES_COUNT_MAX` (#44) - `dial_order::<COUNT_MAX>` takes the cap as a const parameter. Its only values are `ADDRESSES_COUNT_MAX` and `SEED_ADDRESSES_COUNT_MAX`, so a run-time `assert!` on the argument checked a fact that the build knows. - `const { assert!(COUNT_MAX <= ADDRESSES_COUNT_MAX) }` checks each cap when it compiles. A cap of 257 does not compile. - The `const _` assert on `SEED_ADDRESSES_COUNT_MAX` goes: the check in `dial_order` holds each cap that a caller uses. - The assert of `before.len() < COUNT_MAX` after the `pop` stays.
…a seed shows which of its two lookups did not end (#44) - `LookupError::Timeout` has the `host` that `lookup` looked up. Its text is `the lookup of <host> took longer than 30 s`. - A dial to a seed looks up `x9.<seed>`, and then the seed itself. Before, a timeout of each one gave the same `reason`, and the `destination` of the `end` line is the seed itself. So a timeout of `x9.<seed>` looked like a timeout of the seed, which can answer. - The seed arm of `addresses` gives the timeout of `x9.<seed>` as it is, with no copy of the variant. - Rejected: a `ServicesTimeout` variant only for `x9.<seed>`. The match on the result of `seed_order` then needs an arm for a variant that `lookup` never gives.
…rison is left that a mutant can flip with no change of the choice (#44)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #44. Slice 2: the seeds of the network when the command line names no peer.
What
elo <network> [<ip|name>[:port]]. With no peer, each dial uses a seed of the network.chainparams::Network::seedsgives the DNS seeds of each network: 8 for mainnet, 2 for testnet4, 2 for signet. Regtest has none, soelo regtestwith no peer is bad usage (exit 2). The usage text says so.net::Sourceis what the command line names:Destination(Destination), the same for each dial, orSeeds(Seeds).Source::destinationgives the destination of the next dial. OnlySeeds::newmakes aSeeds, and it refuses a network with no seeds, so aSeedshas at least one seed.Seedschooses one seed at random: the seed with the lowest hash under a newRandomState.Destination::Seed { seed, port }is a third kind of destination. OnlySeedsmakes aSeed, so it is on the list of its network. The dial looks upx9.<seed>: the nodes withNODE_NETWORKandNODE_WITNESS. If that lookup fails or gives no address to dial, it looks up the seed itself. If that lookup times out, the dial ends.is_reserved), and at most 32 of them. These do not pass:0.0.0.0/8,127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,169.254.0.0/16,100.64.0.0/10,198.18.0.0/15, the 3 IPv4 documentation ranges,255.255.255.255,::,::1,fc00::/7,fe80::/10,2001:db8::/32,2001:10::/28and2001:20::/28. An IPv4 address in IPv6 is checked as the IPv4 address. A name that you type keeps the filter of feat: take a name as the peer, look it up before each dial, and dial its addresses in a random order until one takes the connect (#44) #89 only: no0.0.0.0or::.dial_order::<COUNT_MAX>takesPeerAddressvalues. The count max is a const parameter, andconst { assert!(COUNT_MAX <= ADDRESSES_COUNT_MAX) }checks it when it compiles. After thepop, it assertsbefore.len() < COUNT_MAX, becauseconnect_firstchecks onlyADDRESSES_COUNT_MAX.name_order(cap 256) andseed_order(cap 32, routable only) do the filter before it.endline has the destination of the dial. For a seed it is the seed, such asdestination=seed.bitcoin.sipa.be.:8333.LookupError::Timeout { host }names the host that timed out:the lookup of x9.<seed> took longer than 30 s. Thedestinationof theendline is the seed itself, so without the host a timeout ofx9.<seed>looks like a timeout of the seed.protocol::ServiceFlags::NETWORK_WITNESS(0x9).destinationof a seed. A separate commit fixes the README: a log value is at most 260 bytes, not 256.no_peer_is_the_seeds_of_the_network, and["regtest"]and["testnet3"]rows in the usage test.each_network_but_regtest_has_seeds_that_are_names_at_its_default_port: each seed and eachx9.<seed>is aName, so it fits in a log value.a_seeds_source_chooses_each_seed_of_the_network: 1000 choices reach each of the 8 mainnet seeds.routable_is_each_address_but_this_host_private_networks_links_and_test_ranges: the first and last address of each range, and the addresses next to them.seed_order_keeps_at_most_the_seed_count_max_of_the_routable_answers.nix flake checkpasses.cargo mutants --in-diffon the last 2 commits: 9 mutants, 4 caught, 5 unviable.cargo mutants --in-diffon the first feat commit: 67 mutants, 49 caught, 15 unviable, 3 missed. The 3 do not change what elo does.<to>or<=inSeeds::choosetakes the seed with the highest hash, which is just as random, and two equal hashes do not occur.1 | 1 << 3to1 ^ 1 << 3is also 9, so the value is now0b1001.x9.. No test catches a dial without the second lookup (see "Not confident").version. Testnet4 8 of 8: 4 peers came fromx9.seed.testnet4.bitcoin.sprovoost.nl., and 4 came fromseed.testnet4.wiz.biz.through the second lookup.x9.seed.testnet4.bitcoin.sprovoost.nl., and logged 4 more tips after that. Its first dial gotx9.seed.testnet4.wiz.biz., which failed withName or service not known. That failure is the reason for the second lookup.elo regtestwith no peer prints the usage and exits with 2.Why
One seed for each dial, at random. Each seed gets the same part of the dials, also a seed that gives few answers. A seed that gives many answers gets no more. One lookup for each dial sends the fewest DNS questions. A dial that fails goes to another seed after 5 s, with the retry of #42. Rejected: a lookup of all the seeds, with the answers mixed. Then a seed that gives more answers chooses more of the peers. Mixing seeds and trust in a seed are still open on #44.
x9.<seed>, then the seed itself. A seed answersx9.<seed>with nodes that serve each block and its witness data. Block download (#62) needs those nodes. A timeout gets no second lookup: the resolver does not answer, so the second lookup would only wait 30 s again.seed.testnet4.wiz.biz.has nox<bits>.names:x1,x5,x8,x9,xdandx809give no address, and the seed itself gives 22. Without the second lookup, half of the testnet4 dials fail. A node from the second lookup can have other services. The header sync needs none, because elo asks only for headers.Only the answers that the internet routes to. The person who runs elo did not choose the answers of a seed. A seed can give the address of a host on the network of elo, such as a router or a service on
127.0.0.1. The ranges are the ones that Bitcoin nodes refuse as addresses of peers. For a name that you type, the address can be on this host or on your network, so that filter does not apply.fe80::/10is a little wider thanfe80::/64. The rest offe80::/10is not routable either. Multicast and240.0.0.0/4pass, and their connect fails.At most 32 addresses of a seed. A seed whose answers are down costs at most 32 connect timeouts, 160 s, before the next seed. With 256, that is about 21 min. One DNS answer over UDP has room for about 30 addresses.
Source, and not a third case inDestinationalone. ADestinationis what one dial looks up, and theendline shows it. With seeds, each dial has another one.Sourceholds the choice, andDestination::Seedholds the seed of one dial. So theendline shows which seed gave the peer, or which seed failed. Rejected:destination=seeds. Then the log does not show a seed that is down.A
Seedshas at least one seed.Seeds::newrefuses regtest, andparsegives bad usage for it. So no dial can choose from an empty list, and the choice needs no check. Rejected: the dummy seed of regtest. A lookup that always fails would retry each 5 s forever.No new dependency. The random choice uses
RandomState, as the order of the addresses does.Not confident:
x9.<seed>and answers the seed with a routable address. The real testnet4 dials hold it.x9.<seed>ends the dial, also when the seed itself would answer. The next dial chooses a seed again after 5 s.