Repository navigation
fix: batch of six quick-win review follow-ups (#845 #864) - #868
Conversation
…y voucher verify (#845) Three doc-only LOW follow-ups from the 2026-06-09 review (#845): - PaymentChannel.sol: note at VOUCHER_TYPEHASH that cross-chain/cross-contract voucher replay protection comes from the inherited EIP-712 domain separator (chainId + contract address), not the typehash. - appendix-peer-table-eviction.md: document the implicit ~60s announce-replay window for not-yet-tabled peers (clock-skew rule 3 is the only guard; tabled peers get strict monotonicity via rule 4). - incentive/channel.rs: note at the verify_signer call site that off-chain verification is EOA-only and fail-closed vs the contract's ERC-1271 path, deferred per ADR 024. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…oes (#845 #864) Two LOW review follow-ups: - cli (#864): `decdn node *` / `node top` admin/metrics URL resolution now consults DECDN_ADMIN_PORT / DECDN_METRICS_PORT (the same vars the daemon reads) between the URL flag and the config file. An env-only deployment was otherwise unreachable — the CLI dialed the default 9191/9090 and reported the node down. A malformed or 0 value errors rather than silently falling through. Logic lives in pure `admin_url_from_env` / `metrics_url_from_env` helpers (take the raw value) so it's tested without env-global mutation. - gossip (#845): the NodeAnnounce subscriber now drops an echo of this node's own announce (`is_self_announce`) before `dispatch_insert`, so a node never inserts itself into its own peer table. Latent today (Plumtree doesn't echo to origin) — defense-in-depth. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…nt credit (#864) When a live `ChannelSettled` is processed before its matching `ChannelOpened` (the two live filter streams have no cross-ordering), `client_addr` resolved to None and the settlement was credited provider-only and marked seen — the client party's reporter credit was dropped permanently, since the settled log event is consumed from the stream and never re-emitted. Park such events in a bounded FIFO buffer (`pending_settled` / `pending_order`, cap `MAX_PENDING_SETTLED`) keyed by channelId and re-credit them when the matching open arrives (`handle_opened`). On buffer overflow the oldest is evicted and the backfill re-armed from its block so it isn't lost (provider-only if its open never arrives). The backfill path is unchanged: it processes opens before settles deterministically, so in-window channels always resolve. The two select arms moved into `handle_opened` / `handle_settled` helpers. Tests cover the buffer's FIFO/sync invariants and bounded eviction-with-rearm. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
#845) `CacheEngine::evict` persists the eviction with a blocking `fsync` (`append_evicted_log`). It is reached not only from the operator DMCA admin RPC but from the hash-mismatch path in pull-through (`commit_buffered_bytes` and the streaming path), which runs on a request-serving worker — the blocking fsync stalled the async runtime there. Make `evict` async and run the append inside `tokio::task::spawn_blocking`. A blocking-task panic (JoinError) and an I/O failure are both surfaced as `Err`, preserving the durability contract (an `Ok` always means the eviction was fsync'd). All callers are already async, so this is a mechanical `.await` propagation. Scope is strictly the fsync offload — the hash-mismatch eviction logic (owned by #835/#853/#860) is unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…threshold (#864) `NetworkScores::record` folded every weighted report into `entry.score` immediately, while `score()`/`is_scored()` stayed neutral until `min_distinct_reporters` (default 3) distinct reporters were seen. A single staked reporter could therefore EWMA-drive the still-hidden score to an extreme value that two one-shot reporters then instantly revealed by crossing the visibility threshold. Count the reporter first, then fold only once the threshold is reached — below it the score stays at neutral `initial_score` (decaying neutral is a no-op) and only the monotonic timestamp advances. The threshold-crossing report begins folding from neutral, so no single reporter can dominate. This makes the code conform to ADR 008 §Minimum reporter threshold ("...before departing from the default 0.5 neutral score"), which the old immediate-fold path only honored at the visibility layer. Updated the ±0.05-clamp test to cross the threshold; added a test that a solo reporter cannot pre-load the revealed score. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
`NetworkScores`/`Coverage` create an aggregation entry for any 32-byte `provider` key on first report, with no existence check. A staked but rate-limited reporter could therefore name arbitrary fabricated provider ids and grow the maps unboundedly (bounded per-entry, unbounded in count). Guard the provider in `NodeReputationSink::accept` against the active-staker set (`StakerSet::is_active`) — the authoritative, chain-backed oracle that already gates inbound reporters via `NodeStakedReporterSet` — and drop the report the same way a malformed key is dropped, before any `network.record` / `coverage.record` call. Keeps the `reputation` crate caller-agnostic. The staker set is threaded into `NodeReputationSink::new` (the runtime already holds it). Tradeoff: a provider that is briefly absent from the local staker-set cache (chain lag) has its reports dropped; the set is event-subscribed so this is rare, and it matches the existing reporter-gating posture. Added a test that a non-staked provider creates no entry and stays unscored/neutral. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Gas snapshotGas changes vs baseRun: 27279865106 |
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 configuration improvements across the codebase. Key changes include making the cache eviction process asynchronous to run blocking disk I/O on a dedicated thread, adding environment variable support (DECDN_ADMIN_PORT and DECDN_METRICS_PORT) for CLI loopback resolution, and preventing self-insertion in the gossip peer table. Additionally, the reputation system has been hardened by parking out-of-order blockchain events, filtering out reports for non-staked providers, and implementing a pre-threshold magnitude guard to prevent single-reporter score manipulation. No review comments were provided, so there is no feedback to address.
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 several low-risk follow-ups from review umbrellas #845 and #864 across docs, CLI ergonomics, gossip hygiene, cache eviction behavior, and reputation/indexing correctness. It tightens reputation semantics to match ADR 008, improves resilience to event ordering in the settlement indexer, and reduces async-runtime blocking in the cache hot path.
Changes:
- Reputation: gate EWMA folding on distinct-reporter threshold; drop inbound reports for non-staked providers before creating network/coverage entries.
- Node robustness: ignore self-echoed
NodeAnnounce; park out-of-orderChannelSettledevents until theirChannelOpenedarrives (bounded FIFO + backfill re-arm). - Ops/UX + perf: CLI
node */node topresolve admin/metrics ports fromDECDN_{ADMIN|METRICS}_PORT;cache.evict()becomes async and moves eviction-logfsynctospawn_blocking.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
crates/reputation/src/network.rs |
Defers score folding until min_distinct_reporters is reached; updates/adds tests to lock in the new semantics. |
crates/node/tests/client_loopback.rs |
Updates test call sites for async cache.evict(..).await. |
crates/node/src/runtime/mod.rs |
Wires staker_set into the node reputation sink constructor. |
crates/node/src/reputation_wiring.rs |
Drops reports for non-staked providers (prevents unbounded entry creation); adds targeted tests. |
crates/node/src/reputation_indexer.rs |
Adds bounded buffering for ChannelSettled observed before ChannelOpened, with retry/backfill re-arming. |
crates/node/src/admin.rs |
Awaits async cache eviction in admin RPC + adjusts tests. |
crates/incentive/src/channel.rs |
Documents EOA-only off-chain signature verification vs ERC-1271 on-chain path. |
crates/gossip/src/service.rs |
Introduces is_self_announce and drops self-announce echoes before peer-table insertion; adds unit test. |
crates/cli/src/commands/node.rs |
Resolves admin URL using DECDN_ADMIN_PORT between flag and config; adds pure helper + tests. |
crates/cli/src/commands/node_top.rs |
Resolves metrics URL using DECDN_METRICS_PORT between flag and config; adds pure helper + tests. |
crates/cache/src/engine.rs |
Makes evict() async and moves eviction-log fsync into spawn_blocking; propagates .await through callers/tests. |
contracts/src/PaymentChannel.sol |
Clarifies replay protection source (EIP-712 domain separator, not typehash). |
adr/appendix-peer-table-eviction.md |
Documents announce replay window behavior for not-yet-tabled peers. |
Comments suppressed due to low confidence (1)
crates/cache/src/engine.rs:888
- The pre-check comment claims idempotency that prevents duplicate
evicted.loglines, but the lock is released before the append, so concurrentevict()calls for the same hash can still race and append duplicates. Either strengthen synchronization (if required) or soften the comment to match the actual best-effort behavior.
// Pre-check under one lock acquisition: short-circuit on
// already-evicted (idempotent — don't grow `evicted.log` with a
// duplicate line) and reject on cap (DoS bound on an unbounded
// public-ish surface). The cap check is racy against concurrent
// evicts but the cap itself is a soft DoS bound, not a hard
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…mment - node_top.rs: replace non-standard "diallable"/"undiallable" with "cannot be dialed" in the DECDN_METRICS_PORT=0 doc comment and error message. - cache/engine.rs: the pre-check comment claimed the idempotent short-circuit prevents duplicate evicted.log lines, but the lock is released before the append (now a spawn_blocking await, which widens the window). Correct the comment: sequential repeat-evicts short-circuit; concurrent same-hash evicts may each append a line, harmless because replay folds the log into a HashSet. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…ing, threshold-1 test
From the multi-agent PR review (no Critical/Important blockers; these are
accuracy/observability/coverage refinements):
- reputation/network.rs: the pre-threshold guard comment overstated ("no single
reporter can dominate" / "free to report repeatedly"). Scope the claim to
pre-load prevention and note post-threshold influence is bounded by the
per-report clamp + decay, not this guard; reflect the gossip rate limiter.
- reputation/network.rs: add a `min_distinct_reporters == 1` boundary test —
the validated minimum must fold the first report (guards the insert-before-
check ordering against an off-by-one).
- node/reputation_indexer.rs: the eviction warn claimed "re-arming backfill"
unconditionally, but a `None` block (shouldn't occur for a confirmed event)
isn't re-queryable. Split the log so the unrecoverable-drop case is
distinguishable from the recovered one.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Coverage reportTotal: 85.80% (was 85.89%, ▼ 0.09%) — 33874/39479 lines
History
|
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]>
Drains the remaining still-unfixed LOW items from the umbrella review issues #845 (2026-06-09) and #864 (2026-06-10), following the cadence of #865/#867. Items already closed by those batches were verified and skipped. Six commits, grouped by risk so the reputation-semantics changes are independently revertable.
Group 1 — docs only (6305fef)
VOUCHER_TYPEHASH: note that cross-chain/cross-contract voucher-replay protection comes from the inherited EIP-712 domain separator, not the typehash. (Low-severity follow-ups from the 2026-06 full-repository review (umbrella) #845)verify_signercall site that off-chain verification is EOA-only and fail-closed vs the contract's ERC-1271 path (ADR 024 deferral). (Low-severity follow-ups from the 2026-06 full-repository review (umbrella) #845)Group 2 — cli + gossip (569c6cc)
node */node topadmin/metrics URL resolution now consultsDECDN_ADMIN_PORT/DECDN_METRICS_PORTbetween the flag and the config file, so an env-only deployment is reachable. Pure*_url_from_envhelpers + tests.is_self_announce) beforedispatch_insert.Group 3 — localized behavior
ChannelSettledseen before itsChannelOpenedin a bounded FIFO buffer and re-credit it when the open arrives, instead of crediting provider-only and dropping the client party's reporter credit forever. Overflow re-arms the backfill so nothing is lost. Backfill path unchanged.fsynconspawn_blockingso it leaves the async runtime (evictis reached from the request-serving hash-mismatch path). Mechanical.awaitpropagation; eviction/tag/hash-mismatch logic untouched (owned by cache: streaming-path captured-error partial import is never logically evicted — wrong-hash bytes serveable until next GC sweep #835/cache: hash-mismatch handler permanently evicts the *actual* hash — a malicious upstream can durably censor any blob it holds the bytes of #853/cache: evict() never deletes the iroh-blobs named tag — evicted (DMCA) blobs are GC-protected forever; the documented "reclaimed on next GC sweep" is false #860).Group 4 — reputation scoring semantics (ADR 008)
provideris not a current staked node (StakerSet::is_active) before creating a network/coverage entry — closes the unbounded-entry vector.Verification
cargo fmt --check,cargo clippy --all-targets— cleancargo nextest run— 1683 passed, 0 failed (incl. new tests for env-port resolution, self-announce filter, settle-before-open parking, single-reporter pre-load, non-staked provider drop)(cd contracts && forge fmt --check && FOUNDRY_PROFILE=ci forge build --sizes --deny warnings && forge test --match-contract PaymentChannel)— clean, 56 passedUmbrella checkboxes in #845/#864 to be ticked on merge.
🤖 Generated with Claude Code