Skip to content

cli: a confirmed revert's tx hash never reaches the machine-readable receipt #1550

Closed

Description

@thiras

Follow-up from #1548 (issue #1491), raised during review and deliberately left out of scope there because the fix belongs in a shared helper rather than in that PR's surface.

Problem

decdn_incentive::tx::send_for_receipt clears the recorded hash when a transaction confirms as a revert (crates/incentive/src/tx.rs:100-106):

if !receipt.status() {
    // A confirmed revert had no effect, so clear the slot: `Some` must mean
    // "may have taken effect", never merely "was broadcast". The hash stays
    // in the message for lookup.
    *landed = None;
    anyhow::bail!("{label} reverted (tx {hash:#x}){suffix}");
}

That contract is deliberate and correct for its stated purpose: callers use Some to decide whether an effect may have occurred. But it means a mined transaction that burned gas is indistinguishable, at the call site, from a send that was never broadcast — both surface as Err with landed == None.

Downstream, the receipts #1548 introduced report that state as though nothing happened:

  • publish assign — the operator gets state: "failed", tx: null (crates/cli/src/commands/publish.rs, SeatOutcome::Failed).
  • publish revoke / request-vetting — status: "failed", submitted: false.

The hash survives only inside the human-readable error string ("{label} reverted (tx {hash:#x})"), which --json consumers do not parse. A script reconciling nonces, gas spend, or on-chain history from the receipt concludes the transaction was never broadcast.

SeatOutcome::Failed's doc already names this merge explicitly, and the variant is deliberately not called reverted for exactly this reason — the CLI cannot tell the two apart.

Scope note

This is not a defect introduced by #1548. It follows from tx.rs's contract, which every CLI command shares (node register, channel, appeal slash, publish, …). Changing it touches every caller, which is why it wants its own PR.

Possible directions

  1. Second out-param / richer return. Keep landed meaning "may have taken effect" and add a separate broadcast: &mut Option<B256> (or return a small struct) that is set on every path where a transaction reached the mempool, revert included. Callers that want provenance read the second; callers deciding on effect keep reading the first. No semantic change to existing behaviour.
  2. Typed error. Replace the bail! with an error enum carrying Reverted { hash } / SendFailed / ReceiptUnreadable { hash }, letting callers match. Most expressive, largest diff — every .context(…) chain on the call sites would need review.
  3. Do nothing, document it. The hash does reach a human. If no machine consumer needs revert provenance, this is acceptable — but then submitted: false on a mined revert should be called out in the CLI docs, since it currently reads as a factual claim that nothing was sent.

Acceptance (if 1 or 2)

  • publish assign can render a distinct reverted state carrying its hash, separate from a never-broadcast failed.
  • revoke / request-vetting likewise distinguish "mined revert" from "never sent".
  • tx.rs gains direct test coverage for the three failure shapes; it currently has none (crates/incentive/src/tx.rs tests cover run_then_cleanup only).

Activity

  1. added
    rust
    area:cli
    on Jul 31, 2026
  2. added
    kind:bug
    on Jul 31, 2026
  3. github-actions commented on Jul 31, 2026

    @github-actions

    🎯 Triage report

    send_for_receipt deliberately clears landed on a confirmed revert so callers can use Some to mean "may have taken effect" — but this causes JSON receipt consumers to see submitted: false / tx: null for a transaction that burned real gas. The tx hash survives only in the human-readable error string, invisible to --json scripts reconciling nonces or on-chain history. The issue is pre-existing relative to #1548 and shared across all CLI commands that use tx.rs (node register, channel, appeal slash, publish, ...).

    📊 Assessment

    Dimension Value Reasoning
    Type Bug JSON receipts make a false factual claim: a mined revert is reported as if nothing was broadcast.
    Labels bug, cli, rust, medium Correctness bug in CLI JSON output; no fund loss risk but misleading provenance for automation consumers.
    Coding agent Suitable Clear problem statement, three concrete directions, explicit acceptance criteria, well-bounded scope in crates/incentive/src/tx.rs + named call sites.

    🔗 Similar issues

    💡 Notes and suggestions

    Recommended direction: Option 1 (second out-param / small struct)

    Option 2 (typed error) is more expressive but the diff touching every .context() chain is large and risky for a shared helper. Option 1 keeps the landed invariant intact and is the lowest-risk change.

    Suggested return shape for tx.rs:

    pub struct SendOutcome {
        /// `Some` iff the tx may have taken effect on-chain (not-reverted).
        pub landed: Option<TxHash>,
        /// `Some` iff the tx was broadcast to the mempool (revert included).
        pub broadcast: Option<TxHash>,
    }

    Or equivalently, a broadcast: &mut Option<TxHash> second out-param mirroring landed.

    Acceptance checklist (from issue):

    • publish assign renders a distinct reverted state carrying the hash, separate from never-broadcast failed.
    • publish revoke / request-vetting likewise distinguish "mined revert" from "never sent".
    • tx.rs gains direct test coverage for the three failure shapes: Reverted { hash }, SendFailed, ReceiptUnreadable { hash }.

    Files to touch:

    • crates/incentive/src/tx.rs — change return type / add out-param
    • crates/cli/src/commands/publish.rs — update SeatOutcome::Failed rendering
    • Any other CLI command using send_for_receipt (node register, channel, appeal slash)

    Note on SeatOutcome::Failed: the doc comment already acknowledges this merge; renaming to SeatOutcome::Reverted (with hash) alongside a kept Failed (no hash, never sent) would satisfy the acceptance criteria cleanly.

    Generated by Agentic Triage for #1550 · sonnet46 · 13.1 AIC · ⌖ 5.65 AIC · ⊞ 6K · ◷

    Add this agentic workflow to your repo

    To install this agentic workflow, run

    gh aw add githubnext/agentics/workflows/issue-triage.md@94ec5db57374c5b04a4b8eef8b4413f9af44d63f
    
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