Repository navigation
fix(node): bound the DHT dial and skip a peer whose dial timed out - #2536
Merged
Merged
Conversation
…2532) The registry seeds every bonded peer into every routing table, and a bond does not say whether the node behind it answers. One such peer on the testnet resolves an address from the registry mirror, so every `FIND_VALUE` dial to it sends a handshake that nothing answers. The DHT client wrapped connect, handshake and exchange in one 8 s timeout, level with the 8 s round timeout, so every lookup whose α batch held the peer ran to the round timeout, and nothing recorded which peer it was. The client now bounds the connect and handshake separately at `DHT_DIAL_TIMEOUT` (2 s) and fails them as a bare `DialTimeout` naming the peer. The lookup marks that peer in the routing table (`RoutingTable::mark_unreachable`), and this node's lookups skip it for `DIAL_FAILURE_COOLDOWN` (5 min), from the seed and from `closer_nodes` answers alike. A peer a round timeout aborts is marked the same way. The peer stays in the table and in the answers this node gives; an insert or refresh of it, which an inbound request does, ends the skip. `decdn_dht_lookup_dial_timeouts_total` counts the dials that timed out, and the `dht_lookup` span records the `cooling` peers skipped. ADR 022 § Routing Table states the rule; the observability appendix gains the row, and the one for the round ceiling that was missing. Closes #2532 Co-Authored-By: Claude Fable 5.1 <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
Cooldown filtering can hide healthy seed alternatives, and failed referral-only peers escape cooldown tracking.
2 open issues
What changed in this PR
Reduces DHT lookup delays from offline bonded peers using a shorter dial timeout and node-local cooldowns.
Changes:
- Adds a typed 2-second dial timeout and 5-minute peer cooldown.
- Adds timeout metrics, tracing, and regression tests.
- Documents the behavior without changing wire formats or contracts.
| File | Description |
|---|---|
| crates/node/tests/dht_loopback.rs | Tests typed dial timeouts. |
| crates/node/tests/dht_integration.rs | Tests timeout accounting and cooldown skipping. |
| crates/node/src/metrics/tests.rs | Checks exported counters. |
| crates/node/src/metrics.rs | Adds the dial-timeout counter. |
| crates/node/src/dht/routing/tests.rs | Tests cooldown lifecycle. |
| crates/node/src/dht/routing.rs | Tracks peer cooldowns. |
| crates/node/src/dht/lookup/tests.rs | Tests cooling-candidate filtering. |
| crates/node/src/dht/lookup.rs | Marks failed peers and skips cooling candidates. |
| crates/node/src/dht/client.rs | Bounds dialing separately from exchanges. |
| CHANGELOG.md | Describes the lookup improvement. |
| adr/appendix-observability.md | Documents lookup counters. |
| adr/022-content-discovery.md | Specifies local timeout and cooldown behavior. |
Review effort: Balanced
Code coverage overviewLanguages: Rust Rust / code-coverage/cargo-llvm-cov
View coverage of the 6 most impacted files.
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. Updated |
… and mark dead referrals Review of #2536. The seed took the nearest `4α` peers and then dropped the cooling ones, so twelve cooling peers nearer the target than a live peer left the lookup with no seed. `LookupState::seed_from` reads the table past the seed count by the number of cooling peers and keeps the nearest peers that are not cooling; `closest()` is unchanged. `RoutingTable::mark_unreachable` marked only peers in a bucket. A peer a `closer_nodes` answer named is dialed without entering the table, so a dead referral lost its mark and the next lookup dialed it again. The mark no longer needs table membership; the map is bounded by the active staker set and sweeps lapsed entries on read. Unit tests cover both shapes, and a two-hop integration test proves the second lookup skips a dead referral without a second dial. Co-Authored-By: Claude Fable 5.1 <[email protected]>
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.

What
A third of the fleet's DHT lookups waited the full 8 s round because one bonded peer never answers
find_value. The on-chain check (comment on #2532) names it: a third-party bond registered 2026-10-13 from177.2.140.159(BR), not in our fleet, which we cannot deregister. A bonded-but-dead peer is a permanent condition of an open network, so the fix is node-local.Two mechanisms, both constants, no config knob, no wire or on-chain change:
dht/client.rswrapped connect + handshake + exchange in oneDHT_CLIENT_TIMEOUT(8 s), level withDEFAULT_ROUND_TIMEOUT(8 s), and the round clock starts after the RPC tasks spawn, so the round timer always fired first. The connect and handshake are now bounded separately atDHT_DIAL_TIMEOUT(2 s) and fail as a bare, typedDialTimeout { peer }.DHT_CLIENT_TIMEOUTstays as the belt over an accepted connection that stalls. Aconstassert pinsDHT_DIAL_TIMEOUT < DEFAULT_ROUND_TIMEOUT.RoutingTable::mark_unreachable(peer, now)records the peer;cooling_peers(now)is the snapshot a lookup takes under the same lock as its seed;LookupState::add_candidaterejects a cooling peer from the seed and fromcloser_nodesanswers alike. A peer a round timeout aborts is marked too.closest()is unchanged, socloser_nodesanswers to other nodes and the republish fan-out still name the peer; the skip is this node's own. An insert or refresh of the peer (an inbound request does one) orDIAL_FAILURE_COOLDOWN(5 min) ends it.Observability:
decdn_dht_lookup_dial_timeouts_total(new) and acoolingfield on thedht_lookupspan. The appendix also gains thedecdn_dht_lookup_round_ceiling_totalrow, which was missing (the exporter emitted it; the ADR did not list it).Closes #2532
Reviewer notes
exchange_payloadincrates/node/src/dht/client.rs, thenrun_round/mark_unreachable/LookupState::newindht/lookup.rs, then thecoolingmap indht/routing.rs.DEFAULT_ROUND_TIMEOUTandPULL_THROUGH_OUTER_SLACKare unchanged on purpose: the dial budget is what binds for a dead peer, and moving the round budget would move the pull deadline derivation.closer_nodes, costing one more 2 s dial per hour at worst. Chosen over a separate "proof of liveness" insert path; the ADR text says "inserts or refreshes" so it is not overstated.find_providers), sit at constant altitude, and are self-enforced by the node they protect. Nothing on-chain, nothing a peer could exploit beyond being offline.decdn_dht_lookup_round_timeouts_totalfalls to ~0;decdn_dht_lookup_dial_timeouts_totalreads about one per node per 5 min while the BR bond stays dead;dht_lookupspans stop sitting at 8.00 s.Verification
cargo fmt -- --checkCARGO_BUILD_WARNINGS=deny cargo clippy --workspace --all-targets(hook form) andcargo clippy --workspace --all-targets --all-features -- -D warningscargo nextest run -p decdn-node(full crate), including:find_providers_tolerates_unreachable_peernow asserts the lookup finishes inside the 3 s test round, one dial timeout and zero round timeouts counted, the peer marked, and a second lookup that skips it entirely (< 2 s, counter unchanged).client_fails_an_unanswered_dial_at_the_dial_timeout(new,dht_loopback): a closed loopback peer fails asDialTimeoutnaming it, between the dial and half the exchange budget.adr_registry_names_are_exportedandobservability_counters_export_at_zerocover the new counter and the round-ceiling row.CARGO_BUILD_WARNINGS=deny cargo doc --workspace --no-deps --document-private-itemsmake -C adr check-refscontracts/changed: n/aCHANGELOG.mdentry addedpr-titlecheck allows, lowercase subjectFollow-up (not here)
decdn_dht_lookup_dial_timeouts_totalbeside it after the release.🤖 Generated with Claude Code