Repository navigation
Description
Problem
On the node-to-node buyer leg, the successful post-top-up delivery leg is wrongly charged to paid_wait, so its real transfer time is subtracted from the upstream's delivery-speed reputation signal. A slow upstream involved in a reactive top-up then scores as fast (or instantaneous), corrupting the local per-peer delivery-speed EWMA (ADR 008) specifically on topped-up pulls.
Mechanism
In crates/node/src/node_origin/resume.rs, pull_blob:
let leg_started = state.budgets.awaiting_topup_settle.then(Instant::now); // read at loop top
let leg = stream_leg(deps, target, ctx, ledger, deadlines, &mut state).await;
if let Some(started) = leg_started {
state.paid_wait = state.paid_wait.saturating_add(started.elapsed()); // added unconditionally
}
let Err(err) = leg else { /* success returns here */ }; // success check AFTERnote_topup_landed() sets awaiting_topup_settle = true. On the next iteration leg_started is Some. stream_leg clears the flag via note_successful_open() only inside the awaited call — after the open, and before pull_to_sink streams the entire remainder of the blob. So on the completing leg, the whole pull_to_sink delivery is folded into paid_wait, then subtracted from elapsed in pull_from_candidate (node_origin/mod.rs), which feeds Outcome::Delivered { elapsed }.
This contradicts PulledBlob::paid_wait's own doc ("Blocking on a transaction says nothing about how fast the upstream serves") and fires on the feature's main success path (a top-up followed by completion). The existing top-up tests only assert counters and score(provider) > 0.5, so nothing pins the elapsed accounting.
Fix
Charge paid_wait only on the failed-leg path (the failed settle-wait re-open probes are pure funding cost), or time open_leg alone rather than all of stream_leg. The successful leg's pull_to_sink is real delivery and must stay in elapsed. Add a test that pins elapsed/paid_wait for a topped-up pull rather than only the score bound.
Context
Follow-up from the review of #1600 (reactive mid-pull deposit top-up, #1530). Merged as-is; this is a reputation-correctness follow-up, not fund-loss.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
fix(node): keep the post-top-up delivery leg in the delivery-speed sc…