Skip to content

fix(sdk): preserve uncertain submission outcomes through shared broadcast - #5556

Merged
shumkov merged 17 commits into
v5.1-devfrom
codex/submission-recovery
Nov 10, 2026
Merged

shumkov merged 17 commits into
v5.1-devfrom
codex/submission-recovery

Conversation

@llbartekll

@llbartekll llbartekll commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Issue being fixed or feature implemented

A Platform transition can reach a node while its acknowledgement is lost. A later refusal must not erase that history or authorize a replacement operation. Combined submission APIs must check the outcome of the same signed transition and preserve an unresolved result when the required proof cannot be obtained or verified.

What was done?

Implemented lklimek’s simplification in production commit c35e4fe4b8756e9f43c66403f38d3ce712cb6753; 839bcba470a0312054a7e7e66c7d3f13588b2b22 added the final WASM test expectations. 383aa3bab632ad5dffc10d6f9c8eb0389999c124 removes the reported-refusal shortcut described below. e87e9b498fbc8c67ded53eea08d75d8b15d9414d integrates v5.1-dev (9766bab24a14af7cfbcafe33b466a777db8f868c) and resolves the vote confirmation conflict. The 670324539c4a7ba67e87743489e534db1bc8ca56 follow-up preserves uncertainty for unsigned wait errors and routes SDK recording replay through the existing classified loader:

  • The existing DAPI ExecutionError<E> carries possibly_accepted, alongside its original typed cause, address and attempt count. Broadcast-specific classification lives beside the transport; ordinary queries retain their retry rules. DAPI and SDK retry loops accumulate uncertainty without replacing the typed error while retries are active.
  • Ordinary broadcast() is the single send path. Removed BroadcastOutcome, BroadcastPolicy, the observed-send helpers and observer execution/callback plumbing. Existing budgets, local validation, maximum-size checks and signed bytes are retained. Success returns immediately; confirmed mempool/chain presence stops rebroadcasting; raw cache membership remains ambiguous.
  • One wait_after_broadcast(Result<(), Error>, wait_future) checks the same prepared transition after success or possible submission. A concrete rejection ends send retries. Without earlier uncertainty it returns directly; with earlier uncertainty, the existing wait checks the original transition. A server-reported consensus error type alone cannot clear earlier possible delivery or bypass that check.
  • The existing StateTransitionResultUnconfirmed now covers Platform submissions generally and retains its diagnostic cause without double wrapping. Inconclusive waits, missing/invalid proofs, interpretation failures and unsigned result-stream error verdicts remain unconfirmed. Decoding a consensus cause does not authenticate rejection. This applies after both a broadcast acknowledgement and a lost acknowledgement; definite broadcast refusal without earlier uncertainty still returns its original error. Existing execution-proof versus affected-state guarantees remain distinct.
  • Documents (all three result variants), contracts, purchases, price changes, document transfers, identity creation, both vote types and address-funded top-ups share this flow. Preparation/signing occurs once; combined APIs retain the transition locally. Identity fallback and the resource-vote duplicate lookup remain; duplicate recognition uses the typed cause.
  • Affected platform-wallet error boundaries preserve uncertainty before stringification or nonce/revision/price recovery. Definite-rejection recovery remains. FFI/Swift/Kotlin/WASM numeric codes stay unchanged by this simplification; diagnostics are generalized.

Intentional behavior changes: votes and document transfers now share ordinary broadcast settings/retries and nonce-cache refresh after final send failure. Concrete Drive refusals no longer trigger send retries, including the previous owner/nonce exceptions. Earlier uncertainty instead leads to checking the original operation.

Base: v5.1-dev. Companion app integration remains iOS #1254; no iOS PR changes or merge are included here.

Boundaries and retained limitations

  • Deferred raw contract-update and DashPay profile-write callers remain tracked in #4998; this PR does not fix or close them.
  • No protocol/server wire change, additional retry budget, interceptor, outbox, durable operation storage or replacement-operation mechanism.
  • Broadcast-only APIs report unresolved submission through the existing error but do not start a result wait or persist the prepared transition. Ordinary identity-withdrawal error mapping is not broadened here.
  • Existing affected-state snapshots are not execution receipts. This is not complete Core-to-Shielded recovery: randomized Orchard persistence, external-recipient drain recovery and proof-backed drain completion remain outside scope.
  • A dedicated WASM error kind and machine-readable DAPI refusal marker remain deferred. WASM retains its existing generic, non-retryable conversion; transport classification uses existing metadata and DAPI text responses.
  • Separate restart reconciliation is excluded. Unpublished SDK reconciliation files and the iOS history-refresh change remain in separate dirty recovery worktrees. Earlier successful restart tests with those files are not validation of this published code and are not claimed as a feature here.

How Has This Been Tested?

Base integration after human review — 9 November

Validated merge commit dced0c119f9d84f873b931aa84f2e4c4e5057ade, integrating v5.1-dev at 9b36712770c33b2870cbe078f8b386fccb512dcc without rewriting history:

  • Resolved the only conflicted file, broadcast.rs. Retained upstream's type-29 private-document protocol requirement and pre-dispatch network-version check, followed by this PR's existing uncertainty-preserving broadcast retry and shared wait. Existing transition kinds receive no additional probe from this check.
  • Retained the upstream private-document/protocol-gate regression suite and this PR's original-transition retry tests. No additional behavior, retry budget, persistence or public API was introduced by conflict resolution.
  • SDK all-features library: 715 passed. SDK FFI error-mapping tests: 25 passed. SDK→wallet→FFI submission tests: 6 passed. Clippy for SDK, SDK FFI and wallet FFI with all features/all targets and warnings denied, full-workspace all-target compilation, rustfmt and diff checks: passed.
  • Read-only Swift/Rust FFI audit confirmed the new private-document send retains single construction and the shared wait, and unconfirmed status still takes priority over the base's new configuration-error mapping. No new local native/mobile build is claimed.
  • lklimek approved previous head 66243c798e069de1f919a3d83c6c85a1c6ef1932 on 9 November at 14:20 UTC. That review is recorded against its actual SHA; fresh CI/review state is evaluated for this merge commit. No PR merge.

Base integration — 9 November

Validated merge commit 66243c798e069de1f919a3d83c6c85a1c6ef1932, integrating v5.1-dev at e0f21d7137bc7e8d710d1ae56082ce0419418dd0 without rewriting history:

  • Resolved the sole content conflict in put_contract.rs: the base's private-document entry-size preflight runs in the shared preparation helper, before nonce fetching and signing. Both broadcast-only and combined send/wait retain the check; the combined path still waits on the original signed transition after uncertain submission.
  • Preserved the base's validation helpers and tests. Added a public-entry regression for both submission methods with an undersized private document type, asserting the typed preflight refusal and zero signatures without a nonce-fetch expectation.
  • SDK all-features library: 640 passed. SDK→wallet→FFI submission tests: 6 passed. SDK/wallet FFI Clippy all-features/all-targets with warnings denied, cargo check --workspace --all-targets, rustfmt and diff checks: passed.
  • Read-only Swift/Rust FFI integration audit confirmed the unconfirmed wrapper still precedes nonce/marketplace promotion and existing numeric codes are preserved. No new local mobile build or simulator result is claimed for this merge; fresh CI and re-review are required on this exact head.

Unsigned wait verdict and SDK recording loader — 5 November

Validated head 670324539c4a7ba67e87743489e534db1bc8ca56:

  • Removed the shared wait's typed-error exception. Result-stream errors are decoded before proof/quorum-signature verification; a fabricated nonce error cannot authorize replacement recovery. Both acknowledged and uncertain sends preserve the original cause inside the existing unconfirmed envelope, without double wrapping. No API, retry or persistence was added.
  • SDK recording loading now delegates to MockDapiClient::load, preserving versioned classification instead of reclassifying serialized errors. Regression coverage exercises both load_expectations_sync and SdkBuilder::with_dump_dir, connector failures, consensus metadata and both stored flag values. Handcrafted FFI recordings now use the actual request classifier before serialization.
  • Both SDK regressions failed before their fixes. 634 SDK library tests and 6 SDK→wallet→FFI top-up tests passed. The unsigned nonce verdict returns FFI code 20, with no consensus promotion, after ACK or lost ACK; the definite broadcast-refusal control still returns 21. The same transition is signed/submitted once, with one wait and unchanged local identity balance on the unconfirmed paths.
  • SDK and wallet FFI Clippy --all-features --all-targets -- -D warnings, rustfmt and diff checks passed. Read-only Swift/Rust FFI audit confirmed the existing error boundary preserves the wrapper before nonce recovery. No new native framework or simulator run is claimed; earlier mobile results remain attributed to their original artifacts.
  • Fresh CI and external re-review are pending for this head. Review findings remain open for reviewer confirmation; no approval is carried forward.

Cache-processing and mock replay fixes — 5 November

Previously validated head b1e529bc2fd4f8227b1648b5e3cf66fa62ed3ab4 contains two focused commits:

  • 044dab53a23ce2ba2f09c050b7a30a100dbb5ce0: classify the exact cache-processing fallback as possibly accepted, without another broadcast retry. A cache hit can precede mempool insertion; a successful standalone CheckTx and earlier negative lookups do not prove rejection. Combined APIs use the existing wait for the original signed transition. If it cannot be confirmed, the existing timeout yields unconfirmed, not permission to create a replacement. Typed consensus refusals keep their existing classification.
  • b1e529bc2fd4f8227b1648b5e3cf66fa62ed3ab4: classify hand-built mock expectations before serialization loses connector sources/metadata; preserve versioned recording flags during load/replay. Legacy recordings retain existing request-specific classification. No production API, recording format, retry budget or persistence mechanism was added.

Validation: the cache regression and both new replay regressions failed before their respective fixes, then passed. 633 SDK library tests; 206 DAPI unit/integration tests plus 5 doctests passed, with 1 existing ignored test. Final replay-focused run: 4 passed. Clippy for SDK and DAPI with all features/all targets and warnings denied passed; rustfmt and diff checks passed. Tests cover both cache-message forms, no rebroadcast, a real signed original transfer, successful wait and timeout, typed connector failure, consensus metadata, retained prior uncertainty, versioned/legacy replay and unchanged read classification.

The proof-backed duplicate resource-vote decoder repair remains in #4138. These follow-ups do not claim new mobile artifact builds or simulator runs. Fresh CI and external re-review are required for this head.

Base integration — 5 November

Validated commit e87e9b498fbc8c67ded53eea08d75d8b15d9414d, integrating base 9766bab24a14af7cfbcafe33b466a777db8f868c:

  • Resolved the single conflict in vote.rs: retained the base's comparison of the recorded resource vote with the submitted vote inside this PR's shared wait. Kept both regression suites. A mismatched or absent snapshot is not reported as success, and the diagnostic cause remains inside the unconfirmed envelope.
  • SDK all-features library: 633 passed. SDK Clippy all-features/all-targets with warnings denied: passed. cargo check --workspace --all-targets: passed. rustfmt and PR diff whitespace checks: passed.
  • Read-only Swift/Rust FFI integration audit found no additional conflict or error-code mapping regression. No mobile artifact rebuild or simulator rerun is claimed for this integration.
  • Fresh CI and external review are evaluated on this head; old approvals are not carried forward. The cache-processing fallback finding was separate from that conflict resolution and is addressed by the follow-up below.

Reported-refusal fix — 5 November

Validated commit 383aa3bab632ad5dffc10d6f9c8eb0389999c124:

  • Removed the permanent-refusal allowlist and its error-unwrapping shortcut. Unsigned refusal metadata does not prove that the submitted bytes could never have been accepted.
  • A regression uses a real signed address transfer, serialized consensus-error metadata and the production DAPI/SDK retry loops. Both formerly allowlisted errors are tested after a lost acknowledgement and without prior uncertainty. Retries keep identical signed bytes; the wait targets the original hash. Definite rejection without earlier uncertainty still returns the original error without waiting.
  • The new regression failed on the previous implementation (wait incorrectly skipped) and passes with this fix. All 39 broadcast tests and all 591 SDK library tests pass. SDK Clippy --all-features --all-targets -- -D warnings, rustfmt and diff checks pass.
  • No new API, retry budget, local consensus validation or mobile change. Native/mobile results below belong to the earlier c35e4fe artifacts; mobile builds and simulator tests were not rerun for this Rust-only follow-up.

Earlier simplification validation

Production validation used clean c35e4fe4b8756e9f43c66403f38d3ce712cb6753. The final WASM suites and WASM all-target Clippy also cover the test-only follow-up 839bcba470a0312054a7e7e66c7d3f13588b2b22; no production source changed between these commits. The additional full-workspace all-target check also passed on 839bcba470a0312054a7e7e66c7d3f13588b2b22:

Check Result
SDK, all features, library suite 591 passed
DAPI, all features, all targets 204 passed; 1 existing test ignored
Wallet error/recovery boundaries and revision cache 27 + 1 passed
Wallet FFI errors and real SDK→wallet→FFI top-up paths 53 + 6 passed
SDK FFI uncertainty and free paths 2 passed
WASM full host library, default features 197 passed
WASM host library, all features 196 passed; one incompatible pre-existing fixture excluded (see below)
Kotlin production error mapper 26 passed
Clippy, six changed Rust crates, all features/all targets, -D warnings Passed
cargo check --workspace --all-targets Passed
rustfmt and diff whitespace checks Passed

Regression tests execute the real DAPI/SDK retry loops and public submission methods. They cover lost response followed by refusal, retained history across retries/conversions/address exhaustion, connection failure, raw cache versus confirmed presence, consensus metadata under an unusual gRPC code, same signed bytes and existing budgets, proof failures, conclusive business errors, single wrapping, nonce refresh and suppression of replacement recovery. Normal DAPI request tests also pass. The existing DPP Cargo manifest warning about inherited default-features is unchanged.

Fresh mobile artifacts were built from production commit c35e4fe4b8756e9f43c66403f38d3ce712cb6753 (clean), with iOS #1254 baseline 03f781c4e3d231e360c9345b4099dfaf5e4a3b61 and a local SDK-pin override only:

  • Canonical device + arm64 simulator framework builds and SwiftExample warnings-as-errors check passed. Whole XCFramework SHA-256: d71a932783698cca17197b6321431959f418bb3e65dd8a80cd4ac8dedc21aa93.
  • Clean dashpay arm64 simulator build passed; five actual Swift error-decoder/presentation tests linked to the rebuilt C FFI passed (5/5).
  • Isolated Testnet QA: own Transparent→Shielded transfer of 0.01 tDASH succeeded with a verified SDK result; Shielded balance 0.03→0.04. Platform hash 95d21e654d6aa25ff009743117b890b92b449b0186a66d1f965b537dabf9d761.
  • A second 0.01 tDASH transfer was interrupted after the broadcast ACK and wait dispatch, before result delivery. After relaunch, Shielded synchronized 0.04→0.05 without a new submission or manual retry. Platform hash 42b8bbbbd6d120291433f11f578b4b7189d6688f30fa01402aada46b17ac842c. Balance observation alone is not claimed as an exact-transition execution proof.
  • The second history entry remains Pending. Its original lock/proof survived. This reproduces the known restart-history limitation with the separate reconciliation fix excluded. The interruption test covers missing result delivery after ACK, not lost ACK; lost-ACK retry behavior is covered by deterministic transport tests.

Full WASM testing also updated four expectations to preserve the new unconfirmed/non-retryable error after submission while retaining proof-failure diagnostics and unchanged cache/signature assertions. Under --all-features, one existing fixture assumes the withdrawals contract is not compiled in; that assumption conflicts with --all-features. It is unchanged and passes in the complete default-feature suite; the remaining 196 tests pass with all features.

Breaking Changes

Rust source compatibility: ExecutionError<E> has a new required possibly_accepted field, so downstream struct literals must be updated. The observer-specific APIs introduced earlier in this PR are removed. The PR’s SDK error variant/code 11 and wallet code 20 remain; existing C structure layouts and assigned numeric codes are unchanged by this simplification. Downstream exhaustive enum matches must account for the PR’s added error variant.

In-place changes to shipped generations

None. Changes are client submission/error/wait orchestration, not consensus logic or protocol tables.

Checklist

  • Self-reviewed this implementation; earlier approvals/attestations are not carried forward.
  • Checked Rust/FFI/WASM/Swift/Kotlin integration against repository conventions.
  • Updated regression coverage and completed full-workspace compilation.
  • Documented intentional behavior changes, source compatibility and retained limitations.
  • Fresh CI for this head confirmed; external re-review remains required.

No merge or application publication is authorized by this change.

Summary by CodeRabbit

  • New Features

    • Operations that wait for a result can verify the outcome after an uncertain submission acknowledgement, checking the original operation rather than submitting it again.
    • Unconfirmed submissions, including identity top-ups funded from Platform addresses, are identified separately from definite rejections across supported SDKs.
  • Bug Fixes

    • Unconfirmed outcomes advise reconciling the original operation before submitting again and are marked as non-retryable.
    • Definite refusals retain their existing handling and are not treated as potentially accepted submissions.

@coderabbitai

coderabbitai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • Resume reviews
  • Trigger review
Walkthrough

The SDK now tracks whether a broadcast may have been accepted and waits for the transition result when applicable. It represents unresolved results as distinct errors and carries them through wallet, FFI, Kotlin, Swift, and WASM handling.

Changes: Broadcast classification and retry tracking

Layer / File(s) Summary
Classify broadcast outcomes
packages/rs-dapi-client/src/*, packages/rs-sdk/src/sync.rs
Transport requests classify possible acceptance and retry eligibility. DAPI execution and retry handling retain possible acceptance across attempts and exhausted addresses.
Transition submission and result waits
packages/rs-sdk/src/platform/transition/*, packages/rs-sdk/src/sdk/put_test_support.rs, packages/rs-sdk/src/sdk.rs
The SDK routes combined submissions through shared broadcast and wait handling. It waits on the original transition after successful or potentially accepted broadcasts, and skips waits after definite refusals. Transition preparation and tests cover these paths.
Unconfirmed error propagation
packages/rs-sdk/src/error.rs, packages/rs-sdk-ffi/src/error.rs, packages/rs-platform-wallet/src/*, packages/rs-platform-wallet-ffi/src/*
The SDK adds an unconfirmed-result error that does not expose a consensus verdict. Wallet and FFI conversions preserve that result, including identity top-up outcomes.
Language bindings and client messages
packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/*, packages/swift-sdk/Sources/SwiftDashSDK/*, packages/swift-sdk/SwiftExampleApp/*, packages/swift-sdk/SwiftTests/*, packages/wasm-sdk/src/*
Kotlin, Swift, and WASM map unconfirmed outcomes to non-retryable errors. Swift helpers and example views display the new error and reconciliation guidance.

Estimated code review effort: 4 (Complex) | ~60 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant TransitionAPI
  participant DapiClient
  participant BroadcastTransport
  participant ResultWait
  TransitionAPI->>DapiClient: submit signed transition
  DapiClient->>BroadcastTransport: send broadcast attempt
  BroadcastTransport-->>DapiClient: return classified outcome
  DapiClient-->>TransitionAPI: return outcome and acceptance status
  TransitionAPI->>ResultWait: wait when acceptance is possible
  ResultWait-->>TransitionAPI: return verified result or wait error
Loading

Possibly related issues

  • dashpay/platform#5621: This issue concerns the same SDK-to-FFI error mapping, although its substring classification and document-search mapping are not addressed here.
  • dashpay/platform#5690: This PR preserves uncertain results within a call, but does not add persisted transition identification or restart recovery.
  • dashpay/platform#5478: This PR handles uncertain outcomes, but does not change asset-lock input bounds or the asset-lock resume path.
  • dashpay/platform#5665: This PR preserves the distinction between possibly delivered and definite failures, but does not change masternode withdrawal mapping.
  • dashpay/platform#4998: This PR changes shared submit-and-wait handling. Raw contract-update and DashPay profile-write callers remain outside scope.

Possibly related PRs

  • dashpay/platform#5746: Both PRs change handling for duplicate or ambiguous vote submissions.
  • dashpay/platform#5511: This PR continues the broadcast observation, retry preservation, and original-transition wait flow.
  • dashpay/platform#5465: Both PRs use the unconfirmed broadcast outcome contract, including Core transaction messaging.
  • dashpay/platform#5471: This PR changes consensus_error() behavior for unconfirmed results.
  • dashpay/platform#5560: This PR overlaps the broadcast observation, retry preservation, and transition-wait changes.

Suggested reviewers: lklimek, shumkov, quantumexplorer

Merge Risk: Moderate · previous review 383aa

A duplicate submission can report a vote from a different poll as its result. Bind the lookup to the submitted poll before merging.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 29.46% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "fix(sdk): preserve uncertain submission outcomes through shared broadcast" matches the main change. The PR keeps an unconfirmed outcome when an earlier broadcast may have reached a node, an…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "fix(sdk): preserve uncertain submission outcomes through shared broadcast" matches the main change. The PR keeps an unconfirmed outcome when an earlier broadcast may have reached a node, and it routes the combined submission APIs through a shared broadcast path (wait_after_broadcast). The title is specific and concise, and it follows a conventional-commit format.

Full details: Docstring Coverage

Explanation

Docstring coverage is 29.46% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 112 functions across 51 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches

Generate docstrings

  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • 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

@thepastaclaw

thepastaclaw commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Final review complete — no blockers (commit dced0c1)

Base automatically changed from codex/protocol-compatibility to v5.1-dev October 26, 2026 14:17
@github-actions github-actions Bot added this to the v5.1.0 milestone Oct 26, 2026
@llbartekll

Copy link
Copy Markdown
Contributor Author

Self-review completed for 48490f211b2004e27e656019a41b14fbb4c56815 against current v5.1-dev (9fefdf1b4681f9befd7203807420a66f6f168427). No new blocking finding identified.

Reviewed the actual DAPI and outer SDK retry loops: uncertainty survives a later definite refusal, the existing dispatch budget and signed transition are retained, and the existing wait/proof path runs only after success or possible acceptance. Preparation and definite-refusal failures remain outside the top-up unconfirmed-result wrapper. A timeout/cache response alone is never promoted into a new success condition.

A separate FFI/mobile pass checked both SDK error wrappers/free paths, real wallet/composite top-up propagation, and Swift/Kotlin classification. Diagnostic nonce/proof errors do not become a safe-retry verdict. Existing vote lookup and affected-state proof semantics remain unchanged.

Fresh checks: 259 Rust tests pass (75 transition, 1 unconfirmed marker, 157 DAPI, 20 SDK FFI, 6 wallet FFI top-up). Rustfmt, diff checks, and all-features/all-targets Clippy for dash-sdk, rs-dapi-client, rs-sdk-ffi, platform-wallet-ffi and platform-wallet pass. The test seams use controlled transport/proof boundaries; this is not a live transfer or full C ABI end-to-end claim.

Updated the description to the actual base and companion iOS #1254. Explicitly retained the known limits: broadcast-only history exposure, ordinary identity-withdrawal typing, vote lookup behavior, generic WASM kind and textual DAPI refusal marker; no claim to fix external-recipient drain recovery, persist Orchard actions, or provide a proved drain-completion receipt.

No source changes, new commits or live spends in this pass. The prior native framework evidence remains tied to its original source SHA, as documented. External bot/human review is still required; this self-review does not waive it.

@llbartekll

Copy link
Copy Markdown
Contributor Author

/self-reviewed 48490f2

@llbartekll
llbartekll marked this pull request as ready for review October 27, 2026 11:28
@github-actions github-actions Bot added the bot-review-skipped A required review bot did not report; it was skipped by the window or by a person. label Oct 27, 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.

Final validation — Phase 1 + Phase 2

The submission-observation mechanism is generally sound, but three combined submission paths still discard ambiguous broadcast history and can return a misleading failure before verifying the original signed transition. Proxy establishment failures are also classified as possibly accepted, which can suppress safe retry even though no node received the request. Additional non-blocking issues remain around DAPI text classification, WASM error typing, Kotlin metadata masking, and feature-gating the new tests. The Rust workspace test check failed on this head, while several JS checks remain queued; no failure log was available to establish whether the Rust failure is change-related.

🔴 3 blocking | 🟡 4 suggestion(s)

3 finding(s) not shown inline (the lines are not part of this PR's diff)

🔴 Blocking: DashPay profile writes still abort before waiting after an ambiguous broadcast
packages/rs-sdk/src/platform/dashpay/profile.rs:237-238

put_profile_write remains a manual combined submit-and-wait path. It calls state_transition.broadcast(...).await? and only starts wait_for_document_and_owner_balance_with_metadata afterward. If the profile transition was accepted but its acknowledgement was lost, or a later retry ends with AlreadyExists, broadcast returns the final relay error and the proof wait is skipped. The caller can then treat the update as failed and submit another signed update even though the original may have executed. Route this path through the observation-aware broadcast result and wait_after_broadcast, preserving the same signed transition.

source: gpt-6.1-sol (phase2-reviewer: general)

🔴 Blocking: Platform-wallet contract updates bypass the observation-aware combined path
packages/rs-platform-wallet/src/wallet/identity/network/contract.rs:547-554

The wallet contract-update flow still performs a raw transition.broadcast(...).await? and then calls DataContract::wait_for_response. An ambiguous acknowledgement, or a definite final error after an earlier ambiguous retry, therefore prevents the wait from running. This is a separate public combined contract-submission route from the updated SDK PutContract path, so callers can still receive a failed update result without reconciling the original signed transition. It must use the observation-aware broadcast/wait orchestration before returning the final error.

source: gpt-6.1-sol (phase2-reviewer: general)

🟡 Suggestion: Mask consensus metadata on Kotlin unconfirmed submission errors
packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/errors/DashSdkError.kt:50-51

StateTransitionResultUnconfirmed is constructed with the native DashSDKException as its cause, while the base consensusError getter exposes cause.consensusError for every subclass. The current Rust FFI conversion intentionally emits no consensus metadata for this marker, but the Kotlin public type does not enforce that invariant. If a malformed, stale, or future native error carrying code 11 also carries consensus fields, Kotlin callers could observe a contradictory consensus rejection and treat the operation as a definite refusal. Make the base property overridable and return null for StateTransitionResultUnconfirmed, or clear the metadata while mapping code 11.

source: gpt-6.1-sol (phase2-reviewer: ffi-engineer)

Review provenance

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

  • Triage: critical by gpt-6.1-sol (effort low) — This is a large, intricate change to shared transition submission and identity top-up recovery paths that affect funds movement and cross-language error handling, particularly in top_up_identity_from_addresses.rs and the corresponding FFI boundaries.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — ffi-engineer (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `packages/rs-sdk/src/platform/transition/broadcast.rs`:
- [BLOCKING] packages/rs-sdk/src/platform/transition/broadcast.rs:413-425: Proxy establishment failures are incorrectly treated as possibly accepted broadcasts
  The classifier only excludes tonic ConnectError instances before treating transport statuses as possibly accepted. The DAPI transport already exposes TransportError::is_proxy_failure(), which detects SOCKS5 ProxyError values preserved in the status source chain. A proxy connection or handshake failure occurs before the request reaches DAPI or a Platform node, so treating it as possibly accepted causes wait_after_broadcast to poll the transition and can turn an address-funded top-up into StateTransitionResultUnconfirmed. That tells callers not to retry even though no node could have executed the transition. Check is_proxy_failure() before the status-code classification and add a regression test.
- [SUGGESTION] packages/rs-sdk/src/platform/transition/broadcast.rs:426-431: Do not classify DAPI broadcast state by human-readable status text
  The SDK now makes a DAPI-specific decision by comparing the complete human-readable Internal status with DAPI_PROCESSING_REJECTION. That marker is emitted by rs-dapi and is duplicated across handlers, so wording changes or another DAPI implementation can make a definite processing rejection look ambiguous and trigger an unnecessary result wait. Conversely, reusing the same text for another internal condition could skip a required wait. The owning fix belongs in rs-dapi and its gRPC contract: emit a machine-readable error detail or metadata marker for this local processing rejection, then consume that marker here. The PR links the earlier recommendation, so this can be deferred as a tracked follow-up rather than blocking this fix.

In `packages/rs-sdk/src/platform/dashpay/profile.rs`:
- [BLOCKING] packages/rs-sdk/src/platform/dashpay/profile.rs:237-238: DashPay profile writes still abort before waiting after an ambiguous broadcast
  put_profile_write remains a manual combined submit-and-wait path. It calls state_transition.broadcast(...).await? and only starts wait_for_document_and_owner_balance_with_metadata afterward. If the profile transition was accepted but its acknowledgement was lost, or a later retry ends with AlreadyExists, broadcast returns the final relay error and the proof wait is skipped. The caller can then treat the update as failed and submit another signed update even though the original may have executed. Route this path through the observation-aware broadcast result and wait_after_broadcast, preserving the same signed transition.

In `packages/rs-platform-wallet/src/wallet/identity/network/contract.rs`:
- [BLOCKING] packages/rs-platform-wallet/src/wallet/identity/network/contract.rs:547-554: Platform-wallet contract updates bypass the observation-aware combined path
  The wallet contract-update flow still performs a raw transition.broadcast(...).await? and then calls DataContract::wait_for_response. An ambiguous acknowledgement, or a definite final error after an earlier ambiguous retry, therefore prevents the wait from running. This is a separate public combined contract-submission route from the updated SDK PutContract path, so callers can still receive a failed update result without reconciling the original signed transition. It must use the observation-aware broadcast/wait orchestration before returning the final error.

In `packages/wasm-sdk/src/error.rs`:
- [SUGGESTION] packages/wasm-sdk/src/error.rs:184-189: Preserve the unconfirmed classification through the WASM boundary
  The Rust SDK has a dedicated StateTransitionResultUnconfirmed error, but the WASM adapter converts it to WasmSdkErrorKind::Generic. JavaScript callers of identity_top_up_from_addresses cannot distinguish an unconfirmed submission from an ordinary generic failure except by parsing the message; only the non-retryable flag survives. Add a dedicated WASM error kind with is_retriable set to false so the typed recovery classification remains available across this boundary. The PR links the prior recommendation, so this is a tracked non-blocking follow-up.

In `packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/errors/DashSdkError.kt`:
- [SUGGESTION] packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/errors/DashSdkError.kt:50-51: Mask consensus metadata on Kotlin unconfirmed submission errors
  StateTransitionResultUnconfirmed is constructed with the native DashSDKException as its cause, while the base consensusError getter exposes cause.consensusError for every subclass. The current Rust FFI conversion intentionally emits no consensus metadata for this marker, but the Kotlin public type does not enforce that invariant. If a malformed, stale, or future native error carrying code 11 also carries consensus fields, Kotlin callers could observe a contradictory consensus rejection and treat the operation as a definite refusal. Make the base property overridable and return null for StateTransitionResultUnconfirmed, or clear the metadata while mapping code 11.

In `packages/rs-sdk/src/platform/transition/put_contract.rs`:
- [SUGGESTION] packages/rs-sdk/src/platform/transition/put_contract.rs:117-121: Gate new submission tests with the mocks feature
  The new submission_tests module is enabled by #[cfg(test)] but imports crate::sdk::put_test_support::PutFixture, which is declared only under #[cfg(all(test, feature = "mocks"))] in sdk.rs. The same mismatch exists in the new submission test modules in put_document.rs, purchase_document.rs, update_price_of_document.rs, and vote.rs; vote also imports mock-gated IdentityNonceFetcher. Building tests with --no-default-features therefore leaves the consumer modules enabled while their helpers are absent, causing compilation failures. Use the same all(test, feature = "mocks") gate on every new submission_tests module.
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.

  • Persist uncertain submissions for restart recovery — The SDK and wallet now preserve an in-memory unconfirmed result and prevent it from being treated as permission to create a replacement spend, but the original signed address-funded transition is not persisted for reconciliation after process restart. Without a durable recovery record, a crash after an ambiguous submission still requires external recovery handling.
    • Follow-up: Track persistent operation records and proof-backed reconciliation in a separate recovery-focused issue or PR, as the current PR explicitly excludes that broader feature.

Comment thread packages/wasm-sdk/src/error.rs Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix; thepastaclaw left review threads unresolved; resolve them.
Full checklist in the description.

@github-actions github-actions Bot added waiting-self-review Waiting for the author to post /self-reviewed and removed bot-review-skipped A required review bot did not report; it was skipped by the window or by a person. labels Oct 27, 2026
@llbartekll

Copy link
Copy Markdown
Contributor Author

@thepastaclaw Follow-up on the final review of 48490f211b2004e27e656019a41b14fbb4c56815:

  • Proxy establishment: checked the real tonic connector path with a no-network probe; the error retains ConnectError and is already classified as definite non-dispatch. Details are in the inline reply; resolved as not reproduced.
  • Profile writes / wallet contract updates: both raw broadcast-then-wait paths are present and unchanged from the PR's merge base (5b89fe8b529c66d5e972880196545c902285258b). These are real pre-existing gaps, not fixed by moving recovery code into this PR. The owner has frozen the operation scope; I have not extended it to these additional routes. Please reassess their blocking classification against that scope. I have not dismissed your changes-requested review or claimed these paths are fixed.
  • Kotlin consensus metadata: the supported Rust FFI conversion suppresses consensus metadata for unconfirmed errors; the suggested malformed/stale/future native payload requires a separate hardening change. No supported-path regression was demonstrated. Deferred, not implemented.
  • DAPI structured marker / WASM error kind: explicitly deferred in the description; the corresponding non-blocking discussions are resolved as scope decisions, not fixes.
  • Mock-feature guards: confirmed and fixed/tested locally (six one-line guards; 75 transition tests, fmt and Clippy pass), but not pushed. That thread remains open until publication.
  • Durable recovery: the new locally tested reconciliation described in the PR handles only existing own-recipient shielded asset locks through a verified outpoint proof. It does not implement persistence of signed address-funded transitions, nor resolve the broader drain-completion issue Wallet drain completes on an unauthenticated "already consumed" report; add a proof-backed asset-lock outpoint query #5580.

CI diagnosis: the failed Rust workspace job ran the synthetic merge ac36c5b8159ae3f507a7c737bfa26151d7f20a04 onto base 07effc9c460e52aa78e2c8a96889c5cfd8a4abab. It failed drive-abci::...::should_admit_in_check_tx_a_ref_to_a_keyword_a_shorthand_stands_for: the schema reference #/properties/hash/byteArray produced “a schema must be an object” instead of SuccessfulExecution. 12,906 tests passed, one failed, and fail-fast left 7,305 tests unrun. Comparing those exact merge/base trees shows rs-drive-abci, rs-dpp, rs-drive and rs-platform-version unchanged; the only Cargo.lock change adds the existing tempfile dependency to platform-wallet-ffi. This is evidence of a base-side schema-test failure, not a submission-recovery regression; I have not claimed a fresh base-only reproduction or a green full suite. The Swift build was consequently skipped. The companion iOS #1254 checks, including its simulator unit tests, are green.

No commit, push, review dismissal or merge in this pass. Local fixes and their validation are distinguished from published-head evidence in both PR descriptions.

@github-actions

github-actions Bot commented Oct 28, 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 Oct 28, 2026
@github-actions

github-actions Bot commented Oct 28, 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.

@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

The observation-aware submission mechanism is correctly applied to the shared SDK paths, but the platform-wallet contract update and DashPay profile writer still discard ambiguous broadcast history before waiting for proof. Kotlin also exposes consensus metadata on the new unconfirmed error if a code-11 native exception carries contradictory metadata. The Rust workspace check failed on an unrelated unchanged Drive schema assertion, while several CI checks remain pending.

🔴 2 blocking | 🟡 1 suggestion(s)

3 finding(s) not shown inline (the lines are not part of this PR's diff)

🔴 Blocking: Platform-wallet contract updates bypass the observation-aware combined path
packages/rs-platform-wallet/src/wallet/identity/network/contract.rs:547-554

This wallet-owned combined submission path still calls the broadcast-only API and propagates its final error before invoking DataContract::wait_for_response. If an earlier dispatched attempt may have been accepted but its acknowledgement is lost, a later refusal or exhausted retry causes the ? at line 550 to return immediately, so the existing proof lookup for the same signed transition never runs. A caller can then treat an executed contract update as failed and submit a replacement. Route this flow through the SDK's observation-preserving broadcast-and-wait helper.

source: muse-spark-1.3-contributor (phase1-reviewer: general, rust-quality); gpt-6.1-sol (phase2-reviewer: general, architecture-layering, ffi-engineer, rust-quality)

🔴 Blocking: DashPay profile writes still abort before waiting after an ambiguous broadcast
packages/rs-sdk/src/platform/dashpay/profile.rs:237-238

put_profile_write retains the old broadcast-then-wait sequence. An acknowledgement timeout, connection loss, or other possibly accepted broadcast error is returned at line 237, preventing the proof-backed wait_for_document_and_owner_balance_with_metadata call from checking whether that exact signed profile replacement executed. Because both profile create and update use this helper, a successful profile write can be reported as failed and later retried as a new operation. Preserve the broadcast observation and invoke the existing proof wait before returning an ambiguous failure.

source: muse-spark-1.3-contributor (phase1-reviewer: general, rust-quality); gpt-6.1-sol (phase2-reviewer: general, architecture-layering, rust-quality)

🟡 Suggestion: Mask consensus metadata on Kotlin unconfirmed submission errors
packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/errors/DashSdkError.kt:50-51

StateTransitionResultUnconfirmed retains the native DashSDKException as its cause, while the base consensusError accessor returns any consensus metadata from that cause without considering the native error code. The supported Rust conversion correctly emits code 11 without consensus metadata, but a malformed, stale, or future native code-11 payload can still expose a definitive consensus rejection on an operation whose execution remains uncertain. Make the accessor return null for StateTransitionResultUnconfirmed so callers cannot interpret diagnostic metadata as permission to replace the submission.

val consensusError: PlatformConsensusError?
    get() = if (this is StateTransitionResultUnconfirmed) {
        null
    } else {
        (cause as? DashSDKException)?.consensusError
    }

source: muse-spark-1.3-contributor (phase1-reviewer: rust-quality); gpt-6.1-sol (phase2-reviewer: general, architecture-layering, ffi-engineer, rust-quality)

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.1-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 7: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.1-sol (effort low) — This is a large, intricate change to submission and recovery logic that directly affects funds movement and replacement-spend decisions, particularly in identity top-up paths such as top_up_identity_from_addresses.rs and the platform wallet top-up handling.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — ffi-engineer (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `packages/rs-platform-wallet/src/wallet/identity/network/contract.rs`:
- [BLOCKING] packages/rs-platform-wallet/src/wallet/identity/network/contract.rs:547-554: Platform-wallet contract updates bypass the observation-aware combined path
  This wallet-owned combined submission path still calls the broadcast-only API and propagates its final error before invoking `DataContract::wait_for_response`. If an earlier dispatched attempt may have been accepted but its acknowledgement is lost, a later refusal or exhausted retry causes the `?` at line 550 to return immediately, so the existing proof lookup for the same signed transition never runs. A caller can then treat an executed contract update as failed and submit a replacement. Route this flow through the SDK's observation-preserving broadcast-and-wait helper.

In `packages/rs-sdk/src/platform/dashpay/profile.rs`:
- [BLOCKING] packages/rs-sdk/src/platform/dashpay/profile.rs:237-238: DashPay profile writes still abort before waiting after an ambiguous broadcast
  `put_profile_write` retains the old broadcast-then-wait sequence. An acknowledgement timeout, connection loss, or other possibly accepted broadcast error is returned at line 237, preventing the proof-backed `wait_for_document_and_owner_balance_with_metadata` call from checking whether that exact signed profile replacement executed. Because both profile create and update use this helper, a successful profile write can be reported as failed and later retried as a new operation. Preserve the broadcast observation and invoke the existing proof wait before returning an ambiguous failure.

In `packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/errors/DashSdkError.kt`:
- [SUGGESTION] packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/errors/DashSdkError.kt:50-51: Mask consensus metadata on Kotlin unconfirmed submission errors
  `StateTransitionResultUnconfirmed` retains the native `DashSDKException` as its cause, while the base `consensusError` accessor returns any consensus metadata from that cause without considering the native error code. The supported Rust conversion correctly emits code 11 without consensus metadata, but a malformed, stale, or future native code-11 payload can still expose a definitive consensus rejection on an operation whose execution remains uncertain. Make the accessor return `null` for `StateTransitionResultUnconfirmed` so callers cannot interpret diagnostic metadata as permission to replace the submission.
Out-of-scope follow-up suggestions (2)

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.

  • Preserve the unconfirmed classification through the WASM boundary — The WASM adapter still maps the unconfirmed result to its existing generic kind while preserving is_retriable = false, so JavaScript callers cannot consume a dedicated typed classification. This is a concrete public API limitation, but the PR explicitly defers it to the tracked follow-up.
    • Follow-up: Implement the dedicated WASM error kind under #5511 (comment).
  • Do not classify DAPI broadcast state by human-readable status text — The SDK classifies the DAPI processing-rejection marker by exact human-readable text. The producer's duplicate-transaction path can observe an earlier AlreadyExists condition without proving that the transition was never accepted elsewhere, so a structured DAPI error marker would make this boundary safer. The PR explicitly defers the cross-layer contract change to the tracked follow-up.
    • Follow-up: Replace the text comparison with a machine-readable DAPI/gRPC marker under #5511 (comment).

@github-actions

Copy link
Copy Markdown
Contributor

Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix.
Full checklist in the description.

@github-actions github-actions Bot added the waiting-self-review Waiting for the author to post /self-reviewed label Oct 28, 2026
@llbartekll

Copy link
Copy Markdown
Contributor Author

/self-reviewed dced0c1

Conflict-only integration of v5.1-dev at 9b36712 after lklimek's approval of parent 66243c7. Resolved broadcast.rs by retaining upstream type-29 protocol preflight before this PR's existing broadcast retry path, plus both sets of helpers/tests. Existing transition kinds gain no additional probe; shared uncertain-result handling remains intact.

Validation: 715 SDK all-feature library tests, 25 SDK FFI error tests, 6 SDK→wallet→FFI submission tests; SDK/SDK-FFI/wallet-FFI all-feature/all-target Clippy with warnings denied; full workspace all-target check; rustfmt and diff checks passed. Read-only FFI/WASM integration audit found no additional merge correction. No new native/mobile validation claimed. Fresh CI/review state applies to this exact head; no PR merge.

@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Your move: coderabbitai left review threads unresolved; resolve them; thepastaclaw left review threads unresolved; resolve them.
Full checklist in the description.

@llbartekll

Copy link
Copy Markdown
Contributor Author

/self-reviewed

@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

Verified the complete diff at dced0c1: the shared Rust submission paths preserve delivery uncertainty, retain the original signed transition, and wrap unsuccessful confirmation attempts without promoting unsigned verdicts. Three non-blocking suggestions remain concerning generic WASM sibling coverage, public-boundary assertions, and legacy mock replay. This was a static review; current CI shows all completed code checks passing, including Rust workspace, wasm32, Swift, Kotlin, functional, and both browser suites, with only review/hygiene checks pending.

🟡 3 suggestion(s)

1 finding(s) not shown inline (the lines are not part of this PR's diff)

🟡 Suggestion: Explicitly track the generic WASM combined APIs that bypass the shared gate
packages/wasm-sdk/src/state_transitions/broadcast.rs:224-232

Both exported generic combined APIs still broadcast and then wait separately: broadcastAndWait returns here on a broadcast error, and broadcastAndWaitForAffectedState repeats the sequence at lines 295–303. An uncertain send therefore skips the original-transition wait; after an acknowledged send, a failed wait also bypasses the shared unconfirmed envelope and can expose an ordinary proof error or unsigned consensus verdict. These inherited siblings need not expand this PR's implementation scope, but its retained-limitations list and the concrete checklist in #4998 name only contract updates and profile writes. Explicitly add both exported methods to that tracked exception before deferring them. Their eventual repair should delegate combined-outcome orchestration to rs-sdk, preserving ownerBalance and strict-versus-affected-state guarantees rather than adding submission policy to WASM.

source: muse-spark-1.3-contributor (phase1-reviewer: general, rust-quality); gpt-6.1-sol (phase2-reviewer: general, rust-quality)

2 carried-forward finding(s) already raised on this PR; not re-posting as new inline comments.

Review provenance

Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 7: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 8: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 9: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 10: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 11: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 12: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 13: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 14: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.1-sol (effort low) — The intricate retry and outcome-classification changes in packages/rs-sdk/src/platform/transition/broadcast.rs and wallet top-up recovery directly alter funds-moving submission behavior, including whether uncertain delivery permits a replacement operation.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — ffi-engineer (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — platform-versioning (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — ffi-engineer (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — platform-versioning (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `packages/wasm-sdk/src/state_transitions/broadcast.rs`:
- [SUGGESTION] packages/wasm-sdk/src/state_transitions/broadcast.rs:224-232: Explicitly track the generic WASM combined APIs that bypass the shared gate
  Both exported generic combined APIs still broadcast and then wait separately: `broadcastAndWait` returns here on a broadcast error, and `broadcastAndWaitForAffectedState` repeats the sequence at lines 295–303. An uncertain send therefore skips the original-transition wait; after an acknowledged send, a failed wait also bypasses the shared unconfirmed envelope and can expose an ordinary proof error or unsigned consensus verdict. These inherited siblings need not expand this PR's implementation scope, but its retained-limitations list and the concrete checklist in #4998 name only contract updates and profile writes. Explicitly add both exported methods to that tracked exception before deferring them. Their eventual repair should delegate combined-outcome orchestration to rs-sdk, preserving ownerBalance and strict-versus-affected-state guarantees rather than adding submission policy to WASM.

In `packages/rs-sdk/src/sdk/put_test_support.rs`:
- [SUGGESTION] packages/rs-sdk/src/sdk/put_test_support.rs:186-191: Assert the typed unconfirmed outcome at public submission boundaries
  (existing thread: https://github.com/dashpay/platform/pull/5556#discussion_r4480387994)
  When the fixture expects a result wait, its deliberately invalid response must produce a typed unconfirmed outcome. The current assertions require only an error other than top-level AlreadyExists, so a public wrapper returning a bare proof error, timeout, or stringified Generic error would still pass despite losing the classification that prevents replacement-operation recovery. Assert `is_state_transition_result_unconfirmed()`, non-retryability, and no promoted consensus verdict for `expected_waits == 1`, while keeping definite broadcast-refusal controls separate. The lower-level gate and top-up FFI regressions do not establish propagation through each document, contract, purchase, price-update, and transfer API exercised by this fixture.

In `packages/rs-dapi-client/src/mock.rs`:
- [SUGGESTION] packages/rs-dapi-client/src/mock.rs:71-73: Classify retained transport errors when loading legacy recordings
  (existing thread: https://github.com/dashpay/platform/pull/5556#discussion_r4480387988)
  Legacy recordings default their missing possibly_accepted flag to false and load through expect(), but this match classifies only the direct Transport variant. The production executor also retains its last transport failure inside NoAvailableAddressesToRetry when addresses are exhausted. A legacy broadcast recording containing that envelope around Unavailable or DeadlineExceeded consequently replays with possibly_accepted=false, allowing the SDK to skip the original-transition wait even though live execution preserves uncertainty. Classify the transport cause from both variants on the hand-built/legacy path and add a legacy load-through-execute regression with an ordinary-read control. Keep the existing versioned-recording bypass so stored classifications remain unchanged.
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.

  • Authenticate first-attempt refusals before permitting replacement payments — Without earlier uncertainty, broadcast consensus metadata is still treated as a definite refusal and deserialized without execution-proof authentication. A DAPI endpoint that forwards a valid payment and then fabricates a nonce refusal can therefore expose a verdict that callers may use to construct a replacement payment. This first-attempt endpoint-trust assumption predates the reviewed change; the new protection specifically preserves uncertainty from prior attempts and unsuccessful result waits.
    • Follow-up: Address rejection provenance in a separate security-focused issue or PR, including a regression where an endpoint forwards the original payment before returning fabricated nonce metadata and the caller attempts replacement recovery.

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Your move: coderabbitai left review threads unresolved; resolve them; thepastaclaw left review threads unresolved; resolve them.
Full checklist in the description.

@HashEngineering HashEngineering 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.

Kotlin SDK review (kotlin-sdk files only): approving.

Verified end to end:

  • Native code 11 reaches Kotlin unchanged: rs-unified-sdk-jni results::throw_sdk_error passes err.code through, and it can't collide with the +1000 platform-wallet range.
  • Both Rust FFIs zero consensus_code/consensus_kind on unconfirmed results, so DashSdkError.consensusError is null for code 11 and wallet code 20, and consensus-code branching (e.g. DecisionProposals, 40106) can't treat an unconfirmed result as a rejection.
  • No Kotlin SDK or example-app code retries on isRetryable/Timeout, and no exhaustive when over DashSdkError needed a new branch.

Non-blocking suggestions:

  1. Code 20 userMessage parity with Swift. Swift gives transactionBroadcastUnconfirmed the same "Submission result is unconfirmed. Check history and reconcile the original operation before submitting again." text as the SDK path. Kotlin's PlatformWallet.TransactionBroadcastUnconfirmed doesn't override userMessage, so it shows the raw Rust error chain plus the "(do NOT retry…)" suffix. Most Android wallet operations (identity top-ups from addresses, token/document sends through the wallet) surface code 20 rather than 11, so this is the path users will usually see. Suggest overriding userMessage with the same string as StateTransitionResultUnconfirmed.
  2. Stale lockstep comment (nit). rs-unified-sdk-jni/src/support.rs (lines 67 and 76) still documents the rs-sdk-ffi range as "1–10"; the Kotlin counterpart for PLATFORM_WALLET_CODE_OFFSET now says "1–11, 99".
  3. Optional hardening (nit). shouldPreserveUnconfirmedSubmissionWithoutRetrying asserts consensusError is null, but the exception is built without one, so the assert can't fail. If you want Kotlin to enforce it rather than rely on the Rust guarantee, StateTransitionResultUnconfirmed could override consensusError to return null.

@llbartekll

Copy link
Copy Markdown
Contributor Author

/self-reviewed

1 similar comment
@llbartekll

Copy link
Copy Markdown
Contributor Author

/self-reviewed

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Ready for review — files with no dedicated owner: QuantumExplorer or shumkov · js-wasm-sdk: shumkov.
Full checklist in the description.

@github-actions github-actions Bot added ready-for-human Bots have reported, the author has self-reviewed, and the build is green: this needs a human. and removed waiting-self-review Waiting for the author to post /self-reviewed labels Nov 10, 2026
@shumkov
shumkov merged commit dabbec0 into v5.1-dev Nov 10, 2026
45 of 46 checks passed
@shumkov
shumkov deleted the codex/submission-recovery branch November 10, 2026 09:02
@github-actions github-actions Bot removed the ready-for-human Bots have reported, the author has self-reviewed, and the build is green: this needs a human. label Nov 10, 2026
QuantumExplorer added a commit that referenced this pull request Nov 10, 2026
#5815 was squash-merged into v5.1-dev, so its block query files were added
on both sides. Resolved to v5.1-dev with this branch's changes on top, the
same tree a rebase of this branch's two commits gives.

The block queries now set `possibly_accepted: false` on the `ExecutionError`
they build, the field v5.1-dev added in #5556: they are reads, and the
error comes from verifying an answer that arrived.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
QuantumExplorer added a commit that referenced this pull request Nov 10, 2026
…uests

Brings in #5556 (shared broadcast keeps uncertain submission outcomes),
#5823 (proven state transition outcome, getRecentStateTransitionStatus),
#5815, #5834, #5825, #5835, #5838 and #5839.

One textual conflict, in packages/rs-sdk/src/platform/transition/broadcast.rs
at the end of broadcast_with_retries. This branch (#5837) had the shared
broadcast fail over on a nonce-ahead answer and on a missing DPNS owner
(retry_with_additional_error, from #5562), and made is_address_nonce_ahead
public for the wallet's single-dispatch broadcast. #5556 replaced both
failovers with the plain shared retry, so that a concrete refusal ends
sending, with tests saying so (should_stop_on_nonce_rejection_without_
rebuilding_or_resending, should_stop_on_concrete_rejection_regardless_of_
node_failover_settings), and removed is_address_nonce_ahead and
is_missing_transition_owner. The file is taken as v5.1-dev has it.

The wallet's single-dispatch broadcast (broadcast_outcome::track_delivery)
still goes on to the next dispatch after a nonce-ahead answer, as #5837
meant: the classifier moves into broadcast_outcome.rs, unchanged, and its
doc no longer says the SDK's own broadcast fails over too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
QuantumExplorer added a commit that referenced this pull request Nov 10, 2026
… the single-dispatch broadcast and the spend contract

Since #5556 the SDK puts a broadcast that may have been delivered under
Error::StateTransitionResultUnconfirmed, a duplicate answer included
(a gRPC AlreadyExists is classified as possibly accepted). The wallet's
single-dispatch broadcast read only a bare AlreadyExists as admitted, so
a node already holding the transition now read as maybe delivered and
the same bytes went on to the rest of the budget. A node holding the
transition, bare or under the unconfirmed or retry envelope, is admitted
again. The envelope is maybe delivered whatever it wraps, never a
refusal before anything was sent, and the identity shield never reads
it as a refusal.

The FFI's shielded spend contract (map_spend_result) flattened an
unclassified SDK unconfirmed outcome to ErrorWalletOperation (6), which
reads as a failure; it now keeps the blanket conversion's
ErrorTransactionBroadcastUnconfirmed (20).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
QuantumExplorer added a commit that referenced this pull request Nov 10, 2026
…ns in the registry

#5556 routes the SDK's unconfirmed state transition outcome to
ErrorTransactionBroadcastUnconfirmed (20), and the shielded spend
contract keeps it there; the registry row now says so.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
QuantumExplorer added a commit that referenced this pull request Nov 10, 2026
…tact-requests' into feat/ffi-swift-private-contact-requests

Brings in the wallet at 207bd72: #5837 merged into it, v5.1-dev
(#5556, #5823 and others), and the spend contract keeping code 20.

Conflicts:
- shielded_send.rs: the wallet's catch_spend_panic doc is taken, and the
  function stays pub(crate), as the private contact request exports call
  it.
- PlatformWalletResult.swift: the wallet's docs for 16 and 18 (the result
  code and the typed error) are taken. They are newer: a note spend's
  verdict and a shield's are both 18.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
shumkov added a commit that referenced this pull request Nov 10, 2026
Merge upstream f95aa74 without rebasing.

Resolve the two PV15 update v2 implementations into one generation: retain
current-primary pointers, immutable revision writes and history-aware index
references, and carry over #5829's owner-following refreshes for unchanged
indexes and indexed-array members. The current revision's stored flags decide
whether ownership changed, as upstream and moderation require. The normalized
five-hunk ownership delta equals upstream's v1 body with owner-following on.

Preserve upstream's standalone update apply-and-add v1 in the single document
table update block, along with contested insertion v2, the contested verifier
v1, execute-event v2, Grove methods V2 and moderation transform v1. Layer only
the history slots into PV15 tables; retain inactive layout backfills for older
tables. History's protocol note becomes 30 after upstream notes 28 and 29.

Keep #5835's maybe-contested verifier, current/legacy history path selection,
and both-branch global-limit lowering for merge generation 2. Preserve the
legacy history block-time refusal and distinguish released and current query
layouts in tests and documentation. Cover contested-history documents in the
contest and ordinary storage locations with proof verification.

Use upstream's GroveDB fa92511c manifest and lock unchanged. Regenerate DAPI
clients for the combined history and new block-query RPCs. Keep the chained
query's production bytes, Grove V4 lifted-query comparison and V5 refusal;
deduplicate three Query.offset fields and fill possibly_accepted=false in the
history SDK error fixture for #5556.

Rewrite the two sponsorship history tests for immutable time/revision keys:
the first user update hands the current pointer and unchanged index entry over,
revision 1 remains sponsored, and a later shrink retains all revisions and
refunds nobody. Assert raw flags on pointer, index reference and each revision.
Keep the existing estimate-coverage test unchanged. Add native and migrated
history handover tests, including the existing pre-PV15 split-payer residual.

Retain the existing decision-source residual: after a pre-PV15 transfer, the
migrated pointer and unchanged index can name the earliest payer while the
current revision names the last writer. The first PV15 update by that holder
hands the pointer over, but the unchanged index retains its earlier payer
because the revision owner did not change. Do not change the source used by
upstream and moderation to decide ownership changes.

Test would have caught the missing index handover: failed against the exact
pre-merge history v2, passed after the combined implementation. Released
protocol tables and existing history goldens are preserved; activation
migration is unchanged.
PastaPastaPasta added a commit that referenced this pull request Nov 11, 2026
…e in dash-sdk-cxx

Since #5556, a submission whose result could not be confirmed returns
Error::StateTransitionResultUnconfirmed. The C++ status mapping predates it,
so an identity registration, top-up or DPNS name accepted by a node whose
result wait then timed out reached the embedder as Internal: bad input or a
bug, rather than an outcome that is still unknown. Map it to Unavailable,
with no consensus code even when the diagnostic cause is a consensus error,
as the SDK itself declines to read a verdict through the wrapper.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

6 participants