Repository navigation
fix(cli): print the namespace-create receipt before a post-receipt failure - #1568
Conversation
…ilure `publish namespace create` decoded the `NamespaceCreated` log with `?`, so every failure after `createNamespace` had already confirmed on-chain short-circuited before the receipt was written. The namespace existed and was owned by the signer, but its id — and the tx hash `send_for_receipt` records before awaiting the receipt precisely for this case — went out with the dropped struct. On `--json` stdout was empty, while the error told the operator to check a transaction it refused to name. `namespaceCount` had already moved against `maxNamespacesPerPublisher`, so a blind retry silently burned quota. Mirror `request_vetting` (#1548), which fixed the same defect class in `assign`, `revoke`, and `request-vetting`: extract the lookup + decode into `decode_created_namespace`, stash its `Err`, print the outcome with `tx` set and `namespace_id` absent, then propagate through the shared `propagate` helper. The send arm gets the same treatment, so a broadcast whose receipt could not be read reports its hash instead of vanishing. `NamespaceOutcome` gains `in_flight`/`dry_run` and renders a `status` via the shared `single_tx_status`, for parity with the sibling receipts: `created` with a null `namespace_id` is now distinguishable from `failed`, where both previously rendered `submitted=false`-shaped output — and a rejected send no longer prints `dry_run=true`. `submitted` and `namespace_id` keep their names and shapes. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Warning Review limit reached
Next review available in: 46 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 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.19% (was 80.15%, ▲ +0.04%) — 56540/70507 lines
History
|
There was a problem hiding this comment.
🟡 Not ready to approve
One new failure-context message can contradict a concrete decode failure mode (missing NamespaceCreated log) and should be reworded to avoid asserting an impossible recovery path.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.
Pull request overview
This PR updates publish namespace create to preserve and print the recorded transaction hash (and a clear status) even when failures occur after the transaction has already been broadcast or confirmed, matching the conventions established for sibling publish commands.
Changes:
- Extracts
NamespaceCreatedlog decoding intodecode_created_namespaceso decode errors can be deferred until after writing the receipt. - Adds
status/in_flight/dry_runmodeling toNamespaceOutcome, and updates text + JSON output to reliably surfacecreated/unknown/failed/dry_run. - Adds focused tests covering created-with-unknown-id, in-flight, failed, and failure-context guidance.
File summaries
| File | Description |
|---|---|
crates/cli/src/commands/publish.rs |
Defers post-receipt errors until after output is written, adds status semantics for namespace-create receipts, and expands unit tests for the new output contract. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 2
- Review effort level: Lite
We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.
| Some( | ||
| "the namespace exists and is owned by the signer — recover its id from the \ | ||
| NamespaceCreated log of the tx above rather than re-running, which mints a second \ | ||
| namespace", | ||
| ) |
There was a problem hiding this comment.
Confirmed — a missing NamespaceCreated log is the first of decode_created_namespace's three failure modes, so on that path the note pointed at a log the error above it had just said was absent. 713a87a drops the log from the guidance: it now reads "recover its id from the tx above (its logs, or ownerOf on the registry)", which stays true for the missing-log, ABI-drift, and overflow cases alike. The test now asserts the string does not mention NamespaceCreated, with a comment saying why, so it can't drift back.
There was a problem hiding this comment.
Re-checked this against the contract and you were right to push on the wording — but the replacement I first shipped was also wrong. ownerOf is mapping(uint256 namespaceId => address) (PublisherRegistry.sol:54), i.e. id → owner: it needs the id that was just lost, and there is no reverse index (namespaceCount returns a count, _nextNamespaceId is internal), so it cannot bound a scan either.
Fixed properly in ee1073e: the note now points at an owner-filtered log query. createNamespace emits NamespaceCreated unconditionally and indexes both parameters (line 79), so eth_getLogs filtered on the signer returns the id in a topic without decoding any data — true for all three of decode_created_namespace's failure modes. That includes the missing-log case you raised, because the log is still on-chain there; it just was not in what the RPC put in the receipt. So this names the event without reintroducing the contradiction: it points at a log query, not at that receipt's log.
The `landed` failure context told the operator to recover the namespace id from the NamespaceCreated log of the recorded tx. A *missing* NamespaceCreated log is one of the decode failures that context is attached to, so the guidance could contradict the error it wraps. Point at the tx and `ownerOf` instead. Also corrects the `namespace_id` doc comment, which listed three `None` cases and omitted the in-flight one — there are four, one per `status` value. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…orks Review of #1568 found the guidance added in 713a87a unusable. It tells the operator to recover a lost namespace id via `ownerOf`, but PublisherRegistry declares `mapping(uint256 namespaceId => address) public ownerOf` — id → owner. It needs the id that was just lost, and there is no reverse index: `namespaceCount` returns a count and `_nextNamespaceId` is internal, so an operator cannot even bound a scan. The note fired on exactly the path this PR exists to make recoverable. `createNamespace` emits `NamespaceCreated` unconditionally and indexes both parameters, so an owner-filtered `eth_getLogs` returns the id in a topic with no data decode. That works for every decode failure, including a receipt that came back without the log — the log is still on-chain, it just was not in what the RPC returned. Which is also why naming the event here does not reintroduce the contradiction Copilot flagged: it points at a log query, not at that receipt. Also from the review: - The `namespace_id` doc listed the send-rejected cause of `failed` but not the confirmed revert, which `send_for_receipt` folds into the same state. - "Match by signature first, then decode, so an ABI drift surfaces as a decode error" was backwards for the likely drift: a renamed event or changed parameter type changes the signature hash itself, so `find` returns `None` and the operator gets the missing-log error the comment claimed to avoid. Only an `indexed` change reaches the decode arm. That arm now says so too. - `Ok(0)` is a dead sentinel whose 0 is the registry's reserved no-namespace id; say that it is never read. Tests: `decode_created_namespace` and its `decode_vetting_deadline` sibling had no coverage of their error arms — the failures that trigger this whole receipt behavior. Extracting them over `&TransactionReceipt` made them constructible, so add a `receipt_with_logs` fixture and pin all three: missing log, topic0-matched but undecodable, and an id too large for u64. Verified the ABI-drift test fails for the right reason by collapsing the ordering into `find_map(log_decode().ok())`. Two write-path gaps in the same class, applied to all four commands so they stay symmetric: - `drop(out)` discarded the final flush error. `Stdout` is a `LineWriter`, so a partial write can buffer the tail and fail unobservably at drop — a truncated receipt reported as a clean one. - `propagate` dropped everything the command had learned when the write failed, including on full success: a decoded id and its hash, replaced by "failed to write namespace-create output". Reachable with `| head -1`. The facts now ride in the error context, which goes to stderr — a different descriptor, still writable when stdout is a closed pipe. While there, `revoke`'s in-flight guidance was a string literal inside its async fn, untested; extract `revoke_failure_context` to match its two siblings. Refs #1568, #1577, #1578 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
`parse_ready_at` already gates on `status == "vetting_requested"`; the two namespace parsers still checked `submitted`, which cannot separate a confirmed create from a broadcast whose receipt could not be read — both carry `submitted: true`, and only the first has an id to read. That left the `status` field #1568 added with one line of defense, a unit test. Verified against anvil: the four namespace journeys pass serialized. (One failed under the default parallelism on an unrelated DeployProtocol stall, #1384.) Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Gas snapshotNo gas changes vs base. |
Contracts coverageLine coverage: 89.80% (2597/2892 lines) |
publish namespace createwas the last caller inpublish.rsstill discarding a recorded tx hash on a post-receipt failure. #1548 fixed this class inassign,revoke, andrequest-vetting; this bringsnamespace_createonto the same convention.Problem
All three
?s in theNamespaceCreateddecode fired aftercreateNamespacehad confirmed on-chain, short-circuiting beforewrite_namespace_outcome. So the receipt never printed (on--json, stdout was empty),outcome.txwas dropped with the struct even thoughsend_for_receiptrecords the hash before awaiting the receipt precisely so this case can report it, and the first message told the operator to "check the tx on a block explorer" while withholding the tx. The namespace existed and was owned by the signer, but its id was unrecoverable from the CLI — andnamespaceCounthad already moved againstmaxNamespacesPerPublisher, so a blind retry silently burned quota.Change
Mirrors
request_vettingend to end:decode_created_namespace(&receipt) -> anyhow::Result<u64>— the log lookup + decode, extracted so the caller can hold theErr.tx: Some/namespace_id: None, then the stashed error goes through the sharedpropagatehelper, which already keeps a chain error ahead of a broken-pipe write error.Errthat left a hash behind means the transaction was broadcast and only its receipt was unreadable, so it reportsin_flightwith the hash rather than implying nothing happened.namespace_failure_context(landed, in_flight)— the parallel ofvetting_failure_context. It warns about the burnt quota only when something actually reached the chain; a rejected send (the modal case, sinceNamespaceCapReachediscreateNamespace's only revert and so surfaces from the pre-flight gas estimate) minted nothing and has no hash to cite.status, as the issue asks.NamespaceOutcomegainsin_flight/dry_runand rendersstatusthrough the sharedsingle_tx_status(dry_run/unknown/created/failed).createdwith a nullnamespace_idis now distinguishable fromfailed, where both previously renderedsubmitted=false-shaped output.The text receipt moves to the sibling shape (
status=created tx=…, withnamespace_idon its own line likeready_at). That is not cosmetic: the old_ => "submitted=false dry_run=true"arm was only ever correct because a failed send could not reach the writer — now that it can, it would have claimed a dry run for a transaction that was broadcast. JSON keyssubmittedandnamespace_idkeep their names and shapes.Review round
A multi-agent review of the branch found one defect in the fix itself, plus adjacent gaps small enough to close here.
The recovery guidance did not work. The first pass at the
landednote told the operator to recover the lost id viaownerOf, which ismapping(uint256 namespaceId => address)— id → owner. It needs the very id that was lost, and there is no reverse index:namespaceCountreturns a count and_nextNamespaceIdisinternal, so a scan cannot even be bounded. It now points at an owner-filtered log query:createNamespaceemitsNamespaceCreatedunconditionally and indexes both parameters, soeth_getLogson the signer returns the id in a topic with no data decode. That holds for all three decode failure modes, including a receipt that came back without the log — the log is still on-chain, it just was not in what the RPC returned. Which is why naming the event here does not re-create the contradiction it was removed for: it points at a log query, not at that receipt's log.Comment claims that were wrong. The
namespace_iddoc gavefailedone cause (rejected send) whensend_for_receiptalso folds a confirmed revert into it. And "match by signature first, then decode, so an ABI drift surfaces as a decode error" was backwards for the likely drift — a renamed event or changed parameter type changes the signature hash itself, sofindreturnsNoneand the operator gets the "missing log" error the comment claimed to avoid. Only anindexedchange reaches the decode arm; that arm's message now names the other cause too.Two write-path gaps in the same class as the bug, fixed at all four
publish.rssites so the commands stay symmetric:drop(out)discarded the final flush error.Stdoutis aLineWriter, so a partial write can buffer the tail and fail unobservably at drop — a truncated receipt reported as a clean one.propagatedropped everything the command had learned whenever the write failed, including on full success: a decoded id and its hash replaced by "failed to write namespace-create output". Reachable withdecdn publish namespace create | head -1. Those facts now ride in the error context, which goes to stderr — a different descriptor, still writable when stdout is a closed pipe or a full disk.revoke_failure_context—revoke's in-flight guidance was a string literal inside its async fn, asserted by nothing, whilenamespaceandvettinghad both extracted theirs. Extracted and tested.Deliberately not fixed here, now tracked: #1550 (a confirmed revert's hash never reaches the JSON receipt — changing it means changing
send_for_receipt's contract and ~13 call sites), #1577 (a lost send response is indistinguishable from a rejected send, so a broadcast tx can printstatus=failedwith no warning), #1578 (the flat-bools outcome structs can represent contradictory receipts; must convert all three single-tx types at once).Testing
namespace_output_distinguishes_created_unknown_and_failedis the acceptance test, written first and confirmed failing onmainfor the right reason — the writer emittedsubmitted=false dry_run=truewith no tx hash at all.namespace_failure_context_only_claims_a_namespace_when_one_existspins the three-way guidance split, including that the note never citesownerOf.The review round added coverage for
decode_created_namespaceand itsdecode_vetting_deadlinesibling, whose error arms — the failures that trigger this entire receipt behavior — had none. Extracting them over&TransactionReceiptis what made them constructible, so areceipt_with_logsfixture now drives missing-log, topic0-matched-but-undecodable, and id-exceeds-u64. The ABI-drift test was verified to fail for the right reason by collapsing the ordering intofind_map(|l| l.log_decode().ok()).Both e2e receipt parsers now gate on
status == "created"rather thansubmitted, matchingparse_ready_at.submittedis true for an in-flight broadcast too, so it could not defend the field this PR adds.Closes #1549