Skip to content

fix(cli): carry revert + lost-response outcomes into publish receipts (#1550, #1577) - #1590

Merged
alpergundogdu merged 3 commits into
mainfrom
claude/musing-pascal-db96e8
Aug 4, 2026
Merged

alpergundogdu merged 3 commits into
mainfrom
claude/musing-pascal-db96e8

Conversation

@alpergundogdu

Copy link
Copy Markdown
Contributor

What

decdn_incentive::tx::send_for_receipt collapsed its distinct failure shapes into a landed: &mut Option<B256> out-param, so the machine-readable decdn publish receipts made claims they could not support. This gives the shared helper a richer return shape and threads it into the CLI receipts.

Fixes #1550. Fixes #1577.

Why

  • cli: a confirmed revert's tx hash never reaches the machine-readable receipt #1550 — on a confirmed revert, tx.rs cleared the recorded hash (*landed = None), making a mined-but-gas-burning tx indistinguishable at the call site from a send that never broadcast. The hash survived only inside the human error string, so --json consumers saw state: "failed", tx: null and a script reconciling nonces/gas concluded nothing was ever sent.
  • cli/incentive: a lost send response is reported as status=failed, so a retry can burn namespace quota #1577 — send_for_receipt records the hash after call.send() returns, so an Err from send() always left landed == None. But send() covers two indistinguishable outcomes: a node rejection (nothing broadcast) and a lost response (HTTP timeout/reset/502 — the tx is in the mempool and may mine). eth_sendRawTransaction is not idempotent from the client's view, so reporting the lost-response case as failed/submitted=false can lead an operator to retry and permanently burn namespace quota against maxNamespacesPerPublisher.

Both are the same root cause: Option<B256> cannot carry the outcome. The fix belongs in the shared helper (why #1550 was left out of #1548's scope), since every CLI on-chain write goes through it.

How

crates/incentive/src/tx.rs

  • New pub enum SendOutcome { NotSent, Rejected, MaybeBroadcast, InFlight(B256), Reverted(B256), Confirmed(B256) }, with tx() (hash where one exists) and maybe_effected() (the old "may have taken effect" question).
  • send_for_receipt now takes &mut SendOutcome. A confirmed revert becomes Reverted(hash) (keeps its handle); send() errors are classified — a JSON-RPC error response (pre-flight gas-estimate revert, bad nonce) is Rejected, a transport-class failure (timeout/reset/5xx) is MaybeBroadcast, and the latter also warns in the error text.
  • send / send_unrecorded keep their &mut Option<B256> signatures (collapsing via tx().filter(maybe_effected)), so the ?-callers (register, bond, unbond, deregister, appeal) are untouched but still get the improved warning text.

crates/cli/src/commands/publish.rs

  • NamespaceOutcome / RevokeOutcome replace the loosely-coupled tx + in_flight pair with one SendOutcome.
  • single_tx_status yields distinct reverted (with hash) and maybe_broadcast (no hash, warns) instead of flattening both into failed.
  • submitted becomes true / false / null — null for the lost-response case so it no longer falsely claims "nothing happened".
  • SeatOutcome (assign) gains matching Reverted / MaybeBroadcast variants and failure-context notes pointing the hash-less case at the signer's own pending/mined transactions.

Tests

Adds the direct tx.rs coverage the issues call out (the send-error classifier and the SendOutcome mapping — previously untested) plus publish receipt tests for the new states.

  • cargo clippy -p decdn-incentive -p decdn-cli --all-targets — clean (anti-panic policy respected)
  • cargo nextest run -p decdn-incentive -p decdn-cli — 670 passed
  • cargo fmt -- --check — clean
  • cargo test --no-run -p decdn-e2e --features anvil-e2e — compiles (signature change gate)

Reviewer notes

🤖 Generated with Claude Code

…#1550, #1577)

`decdn_incentive::tx::send_for_receipt` collapsed its distinct failure
shapes into a `landed: &mut Option<B256>` out-param, so the machine-readable
CLI receipts made claims they could not support:

- #1550: a confirmed revert cleared the hash (`*landed = None`), making a
  mined-but-gas-burning tx indistinguishable from a send that never
  broadcast. The hash survived only in the human error string, so `--json`
  consumers saw `state: "failed", tx: null`.
- #1577: an `Err` from `send()` always left `landed == None`, but `send()`
  covers both a node rejection (nothing broadcast) and a lost response
  (HTTP timeout/reset/502 — tx may be in the mempool). Reporting the latter
  as `failed`/`submitted=false` can lead an operator to retry and burn
  namespace quota, since `eth_sendRawTransaction` is not idempotent.

Fix in the shared helper (not per call-site): replace the `Option<B256>`
out-param on `send_for_receipt` with a `SendOutcome` enum
{NotSent, Rejected, MaybeBroadcast, InFlight, Reverted, Confirmed} that
carries the tx hash on every arm that has one. Classify `send()` errors —
a JSON-RPC error response is a rejection (nothing broadcast); a
transport-class failure is `MaybeBroadcast` (may still mine). `send` /
`send_unrecorded` keep their `Option<B256>` signatures, so the `?`-callers
(register, bond, unbond, deregister, appeal) are untouched but still get the
improved warning text.

Thread `SendOutcome` into publish.rs: namespace/revoke replace the
`tx` + `in_flight` field pair with one `SendOutcome`; new `reverted` (with
hash) and `maybe_broadcast` (no hash, warns) statuses; `submitted` becomes
`true`/`false`/`null` so a lost response no longer reads as a definite
"nothing happened". `SeatOutcome` (assign) gains matching `Reverted` /
`MaybeBroadcast` variants.

Adds the direct `tx.rs` test coverage the issues call out (the send-error
classifier and the `SendOutcome` mapping, previously untested) plus publish
receipt tests for the new states.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Copilot AI lite review requested due to automatic review settings August 4, 2026 12:21
@coderabbitai

coderabbitai Bot commented Aug 4, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

@alpergundogdu, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 59 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Free

Run ID: 4c49f916-b11a-46e8-a328-f5c4bae457f9

📥 Commits

Reviewing files that changed from the base of the PR and between 85a5ebe and f575606.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock, !**/*.lock
📒 Files selected for processing (3)
  • crates/cli/src/commands/publish.rs
  • crates/incentive/Cargo.toml
  • crates/incentive/src/tx.rs

Note

🎁 Summarized by CodeRabbit Free

Your 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 @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Aug 4, 2026 •

Copy link
Copy Markdown

Coverage report

Total: 80.27% (was 80.23%, ▲ +0.04%) — 56846/70822 lines

File Coverage Lines Δ
crates/cli/src/commands/publish.rs 77.17% 916/1187 ▲ +1.81%
crates/incentive/src/tx.rs 91.04% 183/201 ▲ +2.65%
History
Commit Total Δ vs base
9a8a279 80.35% ▲ +0.05%
e6636aa 80.36% ▲ +0.06%
f575606 (HEAD) 80.27% ▲ +0.04%

Copilot AI 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.

Pull request overview

This PR fixes a long-standing ambiguity in on-chain write reporting by replacing the old landed: &mut Option<B256> “may-have-landed” out-param with a richer SendOutcome enum in decdn_incentive::tx::send_for_receipt, and threading that richer outcome into decdn publish receipts so JSON/text consumers can distinguish reverted, rejected, in-flight, and lost-response (maybe broadcast) cases.

Changes:

  • Introduces SendOutcome and updates send_for_receipt to record Rejected vs MaybeBroadcast, preserve hashes for mined reverts, and record Confirmed on success.
  • Updates decdn publish receipt structs/renderers to derive status/tx/submitted from a single SendOutcome, adding reverted and maybe_broadcast states.
  • Adds targeted unit tests for the send-error classifier and the new receipt state mapping.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.

File Description
crates/incentive/src/tx.rs Adds SendOutcome, send-error classification, preserves revert hashes, and adds direct unit tests for the new behavior
crates/incentive/Cargo.toml Adds serde_json dev-dependency to support JSON-RPC error payload construction in tests
Cargo.lock Updates lockfile for the new dev-dependency
crates/cli/src/commands/publish.rs Threads SendOutcome into publish receipts and adds new status/submitted semantics for lost-response and revert cases

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread crates/incentive/src/tx.rs Resolved
Comment thread crates/incentive/src/tx.rs Resolved
alpergundogdu and others added 2 commits August 4, 2026 13:33
…orthand

Addresses review feedback on #1590. The send-error classifier used
`as_error_resp().is_none()`, which folds local `RpcError` faults
(`UnsupportedFeature`, `LocalUsageError`, `SerError`) and HTTP 4xx gateway
rejections — none of which reach the node — into the uncertain
`MaybeBroadcast` bucket, so a purely client-side bug would warn about a
possibly-broadcast transaction that never touched the wire.

Match the `RpcError` / `TransportErrorKind` variants instead, mirroring the
classifier in `client-pull/src/discovery.rs`: a JSON-RPC error response, a
local fault, or an HTTP 4xx are definite rejections; a timeout, reset, HTTP
5xx, null response, or undeserializable body stays uncertain. Adds tests for
the local-fault and 4xx/5xx splits.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
#1589 landed #1578 on main, reshaping the single-tx publish receipts into
per-command status enums (`NamespaceStatus`, `RevokeStatus`) and extending
`SeatOutcome`, replacing the `dry_run`/`in_flight`/`tx` field soup this branch
had also been editing. Only `crates/cli/src/commands/publish.rs` conflicted.

Resolved by adopting main's enum shape as the base and re-applying the
#1550/#1577 semantics onto it:

- Extend `NamespaceStatus`, `RevokeStatus`, and `SeatOutcome` with `Reverted`
  (mined, keeps its hash — #1550) and `MaybeBroadcast` (transport failure, no
  hash, may still mine — #1577), each with matching `label()`/`tx()`.
- Add a `submitted()` method to the single-tx status enums returning
  `Option<bool>`, so `submitted` serializes to `true`/`false`/`null` (null for
  `MaybeBroadcast`) and text prints `submitted=unknown` there.
- Thread `SendOutcome` from `send_for_receipt` into the three commands, mapping
  each variant to the reshaped status; `SeatOutcome::from_send` derives seats.
- Extend the failure-context helpers and the assign guidance note for the two
  new states; add tests for `reverted`/`maybe_broadcast` on top of main's.

`tx.rs` (the `SendOutcome` type and send-error classifier) did not conflict.

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

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

Gas snapshot

No gas changes vs base.

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

Contracts coverage

Line coverage: 89.75% (2617/2916 lines)
▲ +0.00pp vs base (89.75% → 89.75%)
Run: 30912656340

@alpergundogdu
alpergundogdu merged commit b43bfb1 into main Aug 4, 2026
27 checks passed
@alpergundogdu
alpergundogdu deleted the claude/musing-pascal-db96e8 branch August 4, 2026 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants