Skip to content

feat(cli): decdn publish control plane (namespace/claim/assign) (#1029) - #1074

Merged
alpergundogdu merged 7 commits into
mainfrom
feat/1029-decdn-publish-cli
Jul 8, 2026
Merged

alpergundogdu merged 7 commits into
mainfrom
feat/1029-decdn-publish-cli

Conversation

@yigitdot

@yigitdot yigitdot commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Closes the CLI half of G-ORIGIN-01/02 (#1029) — the origin-publisher control plane. Before this, there was no path to publish on-chain from the CLI.

What

Adds a decdn publish command group wiring the already-deployed PublisherRegistry / OriginAssignment writes into user-facing commands:

Command On-chain call Notes
decdn publish namespace create createNamespace() Prints the new namespace id (decoded from the NamespaceCreated event).
decdn publish claim <hash> --namespace <id> claimContent(namespaceId, blake3Hash) Append-only + enforced on-chain (re-claiming the same hash into a namespace reverts; other namespaces never block). Hash accepts 0x…/b3:…/bare 64-hex.
decdn publish assign <namespace> <ops…> proposeAssignment(namespaceId, operators) Propose-only. Activation is onlyRole(GOVERNANCE_ROLE) (DAO Timelock), out of CLI scope.

How

Reuses the on-chain-write pattern from decdn node register: resolve_publish resolves the PublisherRegistry/OriginAssignment coordinates (flag > [blockchain] config > default), the keystore signer loads via a new load_signer_with_password_file helper (load_operator_signer delegates to it), and each subcommand submits + prints a JSON (--json) or key=value receipt.

The incentive crate's sol! bindings — previously read/event-only — gain the write methods (createNamespace, claimContent, ownerOf, proposeAssignment) and the events used for confirmation (NamespaceCreated, AssignmentProposed, AssignmentProposalCancelled), matching the signatures already used in crates/e2e/src/bindings.rs.

Safety / UX

  • --dry-run needs no secrets — resolves + prints params, loads no keystore, sends nothing.
  • Wrong-network guard — before submitting, all three commands verify the RPC's chain id matches the resolved --chain-id/config (mirrors decdn setup's pre-flight). Submit-only.
  • Duplicate-operator fast-fail — assign rejects duplicate operator addresses client-side (the contract would revert DuplicateOperator and waste gas). Runs on --dry-run too.
  • Honest event decode — namespace create matches NamespaceCreated by signature then decodes, so an ABI drift surfaces as a decode error rather than a misleading "missing event".
  • assign transparency — surfaces ready_at (the timelock deadline for DAO activation) and warns (replaced_prior / warning=replaced_existing_pending_proposal) when a prior pending proposal was silently overwritten on-chain.
  • Errors propagate through the existing sanitize_err_chain boundary, so RPC URLs (with API keys) don't leak.

Tests

Unit tests cover argument parsing, config>flag precedence, output formatting for both key=value and JSON (round-tripped) across all three commands, dry-run states, the dedup guard, and the chain-id guard. cargo fmt / clippy --workspace --all-targets / nextest green (821 tests).

End-to-end binary coverage against the anvil fixture is tracked as a follow-up in #1073 (matching the node register precedent, which is e2e-tested separately).

Review

Addressed inline bot findings (dedup, chain-id guard) and a multi-agent review pass (honest event decode, assign ready_at/overwrite surfacing, JSON output tests, doc accuracy).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added a new publish command with subcommands for creating namespaces, claiming content, and proposing origin assignments.
    • Added support for configuring publisher and origin assignment contract addresses in the CLI config.
    • Improved output options with JSON and key-value formats, plus dry-run support.
  • Bug Fixes

    • Added stronger validation for chain configuration, duplicate operator entries, and namespace IDs.
    • Improved transaction handling by checking receipt status and reporting clearer errors when network settings don’t match.

yigitdot and others added 3 commits July 7, 2026 06:11
…sign) (#1029)

Adds the user-facing publisher control plane closing the CLI half of
G-ORIGIN-01/02: namespace create (createNamespace), claim <hash>
--namespace <id> (claimContent), and assign <namespace> <ops...>
(proposeAssignment, propose-only; DAO activation is out of scope).

Reuses the on-chain-write pattern from decdn node register: resolve_publish
resolves the PublisherRegistry/OriginAssignment coordinates (flag > config >
default), the keystore signer loads via the new load_signer_with_password_file
helper, and each subcommand submits + prints a JSON or key=value receipt.
--dry-run prints resolved params without sending. Unit tests cover output
formatting and arg parsing.

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

coderabbitai Bot commented Jul 7, 2026 •

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

This PR adds a new decdn publish command tree with namespace creation, content claims, and assignment proposals, plus the CLI routing, config resolution, contract bindings, and handler logic needed to execute those operations.

Changes

Publish CLI feature

Layer / File(s) Summary
CLI arguments and routing
crates/common/src/cli/publish.rs, crates/common/src/cli/mod.rs, crates/cli/src/commands/mod.rs, crates/cli/src/main.rs, crates/cli/src/commands/config.rs
Adds the publish command tree, shared chain flags, module exports, CLI routing, and updated default config comments for the new blockchain address fields.
Contract ABI bindings
crates/incentive/src/publisher_registry.rs, crates/incentive/src/origin_assignment.rs
Adds the PublisherRegistry namespace create/claim/owner/event bindings and the OriginAssignment proposeAssignment write binding.
Publish chain context resolution
crates/cli/src/commands/chain_ctx.rs
Extends blockchain config parsing, refactors signer loading, and adds ResolvedPublish / resolve_publish with precedence and path resolution tests.
Publish dispatch and shared resolution
crates/cli/src/commands/publish.rs
Adds publish_dispatch, registry_ctx, and validation helpers for operator uniqueness and chain-id matching.
Namespace, claim, and assign handlers
crates/cli/src/commands/publish.rs
Implements the three command handlers, their output writers, receipt checks, dry-run behavior, and related unit tests.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant CLI
  participant Resolver
  participant Signer
  participant Contract

  User->>CLI: run decdn publish ...
  CLI->>Resolver: resolve flags/config/defaults
  Resolver-->>CLI: ResolvedPublish + addresses
  alt dry-run
    CLI-->>User: print outcome
  else submit
    CLI->>Signer: load keystore signer
    Signer-->>CLI: signer
    CLI->>Contract: createNamespace / claimContent / proposeAssignment
    Contract-->>CLI: receipt
    CLI->>CLI: validate status and extract result
    CLI-->>User: print outcome
  end
Loading

Possibly related issues

Possibly related PRs

  • decdn/decdn#1053: Adds e2e contract bindings for PublisherRegistry and OriginAssignment surfaces that match the ABI extensions in this PR.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding the decdn publish control plane for namespace, claim, and assign commands.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/1029-decdn-publish-cli

Comment @coderabbitai help to get the list of available commands.

@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 the decdn publish subcommand, which serves as the origin-publisher control plane. It allows users to perform three on-chain writes: creating namespaces, claiming content hashes, and proposing authorized-origin operator sets. The changes include CLI argument parsing, configuration resolution, and contract interaction logic. Feedback suggests adding client-side validation to prevent duplicate operator addresses from being submitted in the assign command, which would otherwise cause an on-chain revert and waste gas.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread crates/cli/src/commands/publish.rs Resolved

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/cli/src/commands/publish.rs`:
- Around line 102-155: The publish flow in namespace_create currently ignores
ResolvedPublish.chain_id, so a mismatched RPC can still be used to submit
transactions to the wrong network. Add a chain-id validation step in
namespace_create before creating the signer/provider and sending the
transaction, comparing the RPC chain id against ResolvedPublish.chain_id (or the
resolved config) and failing fast on mismatch; if chain_id is not intended to
affect this path, remove it from ResolvedPublish and any related plumbing
instead.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 796e4fb0-5398-4870-9762-d33be863183c

📥 Commits

Reviewing files that changed from the base of the PR and between 473c57f and 8965a3e.

📒 Files selected for processing (9)
  • crates/cli/src/commands/chain_ctx.rs
  • crates/cli/src/commands/config.rs
  • crates/cli/src/commands/mod.rs
  • crates/cli/src/commands/publish.rs
  • crates/cli/src/main.rs
  • crates/common/src/cli/mod.rs
  • crates/common/src/cli/publish.rs
  • crates/incentive/src/origin_assignment.rs
  • crates/incentive/src/publisher_registry.rs

Comment thread crates/cli/src/commands/publish.rs Resolved
@github-actions

github-actions Bot commented Jul 7, 2026 •

Copy link
Copy Markdown

Coverage report

Total: 81.71% (was 81.99%, ▼ 0.28%) — 42842/52433 lines

File Coverage Lines Δ
crates/cli/src/commands/chain_ctx.rs 77.12% 209/271 ▲ +0.62%
crates/cli/src/commands/config.rs 67.20% 168/250 ● 0.00%
crates/cli/src/commands/publish.rs 52.43% 259/494 new
crates/cli/src/main.rs 64.86% 24/37 ▼ 3.71%
crates/common/src/cli/publish.rs 97.14% 34/35 new
History
Commit Total Δ vs base
8965a3e 81.80% ▼ 0.31%
1653888 81.79% ▼ 0.32%
e4249e0 81.79% ▼ 0.32%
934bde6 81.84% ▼ 0.27%
61e2e21 (HEAD) 81.71% ▼ 0.28%

yigitdot and others added 2 commits July 7, 2026 06:48
Review follow-up on #1074:
- assign now rejects duplicate operator addresses client-side (the contract
  reverts DuplicateOperator, so failing fast saves gas). Runs on dry-run too.
- namespace create / claim / assign verify the RPC's chain id matches the
  resolved --chain-id/config before submitting, mirroring decdn setup's
  pre-flight guard, so a mis-pointed --rpc-url can't hit the wrong network.
  The check is submit-only; --dry-run needs no network. Corrected the now-
  accurate --chain-id flag help (publish does no EIP-712 signing).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…adable_literal) (#1029)

CI runs clippy with --all-targets -D warnings, which lints test code the
scoped local run skipped; 421614/31337 tripped clippy::unreadable_literal.

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

yigitdot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

/gemini review

@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 implements the decdn publish command, introducing the origin-publisher control plane. It allows users to create namespaces, claim content hashes, and propose authorized-origin operator sets on-chain. To support this, new CLI arguments, configuration options, and Solidity contract bindings for PublisherRegistry and OriginAssignment have been added, along with corresponding unit tests. No review comments were provided, so there is no feedback to address.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

yigitdot and others added 2 commits July 7, 2026 15:35
…g, JSON tests (#1029)

Multi-agent review follow-up on #1074:
- namespace create: match NamespaceCreated by signature then decode, so an
  ABI drift surfaces as a decode error instead of a misleading "missing
  event" (the namespace was in fact created).
- assign: decode AssignmentProposed to print ready_at (timelock deadline),
  and warn (replaced_prior / warning=replaced_existing_pending_proposal)
  when a prior pending proposal was silently overwritten on-chain. Binds the
  two events in the incentive OriginAssignment sol! block.
- Add serde_json round-trip tests for all three writers' JSON branch (the
  machine-consumable contract, previously untested) + assign dry-run text.
- Module doc: clarify signer loading is submit-path-only (skipped on
  --dry-run); trim a cross-contract gloss on the createNamespace binding.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…code, chain-id preflight (#1029)

Addresses review findings on the `decdn publish` control plane:

- Reject the reserved namespace id 0 client-side (clap value_parser on
  `claim --namespace` and `assign <namespace>`): id 0 is never owned by a
  publisher, so submitting was a guaranteed revert — now fails fast like the
  duplicate-operator guard, saving gas.
- Correct the "idempotent" wording: claimContent is append-only and *reverts*
  on a repeat claim (AlreadyClaimed), it is not idempotent. Fixed the CLI
  revert message and the binding doc comment.
- Make the AssignmentProposalCancelled decode fail-loud on ABI drift (was
  `.filter_map(...ok())`, silently dropping a signature-matched-but-undecodable
  log and under-reporting `replaced_prior`), matching the honest decode of the
  other two events. No-match remains the normal (nothing-replaced) case.
- Run the chain-id check via a read-only provider *before* keystore decryption,
  so a mis-pointed --rpc-url fails before the password prompt + scrypt KDF.
- Rescope the origin_assignment_address config comment: `publish assign` needs
  only that address; the "paired with publisher_registry_address" note applies
  to DHT prefetch, not assign.
- Move the operator Vec into AssignOutcome instead of cloning it, so the
  dry-run path does no extra allocation (submit clones exactly once).

Also bumps crossbeam-epoch 0.9.18 -> 0.9.20 (RUSTSEC-2026-0204, transitive via
iroh) so cargo-deny is green; unrelated to the CLI changes.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@alpergundogdu
alpergundogdu merged commit 26cb7e4 into main Jul 8, 2026
23 checks passed
@alpergundogdu
alpergundogdu deleted the feat/1029-decdn-publish-cli branch July 8, 2026 17:03
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.

2 participants