Repository navigation
fix: batch of nine quick-win review follow-ups (#845 #864) - #867
Conversation
`collect_voucher` only handled `RateError::Underpayment`; any other variant (`ZeroBytes`, `Overflow`, or a future addition) fell through and was silently treated as acceptable, with `apply_voucher` the only backstop. Replace the `if let` with an exhaustive `match` so a new variant is a build failure here. `ZeroBytes`/`Overflow` cannot occur at this call site (`delta_bytes > 0` is guaranteed by the caller) but are rejected defensively. Refs #845 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The unauthenticated admin RPC surface bound silently on any address, unlike `metrics::bind` (#579) which warns when it leaves loopback. Mirror that warning (unspecified vs non-loopback) as defense-in-depth so an operator exposing the admin port — which can drain channels, trigger announces, and read peer state — sees it in the startup log. Adds a loopback/non-loopback smoke test mirroring the metrics one. Refs #845 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The module doc and two fn docs said the watcher follows "six" membership-mutating events, but it installs five filters (the `:354` comment is the accurate one). Correct all three to "five". Refs #845 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
… off (#864) `spawn_reputation_tasks` returns early with no tasks and no log when `subscribe_reputation = false`, silently dropping a wired report drain: the node keeps buffering outbound reputation observations that never publish. Warn on this opt-out-only inert combination (it cannot arise at defaults). Adds a test asserting no publisher/trigger is spawned when a drain is supplied with reputation gossip disabled. Refs #864 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…st (#845) `deserialize_bounded_vec` enforces its cap after `Vec::deserialize`, so a peer's length prefix is untrusted at decode time. Document why that is sound — serde's `cautious` capacity bounds the up-front allocation and postcard streams elements — and add a regression test: a giant length prefix with a truncated body must error at EOF rather than pre-allocate a multi-GB Vec. Refs #845 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
#845, #864) Two caller-obligation gaps at `apply_voucher`: - It does not enforce `amount_delta/bytes_delta >= rate_per_mb`; the serving node must call `verify_rate` before accepting/serving bytes (#845). - It accepts `amount == last_amount` with `bytes_delivered` advanced, which the on-chain `PaymentChannel` rejects (`ByteAdvanceWithoutPayment` in `_requireBytesTrackPayment`). With `rate_per_mb == 0` this strands the close path until expiry + `reclaimExpired` (#864). Document both at the call site; no behavior change. Refs #845, #864 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
`IndexerState.channels` accumulated every `ChannelOpened` for the process lifetime, never removed after the settlement that consumes it. A channel settles exactly once, so drop its open→parties entry when it is marked seen (both the credited path and the amount-overflow skip). Adds a test asserting the entry is removed once credited while `settled_seen` still dedups. (Bounding `settled_seen` and re-crediting a settle-before-open are separate #864 follow-ups.) Refs #864 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
`decdn node announce` printed `announce_queued=false` and exited 0 when the server reported `triggered=false`. A well-formed node never returns that shape (publisher-disabled is a distinct error code), so treat it as a failure: keep the stdout line but surface a stderr diagnostic and a non-zero exit. Adds fake-server tests for the false (error) and true (ok) cases. Refs #845 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
`cargo llvm-cov nextest` does not run doctests, so the `compile_fail` doctest at crates/node/src/receipt_log.rs (and any future runnable doctest) never executed. Add a required `cargo test --doc --workspace` step after the coverage run so a doctest regression fails the job. Refs #864 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Gas snapshotGas changes vs baseRun: 27275601030 |
Contracts coverageLine coverage: 89.36% (1814/2030 lines) |
There was a problem hiding this comment.
Code Review
This pull request introduces several robustness, security, and memory-safety improvements across multiple crates. Key changes include treating untriggered announce responses as errors in the CLI, warning when gossip reputation reports are configured to accumulate without being drained, warning when binding the unauthenticated admin RPC server to non-loopback interfaces, and preventing unbounded memory growth in the reputation indexer by removing settled channels. Additionally, the PR ensures exhaustive matching of rate errors, documents caller obligations for payment channels, and adds a test to verify that giant length prefixes do not cause over-allocation during DHT response deserialization. As there are no review comments provided, I have no additional feedback to offer.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
Pull request overview
This PR batches a set of low-risk Rust-only follow-ups from review umbrellas #845 and #864, tightening defensive behavior, improving operator visibility, correcting doc drift, adding regression tests, and extending CI to execute doctests.
Changes:
- Harden edge-case handling and observability (exhaustive
RateErrormatching; non-loopback admin bind warning; gossip warning for inert report-drain wiring). - Add/adjust tests and docs to pin security/alloc-safety and behavior invariants (bounded-vec decode regression; indexer channel map eviction; announce
triggeredsemantics; doc corrections). - Update CI to run workspace doctests explicitly.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| crates/protocol/src/dht.rs | Documents bounded-Vec allocation safety assumptions and adds a regression test for giant length-prefix + truncated-body decode. |
| crates/node/src/reputation_indexer.rs | Removes settled channel entries from IndexerState.channels to prevent unbounded growth; adds test coverage. |
| crates/node/src/handlers/client.rs | Makes verify_rate handling exhaustive to avoid silently accepting new RateError variants. |
| crates/node/src/dht/chain_staker_set.rs | Fixes doc drift: watcher follows five (not six) membership-mutating events. |
| crates/node/src/admin.rs | Warns on non-loopback admin binds (defense-in-depth) and adds a smoke test for loopback/non-loopback branches. |
| crates/incentive/src/channel.rs | Adds caller-obligation docs for rate verification and documents off-chain/on-chain divergence for zero-payment byte advance. |
| crates/gossip/src/service.rs | Warns when a report drain is wired but subscribe_reputation=false; adds test guarding the inert wiring behavior. |
| crates/cli/tests/admin_peers.rs | Adds tests asserting decdn node announce treats triggered=false as an error and triggered=true as OK. |
| crates/cli/src/commands/node.rs | Makes decdn node announce fail when triggered=false. |
| .github/workflows/ci.yml | Adds a required cargo test --doc --workspace step to ensure doctests execute in CI. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Coverage reportTotal: 85.89% (was 85.82%, ▲ +0.07%) — 33603/39122 lines
History
|
Per review: the non-JSON path printed `announce_queued=false` before the `ensure!` failed, so a failing run emitted a contradictory line on stdout alongside the non-zero exit. Move the `triggered` check ahead of all output (JSON path too) so stdout carries only the success result. Refs #845 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
reputation_indexer: - Correct the MAX_SETTLED_SEEN comment: a re-delivered settlement for an evicted channel re-credits the provider (resolved from the never-removed on-chain CapacityBond binding), it is NOT a no-op as previously claimed. Document it as a bounded, astronomically-unlikely double-count and explain why eviction stays at debug! (routine once saturated). Cross-reference from the mark_settled_seen doc; harmonize the #867/#868 citation to #864. node/dht: - The cap/age break dropped the peer's further requests silently. Now log (debug) which bound tripped and conn.close() with APP_ERR_RATE_LIMITED, mirroring close_stream_with_rate_limit and the client permit-exhaustion close, so the peer gets a reason and the close is observable. - Extract the accept-budget gate into accept_budget_reached() so the unit test exercises the real predicate instead of a re-implementation, and cover the previously-untested age branch. Correct the false comment that claimed tests/dht_loopback.rs exercises the cap end-to-end (it does not — it only proves multi-stream serving); state honestly what is covered. cli/bundle: - Add a test for an excluded directory that is itself an escaping symlink (tmp/** where tmp -> external dir): confirms the subtree is pruned before canonicalize and does not trip the escape bail!. Verification: cargo fmt/clippy --all-targets clean; decdn-node + decdn-cli 753 tests pass. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
* fix: close out remaining LOW review follow-ups (#845 #864) Resolves the five still-open `[ ]` items across the two 2026-06 full-repository review umbrellas; all prior items shipped in #867/#868. node: - dht: cap per-connection served streams (MAX_DHT_REQUESTS_PER_CONN=256) and connection age (MAX_DHT_CONN_AGE=5m) so a peer staying under the per-stream rate limit can no longer pin its dispatch permit forever, mirroring handlers::client's hardcoded-constant precedent (#845). - reputation_indexer: bound the settled_seen dedup set with a companion FIFO (MAX_SETTLED_SEEN=65536), evicting the longest-settled ids first, mirroring the existing pending_settled bound — it no longer grows for the whole process lifetime (#864). cli: - bundle: consult the --exclude globset via filter_entry before canonicalize, pruning recursively-excluded directories. An escaping symlink inside an excluded subtree is no longer resolved and can't trip the escape bail!; a one-level tmp/* still keeps deeper tmp/sub/y via a sentinel-child recursion probe (#845). - config: add [gossip]/[security]/[dht.rate_limit]/[receipts] template blocks plus the missing network/blockchain/cache/payment/observability knobs to DEFAULT_CONFIG, and surface each section's kill-switch / rate-limit knobs in the validate summary; add a template round-trip parse test (#864). contracts (docs-only): - IFeeRouter: NatSpec now marks the 60/30/10 split as the default, governance-mutable within per-bucket bounds via setShares — the drift flagged in #845 was in fact still present (not resolved by #777). Verification: cargo fmt/clippy --all-targets clean; cargo nextest run 1694/1694 pass; forge fmt --check + FOUNDRY_PROFILE=ci forge build clean. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * fix(cli): use working example values for settlement_auto_* template knobs The DEFAULT_CONFIG template showed `settlement_auto_threshold_micro_usdc = 0` and `settlement_auto_by_voucher_nonce_span = 0`, but the resolver rejects `Some(0)` for both ("must be > 0 when set", mod.rs:1065-1080) — these fields disable via omission (None / commented-out), not via 0. Uncommenting the line verbatim would fail `config validate` / node startup. Show realistic positive example values (50 USDC / 1000 nonces) and reword the annotation to "leave unset/commented to disable", matching how the other commented knobs in the template carry working values. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * fix: address multi-agent review findings (#845 #864) reputation_indexer: - Correct the MAX_SETTLED_SEEN comment: a re-delivered settlement for an evicted channel re-credits the provider (resolved from the never-removed on-chain CapacityBond binding), it is NOT a no-op as previously claimed. Document it as a bounded, astronomically-unlikely double-count and explain why eviction stays at debug! (routine once saturated). Cross-reference from the mark_settled_seen doc; harmonize the #867/#868 citation to #864. node/dht: - The cap/age break dropped the peer's further requests silently. Now log (debug) which bound tripped and conn.close() with APP_ERR_RATE_LIMITED, mirroring close_stream_with_rate_limit and the client permit-exhaustion close, so the peer gets a reason and the close is observable. - Extract the accept-budget gate into accept_budget_reached() so the unit test exercises the real predicate instead of a re-implementation, and cover the previously-untested age branch. Correct the false comment that claimed tests/dht_loopback.rs exercises the cap end-to-end (it does not — it only proves multi-stream serving); state honestly what is covered. cli/bundle: - Add a test for an excluded directory that is itself an escaping symlink (tmp/** where tmp -> external dir): confirms the subtree is pruned before canonicalize and does not trip the escape bail!. Verification: cargo fmt/clippy --all-targets clean; decdn-node + decdn-cli 753 tests pass. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Batch of nine small, independent quick-win fixes drawn from the LOW-severity
review umbrellas #845 (2026-06-09 review) and #864 (2026-06-10 review),
mirroring the prior batch #865. Each is localized and low-risk; one
conventional commit per item, Rust-only plus one CI step. No Solidity logic,
no API/precedence changes, no config-template churn.
Fixes
fix(node)(Low-severity follow-ups from the 2026-06 full-repository review (umbrella) #845) —collect_vouchernow matches everyRateErrorarm exhaustively; a future variant fails the build instead of silently
passing as acceptable.
ZeroBytes/Overfloware unreachable here(
delta_bytes > 0) but rejected defensively.fix(node)(Low-severity follow-ups from the 2026-06 full-repository review (umbrella) #845) — warn on a non-loopback admin bind, mirroringmetrics::bind(Origin pull-through SSRF + metrics_bind non-loopback warning #579); defense-in-depth for the unauthenticated admin RPC.docs(node)(Low-severity follow-ups from the 2026-06 full-repository review (umbrella) #845) — correct "six"→"five" membership-mutating events inthree
chain_staker_setdocs (the watcher installs five filters).fix(gossip)(Low-severity follow-ups from the 2026-06-10 full-repository review (umbrella) #864) — warn at bring-up when a report drain is wired butsubscribe_reputation = false; previously outbound reports buffered foreverwith no log. Cannot arise at defaults.
docs(protocol)(Low-severity follow-ups from the 2026-06 full-repository review (umbrella) #845) — pin the allocation-safety assumption ofdeserialize_bounded_vec(cap enforced post-decode; serdecautiouscapacity + postcard streaming) and add a giant-length-prefix/truncated-body
regression test.
docs(incentive)(Low-severity follow-ups from the 2026-06 full-repository review (umbrella) #845, Low-severity follow-ups from the 2026-06-10 full-repository review (umbrella) #864) — documentapply_voucher's rate-checkcaller obligation and the off-chain/on-chain divergence on zero-payment byte
advance (
ByteAdvanceWithoutPayment; stranded close path atrate_per_mb=0).Doc-only.
fix(node)(Low-severity follow-ups from the 2026-06-10 full-repository review (umbrella) #864) — drop theIndexerState.channelsentry once itssettlement is credited so the map doesn't grow for the process lifetime.
fix(cli)(Low-severity follow-ups from the 2026-06 full-repository review (umbrella) #845) —decdn node announcenow exits non-zero with astderr diagnostic when the server reports
triggered=false, instead ofexiting 0.
ci(Low-severity follow-ups from the 2026-06-10 full-repository review (umbrella) #864) — add a requiredcargo test --doc --workspacestep;llvm-cov nextestdoesn't run doctests, so thereceipt_logcompile_failguard was dead.
Verification
cargo fmt -- --check— cleancargo clippy --all-targets— clean (-D warnings)cargo nextest run— 1672/1672 passcargo test --doc --workspace— pass (thereceipt_logcompile_faildoctest is now collected and runs)
RUSTDOCFLAGS=-D warnings cargo doc -p decdn-incentive— clean (newintra-doc link resolves)
New/updated tests: admin bind loopback/non-loopback smoke test, gossip
report-drain-without-subscription, bounded-Vec truncated-body regression,
reputation-indexer channel-eviction, and announce
triggeredtrue/false.Both umbrellas retain deferred items, so this references rather than closes
them.
Refs #845
Refs #864
🤖 Generated with Claude Code