Skip to content

cli: post-receipt failures in publish namespace create discard a recorded tx hash and the new namespace id #1549

Closed

Description

@thiras

Follow-up from #1548 (issue #1491). That PR fixed this defect class in assign, revoke, and request-vetting; namespace_create is the last caller still carrying it.

Problem

crates/cli/src/commands/publish.rs namespace_create (~:216-252):

let receipt = decdn_incentive::tx::send_for_receipt(
    contract.createNamespace(), "createNamespace", …, &mut outcome.tx,
).await?;
let tx = receipt.transaction_hash;
let created = receipt.inner.logs().iter()
    .find(|log| log.topic0() == Some(&PublisherRegistry::NamespaceCreated::SIGNATURE_HASH))
    .context("createNamespace succeeded on-chain but its receipt carried no NamespaceCreated log (…check the tx on a block explorer)")?
    .log_decode::<PublisherRegistry::NamespaceCreated>()
    .context("…ABI mismatch…")?;
let id_u64 = u64::try_from(created.inner.data.namespaceId)
    .context("namespace id exceeds u64 …")?;

All three ?s fire after createNamespace has confirmed successfully on-chain. Each short-circuits before write_namespace_outcome at :249, so:

  • the receipt never prints — on --json, stdout is empty;
  • outcome.tx is dropped with the struct, even though send_for_receipt deliberately recorded the hash before awaiting the receipt (crates/incentive/src/tx.rs:88-93) precisely so this case can report it;
  • the first message tells the operator to "check the tx on a block explorer" while withholding the tx.

The namespace exists and is owned by the signer, but its id is unrecoverable from the CLI. Recovery means finding the transaction by hand and decoding NamespaceCreated — and namespaceCount went up, counting against maxNamespacesPerPublisher, so a blind retry silently burns quota.

Why it matters more now

#1548 established the opposite convention in the same file. assign (:685-697), revoke, and request-vetting all capture the error, print the receipt, and then propagate through a shared propagate helper, on the stated principle that "an operator who only sees the error has no way to tell which [writes] landed." namespace_create is now the sole inconsistent caller, which makes the file's behaviour unpredictable rather than merely imperfect.

Suggested fix

Mirror request_vetting (:333-380): extract the log lookup + decode into a decode_created_namespace(&receipt) -> anyhow::Result<u64>, stash its Err, print the outcome (with tx: Some, namespace_id: None), then propagate(chain_err, write_err, …). NamespaceOutcome already renders tx without namespace_id, so no shape change is needed — only the ordering.

Worth a status field for parity with the sibling receipts, so a --json consumer can distinguish "created, id unrecoverable" from "not created". Today both render submitted=false-shaped output.

Acceptance

  • A post-receipt failure prints the receipt (with the tx hash) before exiting non-zero.
  • A unit test over the writer for the created-but-id-unknown state.
  • No behaviour change on the success or dry-run paths.

Activity

  1. added
    rust
    area:cli
    on Jul 31, 2026
  2. added
    kind:bug
    prio:high
    on Jul 31, 2026
  3. self-assigned this
    on Aug 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:clikind:bugprio:highrust

Type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions