Repository navigation
fix(client-pull): confirm the armed voucher on a StreamEnd read after its write failed - #1999
Merged
Merged
Conversation
… its write failed A node writes StreamEnd only once every interval, the closing voucher included, is paid. So the StreamEnd the voucher-write recovery reads proves the node holds the voucher whose write its STOP_SENDING failed. The ledger kept that voucher armed, not committed: settlement() reported it (settle high) but committed() did not move, and driver::fill_gap decides completion from committed(). A sub-chunk leg therefore cleared nothing and the driver re-opened the whole gap; against a node that keeps accepting and stop-sending that was an unbounded re-pull loop arming a higher voucher every round, and a multi-chunk leg re-pulled its tail. PoolLedger::confirm_armed commits the armed voucher exactly as a successful issue would; the recovery calls it on StreamEnd and anchors the stream's last proof to it. Pinned on the production drive + PeerSource + ClientRangedStore path against a connection-counting stop-send upstream: one connection, the blob finalized, committed == settlement == one honest wire, for both the sub-chunk and the reveals-then-residual shapes; the typed-rejection twin confirms nothing and does not re-leg. honest_bao_wire_range moves into the shared test support so both node suites serve honest range encodings for a re-opened gap. Closes #1995. Co-Authored-By: Claude Opus 5 <[email protected]>
Coverage reportTotal: 82.73% (was 82.71%, ▲ +0.03%) — 76870/92914 lines
History
|
…ater accrual `confirm_armed` runs after the failed send released the issuance lock, so the lane can move between the arming and the confirm: - A sibling's reveal on the rolled chain accrues in that window. The confirm now subtracts only the accrual the voucher folded (recorded when it is armed) instead of zeroing `accrued`. - A sibling's failed voucher can be armed on top of this stream's. The failed `send_voucher` tags its error with the amount it tried to send (`UnconfirmedVoucher`), and `confirm_armed(amount)` commits only a matching voucher. A failed reveal or re-anchor write confirms nothing. The recovery logs whether a `StreamEnd` confirmed a voucher, and clears `unproved` only when it did. A missing voucher provider is marked `LocalPullFault`, so the recovery never masks it. The stop-send drive tests capture the recovery's event and assert it fired, so a voucher write that wins the race cannot pass them silently. The node drain docs no longer describe the closing voucher as in flight after `StreamEnd`. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01EGFxSuztfWaNLHZyQ8irTW
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.
Closes #1995.
Problem
UpstreamPull::next_chunkrecovers a failed voucher write by reading one terminal message: aStreamEndmarks the stream ended and the chunk is still delivered. The two loopback tests that covered it drove it through thetest-utilstream_fetchwrapper, whose completion is decoder-based and never consults the ledger.On the production
driver::drive/PeerSourcepath completion is payment-based:fill_gapderives the paid frontier fromledger.committed(). A write that fails insidePoolLedger::issueleaves that voucher armed, not committed —settlement()reports it (settle high) butcommitted()does not move. Traced onmainwith the new tests:paid_wire_this_leg == 0, sopaid_frontier == gap_start,BudgetPacerreturnsDrawagain, and the driver re-opens the whole gap. Against a node that keeps accepting and stop-sending, each leg re-pulls the blob and arms a higher voucher (issuebuilds on the armed frontier) — an unbounded re-pull loop withsettlement()growing every round. The RED run: three re-legs, then the fourth open timed out against the capped fixture.accrued, the residual's closing voucher stays armed, and the tail is re-pulled and re-billed.Change
A node writes
StreamEndonly once every interval — the closing voucher included — is paid (handlers/client/delivery.rs,serve_leg.rs). So theStreamEndthe recovery reads proves the node holds the voucher whose write failed.PoolLedger::confirm_armed: commits the armed voucher exactly as a successfulissuewould (the epoch already rolled when it was armed);Nonewhen nothing is armed (a sibling on the shared lane issued past it).terminal_after_write_failurecalls it onStreamEndand anchors the stream'slast_proof/anchored_rootto the confirmed voucher;next_chunkclearsunprovedonce the recovery returnsOk.settlement()already reported the armed amount;committed()now catches up to it.Tests
All RED before the fix, GREEN after.
ledger::a_terminal_stream_end_confirms_the_armed_voucher— failedissue→confirm_armedcommits it once,committed == settlement, the next voucher builds on it.drive_completes_in_one_leg_when_its_send_is_stopped_before_the_closing_voucher(256 KiB) and…_after_reveals_…(1.5 MiB; the stop lands after the first reveal's proofs are read, via a newStopPoint::AfterFirstReveal) — run the productiondrive+PeerSource+ClientRangedStorewiring against a connection-counting stop-send upstream capped at three accepts (a re-leg loop fails fast instead of hanging). Assert: one connection, the blob promoted,committed == settlement == wire(blob).drive_surfaces_typed_rejection_when_…— theVoucherRejectedtwin errors withUpstreamVoucherRejectedon one connection, promotes nothing, confirms nothing.Fixture:
serve_stop_send_then_signalnow honours[byte_offset, byte_len);honest_bao_wire_rangemoves intotests/supportso both node suites share it.Verification
cargo clippy --workspace --all-targets -- -D warnings,cargo fmt --check,RUSTDOCFLAGS=-D warnings cargo doc --workspace --no-deps --document-private-items,cargo nextest run --workspace --no-fail-fast(3422 passed; one unrelated probe-cache test flaked and passed on retry).Out of scope
A failed reveal write followed by
StreamEnd(wire an exact multiple of 1 MiB) has no armed state to confirm —meterdoes not consume the index on a failed send — so the driver would still re-leg that one chunk. Rare and not this issue's case; worth its own follow-up.🤖 Generated with Claude Code