Skip to content

refactor: two protocol simplifications — probe-hold reason label, ADR 024 scope - #1474

Merged
thiras merged 2 commits into
mainfrom
refactor/simplifications-probe-hold-label-adr024
Jul 27, 2026
Merged

thiras merged 2 commits into
mainfrom
refactor/simplifications-probe-hold-label-adr024

Conversation

@thiras

@thiras thiras commented Jul 26, 2026 •

Copy link
Copy Markdown
Contributor

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} label

decdn_probe_hold_violations_total, decdn_probe_holds_disabled_total and decdn_probe_stake_lane_reserved_total become 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.

Two details that make this safe rather than merely shorter:

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), ChannelOpenFailureReason and AnnounceReject all fan out to sibling unlabeled counters, and the only Family in decdn-node was streams_active, a Gauge. metrics.rs:214/:253/:1086 state the sibling split as deliberate convention. So this change makes probe_hold_unavailable the 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_metrics carries 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 _total suffix and the derive's snake_case label encoding were pinned rather than assumed:

decdn_probe_hold_unavailable_total{reason="exhausted"} 0
decdn_probe_hold_unavailable_total{reason="disabled"} 0
decdn_probe_hold_unavailable_total{reason="stake_lane_reserved"} 0

#1431 — ADR 024 narrowed to what shipped

Kept: contract-level SignatureChecker at 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 that decdn setup guide 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-line alloy sketch 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:

  1. A Safe-addressed node operator is already broken off-chain. probe.rs signs slash_sig with 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.md recommended exactly that migration. It is now optional, the constraint is documented, and the procedure is kept in full.
  2. Nine citations referenced ADR 024 §18 by line number into the bullet this change rewrites (crates/protocol/src/message.rs ×5, client.rs ×3, CHANGELOG.md), plus Token.sol:19 citing a § ERC-4337 path heading that has never existed. All now name §Off-Chain ERC-1271 Verification, a heading guarded by check-anchor-targets.

Verification

Gate Result
make -C adr check-refs 1568 anchors resolve, no bare refs, no numeric §N
make -C adr check-book-list in sync (24 ADRs + 11 appendices)
cargo fmt / clippy -D warnings / doc -D warnings clean
cargo nextest run -p decdn-node -p decdn-protocol -p decdn-incentive -p decdn-cache 1531 passed
forge fmt --check, FOUNDRY_PROFILE=ci forge build --deny warnings, forge test 749 passed
pre-commit run --all-files clean¹

¹ 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/*.md from its glob, so it is a local-only pre-commit divergence.

No contracts/.gas-snapshot regen (the only Solidity change is a comment) and no decdn-protocol public-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 SignatureChecker keeps 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

  • Whether dispatch_rejected_*, probe_rate_limit_rejected_* and channel_open_failures_* should follow probe-hold onto {reason} labels, or the sibling-counter convention stands.
  • decdn-website (separate repo, live and indexable): lib/faq.ts presents 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

  • Documentation
    • Updated wallet guidance (EOA defaults, Safe supported but not recommended for hot paths) and clarified ERC-1271/off-chain verification behavior and signature handling.
    • Refreshed protocol/architecture ADR references and runbook/metric documentation.
  • Observability
    • Consolidated probe-hold refusal monitoring into a single reason-labeled counter and updated dashboards/alerts to track exhaustion vs intentional refusals.
  • Tests
    • Updated probe-loopback assertions to match the new reason-labeled metrics.
  • Maintenance
    • Documentation/comment updates across related ADRs and contracts without changing runtime behavior.

… 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]>
Copilot AI review requested due to automatic review settings July 26, 2026 19:45
@thiras thiras added this to the Protocol simplifications milestone Jul 26, 2026
@coderabbitai

coderabbitai Bot commented Jul 26, 2026 •

Copy link
Copy Markdown

Review Change Stack

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Free

Run ID: 951df329-5997-4592-9a92-cb3c9ce34b1c

📥 Commits

Reviewing files that changed from the base of the PR and between 3e88221 and 696e79d.

📒 Files selected for processing (8)
  • adr/019-node-onboarding.md
  • adr/024-account-abstraction.md
  • adr/appendix-operator-key-rotation.md
  • contracts/src/Token.sol
  • crates/cache/src/probe_hold.rs
  • crates/node/src/metrics.rs
  • crates/node/tests/probe_loopback.rs
  • crates/protocol/src/message.rs
🚧 Files skipped from review as they are similar to previous changes (7)
  • adr/019-node-onboarding.md
  • crates/protocol/src/message.rs
  • crates/cache/src/probe_hold.rs
  • contracts/src/Token.sol
  • crates/node/tests/probe_loopback.rs
  • crates/node/src/metrics.rs
  • adr/024-account-abstraction.md

Walkthrough

The 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.

Changes

Wallet and signature verification guidance

Layer / File(s) Summary
EOA default and Safe support policy
adr/*.md, CHANGELOG.md, CLAUDE.md, crates/incentive/..., crates/protocol/..., contracts/src/Token.sol
Documentation now describes encrypted EOA keystores as the default, Safe as supported but constrained for off-chain slash_sig verification, and ERC-1271 verification and session keys as Production-targeted behavior.

Probe-hold metric consolidation

Layer / File(s) Summary
Reason-labeled metric contract and recorder
crates/node/src/metrics.rs
Introduces ProbeHoldUnavailableReason, replaces three counters with a labeled Family, pre-materializes all reason series, and adds reason-specific recording tests.
Probe refusal classification and validation
crates/node/src/handlers/probe.rs, crates/node/tests/probe_loopback.rs, crates/cache/...
Probe refusal paths emit exhausted, disabled, or stake_lane_reserved; tests verify the corresponding metric values and zero-valued alternatives.
Monitoring and operational documentation
monitoring/*, docs/runbook.md, adr/appendix-*, CHANGELOG.md
Alerts, dashboards, ADRs, and remediation guidance use decdn_probe_hold_unavailable_total{reason="exhausted"} and distinguish deliberate refusals.

Estimated code review effort: 3 (Moderate) | ~25 minutes


Note

🎁 Summarized by CodeRabbit Free

Your 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 @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

Gas snapshot

No gas changes vs base.

@github-actions

github-actions Bot commented Jul 26, 2026 •

Copy link
Copy Markdown

Contracts coverage

Line coverage: 89.54% (2413/2695 lines)
▲ +0.00pp vs base (89.54% → 89.54%)
Run: 30219828984

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-actions

github-actions Bot commented Jul 26, 2026 •

Copy link
Copy Markdown

Coverage report

Total: 81.10% (was 81.08%, ▲ +0.02%) — 52324/64515 lines

File Coverage Lines Δ
crates/cache/src/engine.rs 90.60% 2632/2905 ▲ +0.03%
crates/incentive/src/bind_sig.rs 87.60% 113/129 ● 0.00%
crates/node/src/handlers/probe.rs 87.27% 240/275 ▲ +0.14%
crates/node/src/metrics.rs 95.41% 978/1025 ▲ +0.34%
crates/protocol/src/client.rs 97.35% 697/716 ● 0.00%
crates/protocol/src/message.rs 100.00% 230/230 ● 0.00%
History
Commit Total Δ vs base
3e88221 81.10% ▲ +0.02%
696e79d (HEAD) 81.10% ▲ +0.02%

@thiras thiras removed this from the Protocol simplifications milestone Jul 26, 2026
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]>
@thiras
thiras merged commit 730336e into main Jul 27, 2026
24 checks passed
@thiras
thiras deleted the refactor/simplifications-probe-hold-label-adr024 branch July 27, 2026 03:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incentive: implement off-chain ERC-1271 verification for smart-account clients

2 participants