You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
No test covers the per-chunk ChannelContext rebuild (spent-nonce regression is invisible) #1302
kind:testTest coverage, flakes, fixtures or the e2e harnessprio:mediumScheduledrustDependabot: a Cargo update; use area: labels for Rust code otherwise
ChunkFetcher::fetch (crates/cli/src/commands/fetch.rs) rebuilds the ChannelContext for every chunk. That is load-bearing: the context snapshots the channel's voucher watermark (prior_nonce), and fetch_blob advances it in the store as it pays. A hoisted context would re-sign a spent nonce on chunk 2 and the node would reject it as StaleNonce.
Nothing in the repo tests this. The correctness chain is:
fetch_blob persists the acked watermark via store.advance_progress
build_channel_ctx -> open_or_reuse re-reads it
the next voucher signs prior_nonce + 1 against the new watermark
Links 1 and 2 have individual coverage (crates/node/tests/anvil_settlement_e2e.rs asserts open_or_reuse resumes from recorded progress), but that test seeds the watermark by calling record_progress directly. No test exercises the composed loop — N sequential paid pulls each rebuilding the context and each producing a strictly increasing nonce.
The file_manifest unit tests structurally cannot cover it: reconstruct is generic over F: Fn([u8;32]) -> Fut and the test double takes only a hash, so the payment layer is outside what they can observe.
Failure mode: someone hoists build_channel_ctx out of the per-chunk loop as an obvious-looking optimization (it does an on-chain reuse check per chunk). It compiles, every test passes, and every multi-chunk download breaks at chunk 2 in production. The saving grace is that it fails loudly rather than corrupting payment state.
Suggested: an anvil-backed test serving a 3-chunk manifest through the real client path, asserting recorded nonces are 1, 2, 3. #1301 makes this materially easier by routing the part directory through the resolved data_dir (it previously hardcoded ~/.decdn/downloads, so any such test would have written to the real $HOME).
Note the anvil-e2e stale-binary gotcha if driving it through the CLI binaries rather than the library path.
Closing as already covered — I filed this on a stale reading and should have checked before opening it.
crates/e2e/tests/cli_fetch_manifest.rsdoes exercise the composed loop. It serves a 3-chunk manifest from a real node, drives decdn fetch through the real paid path, and then asserts against the persisted store:
state.last_nonce >= U256::from(chunks.len()asu64)
Its own comment makes the regression argument explicitly: a hoisted ChannelContext would re-sign a spent nonce, the node would refuse the voucher, and the fetch would fail outright before reaching the assertion — so arriving there already proves per-chunk signing, with the nonce floor as a second check.
Why I got it wrong: that test landed in the squash-merge of #1293 (b9c2b0a), after the branch state my review ran against (6619dcb). The review correctly reported no coverage for the code as it stood at the time, and I repeated that conclusion without re-checking it against main.
The one real gap left is narrower and now closed by #1301: nothing asserted chunk parts honor --data-dir. That assertion is added to this same test.
kind:testTest coverage, flakes, fixtures or the e2e harnessprio:mediumScheduledrustDependabot: a Cargo update; use area: labels for Rust code otherwise
Activity
yigitdot commentedon Jul 19, 2026
Closing as already covered — I filed this on a stale reading and should have checked before opening it.
crates/e2e/tests/cli_fetch_manifest.rsdoes exercise the composed loop. It serves a 3-chunk manifest from a real node, drivesdecdn fetchthrough the real paid path, and then asserts against the persisted store:Its own comment makes the regression argument explicitly: a hoisted
ChannelContextwould re-sign a spent nonce, the node would refuse the voucher, and the fetch would fail outright before reaching the assertion — so arriving there already proves per-chunk signing, with the nonce floor as a second check.Why I got it wrong: that test landed in the squash-merge of #1293 (
b9c2b0a), after the branch state my review ran against (6619dcb). The review correctly reported no coverage for the code as it stood at the time, and I repeated that conclusion without re-checking it against main.The one real gap left is narrower and now closed by #1301: nothing asserted chunk parts honor
--data-dir. That assertion is added to this same test.