Repository navigation
fix: batch three hygiene issues (#1311, #1265, #1292) - #1334
Conversation
|
Warning Review limit reached
Next review available in: 41 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Free Run ID: 📒 Files selected for processing (1)
WalkthroughThe PR centralizes relief-slot accounting checks, introduces explicit empty and static origin-directory implementations, updates runtime and test wiring, and clarifies metrics documentation without changing metric behavior. ChangesRelief accounting enforcement
Origin directory implementations
Metrics documentation
Estimated code review effort: 3 (Moderate) | ~25 minutes Note 🎁 Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login. Comment |
Gas snapshotNo gas changes vs base. |
Contracts coverageLine coverage: 88.94% (2500/2811 lines) |
There was a problem hiding this comment.
Code Review
This pull request refactors the ContentBlacklist contract to consolidate relief slot release logic into a new _releaseReliefSlot helper, and restructures the DHT origin directory implementation by splitting ConfigOriginDirectory into StaticOriginDirectory (for tests) and EmptyOriginDirectory (as the unconfigured fallback). Additionally, gossip metrics documentation was updated. The review feedback suggests two valuable improvements: optimizing gas in _releaseReliefSlot by caching storage reads to avoid warm SLOADs, and adding a startup warning in the node runtime if prefetch is enabled while using the empty origin directory fallback to prevent silent failures.
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 three independent “surface honesty” fixes across contracts, gossip docs, and node internals: it (1) enforces an appeal interim-relief accounting invariant on-chain, (2) corrects gossip metrics documentation to stop implying a non-existent per-topic label, and (3) clarifies the node’s non-chain origin-directory fallback by giving it explicit types/names.
Changes:
- contracts: Replace unreachable relief-counter underflow clamps with a single
_releaseReliefSlotinvariant guard that reverts on divergence. - gossip (docs): Update
GossipMetricsdocs to state thattopicis accepted but not exported as an OpenMetrics label (current implementation uses unlabeled counters). - node: Rename
ConfigOriginDirectory→StaticOriginDirectory, addEmptyOriginDirectoryfor the runtime fallback path, and update runtime/tests/docs accordingly.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| contracts/src/ContentBlacklist.sol | Deduplicates relief-slot release logic and enforces the relief-counter invariant via a new revert. |
| crates/gossip/src/metrics.rs | Updates GossipMetrics trait docs to clarify topic is not exported as a metrics label. |
| crates/node/src/dht/origin.rs | Introduces EmptyOriginDirectory + renames the static map implementation to StaticOriginDirectory; updates module docs and tests. |
| crates/node/src/dht/mod.rs | Updates re-exports to expose EmptyOriginDirectory/StaticOriginDirectory instead of ConfigOriginDirectory. |
| crates/node/src/runtime/mod.rs | Switches the non-chain fallback from an empty config directory to EmptyOriginDirectory. |
| crates/node/src/handlers/client/mod.rs | Adjusts tests to reflect the new empty-fallback type and updated static directory name. |
| crates/node/src/node_origin.rs | Updates internal commentary to reference StaticOriginDirectory in test contexts. |
| crates/node/src/prefetch/mod.rs | Updates prefetch tests to use StaticOriginDirectory. |
| crates/node/src/prefetch/decision.rs | Updates decision tests to use StaticOriginDirectory. |
| crates/node/tests/dht_loopback.rs | Updates integration test to use StaticOriginDirectory. |
| crates/node/tests/node_origin_pull.rs | Updates integration tests/builders to use StaticOriginDirectory and updated imports. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Coverage reportTotal: 81.71% (was 81.71%, ● 0.00%) — 51095/62529 lines
History
|
…1311) Five sites released a fast-tracked appeal's interim-relief slot with a clamped decrement: if (regionActiveReliefCount[r] != 0) regionActiveReliefCount[r] -= 1; `fastTrackBlacklistAppeal` is the sole increment site and runs exactly once per entry into `FastTracked`, and every release is gated on that status -- so both counters are provably nonzero at each site and the clamps are unreachable by construction. That is the problem: if one ever fired, the relief-cap accounting had already diverged, and the clamp hid it at precisely the moment it mattered. The failure would be silent and permanent, throttling future legitimate fast-tracks in that region. Collapse the ten inline decrements into `_releaseReliefSlot`, which reverts with a new `ReliefAccountingUnderflow` rather than clamping. The helper caches both counters in locals so the guard and the decrement share one warm SLOAD each (-214 gas per release across all five paths). Its `@dev` names the invariant that makes the branch unreachable so a future reader does not mistake it for handling a live case, and notes that it is expected to show as uncovered. Deduplicating the call sites more than pays for the new error: ContentBlacklist deployed size drops 14,920 -> 14,348 bytes (10,228 bytes of EIP-170 headroom). No existing assertion changes -- the five decrement tests (test_filerReliefCap_decrementsOn{Reject,Perjury,Ratify,Reverse,Cleanup}) already assert via the public getters and none exercised the `== 0` branch. 753 contract tests pass; slither and aderyn clean. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…1265) `GossipMetrics::inc_published` and `inc_received` were documented as "labelled by topic", and `inc_reconnected` took a topic and said nothing either way. No implementor uses the argument -- not `NoopMetrics`, not the node's `NodeGossipMetrics`, not the test doubles. The node forwards the topic faithfully and it is dropped one layer down, where the recorder macro binds `_topic` and never reads it. So the exported series are correct and the docs were wrong, in the way most likely to mislead someone wiring a dashboard or extending the trait. Document the actual contract: name each backing counter's operator-visible series and say it is unlabeled. Be precise about *why*, since the backend is not the constraint: `iroh-metrics` 1.x does support labels via `Family<L, M>` (the node uses one for `streams_active`), but a `Family` needs a statically typed closed `EncodeLabelSet`, and a `&str` topic is open-ended -- exporting it directly would put unbounded cardinality in the label position. A per-topic breakdown would therefore mean either enumerating topics into a label type or one sibling counter per topic (the established convention for small closed splits, e.g. `dispatch_rejected_{global,per_source}`). Neither is wired today. The `topic` parameter stays, its doc now saying why it is accepted and discarded. Also records what the issue did not note: the topic argument genuinely varies -- announce paths pass a dynamic name, three sites pass the reputation-topic const -- so these counters merge at least two topic families. That is the fact an operator reading the series most needs. `inc_rejected(reason)` is untouched: the node does branch on `reason`. Docs only, no signature change. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…med gate (#1292) `ConfigOriginDirectory` read as an operator-facing config surface but no config key ever populated it -- `static_origins` has zero hits repo-wide, in the schema, the resolver, or the example TOML. The runtime's non-chain arm always built it empty, so it was an empty stub with a name that promised otherwise. Resolve the behavior question the issue raised in favour of "intended": `ChainOriginDirectory` is the only production path. ADR 022 supports this rather than contradicting it -- the issue suspected its "deterministic fallback" language implied an operator-supplied map, but every occurrence (§FIND_VALUE Flow, §Bootstrap, §Prefetch Decision) says *the on-chain origin directory*, and §FIND_VALUE spells out the exact namespaceOf -> getOrigins -> nodeIdOf read chain. So no ADR edit is needed. - Add `EmptyOriginDirectory`, a zero-sized directory that resolves nothing, and install it in the runtime fallback arm so the production path constructs a type that names its own behavior. - Rename `ConfigOriginDirectory` -> `StaticOriginDirectory` and document it as a test/known-set fixture. This mirrors `StaticNodeAddressDirectory` one module over, which is likewise public, test-only, and ungated -- the same `Chain*` / `Static*` pairing. - Drop the dead `empty()`, `len()`, and `is_empty()`, and a stale doc claim that a resolver pre-filtered malformed entries at construction. No such resolver exists. The empty fallback is not merely inert -- it hard-denies, and two of the three denials are invisible. With `prefetch.require_authorized_origin` every hash skips as `Unauthorized`; with `cache.pull_through_require_authorized_origin` every cache miss returns a wire `NotFound` the code itself calls indistinguishable from a plain miss. An operator can enable either without chain addresses and get a permanently dead path with no signal. So the runtime now warns at bring-up when either gate is armed over the empty fallback. The gating is extracted into `armed_origin_gates_over_empty_fallback` and unit-tested: the load-bearing case is that `require_authorized_origin` defaults on, so the prefetch warning must be guarded on prefetch also being *enabled* -- otherwise it would fire on every chain-less node. (The switch to the `if let` form is what clippy's `single_match_else` wants once the else arm grows a body.) Not feature-gated: `#[cfg(test)]` cannot work here (the type is used from integration tests in tests/, which compile against the crate externally), so a gate would need a dev-dependency self-reference for no gain the rename does not already provide. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Surfaced by review of #1265. Ten field/module docs across three crates justified their sibling-counter layout by claiming `iroh_metrics` "has no label support" / "has no labels" / "no per-field labels". That is wrong: `iroh-metrics` 1.x supports labels via `Family<L, M>`, and this very crate uses one for `streams_active` (keyed on `StreamDirection`). The accurate reason a plain `Counter`/`Gauge` field carries no label is that a labeled series needs a `Family`-typed field with a statically typed closed `EncodeLabelSet` -- which is why these open-ended or not-worth-the-machinery splits stay as sibling counters by the `dispatch_rejected_*` convention. Reword all ten to say that instead, without changing any metric or its layout. Sites: crates/node/src/metrics.rs (7), crates/incentive/src/channel_open_error.rs (2), crates/client-pull/src/buyer_channel.rs (1). Docs only. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
5a9acb4 to
8e03e9c
Compare
The `_releaseReliefSlot` SLOAD caching in the #1311 commit lowered gas on every ContentBlacklist appeal-resolution path and, transitively, on the tests that deploy or cross-call ContentBlacklist (DeployProtocol, GenesisBuyback, CapacityBondRegionE2E). Regenerated with `FOUNDRY_PROFILE=ci forge snapshot --snap .gas-snapshot` (forge 1.7.1, solc 0.8.28 — the CI pins), which reproduces CI's fresh values exactly. The deterministic entries are the only meaningful diff; the fuzz `runs:` lines are machine-dependent and stripped by the CI freshness gate. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Four commits. The first three are unassigned hygiene issues that share a shape: the code behaves correctly, but a surface around it misrepresents what it does. The fourth is a doc-rot sweep surfaced by review. Each commit is independent and can be reviewed or reverted separately.
fix(contracts)— #1311: enforce the relief-counter invariantFive sites released a fast-tracked appeal's interim-relief slot with a clamped decrement.
fastTrackBlacklistAppealis the sole increment site and runs exactly once per entry intoFastTracked, and every release is gated on that status, so the clamps were unreachable by construction — which is the problem. If one ever fired, the accounting had already diverged, and the clamp hid it at precisely the moment it mattered.Collapsed into
_releaseReliefSlot, which reverts with a newReliefAccountingUnderflow. Per review, the helper caches both counters in locals so the guard and decrement share one warm SLOAD each — −214 gas per release across all five paths (measured, not assumed).Size: deduplication more than pays for the new error — ContentBlacklist drops 14,920 → 14,348 bytes (10,228 bytes of EIP-170 headroom).
CapacityBond, not this contract, is the one near the ceiling.Regression signal: no existing assertion changed; the new revert branch is unreachable and will show as uncovered (the
@noticesays so).docs(gossip)— #1265: stop promising a metrics label that cannot existinc_published/inc_receivedwere documented as "labelled by topic". No implementor uses the argument. The exported series were correct; the docs were wrong.Per review, the doc is now precise about why: the backend is not the constraint (
iroh-metricssupports labels viaFamily<L, M>— the node uses one forstreams_active). The real constraint is that aFamilyneeds a statically typed closedEncodeLabelSet, while a&strtopic is open-ended, so exporting it would put unbounded cardinality in the label position. A breakdown would mean a label type or sibling counters; neither is wired.Beyond the issue: the topic argument genuinely varies — announce paths pass a dynamic name, three sites pass the reputation-topic const — so these counters merge at least two topic families. Now documented.
refactor(node)— #1292: name the empty origin-directory fallback + warn on an armed gateConfigOriginDirectoryread as an operator-facing config surface, butstatic_originshas zero hits repo-wide. The runtime's non-chain arm always built it empty.Resolved in favour of intended:
ChainOriginDirectoryis the only production path. ADR 022 supports this — its "deterministic fallback" is the on-chain origin directory, and §FIND_VALUE spells out the exactnamespaceOf → getOrigins → nodeIdOfchain. So no ADR edit was needed.EmptyOriginDirectory(zero-sized) installed in the runtime fallback arm.ConfigOriginDirectory→StaticOriginDirectory, documented as a test fixture. MirrorsStaticNodeAddressDirectoryone module over.empty()/len()/is_empty(), and a stale doc claim about a resolver that never existed.New in this revision (per review): the empty fallback doesn't just go inert — it hard-denies, and two of the three denials are invisible (
prefetch.require_authorized_originskips every hash asUnauthorized;pull_through_require_authorized_originreturns a wireNotFoundthe code itself calls indistinguishable from a plain miss). The runtime now warns at bring-up when either gate is armed over the empty fallback. The load-bearing subtlety:require_authorized_origindefaults on, so the prefetch warning is guarded on prefetch also being enabled — else it would fire on every chain-less node. Gating is extracted intoarmed_origin_gates_over_empty_fallbackand unit-tested.Not feature-gated:
#[cfg(test)]cannot work (the type is used from integration tests intests/, which compile against the crate externally).docs(metrics)— #1265 review: correct pre-existing label-claim rotThe review of #1265 revealed the same wrong "
iroh_metricshas no label support" claim in ~10 pre-existing field/module docs acrossnode,incentive, andclient-pull. All reworded to the accurate reason (a plain counter field carries no label; a labeled series needs aFamily). Docs only, no metric or layout change.Deliberately out of scope
--no-keep-blobsre-pays for a duplicated file) — verified real, but every option amends ADR 012 § Blob retention, a spec change on the voucher-paying path. Correction for whoever takes it: appendix-bundles has no literal "entries are independent" guarantee — its "independently" is scoped strictly to node selection.total_bytesguard is size-only, so a same-length part swap defeats it (repo's own test documents this atfile_manifest.rs:623). The real defect is a verify→concat TOCTOU window; a lockfile alone would not close it.Verification
forge fmt --check+FOUNDRY_PROFILE=ci forge build --sizes --deny warningsforge testslither(fail-on: medium) /aderyn(fail-on: high)cargo fmt --check/cargo clippy --all-targets -D warningsRUSTDOCFLAGS="-D warnings" cargo doccargo nextest runCloses #1311
Closes #1265
Closes #1292
🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Improvements
Documentation