Skip to content

cli: single-tx outcome structs can represent contradictory receipts (status=dry_run beside submitted: true) #1578

Closed

Description

@yigitdot

Found during review of #1568. Not a live bug — every state is currently unreachable — but the encoding is what makes it unreachable, and that guarantee is one dropped struct field wide.

Problem

NamespaceOutcome, VettingOutcome and RevokeOutcome in crates/cli/src/commands/publish.rs each carry four loosely-coupled fields — dry_run: bool, in_flight: bool, tx: Option<B256>, plus a decoded Option (namespace_id / ready_at). The domain has five mutually exclusive states; the fields admit 16 combinations.

single_tx_status is a precedence chain, so it masks contradictions instead of detecting them:

if dry_run { "dry_run" } else if in_flight { "unknown" } else if tx.is_some() { confirmed } else { "failed" }

Concretely, for NamespaceOutcome:

  • dry_run: true + tx: Some → text prints status=dry_run tx=0x…, and JSON is worse: submitted is derived independently from tx.is_some(), so the object carries "submitted": true next to "status": "dry_run" — two keys of the same receipt contradicting each other.
  • dry_run: true + in_flight: true → dry_run wins, so a broadcast transaction reports as a dry run. That is the precise inversion of what cli: post-receipt failures in publish namespace create discard a recorded tx hash and the new namespace id #1549 fixed.
  • in_flight: true + tx: None → status=unknown submitted=false: an unknown with no hash is the one state an operator cannot act on at all, and is exactly what send_for_receipt's out-param exists to prevent.

All are well-formed struct literals. None is a compile error. Each renders as confident, plausible output.

The distance from correct to wrong is one field in a struct-update literal — and that shape is already live in the file: namespace_dry_run_and_submitted_formats builds its done case with ..base where base.dry_run == true, carrying an explicit dry_run: false line for exactly this reason. Delete that line and it still compiles, printing status=dry_run tx=0x5555.

The invariants are enforced today by a single assignment (outcome.in_flight = outcome.tx.is_some()) in each command's Err arm, plus a landed function local that no type relates to in_flight.

Direction

SeatOutcome (same file) is already the right shape — Seated(B256) | InFlight(B256) | Failed | NotAttempted with tx() and label() derived from the variant. Give the single-tx commands the same treatment:

enum NamespaceStatus {
    DryRun,
    Failed,
    InFlight(B256),
    Created { tx: B256, id: Option<u64> },
}

This also lets namespace_failure_context / vetting_failure_context / revoke_failure_context become total matches over the same value the renderer matches on, deleting the landed local that currently duplicates part of the state machine.

Scope

Must convert all three at once and delete single_tx_status — converting one leaves three different outcome shapes in one file, which is worse for a reader than the current two and destroys the cross-command symmetry established by #1548. AssignOutcome stays as-is: its dry_run: bool is genuinely orthogonal (per-command, whereas seats are per-operator), as its own doc comment explains.

The JSON contract is unaffected — these structs are private to the module, so they mirror the schema rather than being it. write_*_outcome keeps emitting the same keys, which is what crates/e2e/tests/cli_publish.rs and crates/e2e/tests/g_origin_01_publish.rs consume. submitted should become status.tx().is_some() so it can no longer disagree with status.

Explicit non-goal: do not add debug_assert!s to single_tx_status as a half-measure — it adds a panic path to a CLI, against the workspace anti-panic policy.

Activity

  1. added
    kind:bug
    area:cli
    rust
    on Aug 2, 2026
  2. added a commit that references this issue on Aug 4, 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:bugrust

Type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions