Repository navigation
fix(cli): carry revert + lost-response outcomes into publish receipts (#1550, #1577) - #1590
Conversation
…#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]>
|
Warning Review limit reached
Next review available in: 59 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Free Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (3)
Note 🎁 Summarized by CodeRabbit FreeYour 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 |
Coverage reportTotal: 80.27% (was 80.23%, ▲ +0.04%) — 56846/70822 lines
History
|
There was a problem hiding this comment.
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
SendOutcomeand updatessend_for_receiptto recordRejectedvsMaybeBroadcast, preserve hashes for mined reverts, and recordConfirmedon success. - Updates
decdn publishreceipt structs/renderers to derivestatus/tx/submittedfrom a singleSendOutcome, addingrevertedandmaybe_broadcaststates. - 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.
…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]>
Gas snapshotNo gas changes vs base. |
Contracts coverageLine coverage: 89.75% (2617/2916 lines) |
What
decdn_incentive::tx::send_for_receiptcollapsed its distinct failure shapes into alanded: &mut Option<B256>out-param, so the machine-readabledecdn publishreceipts 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
tx.rscleared 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--jsonconsumers sawstate: "failed", tx: nulland a script reconciling nonces/gas concluded nothing was ever sent.status=failed, so a retry can burn namespace quota #1577 —send_for_receiptrecords the hash aftercall.send()returns, so anErrfromsend()always leftlanded == None. Butsend()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_sendRawTransactionis not idempotent from the client's view, so reporting the lost-response case asfailed/submitted=falsecan lead an operator to retry and permanently burn namespace quota againstmaxNamespacesPerPublisher.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.rspub enum SendOutcome { NotSent, Rejected, MaybeBroadcast, InFlight(B256), Reverted(B256), Confirmed(B256) }, withtx()(hash where one exists) andmaybe_effected()(the old "may have taken effect" question).send_for_receiptnow takes&mut SendOutcome. A confirmed revert becomesReverted(hash)(keeps its handle);send()errors are classified — a JSON-RPC error response (pre-flight gas-estimate revert, bad nonce) isRejected, a transport-class failure (timeout/reset/5xx) isMaybeBroadcast, and the latter also warns in the error text.send/send_unrecordedkeep their&mut Option<B256>signatures (collapsing viatx().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.rsNamespaceOutcome/RevokeOutcomereplace the loosely-coupledtx+in_flightpair with oneSendOutcome.single_tx_statusyields distinctreverted(with hash) andmaybe_broadcast(no hash, warns) instead of flattening both intofailed.submittedbecomestrue/false/null—nullfor the lost-response case so it no longer falsely claims "nothing happened".SeatOutcome(assign) gains matchingReverted/MaybeBroadcastvariants and failure-context notes pointing the hash-less case at the signer's own pending/mined transactions.Tests
Adds the direct
tx.rscoverage the issues call out (the send-error classifier and theSendOutcomemapping — 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 passedcargo fmt -- --check— cleancargo test --no-run -p decdn-e2e --features anvil-e2e— compiles (signature change gate)Reviewer notes
status=dry_runbesidesubmitted: true) #1578 (reshaping the single-tx outcome structs into enums) is open but has no PR in flight, so no collision — replacing thetx+in_flightpair with oneSendOutcomemoves in the direction cli: single-tx outcome structs can represent contradictory receipts (status=dry_runbesidesubmitted: true) #1578 wants and shrinks the combinatorial surface.request-vettingcommand /VettingOutcome; no such surface exists in the code. The real single-tx commands arenamespace create,revoke, andassign, all covered here.MaybeBroadcastcarries no hash by design: a transport error surfaces beforesend()returns a handle, so the honest report ismaybe_broadcast+ a "check this signer's transactions" warning rather than a fabricated hash.🤖 Generated with Claude Code