Skip to content

refactor: four protocol simplifications — rate ceiling, settlement ranking, blacklist appeals, probe-hold alerts - #1472

Merged
thiras merged 8 commits into
mainfrom
refactor/protocol-simplifications-batch
Jul 26, 2026
Merged

thiras merged 8 commits into
mainfrom
refactor/protocol-simplifications-batch

Conversation

@thiras

@thiras thiras commented Jul 26, 2026 •

Copy link
Copy Markdown
Contributor

Four issues from the Protocol simplifications milestone, landed as one batch. Net +218 / −3,447 across 5 commits, each self-contained so the series stays bisectable if CI goes red.

Closes #1471, Closes #1441, Closes #1434, Closes #1432

What's in it

Commit Issue Layers
fix(monitoring) #1471 monitoring, docs
refactor(contracts,node)! #1441 Solidity, Rust, config, ADR
refactor(contracts)! #1434 Solidity, ADR
refactor(contracts,node)! #1432 Solidity, Rust, ADR
chore — gas snapshot, CHANGELOG, CLAUDE.md

Each commit message carries the full rationale; the highlights and the three places where the issues' own premises turned out to be wrong are below.

Three corrections to the issues

#1434 — the capacityBond_ constructor arg cannot be removed. The issue assumed deleting the recordSettlement call frees the whole wiring. It does not: FeeRouter.sol:164 reads capacityBond_.epochLength() for the bondEpoch == epochLength_ assertion, a deploy-time invariant that stops a mismatched deployment silently mis-anchoring DecdnGovernor epoch arithmetic. The param and assertion stay; only the retained immutable and the call go, and ICapacityBondReporter — down to epochLength() alone — is renamed ICapacityBondEpoch.

#1432 — entry.suspended is not confined to ContentBlacklist. SlashJudge destructures it out of the getHashEntry tuple via IContentBlacklistHashView, and blacklist_watcher.rs carries a whole HashSuspensionUpdated handler (#1300) plus its resume-edge tests. With no fast-track nothing can set it, so it is removed end to end rather than left as dead state on the hot slash-eligibility path. That is the one cross-boundary ABI change in the batch.

#1432 — totalBondsEscrowed does not exist. It is spec-only (ADR 031), never implemented, so that cut is doc-only.

#1443 is deliberately not here

Its motivation #2 — "the codebase already uses reason= labels for exactly this shape" — is false, and the issue has been updated with the evidence. The metrics backend is iroh_metrics, not the prometheus crate: there is no CounterVec and no with_label_values anywhere in crates/. RejectReason::as_str() feeds a tracing field; AnnounceReject string-compares onto a sibling counter; VoucherRejectReason is a wire enum with no metric attached. Sibling-counters-instead-of-labels is stated as the deliberate convention in three places precisely because iroh_metrics carries no label dimension. Renaming three Tier-M mandatory metrics on a false premise is the wrong trade; the issue stays open for a re-decision.

Operator-facing breaking changes

  • Config: payment.delivery_ceiling / --delivery-ceiling / DECDN_DELIVERY_CEILING are removed. [payment] uses deny_unknown_fields, so a TOML that still sets the key now fails startup and decdn config validate rather than ignoring it. Delete the key — nothing replaces it, because the node no longer clamps its quote downward at all. The absolute upper bound is still the wire constant MAX_RATE_PER_MB.
  • ABI (lockstep upgrade required): setRateBounds arity, RateBoundsUpdated topic0, RateBoundsInvalid arity, getRateBounds() return shape, both PaymentChannel and ContentBlacklist constructors, and the getHashEntry tuple. SettlementRecorded / SETTLEMENT_REPORTER_ROLE and the appeal surface are gone.
  • Deploy: BLACKLIST_APPEAL_BOND is no longer read; two post-deploy grantRole steps drop out.

Size wins

  • ContentBlacklist deployed bytecode 24,576 → 11,193 bytes; source 1,577 → 854 lines; its test suite 2,203 → 949.
  • CapacityBond gains 1,396 bytes of EIP-170 margin — worth noting given how close it was sitting to the limit.
  • crates/node/src/rate_bounds.rs collapses from Arc<ArcSwap<Bounds>> to Arc<AtomicU64>. The ArcSwap existed solely to publish (floor, ceiling) atomically, because a reader seeing a new floor beside an old ceiling would hit u64::clamp's assert!(min <= max) on the signing path. With one value that whole bug class is unrepresentable rather than defended against.
  • The config resolver loses a guard structurally: delivery_ceiling >= 1 existed because clamping to 0 would sign a free rate. A raise-only clamp cannot go below rate_per_mb, already validated >= 1.

Verification

All green locally:

  • cargo clippy --workspace --all-targets, cargo doc, cargo nextest run --workspace — 2,555 passed
  • forge fmt --check, FOUNDRY_PROFILE=ci forge build --sizes --deny warnings, forge test — 744 passed, forge snapshot --check clean
  • aderyn — 0 high; slither — exit 0 (the three missing-inheritance informationals are byte-identical on main)
  • make -C adr check-md-anchors — clean, and every referenced ADR 011 anchor re-verified by hand after the section rename
  • cargo nextest run -p decdn-e2e --features anvil-e2e — 27/27, and -p decdn-node --features anvil-e2e --test anvil_settlement_e2e — 4/4. This is the only gate that catches sol! ABI drift, so it matters more than usual here.

Follow-ups, not addressed here

  • cli+e2e G-ORIGIN-03: decdn appeal blacklist (publisher appeal) #1040 (decdn appeal blacklist CUJ) is now moot — there is no blacklist-appeal surface to drive. Worth closing alongside this.
  • crates/node/tests/anvil_bringup_shutdown_e2e.rs does not compile under --features anvil-e2e — missing content and max_rate_per_mb initializers. Pre-existing on main, unrelated to this batch: CI only builds --test anvil_settlement_e2e, so that file is never compiled and has rotted unnoticed.
  • ADR 011 and the runbook both name the first-regional-body governance vote as where a minimal interim-relief primitive (multisig suspend + governor ratify on one (hash, region), bond as standing) should be reconsidered.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Breaking Changes
    • Content-blacklist entry appeals and interim-relief suspension workflows have been removed; wrongful-entry remediation now uses regional or governance removal paths, with slash appeals remaining separate.
    • Payment rate configuration is now floor-only (delivery ceiling, related APIs/events/env vars removed).
    • Settlement routing no longer records settlement data for bootstrap ranking; settlement recording surfaced by capacity-bond reporting has been removed.
  • Documentation
    • Updated ADRs, operator/runbook, monitoring, and deployment/onboarding guidance to match the revised blacklist and floor-only rate-bound behavior.

thiras and others added 5 commits July 26, 2026 18:57
…uidance

`DecdnProbeHoldViolations` told an on-call operator they were producing valid
phantom slash evidence. They are not. The counter fires when a blob is present
but un-holdable because every probe-hold slot is live — the node then signs
`has_blob: false` and forgoes the delivery. The literal "evicted within
probe_hold_duration after signing has_blob: true" case the annotation described
is unreachable by construction: held hashes are invisible to the LRU driver
(appendix-observability.md §Slash-Safety Metrics). ADR 005 §Hold budget is
explicit that hold-budget exhaustion at the admitted rate is "an availability
degradation, not a safety violation".

The remedy the annotation gave ("raise max_probe_holds") was already right, so
this rewrites the diagnosis and drops the `slash_risk: phantom_announcement`
label. Severity and the `decdn-slash-safety` group placement both stay: the
appendix sets Critical at `> 0 sustained` and deliberately groups the probe-hold
capacity metrics there. The group header now names the exception so the
"sustained alert here means slash risk" summary is not read as covering it.

`DecdnProbeHoldsSaturated` had its inequality backwards — "recommended: ≥25% of
cache capacity" against ADR 005's "no more than 25%", scoped to small caches.
`crates/common/src/config/types.rs` carries the same ≤ framing; the alert file
was the only place saying ≥.

Both annotations now note that `max_probe_holds` is restart-required, so an
operator who edits it mid-incident and reloads is not left wondering why nothing
changed. `warn_restart_required_sections` now names the field in its
`cache.*` notice for the same reason.

docs/runbook.md flagged the annotation as wrong inline (#1469); that caveat is
removed now that it is fixed.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…nd (#1441)

The enforced `deliveryFloor` stays and is untouched. Only the advisory ceiling
half of the band goes.

The ceiling enforced nothing, as its own doc comment conceded: it appeared in
zero require/revert on the settlement path. `_advanceClaimWatermark` — the sole
voucher-validation chokepoint — reads `deliveryFloor` only. The ceiling was
store-and-emit: a constructor arg, a storage slot, a governance setter, and a
tuple slot on `getRateBounds()`, with the node dutifully re-reading it hourly.

The mechanism it implemented does not make sense on inspection. A ceiling asks a
seller to self-clamp its own advertised rate *downward*, and a seller never wants
to charge less. The buyer's actual protection is seeing the signed rate in
`StreamResponse` before paying a single voucher, which no governance parameter
mediates. The absolute upper bound survives as the wire constant
`MAX_RATE_PER_MB`, already enforced in `ProbeResponse` validation, so nothing
becomes unbounded — it merely stops being governance-tunable.

**The Rust simplification is the real win.** `rate_bounds.rs` existed almost
entirely to publish `(floor, ceiling)` atomically: an earlier two-`AtomicU64`
design let a reader observe a new floor beside an old ceiling, and `u64::clamp`
is `assert!(min <= max)`, so a routine governance retune raising the band could
panic the signing task. That whole class of bug is now unrepresentable rather
than defended against. `RateBounds` collapses from `Arc<ArcSwap<Bounds>>` to
`Arc<AtomicU64>`; `Bounds`, its ceiling-normalising constructor, the
max-then-min `clamp`, `snapshot()`, and the `ceiling()` accessor (which had no
production caller at all) are gone, along with four of five tests that existed
only to pin pair semantics. The watcher loses its floor/ceiling asymmetry — an
out-of-range floor aborted the update while an out-of-range ceiling saturated to
`u64::MAX` — and is now uniformly fail-closed.

The config resolver loses a guard too, structurally: `delivery_ceiling >= 1`
existed because clamping to 0 would sign a free, selection-winning rate. A
raise-only clamp cannot produce a rate below `rate_per_mb`, already validated
`>= 1`, so the invariant now holds by construction.

`InterfaceFreeze.t.sol` needs no change: selectors do not encode return types, so
`getRateBounds()` keeps its pinned selector while its tuple shrinks.

BREAKING CHANGE: `payment.delivery_ceiling` is removed, along with
`--delivery-ceiling` and `DECDN_DELIVERY_CEILING`. `[payment]` uses
`deny_unknown_fields`, so a TOML that still sets the key now fails startup and
`decdn config validate` rather than ignoring it — a silent ignore would leave the
operator believing a ceiling is still in force. Delete the key; nothing replaces
it, because the node no longer clamps its quote downward at all.

BREAKING CHANGE: ABI. `setRateBounds(uint256,uint256)` becomes
`setRateBounds(uint256)` (selector changes), `RateBoundsUpdated` drops
`newDeliveryCeiling` (topic0 changes), `RateBoundsInvalid` drops its second
param, `getRateBounds()` returns a single `uint256`, and the `PaymentChannel`
constructor drops `deliveryCeiling_`. A node built against the old ABI
mis-decodes the event and must be upgraded in lockstep with the deployment.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
`FeeRouter.routeSettlement` called `CapacityBond.recordSettlement(operator)` on
every settlement and every mid-channel withdraw — an external CALL, an
`onlyRole` check and a LOG on the most-executed mutating function in the system
— so that clients *could* index `SettlementRecorded` and bias bootstrap ordering
toward proven deliverers.

Nothing ever indexed it. `grep -rn SettlementRecorded crates/` returns zero
hits: the client's real bootstrap ranker (`crates/client-pull/src/discovery.rs`)
reads `getActiveNodes`, orders region-first, probes the top-K for liveness and
blob-holding, and ranks by probe result. The mechanism was pure write-side
machinery with no consumer, taxing the hottest on-chain path.

It would not have been the right signal even with a consumer. A settlement log
says "this operator settled a channel at some past block"; a probe RTT says
"this operator answered me 40ms ago and holds the blob". The probe strictly
dominates for the decision actually being made — which peer to fetch from now —
and ADR 016 already conceded the registry is "a cold-start seed list, not a
liveness oracle". The one case the log served better, a cold client ranking the
seed list before spending its first probe, is still available at zero added
on-chain cost: `FeeRouter.Settled(operator, bytes, amount, epoch)` is already
emitted on the same path and already carries the operator address.

`recordSettlement` wrote no storage, so nothing is lost but the event. Removing
it also drops `SETTLEMENT_REPORTER_ROLE`, one post-deploy `grantRole`, one
`_requireRole` deploy assertion, and one cross-contract trust edge. `CapacityBond`
gains 1,396 bytes of EIP-170 margin.

Note the constructor arg could NOT go with it, contrary to the issue: FeeRouter's
`capacityBond_` is read at `:164` for the `bondEpoch == epochLength_` assertion,
a deploy-time invariant that stops a mismatched deployment silently mis-anchoring
DecdnGovernor epoch arithmetic. So the param and the assertion stay; only the
retained `immutable` goes, and `ICapacityBondReporter` — now down to
`epochLength()` alone — is renamed `ICapacityBondEpoch` to match what it is.

`FeeRouter.bytesPerEpoch` / `totalBytesPerEpoch` (the ADR 036 governance-canonical
served-bytes vote weight) is incremented inline in `routeSettlement` and is
entirely independent — untouched.

ADR 016 § Settlement-Weighted Bootstrap Ranking is replaced by § Bootstrap
Ranking, which keeps both forward-compatibility design principles and states the
client-side pipeline that actually ships. The class diagram edge, deployment step
5, the call-graph edge and table row, the roles and function-signature table
rows, and the `CapacityBond` surface list are all reconciled; post-deploy steps
renumber 1-7.

BREAKING CHANGE: ABI. `CapacityBond.recordSettlement(address)`,
`SettlementRecorded(address)` and `SETTLEMENT_REPORTER_ROLE()` are removed, as is
`ICapacityBondReporter` (renamed `ICapacityBondEpoch`, `recordSettlement`
dropped). No Rust binding referenced any of them, so no node change is required;
an external indexer subscribed to `SettlementRecorded` must switch to
`FeeRouter.Settled`, which carries the same operator address.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…1432)

Enforcement is untouched. Blacklisting hashes, origins and operators — global,
regional and emergency — the compliance window, `effectiveAt` stamping,
`addOperator` → `CapacityBond.ejectNode`, and slashing for serving blacklisted
content past the window all stay exactly as they were. What goes is the *second*
appeal state machine layered on top of that enforcement.

Three cuts, per the issue:

**Standing collapses.** ADR 011 already conceded the three `StandingPath`
branches grant the identical thing — permission to file — and that path 1
"confers no more than path 3". Because hash→namespace is off-chain, the
Publisher path only ever proved the filer controlled *a* namespace, not that the
hash fell under it, and #1394 removed even the on-chain hash↔namespace binding.
Three verification branches, one effective capability.

**The fast-track goes.** Its only value over the removal path is fast interim
relief on a regional entry, and ADR 011 states it is "structurally
non-functional" until a regional body is registered — at launch, none is, so
`addHashGlobal` and the appeal would be adjudicated by the same admin key. That
is a governance-rollout precondition, not a scale one, so this is
deferred-not-deleted: ADR 011 and the runbook both name the first-regional-body
vote as where a minimal interim-relief primitive (multisig suspend + governor
ratify on one `(hash, region)`, bond as standing) should be reconsidered.

**The per-filer knobs go.** The rejection cooldown, frequency cap and perjury
denylist are all address-keyed, and the ADR admits a holder can split funds
across `n` addresses to evade them; its own conclusion is that "the deterrent
surface ... is the bond + concurrent-relief economics, not the per-address
counters". `totalBondsEscrowed` turned out not to exist in the implementation at
all — spec-only, so that cut is doc-only.

**`entry.suspended` is removed end to end**, which is the part the issue did not
anticipate. It is not confined to `ContentBlacklist`: `SlashJudge` destructures
it out of the `getHashEntry` tuple via `IContentBlacklistHashView`, and
`blacklist_watcher.rs` carries a whole `HashSuspensionUpdated` handler (#1300)
plus its resume-edge tests. With no fast-track nothing can ever set it, so
keeping it would leave dead state on the hot slash-eligibility path and a
watcher subscribed to an event that can never fire. Liveness collapses to
`addedAt != 0 && !expired` in both contracts, and the watcher's periodic
re-scope — which was always the only thing catching a region/ripening
transition, since that emits nothing — is now its sole re-arm path.

`IPublisherRegistryStanding` drops out entirely: `ContentBlacklist` was its only
production consumer, and `OriginAssignment` reaches `PublisherRegistry` through
the separate `IPublisherRegistryOwnership`. `PublisherRegistry` itself is
untouched.

Net: `ContentBlacklist.sol` 1,577 to 854 lines and its deployed bytecode
24,576 to 11,193 bytes; `ContentBlacklist.t.sol` 2,203 to 949; ADR 031 archived
to `adr/_history/` (303 lines); ADR 011 § Blacklist Entry Appeals (146 lines)
replaced by § Removing a Wrongful Entry, which states the two removal routes and
the ADR 028 restitution path plainly.

ADR 030 keeps `REGION_STABILITY_WINDOW` — only its appeals-standing leg is cut.
The window's other job, foreclosing a reactive blacklist-scope flip, is squarely
inside the enforcement model being kept.

BREAKING CHANGE: ABI. `ContentBlacklist`'s constructor drops
`publisherRegistry_` and `appealBond_`; `getHashEntry` and
`IContentBlacklistHashView` lose the `suspended` tuple slot;
`HashSuspensionUpdated`, the seven `BlacklistAppeal*` events, the six appeal
entry points, `setAppealBond`, `setRejectionCooldownWindow` and their views are
removed, as is `IPublisherRegistryStanding`. A node built against the old ABI
mis-decodes `getHashEntry` and must be upgraded in lockstep with the deployment.
`BLACKLIST_APPEAL_BOND` is no longer read by the deploy script.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…UDE.md

Three of the four preceding commits change contract bytecode or storage, so
`.gas-snapshot` is regenerated wholesale (822 -> 755 rows; the dropped rows are
the deleted appeal, rate-ceiling and settlement-reporter tests). Local
`forge test` passes without this, so it only ever fails in CI.

CHANGELOG gains a BREAKING entry per issue, each naming the config key or ABI
symbol an operator has to act on. CLAUDE.md's ADR note records 031 as retired
and adds it to the do-not-reuse list, and notes that ADR 030's region-stability
window survived the cut with only its appeals-standing leg removed.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings July 26, 2026 16:56
@coderabbitai

coderabbitai Bot commented Jul 26, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@thiras, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 34 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Free

Run ID: 8daf9144-d3f7-4c71-8bf9-5c1a4f0c7a62

📥 Commits

Reviewing files that changed from the base of the PR and between 78f97f4 and ac44a0f.

📒 Files selected for processing (14)
  • adr/011-content-takedown.md
  • adr/016-contract-interactions.md
  • contracts/.gas-snapshot
  • contracts/script/BaseProtocolDeploy.s.sol
  • contracts/src/ContentBlacklist.sol
  • contracts/src/PaymentChannel.sol
  • contracts/test/FeeRouter.t.sol
  • crates/common/src/config/mod.rs
  • crates/e2e/tests/g_gov_02_rate_bounds.rs
  • crates/node/src/rate_bounds.rs
  • crates/node/src/rate_bounds_watcher.rs
  • crates/node/src/runtime/mod.rs
  • docs/runbook.md
  • monitoring/prometheus-alerts.yml

Walkthrough

The change removes blacklist-entry appeals and settlement reporting, narrows PaymentChannel rate bounds to a delivery floor, updates deployment and node integrations, and synchronizes tests, ADRs, runbook guidance, monitoring, and changelog entries.

Changes

Protocol surface simplification

Layer / File(s) Summary
Blacklist appeal removal
contracts/src/ContentBlacklist.sol, contracts/src/SlashJudge.sol, crates/node/src/blacklist_watcher.rs, crates/incentive/src/content_blacklist.rs, contracts/test/ContentBlacklist.t.sol, docs/runbook.md
Appeal state, suspension fields, appeal entry points, events, configuration, watcher handling, and related tests are removed. Wrongful entries use the regional or global removal paths.
Settlement reporting removal
contracts/src/CapacityBond.sol, contracts/src/FeeRouter.sol, contracts/src/interfaces/*, contracts/script/*, contracts/test/FeeRouter.t.sol, adr/016-contract-interactions.md
FeeRouter.routeSettlement no longer calls CapacityBond.recordSettlement; the reporter role and event are removed, and ICapacityBondEpoch retains only epochLength().
Delivery-floor rate model
contracts/src/PaymentChannel.sol, crates/common/src/config/*, crates/node/src/rate_bounds.rs, crates/node/src/rate_bounds_watcher.rs, crates/node/src/runtime/*, crates/e2e/tests/g_gov_02_rate_bounds.rs
The delivery ceiling is removed from contract ABI, configuration, CLI/environment options, node state, event polling, signing clamps, reload handling, and governance coverage.
Documentation and operational alignment
CHANGELOG.md, adr/*, CLAUDE.md, monitoring/prometheus-alerts.yml, docs/runbook.md
ADRs, deployment notes, onboarding guidance, monitoring descriptions, runbook procedures, and changelog entries describe the revised blacklist, settlement, and rate-floor surfaces.

Estimated code review effort: 4 (Complex) | ~60 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

github-actions Bot commented Jul 26, 2026 •

Copy link
Copy Markdown

Contracts coverage

Line coverage: 89.54% (2413/2695 lines)
▼ -0.39pp vs base (89.92% → 89.54%)
Run: 30215262776

@github-actions

Copy link
Copy Markdown

Gas snapshot

No gas changes vs base.

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 batches four “protocol simplifications” changes that reduce on-chain and node-side surface area (and bytecode) while keeping the remaining invariants explicit: (1) probe-hold alert text is corrected to match actual runtime semantics, (2) delivery-rate governance is simplified to a single enforced floor (no advisory ceiling), (3) settlement-weighted bootstrap ranking is removed, and (4) blacklist-entry appeals (and the associated suspended state) are removed end-to-end.

Changes:

  • Fix probe-hold alert annotations/guidance to reflect “lost revenue under budget pressure” (not slash evidence) and document restart-required behavior for max_probe_holds.
  • Remove governance “delivery ceiling” across contracts/Rust/config/docs; keep only the governance-set deliveryFloor and enforce an absolute wire cap (MAX_RATE_PER_MB).
  • Remove settlement-reporting callback and blacklist-entry appeal machinery (including ABI changes to getRateBounds, setRateBounds, RateBoundsUpdated, and getHashEntry tuple shape).

Reviewed changes

Copilot reviewed 68 out of 69 changed files in this pull request and generated no comments.

Show a summary per file
File Description
monitoring/prometheus-alerts.yml Correct probe-hold alert copy and adjust guidance/labels to reflect revenue-loss semantics and restart requirements.
docs/runbook.md Update operator runbook to match removed blacklist appeals and corrected probe-hold alert meaning.
crates/node/tests/support/mod.rs Update test harness rate-bounds construction for floor-only RateBounds.
crates/node/tests/sighup_signal.rs Remove config/CLI references to delivery_ceiling in reload tests.
crates/node/tests/self_hosted_discovery.rs Update discovery tests for floor-only RateBounds.
crates/node/tests/probe_warm_reconnect.rs Update probe warm reconnect tests for floor-only RateBounds.
crates/node/tests/probe_loopback.rs Update probe tests and rename/assert floor-raise behavior (no ceiling clamp).
crates/node/tests/anvil_bringup_shutdown_e2e.rs Remove delivery_ceiling from e2e config wiring.
crates/node/src/runtime/reload.rs Track only applied delivery floor; add restart-required notice coverage for max_probe_holds; remove ceiling handling.
crates/node/src/runtime/mod.rs Seed/store only the on-chain delivery floor at startup (single-value getRateBounds()).
crates/node/src/rate_bounds.rs Refactor RateBounds from (floor, ceiling) to a single atomic floor with raise-only clamp.
crates/node/src/rate_bounds_watcher.rs Update watcher to decode/store only the on-chain floor from event + poll paths.
crates/node/src/handlers/probe.rs Raise quoted probe rate to the governance floor before signing (no ceiling clamp).
crates/node/src/handlers/client/wire.rs Raise quoted stream rate to the governance floor before signing (no ceiling clamp).
crates/node/src/handlers/client/mod.rs Update client handler tests for floor-only RateBounds::store.
crates/node/src/blacklist_watcher.rs Remove suspend/resume event handling and related tests after dropping entry.suspended.
crates/incentive/src/payment_channel.rs Update Rust ABI bindings: getRateBounds() returns single floor; RateBoundsUpdated carries one param.
crates/incentive/src/content_blacklist.rs Update Rust ABI bindings: remove suspended field and HashSuspensionUpdated event.
crates/e2e/tests/g_gov_02_rate_bounds.rs Update end-to-end governance journey to retune/release only the delivery floor.
crates/common/src/config/types.rs Remove payment.delivery_ceiling; clarify buyer-side max_rate_per_mb vs seller-side floor semantics.
crates/common/src/config/resolved.rs Remove resolved delivery_ceiling; update related doc comments.
crates/common/src/config/mod.rs Remove ceiling resolution/validation; add floor ≤ MAX_RATE_PER_MB guard and update tests.
crates/common/src/cli/run.rs Remove --delivery-ceiling / DECDN_DELIVERY_CEILING.
crates/cli/tests/config_validate.rs Update config-validate fixtures for removed delivery_ceiling.
crates/cli/src/commands/config.rs Update default config template comments to reflect floor-only seller-side clamp.
contracts/test/SlashJudge.t.sol Remove suspended-entry cases and update mock blacklist view tuple to match new ABI.
contracts/test/PaymentChannel.t.sol Update tests for floor-only setRateBounds/getRateBounds and new RateBoundsInvalid shape.
contracts/test/GovernanceLifecycle.t.sol Remove blacklist appeal bond config and lifecycle tests for setAppealBond.
contracts/test/GenesisBuybackActivationBalancer.fork.t.sol Remove blacklist appeal bond from deploy config in fork test.
contracts/test/GenesisBuybackActivation.t.sol Remove blacklist appeal bond from deploy config.
contracts/test/GenesisBuybackActivation.fork.t.sol Remove blacklist appeal bond from deploy config in fork test.
contracts/test/FeeRouter.t.sol Update to ICapacityBondEpoch and remove settlement reporter assertions.
contracts/test/E2EProtocol.t.sol Remove blacklist appeal bond from end-to-end deploy config.
contracts/test/DeployProtocolScript.t.sol Remove blacklist appeal bond expectation from deploy script test.
contracts/test/DeployProtocol.t.sol Remove settlement-reporter role assertion and blacklist appeal bond config.
contracts/test/CapacityBondRegionE2E.t.sol Update ContentBlacklist construction after removing appeal surface + publisher-standing wiring.
contracts/src/SlashJudge.sol Update blacklist enforceability checks for new getHashEntry tuple (no suspended).
contracts/src/PaymentChannel.sol Remove delivery ceiling; change ABI for getRateBounds/setRateBounds/RateBoundsUpdated/RateBoundsInvalid.
contracts/src/interfaces/IPublisherRegistryStanding.sol Deleted: publisher-standing interface removed with blacklist-entry appeals.
contracts/src/interfaces/IFeeRouterSettlement.sol Update interface docs to reference ICapacityBondEpoch.
contracts/src/interfaces/IFeeRouter.sol Remove mention of settlement reporting side-effect.
contracts/src/interfaces/IContentBlacklistHashView.sol Update getHashEntry tuple shape (remove suspended).
contracts/src/interfaces/ICapacityBondSlasher.sol Update interface docs to reference ICapacityBondEpoch.
contracts/src/interfaces/ICapacityBondReporter.sol Deleted: settlement reporter interface replaced by ICapacityBondEpoch.
contracts/src/interfaces/ICapacityBondEpoch.sol Added: minimal epoch-length view used for deploy-time invariant check in FeeRouter.
contracts/src/interfaces/ICapacityBondEjector.sol Update docs to remove ADR 031 references.
contracts/src/interfaces/ICapacityBondActivity.sol Update docs to reference ICapacityBondEpoch.
contracts/src/FeeRouter.sol Remove stored CapacityBond reporter + callback; keep constructor-time epoch-length assertion.
contracts/src/CapacityBond.sol Remove SETTLEMENT_REPORTER_ROLE, SettlementRecorded, and recordSettlement.
contracts/script/DeployProtocol.s.sol Remove BLACKLIST_APPEAL_BOND env/default wiring.
contracts/script/BaseProtocolDeploy.s.sol Remove settlement-reporter role wiring; simplify ContentBlacklist deployment params; update PaymentChannel deploy args.
CLAUDE.md Update ADR canonical/retired list and history to reflect blacklist-appeals removal.
CHANGELOG.md Document breaking changes (ABI/config) for rate ceiling removal, blacklist appeals removal, and settlement ranking removal.
adr/Makefile Remove ADR 031 from book build sources.
adr/architecture.md Remove ADR 031 references and update ADR 011 summary to “removal path” semantics.
adr/appendix-observability.md Update metric descriptions around rate-floor clamping and readiness wording.
adr/appendix-l2-deployment.md Remove mention of CapacityBond.recordSettlement overhead from settlement path description.
adr/030-node-region-self-attestation.md Remove appeals-standing flipping discussion and tighten scope to blacklist-scope flipping.
adr/028-slashing-appeals.md Update text to point “wrongful entry removal” to ADR 011’s ordinary removal path.
adr/019-node-onboarding.md Update onboarding steps/readiness criteria to “rate floor” (not bounds pair) and adjust constraints.
adr/009-governance.md Remove emergency multisig’s blacklist-appeal sub-modes and update unlawful-content removal text.
adr/005-protocol.md Update rate validation semantics to floor-only (raise-only clamp) and remove ceiling language.
adr/003-payments.md Update PaymentChannel surface, events, constructor, and refresh semantics for floor-only governance parameter.

💡 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.08% (was 81.10%, ▼ 0.02%) — 52252/64442 lines

File Coverage Lines Δ
crates/cli/src/commands/config.rs 74.76% 231/309 ● 0.00%
crates/common/src/config/mod.rs 97.03% 6802/7010 ▲ +0.02%
crates/common/src/config/resolved.rs 100.00% 33/33 ● 0.00%
crates/incentive/src/store.rs 90.76% 167/184 ● 0.00%
crates/node/src/blacklist_watcher.rs 94.11% 1326/1409 ▲ +0.02%
crates/node/src/handlers/client/mod.rs 89.42% 642/718 ● 0.00%
crates/node/src/handlers/client/wire.rs 95.16% 118/124 ▼ 0.04%
crates/node/src/handlers/probe.rs 87.13% 237/272 ▼ 0.05%
crates/node/src/rate_bounds.rs 97.50% 78/80 ▼ 2.50%
crates/node/src/rate_bounds_watcher.rs 0.00% 0/83 ● 0.00%
crates/node/src/runtime/mod.rs 46.98% 1082/2303 ▲ +0.14%
crates/node/src/runtime/reload.rs 96.56% 1629/1687 ▼ 0.06%
History
Commit Total Δ vs base
3bc8523 81.06% ▼ 0.04%
6923db4 81.06% ▼ 0.04%
78f97f4 81.07% ▼ 0.03%
ac44a0f (HEAD) 81.08% ▼ 0.02%

thiras and others added 3 commits July 26, 2026 20:30
Five review agents ran against this branch. Three findings were real defects I
introduced, and the rest is drift the deletions left behind.

**Regression: the rate floor lost its effective upper bound.** The old two-arg
guard required `newCeiling > newFloor` AND `newCeiling <= type(uint64).max`,
which made `floor == type(uint64).max` unreachable. Collapsing to one argument
made it reachable, and `test_setRateBounds_succeedsAtUint64Cap` then *codified*
it as intended. A floor anywhere in the ~18-million-fold gap between
`MAX_RATE_PER_MB` (1e12) and `u64::MAX` is silently network-isolating: nodes
raise every quote to the floor before signing, so every `ProbeResponse` and
`StreamResponse` becomes undecodable to every honest peer and settlement reverts
`RateFloorViolation` on essentially every voucher — while the only local signal
is a clamp warning byte-identical to a routine retune, and the documented
remediation for that metric is a config-validation dead end. `setRateBounds` and
the constructor now cap at `MAX_RATE_PER_MB`; the test asserting `u64::MAX`
succeeds is inverted to assert it reverts; the node refuses to start against
such a floor rather than serving into the void; and the e2e negative is re-aimed
at the real boundary.

**Wrong operator-facing safety claim.** The new runbook procedure said
`suspendRegionalBody` "freezes every entry that body issued". It does not:
`_bodySuspended` gates writes only and is not consulted by `_isLive` or by
`SlashJudge`. Existing entries stay live, enforceable and slashable. ADR 011
already said this correctly twelve lines from where I wrote the contradiction,
and an operator trusting my version could have kept serving slashable content.
Both the runbook and my ADR 011 section are corrected.

**Accidental coverage loss.** `test_getBlacklistVersion_unaffectedByNonEntryOperations`
was deleted whole because its tail drove appeals, but its first half asserted
retained behaviour — that `addOperator` / `removeOperator` / `setOriginBlacklist`
and the compliance-window setters do NOT bump the version, and neither do reads.
Nothing else covered that. It matters because `blacklist_watcher.rs` uses the
counter as its missed-log detector, so a phantom bump costs every node a full
delta re-fetch. Restored, extended to the two window setters.

Also fixed:

- `RateBounds::clamp` had zero production callers — both signing paths
  open-coded `raw.max(floor)` because they need the floor for the log line, so
  the unit tests exercised a method nothing called while the real logic was
  duplicated. Replaced with `raise_to_floor` returning `(clamped, floor)` from
  one load, and both call sites now use it.
- Added the store-lowers-the-floor unit test: `store` implemented as `fetch_max`
  would have passed every other assertion while latching at a high-water mark.
  That bug was caught only by a 60-second anvil poll; it is now instant.
- `FeeRouter`'s `EpochLengthMismatch` / `ZeroEpochLength` constructor guards had
  no test anywhere, and since #1434 that assertion is the *only* remaining
  purpose of the `capacityBond_` argument. Covered now.
- `ContentBlacklist` kept a write-only `token` immutable, its constructor arg,
  a zero-check, and two dead OZ imports after the bond escrow was removed.
  Dropped — the constructor was already breaking in this batch, so it was free.
  Contract drops another 50 bytes and ADR 016's "contracts custody funds" count
  goes 6 → 5, which it already claimed for `ContentBlacklist`.
- A stale `DECDN_DELIVERY_CEILING` now warns at startup. The TOML key and CLI
  flag fail loudly on their own; an env var has no such backstop, so an operator
  whose systemd unit still sets it was upgrading cleanly and silently losing it.
- Thirteen prose sites still describing deleted machinery: two `adr/003` table
  rows, `adr/009`'s governable-parameter row and appeal reference, two
  `adr/011` §Negative bullets, `adr/016`'s multisig capability row and step
  count, `architecture.md`'s retired-ADR list (031 was archived but unlisted),
  `contracts/README.md`'s link to the archived ADR 031 (the only broken
  repo-owned markdown link), `CapacityBond`'s "settlement reporter sink"
  notice, the deploy script's phase summary, and three Rust doc comments naming
  an appeal transition that can no longer occur.
- `IContentBlacklistHashView`'s `@dev` cited the matching selector as evidence
  the tuple decodes correctly. Selectors derive from inputs only, so a
  return-shape mismatch does not revert — it silently mis-decodes. The comment
  cited the very property that makes the failure invisible as protection
  against it.
- CHANGELOG bytecode figures were wrong in both directions: I read the margin
  column as the size column. `ContentBlacklist` drops 19,723 → 11,143 (not from
  24,576, which is the EIP-170 cap), and `CapacityBond` gains 231 bytes of
  margin, not 1,396 — the figure that matters, since it sits near the size gate.

Rejected one finding: `arc-swap` is still used by `announce_gate.rs` and
`content_deny.rs`, so the dependency stays.

Verification: clippy clean, 2,557 Rust tests, 749 contract tests, gas snapshot
regenerated, ADR anchors clean, both anvil e2e targets and the rewritten
rate-bounds journey pass.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
… were broken

A verification pass over `78f97f4b` found that two fixes did not do what their
commit message claimed, and that the runbook correction replaced one false
statement with another. CI was green on all of it.

**The retired-env-var warning never reached anyone.** `warn_retired_env_vars`
used `tracing::warn!`, but `resolve_config` runs before `init_tracing` in the
daemon, and `decdn` (the CLI, which reaches it via `config validate`) has no
`tracing` dependency at all. With no global subscriber the event is discarded,
so the fix for a silently-ignored env var was itself silent. Confirmed by
running the binary. Now `eprintln!`, matching the adjacent malformed-`RUST_LOG`
notice that already solved this exact ordering problem. The function returns the
names it reported so the "var is set" branch is testable: `unsafe` is forbidden
workspace-wide and `env::set_var` is unsafe in edition 2024, so the lookup is
injected rather than the environment mutated.

**The floor cap guarded startup but not the watcher.** `store_bounds` checked
only `u64::try_from`, so the value that refuses to boot was installed at runtime
one event later at `info!` severity. That split the fleet into running nodes
silently isolated from the network and restarted nodes loudly dead — and only
the dead ones were diagnosable. Same bound now applies on both paths, at
`error!`, keeping the previous floor. The comment is explicit that keeping it is
the lesser evil rather than safe: the node is then quoting under a floor the
chain will not honour, so what it serves accrues vouchers that revert at
redemption.

**The runbook's removal procedure was still wrong, in a new way.** It sent
operators to a DecdnGovernor `removeHashGlobal` proposal for a regional entry.
`removeHashGlobal` routes to `_removeHashRegional(GLOBAL_REGION, …)` and cannot
touch one; `removeHashRegional` requires the caller to *be* that region's
registered, unsuspended body, so governance reaches a regional entry only by
replacing the body. Worse, it recommended `suspendRegionalBody` for "a body that
will not act" — but `_requireActiveBodyFor` gates removals as well as additions,
so suspending closes the only route by which that body's entries could ever come
off. Both the runbook and ADR 011 now state the three routes by scope and say
plainly which tool is wrong for which failure.

On the operational question the review was asked to settle: **fail-closed at
startup is correct.** The feared trade — a bad vote bricking restarts while
running nodes serve on — does not exist, because a running node under an
over-cap floor is already non-functional and merely unaware. Refusing to start
costs no availability; it converts an invisible outage into a visible one. The
guard's one genuine new exposure is that a wrong-chain RPC or a bad
`payment_channel_address` now crash-loops a node, which argues for better
diagnosis text, not a weaker guard — so both messages now name that cause.

Also:

- The startup guard had no test and was unreachable from one: it sat inline
  behind an async chain read no fixture could drive to a bad value. Extracted to
  `rate_bounds::on_chain_floor_to_u64` and both rejection arms plus the
  accept-at-cap case are now unit-tested.
- `test_constructor_revertsOnZeroEpochLength` passed for the wrong reason —
  with a 7-day bond both guards are live, so it only proved ordering. Added the
  case the guard uniquely defends (a bond that itself reports `0`, where the
  mismatch check passes cleanly and the router would otherwise deploy with
  `epochLength() == 0`). Note the foundry gotcha it exposed: a `new` in the
  argument list is a CREATE, so `expectRevert` latches onto the mock instead of
  the router.
- The e2e's `MAX_RATE_PER_MB` was a local literal, so a Rust↔Solidity divergence
  would have failed nothing anywhere. It now uses `decdn_protocol::MAX_RATE_PER_MB`
  and adds the missing accept-at-cap case, making the anvil job — per this
  repo's own convention the only one that catches cross-layer drift — actually
  bind the two constants.
- `setUp` now uses `_deployRouter`, so the shared shares/window values live once.
- `monitoring/prometheus-alerts.yml`'s `DecdnRateBoundsClamp` still described a
  two-sided window and told operators to "update config to within bounds"; the
  runbook says it is raise-only. The alert is what reaches the pager.
- `adr/016` claimed `ContentBlacklist` was the fund-holding exception to
  pausability, contradicting the 6→5 custody correction in the same commit.
- A duplicated "slash-appeal driver" list item in the deploy script's phase
  summary, an orphaned `forge-lint` directive left by the `token` removal, and
  two Solidity cross-references to a "step 8" that no longer exists.
- The `PaymentChannel` NatSpec claimed capping was "the one place" that could
  make the state unrepresentable — no longer true once the node-side guards
  landed in the same commit.

Verification: clippy clean, 2,561 Rust tests, 749 contract tests, gas snapshot
regenerated, ADR anchors clean, both anvil targets and the rate-bounds journey
pass.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@thiras
thiras merged commit c390515 into main Jul 26, 2026
24 checks passed
@thiras
thiras deleted the refactor/protocol-simplifications-batch branch July 26, 2026 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants