Skip to content

fix(node): drop the requester before the directory fallback is judged - #2535

Merged
thiras merged 1 commit into
mainfrom
fix/requester-only-dht-answer-2534
Oct 18, 2026
Merged

thiras merged 1 commit into
mainfrom
fix/requester-only-dht-answer-2534

Conversation

@thiras

@thiras thiras commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

What

The serve-miss pull leg never pulls from the node it answers. It dropped the requester after discover had chosen between the DHT answer and the origin-directory fallback. So when the requester was the hash's only DHT provider (a partial holder asking a bonded non-holder for the blocks it lacks), the leg ended with no provider and refused NotFound, logged since #2533 as path=pull_leg_miss source=dht discovered=0, without reading the directory that lists the origin.

discover now takes requester: Option<DhtNodeId> and drops it from both the DHT answer and the directory list before the empty check, so that answer falls back to the directory and the origin fills the serve. The buffered Origin::fetch fill passes None.

Closes #2534

Reviewer notes

  • Read discover / directory_origins in crates/node/src/node_origin/mod.rs first, then the call in open_pull_leg.
  • The second requester drop after probe_and_rank (ranked.retain(...)) stays: the origin-directory supplement inside the probe round reads the directory without a requester and can list it.
  • PullLegTrail.discovered already documented itself as "after the requester drop"; the trail's meaning is unchanged, only source now reflects the list the walk actually probes.
  • ADR 022 § FIND_VALUE Flow gains one sentence stating the rule; ADR 037 § Node serving already held "never uses the node that sent the request".
  • Test: holder_pull_case gains a HolderDiscovery::DhtNamesFirst shape (a real DhtHandler record naming the leaf alone, directory listing the origin). a_dht_answer_naming_only_the_requester_falls_back_to_the_directory refused with delivery refused: Some(NotFound) before the fix and completes after it. The leaf is put in stakers on purpose; otherwise the active-staker filter empties the DHT answer and the test passes through the fallback without exercising the bug.

Verification

  • cargo fmt -- --check
  • CARGO_BUILD_WARNINGS=deny cargo clippy --workspace --all-targets --all-features
  • cargo nextest run -p decdn-node --test node_origin_pull (106 passed) and cargo nextest run -p decdn-node --lib node_origin wire (127 passed)
  • CARGO_BUILD_WARNINGS=deny cargo doc -p decdn-node --no-deps --document-private-items
  • make -C adr check-refs
  • contracts/ changed: n/a
  • User-visible change: CHANGELOG.md entry added
  • Design change: ADR 022 updated
  • PR title uses a type the pr-title check allows, lowercase subject

🤖 Generated with Claude Code

…#2534)

The serve-miss pull leg never pulls from the node it answers. It dropped
the requester after `discover` had chosen between the DHT answer and the
origin-directory fallback, so a DHT answer that named only the requester
(a partial holder asking for the blocks it lacks) left the leg with no
provider and a `NotFound` refusal logged as `source=dht discovered=0`,
without reading the directory that lists the origin.

`discover` now takes the requester and drops it from both the DHT answer
and the directory list before the empty check, so that answer falls back
to the directory and the origin fills the serve. The buffered
`Origin::fetch` fill passes no requester. The supplement round inside
`probe_and_rank` keeps its post-round drop.

ADR 022 § FIND_VALUE Flow states the rule; `holder_pull_case` gains a
DHT-names-the-requester shape and a test that pulls through it.

Closes #2534

Co-Authored-By: Claude Fable 5.1 <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused filtering-order fix updates callers consistently and includes targeted regression coverage, with no unresolved findings.

No open issues 🎉

What changed in this PR

Fixes #2534 by excluding the requester before deciding whether node-origin discovery needs the directory fallback.

Changes:

  • Filters the requester from discovery candidates while preserving buffered-fetch behavior.
  • Adds a regression test for a DHT answer naming only the requester.
  • Documents the corrected fallback behavior.
File Description
crates/​node/​tests/​node_origin_pull.rs Adds DHT-backed regression coverage.
crates/​node/​src/​node_origin/​pull_leg.rs Passes requester identity into discovery.
crates/​node/​src/​node_origin/​mod.rs Filters the requester before fallback selection.
CHANGELOG.md Records the serve-miss fix.
adr/​022-content-discovery.md Clarifies requester filtering in discovery.

Review effort: Balanced

@github-code-quality

Copy link
Copy Markdown

Code coverage overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

main f81ab73 fix/requester-only-d... 8c9d494 +/-
76% 76% 0%
View coverage of the 6 most impacted files.
File main f81ab73 fix/requester-only-d... 8c9d494 +/-
crates/node/src/dht/publish.rs 80% 78% -2%
crates/client/src/lib.rs 89% 89% 0%
crates/node/src...e_origin/mod.rs 88% 88% 0%
crates/cache/src/engine.rs 91% 91% 0%
crates/node/src...gin/pull_leg.rs 84% 84% 0%
crates/protocol/src/framing.rs 92% 93% +1%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.

@thiras
thiras merged commit 3c4d34f into main Oct 18, 2026
32 checks passed
@thiras
thiras deleted the fix/requester-only-dht-answer-2534 branch October 18, 2026 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

node: a DHT answer that names only the requester skips the origin-directory fallback

2 participants