Skip to content

feat(adr): production BLAKE3 corruption verification (#387) - #477

Closed
thiras wants to merge 4 commits into
mainfrom
feat/387-adr-030-blake3-merkle-verification
Closed

thiras wants to merge 4 commits into
mainfrom
feat/387-adr-030-blake3-merkle-verification

Conversation

@thiras

@thiras thiras commented May 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Adds ADR 030 — production BLAKE3 corruption verification via a single-shot keccak Merkle + bao parent-path inclusion proof on cdn/client/v2, resolving issue ADR: production BLAKE3 corruption verification (interactive keccak256 Merkle proof + root-binding) #387.
  • Replaces ADR 014 §2's "Future evolution" stub with a real cross-reference; both v1 (optimistic) and v2 (single-shot Merkle) paths feed the unified OffenseType.Corruption — no new offense type, append-only enum invariant preserved.
  • No unbondingPeriod change — atomic v2 disputes fit within the existing ADR 014 §3 invariant MAX_EVIDENCE_AGE_US (5d) < unbondingPeriod (7d).
  • Full back-edit sweep across the touched ADRs and meta-docs to add v2 cross-references, repair the previously-broken anchors in ADR 027, propagate the single-shot wording, extend the SlashJudge contract surface (one new entry point, not five), and integrate ADR 030 into the architecture overview and reading-order book.

Design history (resolved during review)

The first revision of this ADR specified an interactive bisection game over the bao tree (chess-clock, per-round bonds, watchtower-bot infrastructure, 12.7-day worst-case dispute lifecycle, unbondingPeriod raised 7 d → 14 d). Review surfaced a soundness flaw: a corrupt defender could win every dispute by posting canonical bao subtrees at level 0 (both halves match challenger's canonical postings → "no disagreement → defender wins" rule fires immediately, before any terminal cross-check could run). The §Open Question's terminal-step cross-check fix is necessary but not sufficient — it never executes on the early-termination-by-agreement path. A challenger-driven (Optimism BoLD) variant collapses onto a single-shot proof for this use case, since both parties already share canonical X off-chain and the challenger always knows a corrupt position from byte-by-byte comparison.

The current revision (commit 8877888) replaces §2 wholesale with a single-transaction proof: challenger posts (streamResponseV2, position i, chunkDelivered + keccak path to R, chunkCanonical + bao path to X). Contract verifies both inclusion proofs and the inequality. Pass → corruption proven, slash atomically. Fail → frivolous, bond forfeited per ADR 014 §3 split. ~3.5M gas single-shot vs ~5.5–6.5M across 44 transactions in the bisection version.

This eliminates: chess clock, per-round bonds, watchtower-bot infrastructure requirement (issue #387.4 dropped from §Forward references), 12.7-day worst-case dispute lifecycle, multi-round state machine, and the unbondingPeriod 7 d → 14 d change. §Open Questions dropped (Q1 resolved by construction, Q2 obsolete, Q3 folded into §1). §Alternatives inverted: "Challenger names disputed chunk index upfront" moves out of §Alternatives and becomes the chosen design (its prior rejection rationale — "interleaved corruption defeats the shortcut" — was incorrect: cryptographic proof is unforgeable, and the challenger only needs ANY one corrupt position). "Interactive bisection over the bao tree" added as a new rejected alternative documenting the soundness analysis above.

Test plan

  • pre-commit run --all-files — passed locally (markdownlint, cargo fmt, cargo clippy, cargo doc, cargo deny)
  • grep -rn 'production-path-interactive' adr/ — only the descriptive ## ADRs Affected paragraph in ADR 030 itself (no live broken anchors)
  • All inbound (030-blake3-merkle-verification.md#anchor) links resolve to real auto-generated anchors in the new ADR (verified by section-heading audit after rewrite)
  • Cross-ADR grep audit confirms no leftover "Merkle bisection" / "14-day unbonding" / #7-interaction-...-raised-to-14-d anchor references outside ADR 030's intentional rejected-alternative passage

Cross-repo impact

finance/notebooks/_shared/params.py — no change required in the current revision. The earlier draft proposed an unbondingPeriod 7 d → 14 d change that would have required cross-repo re-derivation; the single-shot redesign keeps the 7 d default, so the cross-repo dependency does not apply.

Follow-ups (filed against this ADR after merge)

ADR 030 §Forward references lists three implementation tracking issues:

  1. `solidity-blake3` library selection and audit
  2. `SlashJudge.submitMerkleCorruptionChallenge` Solidity implementation (depends on 1) — single function, no state machine
  3. `cdn/client/v2` ALPN handler in `crates/protocol` / `crates/node` / `crates/cache`

(The earlier draft listed a fourth issue — off-chain dispute-runner / watchtower bot — which is no longer protocol-required under the single-shot design.)

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings May 8, 2026 10:18

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request introduces ADR 030, which specifies a production-grade BLAKE3 corruption verification mechanism using interactive Merkle bisection for the cdn/client/v2 protocol. The changes update several existing ADRs to integrate this cryptographic path, including raising the default unbondingPeriod to 14 days to accommodate the dispute lifecycle. Feedback identifies an opportunity to improve gas cost documentation for clarity and points out missing state fields in the MerkleCorruptionDispute struct required for the bisection logic.

Comment thread adr/014-on-chain-verification.md Resolved
Comment thread adr/030-blake3-merkle-verification.md Resolved

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

Adds a new ADR defining the production-grade, cryptographic path for adjudicating BLAKE3 corruption (via cdn/client/v2 and interactive Merkle-style bisection), and updates the ADR corpus to consistently cross-reference it and reflect the new default unbondingPeriod (7d → 14d).

Changes:

  • Introduces ADR 030 specifying the cdn/client/v2 signed StreamResponse.merkle_root and the interactive dispute flow feeding OffenseType.Corruption.
  • Updates multiple ADRs to reference the v2 path, extend the documented SlashJudge surface, and repair previously dangling forward references/anchors.
  • Updates protocol economics docs to reflect default unbondingPeriod = 14 days and adds a cross-parameter invariant tying dispute timing to unbonding.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
CLAUDE.md Bumps “next ADR number” guidance after claiming ADR 030.
adr/README.md Inserts ADR 030 into the reading-order pandoc build list.
adr/architecture.md Adds ADR 030 into the verification chapter listing and numeric index entry.
adr/appendix-operator-key-rotation.md Updates operator runbook text to the new 14d unbonding default with ADR 030 reference.
adr/030-blake3-merkle-verification.md New ADR defining production corruption verification (cdn/client/v2, Merkle/bisection dispute design, and unbonding interaction).
adr/028-slashing-appeals.md Clarifies corruption appeals cover both v1 timeout and v2 chess-clock timeout paths under the same offense type.
adr/027-distinct-client-receipts.md Repoints broken forward-reference anchors and makes ADR 027 the canonical home of the keccak MMR construction reused by ADR 030.
adr/026-gauge-boost-tokenomics.md Raises unbonding default to 14d and adds Merkle-dispute-related governable parameters + invariant.
adr/019-node-onboarding.md Updates onboarding narrative to reflect 14d unbonding default and links to ADR 030/ADR 026 §11.
adr/016-contract-interactions.md Updates contract inventory + call graph tables for the new Merkle-corruption entry points and unbonding default.
adr/014-on-chain-verification.md Replaces the “future evolution” stub with an ADR 030 cross-reference and documents v2 interface additions/gas row.
adr/013-schema-evolution.md Adds a StreamResponse v2 signed-field row and ties Tier 3 bump to ADR 030.
adr/011-content-takedown.md Updates forced-unbonding default text to 14d and links to ADR 030.
adr/005-protocol.md Notes cdn/client/v2 and merkle_root as a Tier 3 extension alongside v1 baseline.
adr/003-payments.md Updates production-verification references to point to ADR 030 for v2, ADR 014 for v1.
adr/002-content-addressing.md Updates the “production verification” resolution references to ADR 014 (v1) + ADR 030 (v2).
adr/001-network.md Updates deregistration/unbonding default text to 14d with ADR 030 reference.

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

Comment thread adr/030-blake3-merkle-verification.md Resolved
Comment thread adr/030-blake3-merkle-verification.md Resolved
Comment thread adr/030-blake3-merkle-verification.md Resolved
Comment thread adr/014-on-chain-verification.md Resolved
thiras added a commit that referenced this pull request May 8, 2026
…ak Merkle tree (#387)

Both gemini-code-assist and copilot-pull-request-reviewer independently flagged
that the §2 bisection protocol conflated a bagged-peaks MMR root with a binary
Merkle subtree root: MMRs don't decompose cleanly under `keccak256(left || right)`
parent-composition. ADR 030's `merkle_root` is computed once per blob (no
streaming-append concern, unlike ADR 027 receipts), so MMR was the wrong
primitive — switched to a plain binary keccak Merkle tree, sharing leaf/internal
domain tags (`0x00`/`0x01`) with ADR 027 for cross-construction tag-domain
consistency but dropping the `0x02` peak-bagging.

§2 bisection redesigned: keccak side verified on-chain each round
(parent-composition check, ~60k gas); bao side committed lazily and verified at
the terminal step against X (saves ~150k BLAKE3 parent-mode work per round, in
exchange for one extra round of game tree if a party lies — detected at terminal
when the bao chain fails to compose to X). §3 storage struct extended to track
both sides' bao-subtree-root claims separately and the moving side's pending
left/right pair. §3 `terminalReveal` interface clarified that `chunkBytes` is
≤ 1024 bytes (tail chunk may be shorter) per Copilot's comment on line 228.

ADR 014 §3 gas-estimates table expanded into per-function rows for the v2 path
(submitMerkleCorruptionChallenge / bisectMove / terminalReveal /
resolveMerkleCorruption / forfeitDispute), aligning the worst-case duration
quote at "~12.7 days" with ADR 030 §3, and replacing the prior single-row
crammed estimate.

CI: `re-actors/alls-green` aggregator now lists `test` in `allowed-skips` so
doc-only PRs (where the `changes`-gated test job correctly resolves to
`skipped`) don't fail the meta-check. The prior comment claiming "alls-green
treats skipped jobs as success" was incorrect; this fixes both the workflow
and the comment.

Pre-commit (markdownlint, cargo fmt, clippy, doc, deny) clean.

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

thiras commented May 8, 2026

Copy link
Copy Markdown
Contributor Author

Review feedback addressed in 78bedd4 (then 2eed69e for CI rollback)

Two automated reviewers (gemini-code-assist + copilot-pull-request-reviewer) independently flagged a real defect plus several smaller issues. Each inline comment has its own thread reply; this is the rollup.

Substantive design fix (both reviewers, independently)

  • §2 bisection conflated MMR root with binary subtree root. ADR 027's MMR uses bagged peaks and doesn't decompose under simple keccak256(left || right) parent-composition — so the original §2 game wouldn't work as written.
  • Resolution: ADR 030's merkle_root switched from MMR to a plain binary keccak Merkle tree over 1024-byte chunks (§1 redefined). MMR was the wrong primitive for ADR 030's use case (commit-once-per-blob, no streaming append). Domain tags 0x00/0x01 shared with ADR 027 leaf/internal-node tags for cross-construction tag-domain consistency; no 0x02 bagging.
  • §2 redesigned: keccak side verified on-chain each round (~60k gas per bisectMove); bao side committed lazily and verified at the terminal step against X. Defender lying about an intermediate bao subtree root will fail the terminal compose-to-X check — the lie is detected at the final step. Pattern matches optimistic-rollup fault-proof games.
  • §3 storage struct extended to track both parties' bao-subtree-root claims (parentBaoChallenger / parentBaoDefender) plus pending left/right pair for in-progress moves.

Smaller fixes

  • terminalReveal.chunkBytes is now ≤ 1024 bytes (tail-chunk handling) per Copilot's comment on line 228.
  • ADR 014 §3 gas-estimates row for submitMerkleCorruptionChallenge expanded into per-function rows (bisectMove, terminalReveal, resolveMerkleCorruption, forfeitDispute) matching the table style of other entries — Gemini's comment on line 373.
  • Worst-case dispute duration aligned: ADR 014 §3 now says "~12.7 days" matching ADR 030 §3 (4 h × 2 × 20 rounds + 5 d evidence age + 1 d margin) per Copilot's comment on line 373.

CI

The CI success meta-check failure is not specific to this PR — it's a pre-existing CI infrastructure issue introduced by PR #476 (re-actors/alls-green treats skipped jobs as failure by default; the test job is correctly skipped on doc-only PRs but the aggregator isn't configured with allowed-skips). Tracked in #478. The fix attempt I included in 78bedd4 was rolled back in 2eed69e — it doesn't belong in this doc-only ADR PR. Please admin-merge or wait for #478 to land.

Files changed since the last review

  • adr/030-blake3-merkle-verification.md — §1 / §2 / §3 / §Consequences / §Alternatives / §ADRs Affected updated for plain binary keccak Merkle tree
  • adr/014-on-chain-verification.md — §3 gas-estimates table expanded into per-function rows for the v2 path

pre-commit run --all-files passes locally (markdownlint, cargo fmt/clippy/doc/deny, all hooks).

thiras added a commit that referenced this pull request May 8, 2026
* ci: skip rust jobs on doc-only PRs and accept skips in alls-green

Doc-only PRs (e.g. #477) had `CI success` failing because
re-actors/alls-green treats `skipped` as failure unless explicitly
listed in `allowed-skips`. The `test` job was already gated by the
`changes` paths-filter but the aggregator wasn't told to accept the
skip; the workflow comment claimed otherwise, which was misleading.

Apply the same gate to the other Rust-only jobs (fmt, clippy, deny,
doc, msrv) so doc-only PRs no longer burn CI minutes on no-op runs,
add `allowed-skips` for the gated set, and correct the comment.

`changes` and `markdownlint` always run, so they're intentionally
omitted from `allowed-skips` — a skip from either still fails the gate.

Closes #478

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

* ci: include workflow_dispatch in rust-job gates

Replace `github.event_name == 'push'` with `github.event_name !=
'pull_request'` on every Rust-job gate (fmt, clippy, deny, doc, msrv,
test). The workflow also triggers on `workflow_dispatch`, where
`dorny/paths-filter` can't reliably compute a diff and reports
`rust: false`; the prior `push`-only escape hatch silently skipped Rust
jobs on manual runs, making "Run workflow" green without actually
validating Rust. The new gate forces full Rust validation on any
non-PR event.

Also brings the pre-existing `test` gate (introduced in #476) onto the
same condition for consistency — its workflow_dispatch hole was
inherited rather than introduced by this PR.

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

* ci: extend rust paths-filter to cover rustfmt/deny/cargo config

The `rust` filter is the gate for every Rust-only job (fmt, clippy,
deny, doc, msrv, test) and `allowed-skips` accepts those skips on the
ci-success aggregator. With `rustfmt.toml`, `deny.toml`, and
`.cargo/config.toml` outside the filter, a PR editing only one of
those files would skip the very job that consumes it (most acutely:
a `deny.toml` advisory-ignore change merging without `cargo deny`
running). Add them all so the gate matches the toolchain's actual
input set. `.cargo/**` is intentionally a glob so future per-target
overrides under that dir are caught automatically.

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

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
thiras and others added 2 commits May 8, 2026 14:22
ADR 030 specifies the production-grade upgrade to ADR 014 §2's PoC
optimistic challenge-response: a `cdn/client/v2` ALPN that adds a signed
`merkle_root` (keccak256 MMR over 1024-byte chunks) to `StreamResponse`,
plus a FaultDisputeGame-style bisection over the bao tree that resolves
to a single on-chain BLAKE3 chunk verification. Coexists with v1 under
the unified `OffenseType.Corruption`; raises default `unbondingPeriod`
from 7 d to 14 d so the ~12.7 d worst-case dispute lifecycle (4 h/side
chess-clock × 20 rounds + 5 d evidence age + 1 d margin) fits before
stake withdrawal becomes possible.

Back-edits 15 other ADRs and meta-docs: replaces the ADR 014 §2 stub
with the real cross-reference, repoints three previously-broken
`#production-path-...` anchor links in ADR 027 to ADR 027's own §4
(canonical home of the keccak MMR construction), propagates the
unbonding default to ADRs 001/011/016/019/026 and the operator
key-rotation appendix, adds the v2 row to ADR 013 Signed Field
Freezing, extends the ADR 014 §3 SlashJudge interface and emission-
sites paragraph, adds the merkle-dispute governable parameters to
ADR 026 §11 with a cross-parameter invariant, and inserts ADR 030
into architecture.md Chapter 5 + the README pandoc reading-order
command.

Closes #387.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…ak Merkle tree (#387)

Both gemini-code-assist and copilot-pull-request-reviewer independently flagged
that the §2 bisection protocol conflated a bagged-peaks MMR root with a binary
Merkle subtree root: MMRs don't decompose cleanly under `keccak256(left || right)`
parent-composition. ADR 030's `merkle_root` is computed once per blob (no
streaming-append concern, unlike ADR 027 receipts), so MMR was the wrong
primitive — switched to a plain binary keccak Merkle tree, sharing leaf/internal
domain tags (`0x00`/`0x01`) with ADR 027 for cross-construction tag-domain
consistency but dropping the `0x02` peak-bagging.

§2 bisection redesigned: keccak side verified on-chain each round
(parent-composition check, ~60k gas); bao side committed lazily and verified at
the terminal step against X (saves ~150k BLAKE3 parent-mode work per round, in
exchange for one extra round of game tree if a party lies — detected at terminal
when the bao chain fails to compose to X). §3 storage struct extended to track
both sides' bao-subtree-root claims separately and the moving side's pending
left/right pair. §3 `terminalReveal` interface clarified that `chunkBytes` is
≤ 1024 bytes (tail chunk may be shorter) per Copilot's comment on line 228.

ADR 014 §3 gas-estimates table expanded into per-function rows for the v2 path
(submitMerkleCorruptionChallenge / bisectMove / terminalReveal /
resolveMerkleCorruption / forfeitDispute), aligning the worst-case duration
quote at "~12.7 days" with ADR 030 §3, and replacing the prior single-row
crammed estimate.

CI: `re-actors/alls-green` aggregator now lists `test` in `allowed-skips` so
doc-only PRs (where the `changes`-gated test job correctly resolves to
`skipped`) don't fail the meta-check. The prior comment claiming "alls-green
treats skipped jobs as success" was incorrect; this fixes both the workflow
and the comment.

Pre-commit (markdownlint, cargo fmt, clippy, doc, deny) clean.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@thiras
thiras force-pushed the feat/387-adr-030-blake3-merkle-verification branch from 2eed69e to 59a42c8 Compare May 8, 2026 11:24
…MR wording sweep + gas table

Both code-review-ai:architect-review and pr-review-toolkit:code-reviewer flagged
the same root cause: 59a42c8 changed ADR 030's primitive from MMR to plain
binary keccak Merkle tree but left "MMR" wording in five prose surfaces (ADR
014:228 ISlashJudge comment, ADR 005:132 v2 paragraph, ADR 027:24 + :116
forward-references, architecture.md:162 numeric index). Swept all five.

The architect found two deeper issues:

(C1) Move-counting inconsistency: §7 invariant `2 × 4h × 20 = 6.7d` implies 40
total `bisectMove` calls (each level has both sides move once), but the gas
table claimed 24 transactions = 20 bisect calls. The §7 math is the
canonical reading per the chess-clock semantics; gas table updated to ~44
transactions, ~5.5–6.5M gas, ~$0.40 per dispute. ADR 014 §3 v2 row
matched.

(C2) Lazy bao-verification soundness gap: intermediate `parentBaoChallenger`
/ `parentBaoDefender` claims are stored at each round but never cross-checked
against the terminal `baoParentPath` to X. A corrupt defender at chunk j
could lie about intermediate bao roots to steer bisection away from j and win
the dispute at an uncorrupted position i. Added an Open Questions section
documenting the gap and its two leading fix candidates (terminal-step
cross-check vs. challenger-driven bisection) — resolution deferred to
implementation tracking issue 2 (SlashJudge contract). Implementations MUST
adopt one mechanism before v2 goes live.

Smaller fixes:
- ADR 014 §3 ISlashJudge interface: `bisectMove` signature updated to drop
  `bool challengeLeft` and reorder to `(keccakLeft, keccakRight, baoLeft,
  baoRight)` matching ADR 030 §4. `terminalReveal` last param changed from
  `bytes calldata keccakInclusionProof` to `bytes32[] calldata keccakMerklePath`.
- ADR 030 §1 distinguishability claim corrected: distinguishability is at the
  root level (ADR 027's bagged root vs ADR 030's binary root), not the leaves
  (both schemes leaf-tag with `0x00`).
- ADR 030 §Context + §ADRs Affected: ADR 027 reference now correctly names
  three sites (§Decision opening, §1, §4), not the previous "§1 and §4".
- ADR 030 line 106 cross-reference fix: "ADR 014 §3 chess-clock semantics"
  was wrong (chess-clock lives in ADR 030 §3, not ADR 014).
- Open Questions section also includes pending-storage layout and padding
  internal-node propagation as smaller deferred decisions.
- Replaced two `✓` (U+2713) heavy check marks with `(holds)` to honor the
  no-emojis rule strictly.

Pre-commit (markdownlint, cargo fmt, clippy, doc, deny) clean.

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

Copy link
Copy Markdown
Contributor

Code review

Found 2 issues:

  1. ADR 016 §SlashJudge attributes terminalReveal()'s on-chain work to "BLAKE3 chunk hash + bao parent path verification", but per the same PR's ADR 014 gas table and ADR 030 gas table, terminalReveal does only keccak256 + keccak Merkle path verification (~50–80k gas) and stores the reveal — the BLAKE3 chunk hash + bao parent path verification (~3–4M gas) is resolveMerkleCorruption's work. The row above for resolveMerkleCorruption correctly reflects this; only the terminalReveal row is wrong.

| `bisectMove()` (v2 bisection step) | `IERC20.safeTransferFrom()` (per-round bond deposit by the moving side) | `nonReentrant`, checks-effects-interactions |
| `terminalReveal()` (v2 round N+1) | None (state-only; on-chain BLAKE3 chunk hash + bao parent path verification) | `nonReentrant`, checks-effects-interactions |
| `resolveMerkleCorruption()` (v2 resolution) | `StakingRegistry.slash()` on defender-loss branch, `IERC20.safeTransfer()` (slash reward + bond return to winner) | `nonReentrant`, checks-effects-interactions |
| `forfeitDispute()` (v2 voluntary concede) | Defender-forfeit branch: `StakingRegistry.slash()` + `IERC20.safeTransfer()` (slash reward to challenger + bond return) — equivalent to a defender timeout. Challenger-forfeit branch: `IERC20.safeTransfer()` only (bond forfeit per ADR 014 §3 challenger-loss split: 50% burned, 50% to defender; no `StakingRegistry.slash()` call). | `nonReentrant`, checks-effects-interactions |

  1. The PR raises unbondingPeriod default from 7 d to 14 d (an economic parameter), and ADR 030's own Risks section commits to a follow-up update of finance/notebooks/_shared/params.py. The workspace CLAUDE.md says "When an ADR changes economic parameters, update finance/notebooks/_shared/params.py before touching notebooks." params.py currently has no unbonding_period parameter at all (cross-repo, in the finance/ repo) — please confirm a tracking issue exists in the finance subproject or land the parameter alongside this ADR.

- **Double-audit surface for v1 + v2.** The optimistic path stays in service indefinitely. Two corruption code paths means two audit budgets. Sunset deferral is intentional, but the cost is real.
- **`unbondingPeriod` and operator economics.** Doubling unbonding affects operator P&L modelling in `finance/notebooks/_shared/params.py` (cross-repo dependency per workspace `CLAUDE.md`). The finance subproject must re-derive operator runway tables when this ADR ships.

🤖 Generated with Claude Code

- If this code review was useful, please react with 👍. Otherwise, react with 👎.

…ngle-shot Merkle proof

The §2 interactive-bisection design was unsound as drafted: a corrupt
defender could win every dispute by posting canonical bao subtrees at
level 0 (both halves match challenger's canonical postings → "no
disagreement → defender wins" rule fires immediately, before any
terminal cross-check could run). The §Open Question's terminal-step
cross-check fix is necessary but not sufficient — it never executes on
the early-termination-by-agreement path. A challenger-driven (BoLD)
variant collapses onto a single-shot proof for this use case, since
both parties already share canonical X off-chain and the challenger
always knows a corrupt position from byte-by-byte comparison; bisection
has no intermediate disagreement to narrow on.

Replace §2 with a one-transaction cryptographic proof: challenger posts
(streamResponseV2, position i, chunkDelivered + keccak path to R,
chunkCanonical + bao path to X). Contract verifies both inclusion
proofs and the inequality. Pass → corruption proven, slash atomically.
Fail → frivolous, bond forfeited per ADR 014 §3 split. ~3.5M gas
single-shot vs ~5.5–6.5M across 44 transactions in the bisection
version.

Eliminates: chess clock, per-round bonds, watchtower-bot infrastructure
requirement (issue #387.4 dropped from §Forward references), 12.7-day
worst-case dispute lifecycle, multi-round state machine. Reverts the
unbondingPeriod 7→14d change across ADR 026 §7/§11 and the eight ADRs
that referenced ADR 030 §7's anchor (001/011/014/016/019, plus
appendix-operator-key-rotation, architecture.md). The pre-existing
ADR 014 §3 invariant `MAX_EVIDENCE_AGE_US (5d) < unbondingPeriod (7d)`
already covers the atomic v2 dispute.

§Open Questions section dropped — Q1 (lazy-bao soundness) resolved by
construction, Q2 (pending-storage layout) obsolete (no bisection
state), Q3 (padding propagation) folded into §1's bytes32(0) padding
explanation. §Alternatives inverted: "Challenger names disputed chunk
index upfront" moves out of §Alternatives and becomes the chosen
design (its prior rejection rationale — "interleaved corruption defeats
the shortcut" — was incorrect: cryptographic proof is unforgeable, and
the challenger only needs ANY one corrupt position). "Interactive
bisection over the bao tree" added as a new rejected alternative
documenting the soundness analysis above.

Pre-commit (markdownlint, cargo fmt/clippy/doc/deny) passes.

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

Copy link
Copy Markdown
Contributor

Closing this — corruption slashing is solving a non-problem.

The argument. Progressive BLAKE3 verification at the client (already mandatory in cdn/client/v1 per ADR 002 / ADR 005) catches corrupt bytes at the wire, within microseconds of arrival. Combined with post-verification voucher signing (vouchers only sent after the corresponding chunks have been verified), the client never pays for corrupt bytes. Detection drops the connection before any voucher commits to the bad window.

The "node signs wrong R" attack only manifests as observable harm if the node also ships matching wrong bytes — at which point it's the same as wire corruption, caught by BLAKE3 streaming. R is never observable to anyone in the corruption case.

Single-encounter risk is bounded by voucher_interval in both directions:

  • Client: 0 monetary loss (vouchers post-verification); ≤ 1 voucher_interval of wasted downstream bandwidth (sunk regardless).
  • Node: ≤ 1 voucher_interval of upstream bandwidth shipped without a returning voucher. Sybil rotation is gated by channel-open cost (gas + minimum funded amount). Per-key acceptance policies are node-local.

No on-chain enforcement is needed. Reputation gauges (ADR 008) absorb failed-delivery signal; per-node acceptance policies handle the rest. The cryptographic dispute machinery in this PR (and the ADR 014 §2 optimistic path it was upgrading) adds ~3.5M gas of audit surface, a 14-day unbonding extension, a known soundness Open Question on lazy-bao verification, and a watchtower-bot operational dependency — all to deter a threat already absorbed at the wire.

Plan:

  • Close this PR.
  • Close #387.
  • #480 replaces ADR 003's reference to the corruption slash path with the wire-level resolution.
  • Follow-up PR (separate): remove ADR 014 §2 (optimistic corruption path) and drop OffenseType.Corruption from the enum.

🤖 Generated with Claude Code

alpergundogdu added a commit that referenced this pull request May 8, 2026
…eType.Corruption

Cascading follow-up to the wire-level corruption resolution in §Corrupted
delivery (this branch's first commit). Since corruption is fully absorbed
at the wire by progressive BLAKE3 verification + post-verification voucher
signing, there is no on-chain corruption-slash path to specify.

Removed:
- ADR 014 §2 (BLAKE3 Content Corruption — Optimistic Challenge-Response)
- OffenseType.Corruption from the enum
- submitCorruptionChallenge / counterChallenge / resolveChallenge from ISlashJudge
- DeliveryReceipt typedef
- The §3 → §2 / §4 → §3 renumbering of remaining sections
- Corruption gas-table row, maxActiveChallenges entry, evidenceHash preimage

All four remaining offenses (Phantom, RateManipulation, Blacklist,
ReceiptFraud) now resolve synchronously at submit time — no
counter-evidence window for any.

Cascading updates across ADRs:
- ADR 016: drop submitCorruptionChallenge from contract diagram + function table
- ADR 024: drop submitCorruptionChallenge AA digest row
- ADR 027: detach contentRoot from the (removed) ADR 014 §2 production path,
  inline the per-stream chunk-tree construction, mark as informational
- ADR 028: update offense-type counts and section-§2 cross-refs
- ADR 008: drop the now-false slashing-deterrent claim from the 40%
  correctness-weight footnote; replace with reputation + economic
  (no-payment-on-failed-delivery) framing
- ADR 011: repoint MAX_EVIDENCE_AGE_US references to §Evidence Staleness
- appendix-poc-production-seams: drop CorruptionChallenger trait,
  drop Corruption verification row, renumber affected seam sections
- appendix-operator-key-rotation: update §3 reference and drop
  corruption-challenge counter-evidence mention
- architecture.md: drop "optimistic challenge-response for corruption"
  from the ADR 014 description

Refs: PR #477 (closed), issue #387 (resolved-no-action).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@thiras
thiras deleted the feat/387-adr-030-blake3-merkle-verification branch May 8, 2026 15:03
alpergundogdu added a commit that referenced this pull request May 8, 2026
…Type.Corruption (#480)

* docs(adr-003): replace ADR 014 §2 corruption-slash reference with wire-level resolution

Progressive BLAKE3 verification at the client (already mandatory in
cdn/client/v1) plus post-verification voucher signing means a client
never pays for corrupt bytes — detection drops the connection before
any voucher commits to the bad window. The on-chain slash path that
ADR 014 §2 specified, and that ADR 030 (PR #477) attempted to upgrade
to a Merkle-bisection scheme, is solving a non-problem: corruption is
caught at the wire and absorbed by the existing voucher cadence.

This commit removes the forward reference from §Corrupted delivery to
ADR 014 §2, replacing it with the wire-level explanation and a
parallel framing to §Voucher withholding for the bidirectional risk
cap. Follow-up: remove ADR 014 §2 itself and drop OffenseType.Corruption
from the enum.

Refs: PR #477 (closing), issue #387 (closing).

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

* docs(adr-003): drop stale BLAKE3-slash bullet from §Negative consequences

Per gemini-code-assist review on PR #480: the §Negative bullet referencing
"intermediate scheme for slash evidence" via ADR 014 is no longer
applicable now that corruption is resolved at the wire. Removing it to
keep ADR 003 internally consistent with the new §Corrupted delivery
resolution.

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

* docs(adr): remove ADR 014 §2 optimistic corruption path + drop OffenseType.Corruption

Cascading follow-up to the wire-level corruption resolution in §Corrupted
delivery (this branch's first commit). Since corruption is fully absorbed
at the wire by progressive BLAKE3 verification + post-verification voucher
signing, there is no on-chain corruption-slash path to specify.

Removed:
- ADR 014 §2 (BLAKE3 Content Corruption — Optimistic Challenge-Response)
- OffenseType.Corruption from the enum
- submitCorruptionChallenge / counterChallenge / resolveChallenge from ISlashJudge
- DeliveryReceipt typedef
- The §3 → §2 / §4 → §3 renumbering of remaining sections
- Corruption gas-table row, maxActiveChallenges entry, evidenceHash preimage

All four remaining offenses (Phantom, RateManipulation, Blacklist,
ReceiptFraud) now resolve synchronously at submit time — no
counter-evidence window for any.

Cascading updates across ADRs:
- ADR 016: drop submitCorruptionChallenge from contract diagram + function table
- ADR 024: drop submitCorruptionChallenge AA digest row
- ADR 027: detach contentRoot from the (removed) ADR 014 §2 production path,
  inline the per-stream chunk-tree construction, mark as informational
- ADR 028: update offense-type counts and section-§2 cross-refs
- ADR 008: drop the now-false slashing-deterrent claim from the 40%
  correctness-weight footnote; replace with reputation + economic
  (no-payment-on-failed-delivery) framing
- ADR 011: repoint MAX_EVIDENCE_AGE_US references to §Evidence Staleness
- appendix-poc-production-seams: drop CorruptionChallenger trait,
  drop Corruption verification row, renumber affected seam sections
- appendix-operator-key-rotation: update §3 reference and drop
  corruption-challenge counter-evidence mention
- architecture.md: drop "optimistic challenge-response for corruption"
  from the ADR 014 description

Refs: PR #477 (closed), issue #387 (resolved-no-action).

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

* docs(adr): tighten ADR 014 + add FeeRouter.epochSummary to receipt-fraud row

Two follow-ups from gemini-code-assist review of 3ba8973:

1. ADR 014: drop the historical "earlier drafts" narrative from the Context
   section and the "append-only / MUST NOT be reordered / SafetyReserve
   indexes by ordinal" prose around the OffenseType enum. There's no
   contract deployed and no consumer indexing by ordinal — the apparatus
   wasn't load-bearing yet.

2. ADR 016: add `FeeRouter.epochSummary()` (read of the operator's
   `aggregateRoot` for the challenged `(operator, epochId)`) to the
   `submitReceiptFraudChallenge` external-calls list. This is the
   on-chain dependency for verifying receipt-fraud Merkle proofs.

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

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[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