Skip to content

refactor(platform-wallet)!: remove the unused broadcast-and-release wrapper - #6288

Merged
llbartekll merged 2 commits into
v5.2-devfrom
refactor/platform-wallet-remove-unused-broadcast-wrapper
Nov 25, 2026
Merged

llbartekll merged 2 commits into
v5.2-devfrom
refactor/platform-wallet-remove-unused-broadcast-wrapper

Conversation

@llbartekll

@llbartekll llbartekll commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Issue being fixed or feature implemented

This removes an unused public method. It is not a bug fix: no flow in this repository can reach the behaviour described below.

CoreWallet::broadcast_transaction_releasing_reservation and its helper broadcast_releasing_on_rejection broadcast a transaction and, on a definitive rejection, release its inputs by outpoint. They do that with neither the build's reservation token nor the wallet generation's lifecycle gate. Every other release path has one of the two, or a generation check. A caller of this method could therefore free a reservation that belongs to a wallet removed and re-created under the same id in the meantime.

The method has had no caller in this repository since #4323 removed the v1 split build/sign surface. Only its own two tests called it.

How the remaining paths are protected (checked on v5.2-dev at 00e850e):

Path Release Protection
Asset lock (3 call sites in asset_lock/build.rs) release_reservation_after_rejected_broadcast with the build's token Owner-guarded. key-wallet mints ReservationToken from a process-wide counter, so the release is a no-op on any reservation the build no longer owns, on any generation.
DashPay contact send (send_payment, 2 call sites) release_reservation_after_rejected_broadcast, no token Holds the generation's payment_guard from before the build until after the release, so the wallet cannot be removed or re-created in between (should_hold_the_lifecycle_gate_through_a_send_payment_broadcast). The gate does not stop another build, so the in-broadcast fence stays up through the release: a build that selects a fenced input rolls back and leaves no newer reservation to free.
Finalized transaction and deferred payment registry CoreWallet::release_transaction_reservation Compares the registered generation with the handle's own, and is owner-guarded by the token.

What was done?

  • Removed CoreWallet::broadcast_transaction_releasing_reservation and wallet::reservations::broadcast_releasing_on_rejection.
  • Removed the two tests that covered only that method (broadcast_releases_reservation_on_rejection, broadcast_keeps_reservation_on_ambiguous_failure), the build_signed_tx test helper only they used, and the imports that became unused.
  • Rewrote the wallet/reservations.rs module doc. It said every build-then-broadcast path must go through broadcast_releasing_on_rejection, which no production path did. It now lists the release paths and what protects each.
  • Updated three doc comments that pointed at the removed items. The one on broadcast_transaction now also says that neither it nor broadcast_finalized_transaction checks the wallet is still registered; the caller holds generation_payment_guard from an is_current_generation check through the broadcast, as the FFI entry point does.

release_reservation_after_rejected_broadcast is unchanged. It still does not check the generation itself, and the module doc now says a new caller must bring a token or hold the gate.

How Has This Been Tested?

  • cargo fmt --all
  • cargo clippy -p platform-wallet -p platform-wallet-ffi --all-targets: no warnings from either crate.
  • cargo test -p platform-wallet: 1893 unit tests passed, 0 failed; integration and doc test binaries passed.

The rejection and ambiguous-failure behaviour the two removed tests exercised is still covered on the paths that remain, for example definitively_rejected_dispatch_installs_no_fence for the finalized-transaction path and the registry's own rejection tests.

Breaking Changes

CoreWallet::broadcast_transaction_releasing_reservation is removed from the public API of the platform-wallet crate. Build with CoreWallet::finalize_transaction and send with CoreWallet::broadcast_finalized_transaction, which releases the reservation on a definitive rejection and is bound to the build's token and wallet generation.

External consumers checked:

  • GitHub code search across all of GitHub finds both names only in this repository.
  • dashpay/dash-evo-tool: the default branch v1.0-dev stopped calling the method on 2026-11-05 (fix(wallet): make every Max and fee match what the upstream builders accept dash-evo-tool#1107). 18 older branches still contain the call in src/wallet_backend/payments.rs, 14 of them behind open draft pull requests. None of them adds or changes the call: each inherits it from a merge base older than 2026-11-05 and pins a platform revision that still has the method. They lose the call when they pick up v1.0-dev.
  • The Swift, Kotlin and JNI layers do not expose the method; platform-wallet-ffi never called it.

Checklist:

  • I have performed a self-review of my own code
  • My Rust, FFI, WASM, Swift or Kotlin changes follow the coding conventions
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have added "!" to the title and described breaking changes in the corresponding section if my code contains any
  • I have made corresponding changes to the documentation if needed
  • If I added or changed GroveDB structure, I described it in the area's structure.rs, regenerated grovedb-structure.json, and checked the structure viewer link posted on this pull request
  • If I added or changed a system contract's document schemas, I checked the contract viewer link posted on this pull request

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

🤖 Generated with Claude Code

PR Hygiene · 1b44d9b

  • Bots — thepastaclaw ✓
  • Self-review — posted; again after any push
  • Build green
  • Approvals — you own every area touched; none needed

When every merge requirement is met, the PR Hygiene check passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.

…rapper

`CoreWallet::broadcast_transaction_releasing_reservation` and its helper
`broadcast_releasing_on_rejection` have had no caller in this repository
since #4323. They were also the only way to release a reservation by
outpoint with neither the build's owner token nor the generation's
lifecycle gate, so a caller could free a reservation on a wallet that was
removed and re-created under the same id.

The `reservations` module doc now says which paths release a rejected
transaction's inputs and what protects each one.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions github-actions Bot added this to the v5.2.0 milestone Nov 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@github-actions github-actions Bot added the waiting-bots Waiting for the review bots to report on this head label Nov 25, 2026
@thepastaclaw

thepastaclaw commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Final review complete — no blockers (commit 1b44d9b) · triage: low

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final validation — Phase 1 + Phase 2

This PR removes the public broadcast-and-release wrapper, which had no in-repository production callers, and updates the documentation for the remaining reservation-release paths. Linux wallet tests and the Swift and Kotlin SDK checks passed; PastaClaw review and PR Hygiene are pending.

🟡 2 suggestion(s)

Approved: nothing here blocks the merge. The non-blocking findings are optional: fix them forward, in this PR or a follow-up, without waiting for another review round.

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 3: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.2-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.2-sol (agent: phase2-reviewer, role: rust-quality); reviewer 6: gpt-6.2-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: low by gpt-6.2-sol (effort low) — The diff removes an unused in-repository API and its dedicated tests without changing the remaining broadcast or reservation-release logic, so the breaking change is straightforward to verify.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort high); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (completed, effort high); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (lane failed), glm-5.3-flash (zai below 15% reserve: 5h 85% left, weekly 12% left)
  • Fresh verifier: gpt-6.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-sol — general (completed, effort medium); agent phase2-reviewer, gpt-6.2-sol — architecture-layering (completed, effort medium); agent phase2-reviewer, gpt-6.2-sol — rust-quality (completed, effort medium); agent phase2-reviewer, gpt-6.2-sol — security-auditor (completed, effort medium); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.

In `packages/rs-platform-wallet/src/wallet/reservations.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/reservations.rs:22-47: Following the gate-only cleanup rule can free a newer build’s reservation
  Impact: A future caller that releases by outpoint while holding only the lifecycle gate can make inputs reserved by another build selectable again after a TTL sweep.
  The newer build can lose its reservation even when the wallet was never removed. `payment_guard` is shared: it excludes teardown, not coin selection or TTL sweeps, and the helper’s `None` branch releases by outpoint without checking ownership. Both existing DashPay cleanup sites hold the lifecycle gate and keep the in-broadcast fence up until cleanup returns, so a competing build that selects those inputs rolls back. State both requirements in the caller contract, and distinguish the finalized path’s generation check from the owner token that protects it against reuse within that generation.

In `packages/rs-platform-wallet/src/wallet/core/broadcast.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/core/broadcast.rs:276-281: The recommended Rust send sequence can broadcast after wallet removal
  Impact: A Rust consumer that follows the migration guidance can submit a finalized payment after its originating wallet has been removed or re-created.
  A signed payment can reach the broadcaster after the wallet that funded it is gone. `dispatch_unexpired` looks up the wallet by ID to check reservation age and install a fence, but does not compare the transaction’s originating generation to the current registration; if the wallet is missing, the age check does not reject the send. The generation check in rejection cleanup runs too late to prevent dispatch. Document the existing caller contract: use the wallet generation that finalized the transaction, then hold its `generation_payment_guard` from the `is_current_generation` check through broadcast, as the FFI entry point does. The registry introduction should describe finalization and broadcast as two calls, not one uninterrupted step.
Out-of-scope follow-up suggestions (1)

These are valid observations, but they are outside this PR's scope and should be handled in separate issues or author/maintainer-requested PRs rather than blocking this review.

  • The native finalized broadcast API does not enforce wallet liveness — The public Rust method does not use SignedCoreTransaction::origin_generation to authorize sending, so a retained handle can dispatch a payment from a removed generation. The FFI and deferred registry supply their own checks; the wrapper removal does not change this implementation.
    • Follow-up: In a separate platform-wallet PR, enforce originating-generation identity and liveness at the Rust broadcast boundary, keep teardown excluded through dispatch without re-entering the lifecycle gate, and test removal and same-ID recreation.

@github-actions

Copy link
Copy Markdown
Contributor

Bots are done — your move: post /self-reviewed.
Full checklist in the description.

@github-actions github-actions Bot added waiting-self-review Waiting for the author to post /self-reviewed and removed waiting-bots Waiting for the review bots to report on this head labels Nov 25, 2026
…s on

The module doc said a new caller of
`release_reservation_after_rejected_broadcast` needs the build's token or
the lifecycle gate. The gate alone is not enough: it excludes teardown,
not a TTL sweep followed by another build re-reserving the inputs. The
contact send is also covered by its in-broadcast fence, and the doc now
says so.

`broadcast_transaction` pointed at the finalize-then-broadcast pair
without saying that neither call checks the wallet is still registered.
The doc now states the caller's part, as the FFI entry point does it.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@github-actions github-actions Bot added waiting-bots Waiting for the review bots to report on this head and removed waiting-self-review Waiting for the author to post /self-reviewed labels Nov 25, 2026

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

New on this head: This revision changes only documentation: it clarifies the caller-held wallet-generation guard for finalized sends, describes finalization and broadcast as separate calls, and explains what protects each reservation cleanup path. Linux Rust wallet tests and the Kotlin and Swift SDK builds and tests passed; PR Hygiene is still pending.

🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(s)

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 3: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.2-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.2-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 6: gpt-6.2-sol (agent: phase2-reviewer, role: rust-quality); reviewer 7: gpt-6.2-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: low by gpt-6.2-sol (effort low) — The diff removes an unused public wrapper and its dedicated tests, then updates documentation without changing any active broadcast or reservation-release path.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort high); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (completed, effort high); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (lane failed), glm-5.3-flash (zai below 15% reserve: 5h 55% left, weekly 6% left)
  • Fresh verifier: gpt-6.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-sol — general (completed, effort medium); agent phase2-reviewer, gpt-6.2-sol — architecture-layering (completed, effort medium); agent phase2-reviewer, gpt-6.2-sol — platform-versioning (completed, effort medium); agent phase2-reviewer, gpt-6.2-sol — rust-quality (completed, effort medium); agent phase2-reviewer, gpt-6.2-sol — security-auditor (completed, effort medium); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify the current code and confirm that no unresolved issues remain.

No unresolved findings remain from the prior review on this head.
Out-of-scope follow-up suggestions (1)

These are valid observations, but they are outside this PR's scope and should be handled in separate issues or author/maintainer-requested PRs rather than blocking this review.

  • Native Rust finalized sends rely on callers to check wallet liveness — A native caller that omits the documented guard can submit a finalized transaction after its originating wallet is removed. The FFI entry point already holds the lifecycle guard from the liveness check through broadcast; this revision documents that contract without changing dispatch.
    • Follow-up: In a separate PR, make platform-wallet enforce the generation check under the lifecycle guard for finalized sends, so native Rust and FFI callers share the same guarded operation.

@github-actions

Copy link
Copy Markdown
Contributor

Bots are done — your move: post /self-reviewed.
Full checklist in the description.

@github-actions github-actions Bot added waiting-self-review Waiting for the author to post /self-reviewed and removed waiting-bots Waiting for the review bots to report on this head labels Nov 25, 2026
@llbartekll

Copy link
Copy Markdown
Contributor Author

/self-reviewed

@github-actions

Copy link
Copy Markdown
Contributor

Policy satisfied — this can merge.
Full checklist in the description.

@github-actions github-actions Bot removed the waiting-self-review Waiting for the author to post /self-reviewed label Nov 25, 2026

@romchornyi romchornyi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Approve — reviewed at 1b44d9bc63, no findings

Checked:

  • No reference to broadcast_transaction_releasing_reservation or broadcast_releasing_on_rejection remains; the build_signed_tx still in signed_payment_registry.rs is that module's own test helper.
  • The new reservations.rs module doc matches the code:
    • Asset lock: all three release_reservation_after_rejected_broadcast calls in asset_lock/build.rs pass the build's token.
    • DashPay send_payment: takes lifecycle_generation.payment_guard() before the build and holds it for the whole function. Both token-less releases run while in_broadcast_pin is alive, and settle_released() comes after the release.
    • FFI: core_wallet/broadcast.rs holds generation_payment_guard from the is_current_generation check through broadcast_finalized_transaction, as the new doc on broadcast_transaction says.
  • The breaking change is described with its external consumers: dash-evo-tool v1.0-dev no longer calls the method, and the older branches pin revisions that still have it.

🤖 Reviewed with Claude Code

@llbartekll
llbartekll merged commit bd2736d into v5.2-dev Nov 25, 2026
33 checks passed
@llbartekll
llbartekll deleted the refactor/platform-wallet-remove-unused-broadcast-wrapper branch November 25, 2026 20:57
romchornyi added a commit that referenced this pull request Nov 25, 2026
…let-payment-delivery

Brings in #6276 (code 88 `ErrorShieldedMerkleWitnessUnavailable`, the
retry-after-sync message) and #6288 (the unused broadcast-and-release
wrapper removed).

- FFI `error.rs`: kept this PR's `payment_class` / `outcome_message` beside
  the base's `retry_after_sync_message`.
- FFI `shielded_send.rs`: the identity create from the pool maps every
  other error through `map_spend_result`, as the base does; the result
  still carries the wallet error's class.
- JNI `funding.rs`: kept this PR's note that retry is the result's class,
  never the code.
- Swift: `shieldedMerkleWitnessUnavailable` carries `payment` like every
  case (declaration, `payment`, message, mapping).
- Code 88: Rust classes it NotSent (as before) and now retryable, the
  retry after sync #6276 promises, so `is_retryable` decides it. Kotlin's
  host-side `isRetryable = true` override goes: retry is the native flag.
  Registry row 88 states the class.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants