Skip to content

feat(contracts): on-chain enumeration views to eliminate event-log replay - #1497

Merged
alpergundogdu merged 5 commits into
mainfrom
feat/capacity-bond-slash-enumeration
Jul 29, 2026
Merged

alpergundogdu merged 5 commits into
mainfrom
feat/capacity-bond-slash-enumeration

Conversation

@thiras

@thiras thiras commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

Why

Every deCDN watcher that has an on-chain enumeration source has zero boot replay. Every watcher that lacks one replays log history. That correlation is exact, and it is the whole problem:

Watcher Cold boot Warm boot
capacity_bond_registry (uses getActiveNodes) 0 0
chain_origin_directory tail (uses getOrigins) 0 0
chain_origin_directory bootstrap whole chain checkpoint−128 → head
blacklist_watcher whole chain degrades to whole chain
buyer_channel reconcile 700k blocks 700k every boot
slash_watcher 10.4M blocks (~1,037 eth_getLogs) same, every boot

The cost is not really the point — the complexity is. Because the deny-set can only be built from events, the node carries a durable projection whose safety argument is "durable entry write first, cursor advance second", and a projection that fails to load must be treated as "replay from the deploy block", because an empty set would fail open on a slashable compliance gate. BlacklistEntryStore, KeyedCheckpointStore, DebouncedCheckpointStore, ColdStart, REORG_MARGIN_BLOCKS, four redb tables and three config knobs all exist to support one missing read.

This PR is the contract half: index what is already stored and expose it. The watcher migrations that consume these — and the deletions they unlock — follow separately.

What

  • CapacityBond — _operatorSlashIds already existed with no getter at all. Exposed as operatorSlashCount / operatorSlashIdAt (two scalars, not a uint256[] return, which costs several hundred bytes of ABI-encoding against a tight EIP-170 ceiling). SlashRecord gains offenseType (free — slot 0 had 3 spare bytes) and evidenceHash, so the record is self-sufficient: Slashed carries the offense but no slashId, SlashRecorded the reverse. slash() takes the digest, which is a SlashJudge → CapacityBond interface change.
  • ContentBlacklist — _regionHashes per region, and _blacklistedAddrs indexing the union of the origin and operator lists (the same disjunction OriginAssignment._isBlacklisted already computes). getScopeRegions returns the 1–3 in-scope keys; it and isHashBlacklistedForOperator now share one extracted _scopeRegions, so the ADR 030 ripening math cannot drift between them.
  • OriginAssignment — _assignedNamespaces. Membership was always readable via getOrigins; the missing key set is the sole reason bootstrap replays AssignmentActivated.
  • PaymentChannel — per-role enumeration. Stored asymmetrically because only the client can reconstruct an id: it knows its own address and nonce, so one slot holding the counterparty suffices; the provider knows neither and must store ids.

Design notes for review

Views return RAW membership, not liveness-filtered. Filtering would put holes in a paginated view — a short page would stop meaning "end of set" — and the only entries dropped would be lapsed emergency ones. Omitting those is the fail-open direction for a compliance gate; returning them merely over-enforces, which is already what a node does today.

Pagination follows the deferredSettlements idiom, including the len - offset clamp — never offset + limit, which overflows on type(uint256).max.

Two of these sets are swap-and-pop, so pages must be read at a pinned block. That is documented on each view and is a hard requirement for the consumer side.

Cost

Contract Runtime Margin left
CapacityBond 23,180 → 23,571 B 1,005 B
ContentBlacklist 11,143 → 12,948 B 11,628 B
OriginAssignment 6,811 → 7,374 B 17,202 B
PaymentChannel 13,963 → 14,802 B 9,774 B

CapacityBond was the binding constraint and was measured before anything was built on it; it fits without the library-extraction fallback.

openChannel is the one user-paid path affected: median 176,942 → 226,448 gas (+49,506), worst case 211,609 → 278,215 (+66,606). That is the floor for this shape — three cold SSTOREs. Storing client ids directly instead cost a further 22.1k on the worst case for no added capability.

Testing

796 Foundry tests (from 772), forge fmt --check, FOUNDRY_PROFILE=ci forge build --sizes --deny warnings, solhint, slither (exit 0), .gas-snapshot regenerated. Rust side: 2,663 tests, cargo clippy --all-targets, cargo fmt --check.

The load-bearing new test is the differential fuzz in ContentBlacklist.t.sol: paging every region getScopeRegions returns must give the same answer as isHashBlacklistedForOperator, for any hash and region configuration. I verified it has teeth by mutating the ripening leg out of the enumeration side — it fails in 21 runs with a counterexample.

The sol! bindings are hand-written and normally only the anvil e2e job catches drift, so all 14 selectors were checked against forge inspect <c> methods, and the SlashRecord tuple against forge inspect CapacityBond abi field by field — a mis-ordered struct decodes silently rather than failing.

Deployment

ADR 016 forbids proxies, so this is a coordinated redeploy of all five affected contracts (SlashJudge included, via the slash() signature). Additive apart from that signature; no existing selector changes.

Follow-ups (not in this PR)

The watcher migrations, then the deletions they unlock: CursorStart collapse, KeyedCheckpointStore / BlacklistEntryStore removal, four redb tables, and the three *_from_block config knobs (a config-BREAKING change). ADR 011 § Polling / § Version sync recovery, ADR 019 § 3.2, and ADR 003 need rewrites to match — ADR 019's "fetch the full current blacklist" becomes satisfiable for the first time.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added paginated enumeration for operator slashes, payment channels, blacklisted content and addresses, and active namespaces.
    • Slash records now include offense types and evidence hashes for improved traceability.
    • Added region-scope discovery for blacklist queries.
    • Added corresponding read interfaces for integrations and monitoring tools.
  • Bug Fixes

    • Improved blacklist indexing consistency when entries are added, removed, expired, or updated.
    • Preserved accurate enumeration across pagination and overlapping blacklist sources.
  • Breaking Changes

    • Slashing calls now require an evidence hash parameter.

thiras and others added 5 commits July 29, 2026 00:09
… the record

`CapacityBond` already kept `_operatorSlashIds` — an append-only per-operator
list of slashIds — but with no getter at all, so nothing could read it. The node
therefore rebuilds its detected-slash view by re-scanning ~30 days of
`SlashJudge.Slashed` logs (10,368,000 blocks, ~1,037 `eth_getLogs`) on *every*
start, warm or cold, because the store is in-memory and no resume cursor can
skip a still-appealable slash.

Expose the list as two scalar getters and persist the two fields the record was
missing, so an operator's slash history is readable directly from chain state.

- `operatorSlashCount(address)` / `operatorSlashIdAt(address, uint256)`.
  Deliberately two scalars rather than one `uint256[]` return: a dynamic-array
  getter costs several hundred bytes of ABI-encoding bytecode and this contract
  sits close to the EIP-170 ceiling. Measured: 23,180 -> 23,571 B runtime, so
  1,005 B of margin remains.
- `SlashRecord` gains `offenseType` (free — slot 0 had 3 spare bytes) and
  `evidenceHash` (new slot), and `slash()` takes the digest. Without them the
  record cannot replace the log: `CapacityBond.Slashed` carries the offense but
  no `slashId`, and `SlashRecorded` carries the `slashId` but no offense, so
  attributing one to the other off-chain means joining two events by transaction
  ordering.

The record's `appealWindowClose` is also the authoritative deadline — it
includes protocol-pause extensions, which the node's current log-derived value
documents itself as ignoring.

No Rust change: nothing binds `slash()`, and `slashRecords()` keeps its 3-tuple
shape. The new views are bound in a follow-up.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
`ContentBlacklist` exposed no enumeration of anything it stores, so events were
the only way to learn the deny-set. That is the premise behind a large amount of
node-side machinery: a full `HashBlacklisted` replay from the deploy block on a
cold boot, a durable projection of every entry ever seen, and the retention of
entries that are currently OUT of scope — because an operator region change
brings them back into scope while emitting nothing on this contract.

Index what is already stored and expose it, so the set can simply be read.

- `_regionHashes` mirrors `_hashEntries[region]`, maintained in the same two
  choke points as `_blacklistVersion` (`_addHash` / `_removeHashRegional`), so
  no call site can add an entry without indexing it.
- `_blacklistedAddrs` indexes the UNION of `_isOriginBlacklisted` and
  `isOperatorBlacklisted` — the same disjunction `OriginAssignment._isBlacklisted`
  already evaluates per address. Reconciled through `_syncAddr`, which re-derives
  from both sources: the two lists are written independently, so mirroring
  whichever one the caller just touched would drop an address that the other
  still holds. This half matters most — the origin list sits outside the
  `getBlacklistVersion()` mechanism, so a consumer has no counter to detect a
  missed update against.
- `getScopeRegions(operator)` returns the 1-3 in-scope region keys. Both it and
  `isHashBlacklistedForOperator` now resolve through one extracted
  `_scopeRegions`, so the region packing and ADR 030 ripening arithmetic cannot
  drift between the enumeration and point-query paths.
- Four paginated views, following the `deferredSettlements` idiom including the
  `len - offset` clamp (never `offset + limit`, which can overflow).

The views return RAW membership, not `_isLive`-filtered. Filtering would put
holes in a paginated view — a short page would stop meaning "end of set" — and
the only entries dropped would be lapsed emergency ones. Omitting those is the
fail-open direction for a compliance gate; returning them merely over-enforces,
which is already what a consumer does today.

Runtime 11,143 -> 12,948 B, leaving 11,628 B of margin.

The differential fuzz is the load-bearing test: paging every region
`getScopeRegions` returns must give the same answer as the point query, for any
hash and region configuration. Verified it has teeth by mutating the ripening
leg out of the enumeration side — it fails in 21 runs with a counterexample.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
`getOrigins(namespaceId)` already made membership within a namespace readable,
but nothing enumerated the KEY SET — which namespaces have origins at all. That
gap is the sole reason a consumer bootstrapping the origin directory has to
replay `AssignmentActivated` from the deploy block: not to learn who the origins
are, only to learn which ids to ask about.

`_assignedNamespaces` closes it. Seated in `_replaceSet` (where the operator
list is non-empty by construction — propose rejects `EmptyOperatorSet`) and
withdrawn by `_pruneEmptyNamespace` once the last operator is revoked or pruned,
so the index means "has origins now", not "was ever assigned", and
`contains(ns)` matches `getOrigins(ns).length > 0` exactly.

Both single-operator removal paths hook the prune — including the permissionless
`pruneBlacklistedAssignment`, which would otherwise leave a fully pruned
namespace lingering in the enumeration forever.

Runtime 6,811 -> 7,374 B against 17 KB of margin.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Neither party could enumerate its own channels. `channelId` is
`keccak256(client, provider, nonce)`, so the provider sits in the preimage; and
`voucherSigner` is in `ChannelOpened`'s data rather than a topic, so signer-side
enumeration was never topic-filterable either. Both roles therefore reconcile by
scanning `ChannelOpened` over a block-range window — the provider to cover its
downtime gap, the client over a fixed 700k-block lookback that silently misses
anything older.

The two roles are stored differently, because only one of them can reconstruct
an id. The CLIENT knows its own address and already has `clientChannelNonce`, so
recording just the counterparty per nonce lets it recompute every id off-chain —
one storage slot, versus the two a `bytes32[]` push costs (element + length).
The PROVIDER knows neither the client nor that client's nonce, so its side has
to store the ids themselves.

Both are append-only and never rewritten, so a settled or closed channel keeps
its entry and the ordering is stable — unlike the swap-and-pop sets in this
file, paging needs no block pinning. A reader resolves current state with
`getChannel(id).status`, which makes reconciliation idempotent.

This is the one place in the enumeration work where cost lands on a user-paid
path, so it was measured rather than estimated. On `openChannel`, median
176,942 -> 226,448 gas (+49,506) and worst case 211,609 -> 278,215 (+66,606).
The worst case is a first channel for both parties, where every slot touched is
cold. That is the floor for this shape: three cold SSTOREs — the client's
counterparty slot, and the provider list's element and length. Storing client
ids directly instead cost a further 22.1k on that worst case for no added
capability.

The trade is that both sides grow with lifetime channel count, so a reader that
skips entries it already knows holds steady state at one page read.

Runtime 13,963 -> 14,802 B against 9.7 KB of margin.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Adds the `sol!` declarations for the views landed in the four contract changes,
so the node can read protocol state directly. No call sites yet — the watcher
migrations consume these next.

- `ContentBlacklist`: `getScopeRegions`, `blacklistedHashes` /
  `blacklistedHashCount`, `blacklistedAddresses` / `blacklistedAddressCount`,
  and `isOriginBlacklisted`. That last one was deleted once as dead node-side
  surface, because the only thing it was for — a per-address boot reconcile —
  had nothing to iterate over. It does now.
- `CapacityBond`: `operatorSlashCount` / `operatorSlashIdAt` / `getSlashRecord`,
  plus the `SlashRecord` struct and the `SlashRecorded` event for the live tail.
- `OriginAssignment`: `assignedNamespaceCount` / `assignedNamespaces`.
- `PaymentChannel`: `providerChannelCount` / `providerChannels` /
  `clientChannels`.

These bindings are hand-written and normally only the anvil e2e job catches
drift, so all 14 selectors were checked against `forge inspect <c> methods` and
the `SlashRecord` tuple against `forge inspect CapacityBond abi` — field order
and types match, which matters because a mis-ordered struct decodes silently
rather than failing.

Also corrects the `OriginBlacklistUpdated` doc, which asserted that the event
tail is "the whole guarantee" because the origin set is not enumerable. It is
now, so the event is a re-read signal rather than the source of truth.

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

coderabbitai Bot commented Jul 29, 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: 179de902-38fb-486f-b3ef-858b86ac7e72

📥 Commits

Reviewing files that changed from the base of the PR and between f4a1572 and fdc9a37.

📒 Files selected for processing (19)
  • contracts/.gas-snapshot
  • contracts/src/CapacityBond.sol
  • contracts/src/ContentBlacklist.sol
  • contracts/src/OriginAssignment.sol
  • contracts/src/PaymentChannel.sol
  • contracts/src/SlashEscrowLib.sol
  • contracts/src/SlashJudge.sol
  • contracts/src/interfaces/ICapacityBondSlasher.sol
  • contracts/test/CapacityBond.t.sol
  • contracts/test/ContentBlacklist.t.sol
  • contracts/test/E2EProtocol.t.sol
  • contracts/test/OriginAssignment.t.sol
  • contracts/test/PaymentChannel.t.sol
  • contracts/test/SlashAppeal.t.sol
  • contracts/test/SlashJudge.t.sol
  • crates/incentive/src/capacity_bond.rs
  • crates/incentive/src/content_blacklist.rs
  • crates/incentive/src/origin_assignment.rs
  • crates/incentive/src/payment_channel.rs

Walkthrough

Changes

Enumeration and slash metadata

Layer / File(s) Summary
Slash metadata and operator history
contracts/src/CapacityBond.sol, contracts/src/SlashEscrowLib.sol, contracts/src/SlashJudge.sol, contracts/src/interfaces/*, crates/incentive/src/capacity_bond.rs, contracts/test/*Slash*.t.sol, contracts/test/CapacityBond.t.sol
Slash calls and records now carry offense and evidence metadata, with per-operator slash enumeration and updated ABI/test coverage.
Blacklist indexes and scope views
contracts/src/ContentBlacklist.sol, crates/incentive/src/content_blacklist.rs, contracts/test/ContentBlacklist.t.sol
Blacklist state now maintains enumerable regional hashes and union addresses, exposes scope/pagination views, and tests live membership consistency.
Namespace and channel enumeration
contracts/src/OriginAssignment.sol, contracts/src/PaymentChannel.sol, crates/incentive/src/origin_assignment.rs, crates/incentive/src/payment_channel.rs, contracts/test/OriginAssignment.t.sol, contracts/test/PaymentChannel.t.sol
Active namespaces and client/provider channel IDs are indexed and exposed through paginated views with corresponding ABI bindings and tests.
Regression gas baselines
contracts/.gas-snapshot
Gas measurements are refreshed and new deployment, blacklist, enumeration, slash, faucet, and token snapshot entries are added.

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

Copy link
Copy Markdown

Contracts coverage

Line coverage: 89.92% (2516/2798 lines)
▲ +0.35pp vs base (89.57% → 89.92%)
Run: 30413832263

@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 adds on-chain, paginated enumeration views (and supporting indices) across the incentive/contracts surface so off-chain watchers can cold-boot from chain state instead of replaying historical event logs. It also makes CapacityBond slash records self-sufficient by persisting offense metadata and threading an evidence digest through the SlashJudge → CapacityBond slashing call.

Changes:

  • Add per-role PaymentChannel enumeration (provider-stored ids; client ids reconstructed from stored counterparties) plus new Foundry tests.
  • Add enumerable key sets for OriginAssignment namespaces and ContentBlacklist hash/address deny sets, with paging and pinned-block caveats where swap-and-pop applies.
  • Extend CapacityBond slashing: add per-operator slash-id enumeration views, persist offenseType + evidenceHash in SlashRecord, and update the slashing interface/callers accordingly.

Reviewed changes

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

Show a summary per file
File Description
crates/incentive/src/payment_channel.rs Updates Alloy sol! bindings to include new PaymentChannel enumeration views.
crates/incentive/src/origin_assignment.rs Updates Alloy bindings with namespace enumeration views for bootstrap without log replay.
crates/incentive/src/content_blacklist.rs Updates Alloy bindings with deny-set enumeration and scope-region views.
crates/incentive/src/capacity_bond.rs Updates Alloy bindings with expanded SlashRecord, new event, and per-operator slash enumeration views.
contracts/src/PaymentChannel.sol Adds on-chain per-role channel enumeration storage + paginated view functions; indexes on openChannel.
contracts/src/OriginAssignment.sol Adds _assignedNamespaces index and paginated enumeration views; maintains index on activation/revoke/prune.
contracts/src/ContentBlacklist.sol Adds _regionHashes + _blacklistedAddrs indices and enumeration views; factors _scopeRegions to share logic with point query.
contracts/src/CapacityBond.sol Extends slash() signature, persists offense/evidence into slash records, and exposes operatorSlashCount/operatorSlashIdAt.
contracts/src/SlashJudge.sol Threads evidenceHash into the CapacityBond slash() call.
contracts/src/SlashEscrowLib.sol Extends SlashRecord with offenseType and evidenceHash and updates minting to persist them.
contracts/src/interfaces/ICapacityBondSlasher.sol Updates slashing interface to include evidenceHash and documents the new persisted fields.
contracts/test/PaymentChannel.t.sol Adds tests covering new per-role channel enumeration semantics and pagination edge cases.
contracts/test/OriginAssignment.t.sol Adds tests asserting namespace index invariants and pagination behavior.
contracts/test/ContentBlacklist.t.sol Adds tests for enumeration views and a differential fuzz test ensuring scope-enumeration matches point-query semantics.
contracts/test/CapacityBond.t.sol Updates slashing call sites for new signature and adds tests for slash enumeration + record persistence.
contracts/test/SlashAppeal.t.sol Updates slashing call sites for new slash() signature.
contracts/test/SlashJudge.t.sol Updates mock slasher to accept/store evidenceHash.
contracts/test/E2EProtocol.t.sol Updates e2e slashing calls for the new signature.
contracts/.gas-snapshot Refreshes gas snapshot to reflect the added indices/views and additional tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions

Copy link
Copy Markdown

Coverage report

Total: 80.79% (was 80.79%, ● 0.00%) — 54697/67701 lines

No coverage data for changed Rust files.

History
Commit Total Δ vs base
fdc9a37 (HEAD) 80.79% ● 0.00%

@alpergundogdu
alpergundogdu merged commit d4632b8 into main Jul 29, 2026
26 checks passed
alpergundogdu added a commit that referenced this pull request Jul 29, 2026
The origin directory now enumerates the namespace set on chain
(assignedNamespaces, #1497) instead of replaying AssignmentActivated, so
this key is no longer read. It is retained only because [blockchain]
denies unknown fields; removing it is a startup-breaking change deferred
until the remaining *_from_block watchers migrate.

Update the three sites that still described it as an active log-replay
knob: the config-type doc comment, the `decdn config` printed line, and
the sample-config comment. Purely documentation — no behavior change.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
alpergundogdu added a commit that referenced this pull request Jul 29, 2026
…r it (#1500)

* refactor(node): read the origin namespace set instead of replaying for it

The origin directory's membership was always authoritative via `getOrigins` —
the bootstrap replays `AssignmentActivated` from a configured floor purely to
learn *which namespace ids exist*, because the key set was not enumerable on
chain. `assignedNamespaces` closes that, so the replay goes away entirely.

`bootstrap_cache` now reads the namespace set at a pinned block and pages it.
Pinning is load-bearing rather than tidiness: the on-chain set removes by
swap-and-pop, so paging across two heights can relocate an unread element into
an already-read slot and skip it silently. The count is re-read at the same
height and a mismatch aborts the snapshot instead of seating a partial set,
which would leave a namespace's authorized origins invisible until its next
live event.

What this deletes, and why each was only there for the replay:

- `REPLAY_WINDOW_BLOCKS` and the windowed `AssignmentActivated` query.
- `replay_floor` / `resume_replay_floor` and the `REORG_MARGIN_BLOCKS` rewind. A
  cross-restart rewind exists to distrust a checkpoint written before a reorg;
  with no checkpoint there is nothing to distrust.
- `CheckpointKey::Origin` persistence, and the ordered shutdown flush that
  existed so a clean stop would not lose a debounce window of scan progress.
  There is no scan progress to lose.
- The inverted-range degradation path (`replay_from > latest` on a lagging RPC)
  and its `origin_directory_bootstrap_range_anomaly` counter. The condition is
  unreachable now — there is no range to invert — and a counter that can never
  increment is worse than none. Nothing in `monitoring/`, `docs/`, or `adr/`
  referenced it.

This also removes a real gap rather than only cost: a namespace assigned while
the node was down used to be missing from the snapshot until its next live
event, because the replay resumed from a persisted cursor. The enumeration
covers all of history on every boot, so it is present immediately.

Verified against a live anvil chain: both G-NODE-08 journeys pass
(authorized-origin gate opening, and revocation reclosing it).

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

* docs(config): mark origin_directory_from_block as ignored

The origin directory now enumerates the namespace set on chain
(assignedNamespaces, #1497) instead of replaying AssignmentActivated, so
this key is no longer read. It is retained only because [blockchain]
denies unknown fields; removing it is a startup-breaking change deferred
until the remaining *_from_block watchers migrate.

Update the three sites that still described it as an active log-replay
knob: the config-type doc comment, the `decdn config` printed line, and
the sample-config comment. Purely documentation — no behavior change.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

* docs: broaden namespace-enumeration mismatch error to not assert one cause

The `seen != count` abort message named swap-and-pop mid-page removal as
the sole cause. Since the pages are pinned by block number, an
inconsistent or reorged RPC view of that block can trip it too. Describe
the invariant violation without asserting a single root cause.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Co-authored-by: Alper Gundogdu <[email protected]>
@alpergundogdu
alpergundogdu deleted the feat/capacity-bond-slash-enumeration branch July 29, 2026 11:17
alpergundogdu added a commit that referenced this pull request Jul 29, 2026
…1504)

Migrates the slash, buyer-reconcile, and blacklist watchers off eth_getLogs replay onto the #1497 enumeration views (enumerate at a pinned block + follow the tail + periodic re-enumeration), removes the three *_from_block config knobs (config-breaking) and the dead replay framework, and aligns ADRs 011/019/003/016 + the observability appendix. Blacklist address-liveness uses the isOriginBlacklisted||isOperatorBlacklisted union; slash appeal deadlines fold in pausedTotal.

Consolidates the deferred follow-ups from #1497/#1498/#1500 so nothing is left outstanding.
thiras added a commit that referenced this pull request Jul 31, 2026
Money-path fixes, plus the doc/config corrections the review turned up.

Re-anchor the paid-frontier baselines per LEG, not per fetch. `content_paid_frontier`
inverts the wire cost of one contiguous delivery from `fetch_start_offset`, but
`committed().bytes` is channel-cumulative. Anchored once per fetch, a second leg fed
it the sum of two bao range encodings, mapping past the true paid frontier: content
skipped unbilled, `byte_offset` beyond the verified prefix, `set_len` zero-extending
the partial, and the whole-file hash check failing an already-paid fetch. The
successful-open arm is now the single anchor point, which subsumes the from-zero
restart case that had its own re-anchor.

Consume `top_up`'s `DepositOutcome` instead of discarding it. `UnknownChannel` /
`ChannelMismatch` mean the topUp mined but the local row was not credited; the only
report was `tracing`, and the CLI installs no subscriber. The old code printed
success, left `ctx.deposit` stale, and on the next pass blamed a nonexistent funder.
Both are now terminal with a reconcile message, and the note reports the amount.

Guard `ChannelLedger::reseed` against watermark regression, mirroring `resolve_ack`.
The node attaches a bundle to every watermark-gated rejection once a voucher has been
accepted, so an exhausted channel echoes our own watermark back; applying it regressed
`committed` and the retry re-signed a spent nonce (the #1122 wedge). Callers now
surface the real rejection instead of spending the resume budget on it.

Apply the two deposit invariants in `resolve_chain`. It resolves the raw [blockchain]
table plus the CLI flags without `resolve_blockchain_into`, so `decdn fetch` accepted
configs `decdn config validate` rejects, and `--initial-deposit-micro-usdc 0` reached
the chain as an opaque ZeroAmount revert.

ADR 003 claimed graduation happens "once the counterparty has served verified bytes".
It does not, and it cannot: gating the refill on an accepted voucher deadlocks against
the seller's pre-serve reserve, which at a stock rate exceeds the default initial
deposit — such a channel is never served, so never earns the proof, so is never
refilled. Verified against the live daemon. The ADR now states the positional bound
the code actually provides, documents the low-water trigger, and drops a contradictory
claim that topUp incurs no gas. The claim was mirrored into four other files.

Also: fix a remediation message naming a flag and config key this branch deleted
(clap now rejects the advice it gives), four more stale references to them, and add
the missing CHANGELOG entry for a rename that is config-, CLI-, and default-breaking.

Tests: per-leg invariant and re-paid-leg overshoot in sink.rs; reseed monotonicity;
resolve_chain validation via config and via flags; a two-top-up anvil-e2e, ignored
because it reproduces a separate pre-existing defect — a mid-stream rejection on a
blob large enough that the node is still sending reaches the client as a write I/O
error, so the reactive top-up never engages at all. Confirmed pre-existing by
stashing every change here and re-running.

Full workspace 2702/2702, anvil-e2e 29/29, clippy -D warnings, fmt, rustdoc clean.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
alpergundogdu added a commit that referenced this pull request Aug 5, 2026
decdn bundle pull buffered each blob via fetch_blob and had no reactive
top-up. It now streams every blob through the same fetch_blob_streaming loop
decdn fetch uses (#1497), into a per-hash staging file under
out_root/.decdn-partial/, and materializes to each destination path by atomic
file-copy — so bundle pull gains reactive mid-fetch top-up AND O(1) memory
(no whole-blob Vec). Both CLI commands now share one paid-pull loop; the
buffered fetch_blob (and the now-dead write_blob_atomic) are deleted.

Once-per-hash fetch-and-pay, per-provider open locks, dedup, and skip-existing
are unchanged. A staging file is left in place on error (resume, same contract
as fetch's .partial) and removed on success. The node keeps its own separate
loop (node_origin/resume.rs) — to re-evaluate later.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
alpergundogdu added a commit that referenced this pull request Aug 5, 2026
…1612)

decdn bundle pull buffered each blob via fetch_blob and had no reactive
top-up. It now streams every blob through the same fetch_blob_streaming loop
decdn fetch uses (#1497), into a per-hash staging file under
out_root/.decdn-partial/, and materializes to each destination path by atomic
file-copy — so bundle pull gains reactive mid-fetch top-up AND O(1) memory
(no whole-blob Vec). Both CLI commands now share one paid-pull loop; the
buffered fetch_blob (and the now-dead write_blob_atomic) are deleted.

Once-per-hash fetch-and-pay, per-provider open locks, dedup, and skip-existing
are unchanged. A staging file is left in place on error (resume, same contract
as fetch's .partial) and removed on success. The node keeps its own separate
loop (node_origin/resume.rs) — to re-evaluate later.

Co-authored-by: Claude Opus 4.8 <[email protected]>
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.

3 participants