Repository navigation
refactor: two protocol simplifications — probe-hold reason label, ADR 024 scope - #1474
Conversation
… 024 scope The last two issues in the Protocol simplifications milestone. Net 23 files, +428/-196. No contract, ABI, wire, or config change; the one Solidity edit is a comment fixing a citation to a heading that never existed. **#1443 — three probe-hold counters collapsed onto one `reason` label.** `decdn_probe_hold_violations_total`, `decdn_probe_holds_disabled_total` and `decdn_probe_stake_lane_reserved_total` answered one question under three names and are now `decdn_probe_hold_unavailable_total{reason="exhausted"|"disabled"| "stake_lane_reserved"}`. Every semantic distinction survives as a label value, including that `stake_lane_reserved` fires before the hold attempt and so never consults the cache. All three children are materialized in `Metrics::new()`, so each series still exports at zero from a fresh registry — a `Family` creates children lazily, so without that step a dashboard would show a gap where the three counters showed a zero. The `DecdnProbeHoldViolations` alert keeps its name and filters on `reason="exhausted"`, which is what preserves the #739/#757 property that a deliberate disable or a stake-lane reservation never trips a "raise max_probe_holds" page. Worth recording: the issue's stated motivation was inverted. It claimed the codebase already uses `reason=` labels for this shape; it does not. `RejectReason`, `RejectLayer`, `ChannelOpenFailureReason` and `AnnounceReject` all fan out to sibling unlabeled counters, and the only `Family` in the crate was `streams_active`, a Gauge. So this makes `probe_hold_unavailable` the one labeled counter rather than ending an inconsistency. The collapse still stands on its own merits, but the remaining splits are left alone and a follow-up asks whether they should follow. **#1431 — ADR 024 narrowed to what shipped.** Keeps the contract-level `SignatureChecker` at every verification site (already merged; it is what avoids a coordinated on-chain retrofit) and the Production session-key plan. Drops "Safe as the recommended wallet" — the EOA keystore is now the documented default, Safe is supported rather than recommended — and drops the § Consequences obligation that `decdn setup` guide Safe creation, a promise the CLI never grew. The node-side off-chain ERC-1271 verifier is relabelled from PoC deliverable to Production-deferred, matching what the Rust has said since #845, and its `alloy` sketch is removed. No Rust deleted: the path was never built. Two things the ADR read fixed beyond the issue's scope: - A Safe-addressed *node operator* is already broken off-chain. Requesters verify `slash_sig` by recovering it against the registered address, which yields the Safe owner, not the Safe — so every response is rejected. The key-rotation appendix recommended exactly that migration; it is now optional, with the constraint documented, and the procedure kept in full. - Nine citations referenced "ADR 024 §18" by *line number* into the bullet this change rewrites, plus a Solidity comment citing a § that never existed. All now name `§Off-Chain ERC-1271 Verification`, a heading guarded by `check-anchor-targets`. Verification: `make -C adr check-refs` (1568 anchors resolve) and `check-book-list`; `cargo fmt`/`clippy -D warnings`/`doc -D warnings`; 1531 tests across node/protocol/incentive/cache; `forge fmt --check`, `FOUNDRY_PROFILE=ci forge build --deny warnings`, 749 forge tests. The rendered series text was confirmed against a real `metrics.encode()` dump rather than assumed, which is how the `_total` suffix and snake_case label encoding were pinned before the test needles were rewritten. No gas-snapshot or public-API snapshot regen needed (comments only). Closes #1443 Closes #1431 Closes #1186 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Free Run ID: 📒 Files selected for processing (8)
🚧 Files skipped from review as they are similar to previous changes (7)
WalkthroughThe change revises EOA, Safe, and ERC-1271 guidance across ADRs and project documentation. It also replaces three probe-hold refusal counters with one reason-labeled metric and updates emission code, tests, dashboards, alerts, and operational guidance. ChangesWallet and signature verification guidance
Probe-hold metric consolidation
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: 89.54% (2413/2695 lines) |
There was a problem hiding this comment.
Pull request overview
This PR completes two “protocol simplification” refactors in the deCDN codebase: (1) consolidating probe-hold refusal counters into a single labeled metric while preserving alert semantics, and (2) narrowing ADR 024 to match what actually shipped (on-chain SignatureChecker) while explicitly deferring off-chain ERC-1271 verification + Safe recommendation to Production.
Changes:
- Collapse three probe-hold counters into
decdn_probe_hold_unavailable_total{reason=...}, materializing all label children at startup to preserve “exported at zero” behavior and updating alerting/dashboards/tests accordingly. - Update ADR 024 and related ADR/docs references to reflect EOA keystore as the PoC default, Safe as supported (on-chain), and off-chain ERC-1271 verification + session keys deferred to Production.
- Refresh supporting documentation (runbook, observability appendix, architecture index, changelog) to match the new metric and ADR framing.
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| monitoring/prometheus-alerts.yml | Update DecdnProbeHoldViolations to filter on reason="exhausted" for the new labeled counter. |
| monitoring/grafana-dashboard.json | Update dashboard query/legend to use decdn_probe_hold_unavailable_total{reason="exhausted"}. |
| docs/runbook.md | Align runbook guidance with the new probe-hold labeled metric and alert semantics. |
| crates/protocol/src/message.rs | Update ADR 024 citation anchors to §Off-Chain ERC-1271 Verification for EOA-only off-chain signatures. |
| crates/protocol/src/client.rs | Same ADR 024 anchor update for off-chain signature length constants. |
| crates/node/tests/probe_loopback.rs | Update metric assertions to the labeled counter series strings. |
| crates/node/src/metrics.rs | Implement ProbeHoldUnavailableReason + Family counter, materialize children at startup, add tests. |
| crates/node/src/handlers/probe.rs | Switch probe-hold refusal accounting to probe_hold_unavailable(reason). |
| crates/incentive/src/bind_sig.rs | Clarify off-chain ERC-1271 support is deferred to Production; update ADR anchor. |
| crates/cache/src/probe_hold.rs | Update probe-hold outcome docs to reference the new labeled metric semantics. |
| crates/cache/src/engine.rs | Update comment/test wording to reference reason="disabled" series instead of old counter name. |
| contracts/src/Token.sol | Update ADR 024 section reference in NatSpec comment (doc-only). |
| CLAUDE.md | Record ADR 024 narrowing in the ADR history notes. |
| CHANGELOG.md | Document the ADR 024 scope narrowing and the probe-hold metric consolidation + migration notes. |
| adr/architecture.md | Update ADR 024 one-line summary in the architecture index. |
| adr/appendix-operator-key-rotation.md | Reframe EOA as default; Safe migration as optional; document slash_sig constraint. |
| adr/appendix-observability.md | Replace three probe-hold rows with one {reason}-labeled metric; update guidance/mapping table. |
| adr/appendix-blob-cache-eviction.md | Update probe-hold metric reference used in eviction-driver interpretation guidance. |
| adr/024-account-abstraction.md | Narrow PoC scope: EOA default, Safe supported on-chain, off-chain ERC-1271 deferred to Production. |
| adr/019-node-onboarding.md | Update onboarding wallet guidance to reflect EOA default + slash_sig verification constraint. |
| adr/012-client.md | Update client wallet/key lifecycle text to reflect EOA-only off-chain verification in PoC. |
| adr/005-protocol.md | Update probe-hold observability reference to probe_hold_unavailable labeled-by-reason. |
| adr/003-payments.md | Update smart-account support wording and ephemeral binding verification to reflect PoC recovery-only behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Coverage reportTotal: 81.10% (was 81.08%, ▲ +0.02%) — 52324/64515 lines
History
|
Four review agents (general, comments, tests, type-design) plus two rounds of mutation testing. Nine fixes; two are real defects this PR introduced, four are accuracy fixes to claims it wrote, and three close gaps it left open. **Defects introduced by this PR.** - `probe_loopback.rs` — the stake-lane headroom assertion used `.unwrap_or(0) == 0`. On main that slack was dead, because `probe_stake_lane_reserved` was a plain `Counter` field and so was always exported; under a `Family` absence is reachable, which made it the one assertion of the four that survived a mutation deleting the pre-materialization. Now `== Some(0)`, matching the other seven. - `message.rs` cited §Off-Chain ERC-1271 Verification while quoting wording that lives in §Context — the exact drift the line-number repoint existed to prevent. Two agents caught it independently. Requoted from the cited section. **Accuracy fixes to claims this PR wrote.** - ADR 024 / ADR 019 / key-rotation appendix said requesters verify `slash_sig` off-chain by recovery on "every `ProbeResponse` / `StreamResponse`". True for the stream leg (`client-pull` recovers against the registered address); the probe leg is shape-checked only, with attribution left to `SlashJudge` (`crates/cli/src/commands/probe.rs` says so). A Safe-addressed node can be probed but not paid — now stated that way in all three. - ADR 024 §Node Operators said an operator "can hold the on-chain identity in a Safe today — subject to the constraint", contradicting the bullet above it. `registerNode` binds `msg.sender`, so there is no split where a Safe custodies the bond and an EOA serves; it is a non-serving identity, and the appendix already worded it correctly. - `metrics.rs` cross-referenced `channel_open_failure_by_reason` as "the same shape", but gave as the reason the one property the two do not share. - `Token.sol` claimed `CapacityBond.bond` uses EIP-2612 so operators sign approval + call as one user op. `bond()` is a plain `safeTransferFrom`; no protocol contract consumes permit. Same comment block said "20% burn leg" where ADR 026 says 50/50 in four places — stale since the SafetyReserve removal. Both pre-existing, both in a block this PR edited. **Gaps closed.** - A fourth `reason` variant could reach a compiling state via a `_ =>` arm calling `get_or_create`, silently reintroducing the lazy series this design exists to prevent, and the completeness test's hard-coded strings would not notice. `ProbeHoldUnavailableReason::ALL` now drives materialization through a positional destructure, so a new variant fails to compile twice over. Verified: adding one gives E0004 at the recorder, and taking the escape hatch gives E0527 at the destructure. - Nothing tied `monitoring/` to the encoder — no promtool step, no reference to the directory in any workflow — so a rename would leave `DecdnProbeHoldViolations` querying a dead series and silently never firing. Added `alert_and_dashboard_selectors_match_the_exported_series`. It asserts on the `expr:` line rather than the file: a first cut used a whole-file `contains`, and mutating only the query passed anyway because the alert names the series again in its description. Both halves now fail under mutation. Scoped to the series this PR renamed — 13 names in those files are already stale, so a blanket check is a separate job. - `ProbeHoldUnavailableReason` sits eleven lines from `ProbeHoldOutcome::Unavailable`, which is the one outcome emitting no metric — the word selects for the counter in one type and against it in the other. Both types now say so. Kept the names: the enum matches the metric it feeds. Also: `HoldsDisabled` docs now say which reason they map to rather than only which one they must not; the "pending a decision" comment names #1475; and `probe_budget_exhausted_counts_violation_not_disabled` drops the retired "violation" vocabulary. Verification: adr check-refs (1568 anchors), fmt, clippy -D warnings, 1532 tests, forge build --deny warnings + 749 forge tests. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Closes the Protocol simplifications milestone (was 2 open / 16 closed). Same shape as #1472. Net 23 files, +428/−196. No contract, ABI, wire, or config change.
#1443 — three probe-hold counters → one
{reason}labeldecdn_probe_hold_violations_total,decdn_probe_holds_disabled_totalanddecdn_probe_stake_lane_reserved_totalbecomedecdn_probe_hold_unavailable_total{reason="exhausted"|"disabled"|"stake_lane_reserved"}. Every semantic distinction survives as a label value, including thatstake_lane_reservedfires before the hold attempt and so never consults the cache.Two details that make this safe rather than merely shorter:
Metrics::new(). AFamilycreates children lazily onget_or_create, so without this areasonwould be absent from/metricsuntil it first fired — a dashboard gap where the three counters previously showed a zero, and a hole in the alert's input. A new test pins the exported-at-zero property and the exact rendered series text.DecdnProbeHoldViolationsnow watchesreason="exhausted"only, preserving the cache: no metric or structured log event emitted when a probe hold expires naturally vs. is released early by eviction pressure #739/Implement probe-time stake-lane eligibility in probe handler #757 property that a deliberate disable (max_probe_holds = 0) or a stake-lane reservation never trips a "raisemax_probe_holds" page.Note
The issue's stated motivation was inverted, and reviewers should know before approving. #1443 argued the codebase "already uses
reason=labels for exactly this shape." It does not —RejectReason(dispatch.rs:76),RejectLayer(rate_limit.rs:169),ChannelOpenFailureReasonandAnnounceRejectall fan out to sibling unlabeled counters, and the onlyFamilyindecdn-nodewasstreams_active, a Gauge.metrics.rs:214/:253/:1086state the sibling split as deliberate convention. So this change makesprobe_hold_unavailablethe one labeled counter rather than ending an inconsistency. It was done anyway on the audit verdict; the remaining splits are untouched and a follow-up asks whether they should follow. The stale "iroh_metricscarries no label dimension" comment (false —Family<L, M>exists) is corrected.Rendered series were confirmed against a real
metrics.encode()dump before the test needles were rewritten, which is how the encoder's_totalsuffix and the derive's snake_case label encoding were pinned rather than assumed:#1431 — ADR 024 narrowed to what shipped
Kept: contract-level
SignatureCheckerat every verification site (already merged — it is what avoids a coordinated on-chain retrofit) and the Production session-key plan (Safe-7579 +erc7579/smartsessions). Dropped: "Safe as the recommended wallet" — the EOA keystore is now the documented default and Safe is supported — and the § Consequences obligation thatdecdn setupguide Safe creation, a promise the CLI never grew. Relabelled: the node-side off-chain ERC-1271 verifier, from PoC deliverable to Production-deferred, matching what the Rust has said since #845. Its 27-linealloysketch is removed; every normative element (code probe → recovery fallthrough →isValidSignature+ magic value, one round-trip per connection, cache the code result) survives in prose.No Rust deleted — the path was never built. ADR 024 keeps its number and title (Safe is still supported), so only one anchor changed and one was deleted, both with zero external inbound links; the other 24 inbound anchors are untouched.
Two things the code read turned up that the issue did not have:
probe.rssignsslash_sigwith the keystore EOA and requesters recover it against the registered address (client-pull/src/lib.rs:2267), which yields the Safe owner, not the Safe — so every response is rejected.appendix-operator-key-rotation.mdrecommended exactly that migration. It is now optional, the constraint is documented, and the procedure is kept in full.ADR 024 §18by line number into the bullet this change rewrites (crates/protocol/src/message.rs×5,client.rs×3,CHANGELOG.md), plusToken.sol:19citing a§ ERC-4337 pathheading that has never existed. All now name§Off-Chain ERC-1271 Verification, a heading guarded bycheck-anchor-targets.Verification
make -C adr check-refsmake -C adr check-book-listcargo fmt/clippy -D warnings/doc -D warningscargo nextest run -p decdn-node -p decdn-protocol -p decdn-incentive -p decdn-cacheforge fmt --check,FOUNDRY_PROFILE=ci forge build --deny warnings,forge testpre-commit run --all-files¹ One pre-existing markdownlint failure in
.github/workflows/issue-triage.md, a file this PR does not touch — it reproduces with the changes stashed, and CI excludes.github/workflows/*.mdfrom its glob, so it is a local-only pre-commit divergence.No
contracts/.gas-snapshotregen (the only Solidity change is a comment) and nodecdn-protocolpublic-API snapshot regen (comments only).Also closes #1186
#1186 ("implement off-chain ERC-1271 verification", ADR–implementation parity, disposition IMPLEMENT) is the exact work #1431 defers — the two could not both stand. The retained contract-level
SignatureCheckerkeeps this a cheap, uncoordinated node-side add whenever smart-account clients and the session-key path both exist.Follow-ups filed rather than widening this PR
dispatch_rejected_*,probe_rate_limit_rejected_*andchannel_open_failures_*should follow probe-hold onto{reason}labels, or the sibling-counter convention stands.decdn-website(separate repo, live and indexable):lib/faq.tspresents publisher-funded wallet-free fetches — Investigation: a simpler "publisher pays" model to replace ERC-1271 / Safe #1444's un-started investigation — as a shipped capability, and two blog lines need roadmap framing.🤖 Generated with Claude Code
Summary by CodeRabbit
reason-labeled counter and updated dashboards/alerts to track exhaustion vs intentional refusals.