Repository navigation
feat(contracts): vetted-publisher instant origins (#1491) - #1548
Conversation
Origin authorization used to couple two decisions in one flow: a publisher proposed a whole operator set, and governance ratified it after a timelock. Every routine add therefore needed a governance vote, and activation re-validated the already-serving origins — so a transient failure on a live origin blocked seating a redundant one (#1107), and the flow was far too heavy for routine origin management (#1113). Split the two questions into two planes. Governance vets the publisher WALLET once (`requestVetting` -> timelock -> `grantVetting`, or the instant `setPublisherVetted` override). The vetted publisher then seats and unseats origins for its own namespaces itself, one operator at a time, effective in the transaction that carries them. Backstops stay reactive: `removeOrigin`, blacklist + prune, plus a proactive un-vet. Contracts: `proposeAssignment` / `activateAssignment` / `cancelAssignmentProposal` / `getPendingAssignment` and the pending state are gone; `addOrigin` is the single "origin seated" path and emits the single `OriginAdded` event. `revokeAssignment` -> `removeOrigin`, `pruneBlacklistedAssignment` -> `pruneBlacklistedOrigin`, `assignmentTimelock` -> `vettingTimelock` (same 24h-14d bounds, same 3-day default). `IPublisherRegistryOwnership` gains `namespaceCount`. Node: the origin-directory watcher follows the renamed events and drops the `AssignmentActivated` arm. Read semantics are unchanged — every event is still only a signal to re-read the authoritative `getOrigins`, fail-closed. CLI: new `publish request-vetting` and `publish revoke`; `publish assign` now sends one `addOrigin` per operator, stops at the first revert, and prints the seats that landed before propagating the error. ADR 011 § Origin Assignment Authority is rewritten to the two-plane model, with ADR 016 and the ADR 009 parameter row following. Closes #1491 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
) Multi-agent review of the branch surfaced five real defects and a set of prose survivors the rename sweep did not reach. CLI (`decdn publish`), the highest-severity cluster: - `assign` collapsed three distinct `send_for_receipt` failure shapes into one and printed `unseated` for an operator whose transaction had been broadcast but whose receipt could not be read. That is the anti-pattern `tx.rs` documents: telling an operator to re-run a transaction that may still be pending. Seats are now modelled per operator as seated / in_flight / reverted / not_attempted, the in-flight hash reaches the receipt, and `status=unknown` outranks every other status. - The stdout-write `?` could return before the chain error was built, so a broken pipe (`| head -1`) hid the revert entirely — defeating the whole point of printing the receipt first. A shared `propagate` helper now keeps the chain error ahead of any write error. - `status` reported `partial` when nothing landed, which is the modal failure (an unvetted signer); it now reports `failed`. - `request-vetting` discarded its tx hash on any post-receipt decode failure, while telling the operator to look up a hash it never printed. Contracts: - `addOrigin` checked the cap before the duplicate, so re-adding a seated operator at cap reverted `TooManyOrigins` with a count the set never reaches — contradicting ADR 011. Duplicate is now checked first. - `addOrigin` now checks `isVettedPublisher` before the cross-contract `ownerOf` read: it is the blocking prerequisite and a local SLOAD. - `setPublisherVetted` emits `VettingRequestCancelled` when it clears a pending request, so the log stream no longer requires a consumer to know that `PublisherVetted` is also a pending-request terminator. Tests: freeze the vetting/enumeration selectors that the Rust bindings bind by hand; probe the `isVettedPublisher` mapping getter against the live ABI (`InterfaceFreeze` cannot freeze a public variable); ripen the request in the un-vet-clears-pending test, which otherwise passes against an implementation that only clears un-ripened ones; assert the node actually consumes `OriginAdded` (its indexed arity changed and an undecodable log is swallowed by design); cover the partial-seat path end to end; plus the `setContentBlacklist` success path, post-removal pagination, and both governance-parameter ceilings. Prose: ADR 009's rationale bullet still described the removed flow, ADR 011 contradicted itself on the blacklist union being two reads, ADR 016's matrix under-reported `namespaceCount`, and `decdn publish --help` still advertised proposing operator sets. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Warning Review limit reached
Next review available in: 6 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Free Run ID: 📒 Files selected for processing (9)
WalkthroughOrigin authorization now uses governance-vetted publishers and immediate per-origin seating. The CLI adds vetting and revoke workflows. Contracts, e2e helpers, node watchers, tests, gas snapshots, and ADRs reflect the new APIs and events. ChangesOrigin authorization workflow
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant Publisher
participant CLI
participant OriginAssignment
participant PublisherRegistry
participant CapacityBond
participant ContentBlacklist
participant OriginWatcher
Publisher->>CLI: request-vetting
CLI->>OriginAssignment: requestVetting()
OriginAssignment-->>CLI: VettingRequested with readyAt
Publisher->>CLI: assign operators
CLI->>OriginAssignment: addOrigin(namespaceId, operator)
OriginAssignment->>PublisherRegistry: validate ownership and namespace count
OriginAssignment->>CapacityBond: validate active bond
OriginAssignment->>ContentBlacklist: validate blacklist status
OriginAssignment-->>OriginWatcher: OriginAdded
Publisher->>CLI: revoke operator
CLI->>OriginAssignment: removeOrigin(namespaceId, operator)
OriginAssignment-->>OriginWatcher: OriginRemoved
Note 🎁 Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login. Comment |
There was a problem hiding this comment.
Pull request overview
This PR replaces the old per-namespace propose→timelock→governance-activate origin assignment flow with a two-plane model: (1) governance vets a publisher wallet once (cold path), and (2) a vetted publisher seats/unseats origins instantly per operator (hot path). It updates the Solidity contract surface and events, migrates the node’s chain-backed origin directory watcher to the new events, and updates CLI + e2e coverage and ADRs/CHANGELOG to match the new semantics.
Changes:
- Implement publisher vetting lifecycle (
requestVetting/grantVetting/override) and instant origin seating (addOrigin/removeOrigin) inOriginAssignment, with renamed events and updated interfaces. - Update node origin-directory watcher and bindings to consume
OriginAdded/OriginRemoved/BlacklistedOriginPrunedand to rely on authoritativegetOriginsre-reads. - Extend CLI
decdn publishwithrequest-vetting+revoke, changeassignto per-operator transactions with richer receipt reporting, and update anvil e2e + ADR docs accordingly.
Reviewed changes
Copilot reviewed 33 out of 33 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/node/src/metrics.rs | Updates metric doc wording to reflect “seating” semantics. |
| crates/node/src/dht/origin.rs | Updates DHT origin cache doc to new OriginAssignment event names. |
| crates/node/src/dht/chain_origin_directory.rs | Switches watcher event decoding/dispatch to OriginAdded/Removed/Pruned and updates docs/tests accordingly. |
| crates/node/src/chain_events/resumable_watcher.rs | Updates watcher cursor comment/tests to reflect removal of durable origin cursor usage. |
| crates/node/src/chain_events/backfill.rs | Updates backfill module docs to reflect removal of origin seating replay consumers. |
| crates/incentive/src/store.rs | Updates checkpoint key documentation given origin watcher no longer persists a cursor. |
| crates/incentive/src/origin_assignment.rs | Updates Alloy sol! bindings and docs to match vetting + instant seating surface/events. |
| crates/e2e/tests/g_origin_01_publish.rs | Updates e2e doc comment to new vetting + seated-origin flow. |
| crates/e2e/tests/cli_publish.rs | Expands anvil e2e to cover request-vetting, instant seat/unseat, partial multi-operator seating, and node metric assertions. |
| crates/e2e/src/time.rs | Updates timelock helper comment to include publisher vetting. |
| crates/e2e/src/chain.rs | Updates chain fixture helpers to call addOrigin/removeOrigin and adds vetting helpers (fast + timelock path). |
| crates/e2e/src/bindings.rs | Updates e2e bindings for new OriginAssignment functions (vetting + add/remove). |
| crates/common/src/cli/publish.rs | Adds request-vetting and revoke CLI args; updates assign semantics and parser tests. |
| crates/common/src/cli/mod.rs | Re-exports new publish CLI arg structs. |
| crates/cli/src/commands/publish.rs | Implements request-vetting and revoke; changes assign to N tx loop with per-operator outcome reporting and improved error/receipt ordering. |
| contracts/test/OriginAssignment.t.sol | Rewrites contract tests for vetting lifecycle, instant add/remove, blacklist/prune behavior, and namespace enumeration invariants. |
| contracts/test/InterfaceFreeze.t.sol | Updates ABI-freeze assertions for new/renamed selectors and new enumeration + vetting views. |
| contracts/src/OriginAssignment.sol | Core contract rewrite: adds vetting plane, replaces propose/activate with add/remove origin, renames events, keeps enumerable namespace index. |
| contracts/src/interfaces/IPublisherRegistryOwnership.sol | Adds namespaceCount view required for vetting request gating. |
| contracts/src/interfaces/IContentBlacklistOriginView.sol | Updates interface docs to match addOrigin/pruneBlacklistedOrigin usage. |
| contracts/src/ContentBlacklist.sol | Updates reference in docs to renamed prune function. |
| contracts/.gas-snapshot | Updates gas snapshot after contract/test changes. |
| CHANGELOG.md | Documents breaking changes for OriginAssignment ABI and CLI publish behavior. |
| adr/glossary.md | Updates OriginAssignment glossary definition to vetting + instant seating model. |
| adr/architecture.md | Updates high-level architecture text for new origin authorization model. |
| adr/022-content-discovery.md | Updates discovery ADR wording to vetting wait semantics. |
| adr/019-node-onboarding.md | Updates onboarding ADR to reference addOrigin + vetted publisher requirement. |
| adr/016-contract-interactions.md | Updates contract inventory, wiring notes, and interaction diagrams for new functions/events. |
| adr/011-content-takedown.md | Rewrites OriginAssignment authority section to two-plane vetting/seating model and updates lifecycle/edge cases. |
| adr/009-governance.md | Renames governable parameter row to “Publisher vetting timelock”. |
| adr/003-payments.md | Updates origin authorization description to reflect vetted publisher seating. |
| adr/002-content-addressing.md | Updates namespace/origin governance description to vetted publisher seating model. |
| adr/001-network.md | Updates network-level description of origin governance to reflect wallet vetting + publisher seating. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contracts coverageLine coverage: 89.80% (2597/2892 lines) |
Gas snapshotNo gas changes vs base. |
Coverage reportTotal: 80.10% (was 80.13%, ▼ 0.03%) — 56135/70085 lines
History
|
Two findings from the PR review, both confirmed against the code. `addOrigin` performed `set.add` before the cap check, so an add against a full namespace paid two SSTOREs and then reverted — a revert refunds the gas left, not the gas already spent. Read both guards first (`contains`, then `length`) and write only on the success path. The error precedence is unchanged: a duplicate still outranks the cap, which is what ADR 011 promises, and `TooManyOrigins` again reports the would-be count. `revoke` called `send_for_receipt(...).await?` and only wrote its receipt afterwards, so a broadcast whose receipt could not be fetched returned early and printed nothing — losing the tx hash that `send_for_receipt` had already recorded, exactly the case it keeps the out-param for. It now prints the receipt before propagating, matching `assign`. The same gap existed on `request-vetting`'s send leg (the earlier fix covered only its post-receipt decode), so it gets the same treatment. Neither command could previously express "broadcast, outcome unreadable": both now report `status=unknown` with the hash, and a send that never landed reports `failed` rather than being indistinguishable from `dry_run`. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
`request-vetting` told the publisher "the request is queued on-chain — the tx above is its only handle" on the path where the send was rejected and nothing was broadcast. `deadline` is `Err` for both a post-receipt decode failure (queued, hash printed) and a failed send (nothing queued, no hash), and the `!in_flight` branch collapsed them — so the modal failure, an unvetted publisher or one with a request already pending, was told to wait for a grant that will never come, contradicting the `status=failed` receipt printed one line above. The selection is now a `vetting_failure_context` three-way that adds nothing when nothing reached the chain, matching what `revoke` already did. `SeatOutcome::Seated` now takes its hash from the receipt, which makes the "succeeded but recorded no hash" state unrepresentable rather than merely unreachable, and lets `InFlight` carry a plain `B256`. `Reverted` becomes `Failed`: the guards surface from the pre-flight gas estimate, so the usual shape is a transaction that was never broadcast, and "reverted" sent the operator hunting for a hash that does not exist. `status()` answers the zero-seat case before the length comparison, which an empty `seats` otherwise satisfied vacuously. The retry hint now names the failed operator alongside the untried ones, and `propagate` leads its headline with the chain failure. `setPublisherVetted` no longer emits `VettingRequestCancelled` — added last round, but `grantVetting` also clears a pending request while emitting only `PublisherVetted`, so the asymmetry left consumers needing the `PublisherVetted` terminator anyway while the event acquired three distinct meanings. The rule is documented on the event instead, and a `recordLogs` test pins that governance emits no cancellation. Tests: freeze the four event topic0s — `InterfaceFreeze` pins function selectors only, so the indexed-arity change that motivated the e2e metric assertion had no cheap gate. The e2e `assign` gains a third operator the loop never reaches, which is the only thing that exercises the receipt's untried-tail padding; with the run stopping on the last operator it was always empty and could have been deleted silently. Plus a probe for the `vettingTimelock()` getter, a split of the overloaded blacklist test, and unit tests for the vetting-context and empty-seats cases. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
) The seating loop built `seats` by pushing attempted operators and then padding the untried tail from a `stopped_at` index assigned separately in each break arm. That was correct, but "one entry per requested operator, in order" lived in the bookkeeping: a future arm that forgot the assignment would silently drop operators from the receipt AND shrink the denominator of "seated N of M" to match, so a three-operator run failing on the first would report "0 of 1". Seed the vector from the parsed operators up front and have the loop overwrite slots instead. Length and order become properties of the seeding, `NotAttempted` becomes the default rather than a fix-up, and the dry-run branch collapses into the same initialization — net fewer lines and one less invariant to maintain by hand. Also: assert the payloads of the four governance update events, which ADR 011 promises and the CHANGELOG tells indexers to map but nothing checked (a swapped old/new pair would have shipped silently); document in ADR 011 that a pending-request consumer closes on either `VettingRequestCancelled` or `PublisherVetted`, since only the contract carried that rule; drop two stale references to a `claim` subcommand that does not exist; and renumber the e2e step markers to match its own doc list. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…ilure (#1568) * fix(cli): print the namespace-create receipt before a post-receipt failure `publish namespace create` decoded the `NamespaceCreated` log with `?`, so every failure after `createNamespace` had already confirmed on-chain short-circuited before the receipt was written. The namespace existed and was owned by the signer, but its id — and the tx hash `send_for_receipt` records before awaiting the receipt precisely for this case — went out with the dropped struct. On `--json` stdout was empty, while the error told the operator to check a transaction it refused to name. `namespaceCount` had already moved against `maxNamespacesPerPublisher`, so a blind retry silently burned quota. Mirror `request_vetting` (#1548), which fixed the same defect class in `assign`, `revoke`, and `request-vetting`: extract the lookup + decode into `decode_created_namespace`, stash its `Err`, print the outcome with `tx` set and `namespace_id` absent, then propagate through the shared `propagate` helper. The send arm gets the same treatment, so a broadcast whose receipt could not be read reports its hash instead of vanishing. `NamespaceOutcome` gains `in_flight`/`dry_run` and renders a `status` via the shared `single_tx_status`, for parity with the sibling receipts: `created` with a null `namespace_id` is now distinguishable from `failed`, where both previously rendered `submitted=false`-shaped output — and a rejected send no longer prints `dry_run=true`. `submitted` and `namespace_id` keep their names and shapes. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * fix(cli): don't cite the NamespaceCreated log as the recovery path The `landed` failure context told the operator to recover the namespace id from the NamespaceCreated log of the recorded tx. A *missing* NamespaceCreated log is one of the decode failures that context is attached to, so the guidance could contradict the error it wraps. Point at the tx and `ownerOf` instead. Also corrects the `namespace_id` doc comment, which listed three `None` cases and omitted the in-flight one — there are four, one per `status` value. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * fix(cli): make the namespace-create recovery path one that actually works Review of #1568 found the guidance added in 713a87a unusable. It tells the operator to recover a lost namespace id via `ownerOf`, but PublisherRegistry declares `mapping(uint256 namespaceId => address) public ownerOf` — id → owner. It needs the id that was just lost, and there is no reverse index: `namespaceCount` returns a count and `_nextNamespaceId` is internal, so an operator cannot even bound a scan. The note fired on exactly the path this PR exists to make recoverable. `createNamespace` emits `NamespaceCreated` unconditionally and indexes both parameters, so an owner-filtered `eth_getLogs` returns the id in a topic with no data decode. That works for every decode failure, including a receipt that came back without the log — the log is still on-chain, it just was not in what the RPC returned. Which is also why naming the event here does not reintroduce the contradiction Copilot flagged: it points at a log query, not at that receipt. Also from the review: - The `namespace_id` doc listed the send-rejected cause of `failed` but not the confirmed revert, which `send_for_receipt` folds into the same state. - "Match by signature first, then decode, so an ABI drift surfaces as a decode error" was backwards for the likely drift: a renamed event or changed parameter type changes the signature hash itself, so `find` returns `None` and the operator gets the missing-log error the comment claimed to avoid. Only an `indexed` change reaches the decode arm. That arm now says so too. - `Ok(0)` is a dead sentinel whose 0 is the registry's reserved no-namespace id; say that it is never read. Tests: `decode_created_namespace` and its `decode_vetting_deadline` sibling had no coverage of their error arms — the failures that trigger this whole receipt behavior. Extracting them over `&TransactionReceipt` made them constructible, so add a `receipt_with_logs` fixture and pin all three: missing log, topic0-matched but undecodable, and an id too large for u64. Verified the ABI-drift test fails for the right reason by collapsing the ordering into `find_map(log_decode().ok())`. Two write-path gaps in the same class, applied to all four commands so they stay symmetric: - `drop(out)` discarded the final flush error. `Stdout` is a `LineWriter`, so a partial write can buffer the tail and fail unobservably at drop — a truncated receipt reported as a clean one. - `propagate` dropped everything the command had learned when the write failed, including on full success: a decoded id and its hash, replaced by "failed to write namespace-create output". Reachable with `| head -1`. The facts now ride in the error context, which goes to stderr — a different descriptor, still writable when stdout is a closed pipe. While there, `revoke`'s in-flight guidance was a string literal inside its async fn, untested; extract `revoke_failure_context` to match its two siblings. Refs #1568, #1577, #1578 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * test(e2e): gate the namespace receipt on status, not submitted `parse_ready_at` already gates on `status == "vetting_requested"`; the two namespace parsers still checked `submitted`, which cannot separate a confirmed create from a broadcast whose receipt could not be read — both carry `submitted: true`, and only the first has an id to read. That left the `status` field #1568 added with one line of defense, a unit test. Verified against anvil: the four namespace journeys pass serialized. (One failed under the default parallelism on an unrelated DeployProtocol stall, #1384.) Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Supersedes the publisher-propose / governance-ratify origin flow with a two-plane model. Closes #1491 (which itself superseded #1107 and #1113).
Why
proposeAssignment(ns, operators[])took a whole candidate set under onereadyAt, andactivateAssignmentre-validated every operator before replacing the set wholesale. Two consequences:[A, B], dragging the already-liveAthrough a fresh 3-day timelock and re-check. A transient hiccup onAreverted the whole activation and blocked seatingB.Root cause: one flow conflated "is this wallet a network-trusted publisher?" (governance, asked once) with "does this publisher want operator B serving its namespace?" (the publisher's own call, asked constantly).
What
Cold plane — publisher vetting (governance, one-time, per wallet):
requestVetting()(requiresnamespaceCount(caller) > 0) →vettingTimelock→grantVetting(publisher), pluscancelVettingRequest()and asetPublisherVetted(publisher, bool)override for instant grant / un-vet.Hot plane — origin seating (publisher self-serve, instant):
addOrigin(ns, operator)validates only that operator — active, not blacklisted, not seated, under cap — and seats it in the same transaction.OriginAddedis the one and only "origin seated" event.Renames:
revokeAssignment→removeOrigin,pruneBlacklistedAssignment→pruneBlacklistedOrigin,assignmentTimelock→vettingTimelock(same 24h–14d bounds, same 3-day default).IPublisherRegistryOwnershipgainsnamespaceCount.Un-vetting deliberately does not evict already-seated origins — that would be unbounded in the publisher's namespace count, the same reason
ContentBlacklist.addOperatordoesn't cross-call. Governance usesremoveOriginper namespace.Node: the origin-directory watcher follows the renamed events and drops the
AssignmentActivatedarm. Read semantics unchanged — every event is still only a signal to re-read the authoritativegetOrigins, fail-closed.CLI: new
publish request-vettingandpublish revoke.publish assignnow sends oneaddOriginper operator; each seat is reported asseated/in_flight/reverted/not_attempted, and a run that stops part-way prints its receipt before the error so the operator can see what landed.Out of scope (already shipped in #1497/#1504): the enumerable namespace index and the node's replay-free bootstrap.
Review
Reviewed by five specialist agents before opening. Second commit fixes what they found — most notably
assignreporting a broadcast-but-unconfirmed transaction asunseated(telling an operator to re-send a possibly-pending tx), a stdout write that could hide the chain error entirely, and a cap-before-duplicate ordering that contradicted ADR 011. Notably,OriginAddedchanged from 1-indexed-plus-data to 3-indexed-empty-data and nothing decoded it; the e2e now asserts the node consumes it, since an undecodable log is swallowed by design.Verification
forge test851 ·FOUNDRY_PROFILE=ci forge build --sizes --deny warnings·forge fmt --check· gas snapshot regeneratedcargo nextest run2722 · clippy--all-targetsclean (includinganvil-e2etargets, which CI does not lint) ·cargo fmt --check· rustdoc-D warningscli_publish,g_origin_01_publish,origin_blacklist_compliance. Thecli_publishjourney drives the full cold path:assignfails closed while unvetted →request-vetting→ warp past the timelock →grantVettingas the Timelock → instant seat → node consumesOriginAdded→revoke, plus a partial multi-operator seat.pre-commit run --all-filesclean apart from a pre-existing markdownlint failure in.github/workflows/issue-triage.mdthat also fails on untouchedmain.Pre-launch, so no compat shims: every side changes in this PR and the old shape is deleted.
🤖 Generated with Claude Code
Summary by CodeRabbit
Breaking Changes
New Features
publish request-vettingandpublish revokeCLI commands.publish assignnow reports per-operator outcomes and stops after the first failed transaction.Documentation