Repository navigation
fix(sdk): preserve uncertain submission outcomes through shared broadcast - #5556
Conversation
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
Walkthrough
Merge Risk:
|
|
✅ Final review complete — no blockers (commit dced0c1) |
|
Self-review completed for 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 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. |
|
/self-reviewed 48490f2 |
thepastaclaw
left a comment
There was a problem hiding this comment.
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:
criticalbygpt-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 intop_up_identity_from_addresses.rsand the corresponding FFI boundaries. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer,muse-spark-1.3-contributor— rust-quality (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-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; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— ffi-engineer (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort xhigh); agentphase2-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.
|
Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix; thepastaclaw left review threads unresolved; resolve them. |
|
@thepastaclaw Follow-up on the final review of
CI diagnosis: the failed Rust workspace job ran the synthetic merge 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. |
|
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
|
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
thepastaclaw
left a comment
There was a problem hiding this comment.
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:
criticalbygpt-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 astop_up_identity_from_addresses.rsand the platform wallet top-up handling. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer,muse-spark-1.3-contributor— rust-quality (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-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; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— ffi-engineer (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort xhigh); agentphase2-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
AlreadyExistscondition 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).
|
Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix. |
|
/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. |
|
Your move: coderabbitai left review threads unresolved; resolve them; thepastaclaw left review threads unresolved; resolve them. |
|
/self-reviewed |
thepastaclaw
left a comment
There was a problem hiding this comment.
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:
criticalbygpt-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); agentphase1-reviewer,muse-spark-1.3-contributor— rust-quality (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-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; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— ffi-engineer (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— platform-versioning (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— ffi-engineer (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— platform-versioning (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort xhigh); agentphase2-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.
|
Your move: coderabbitai left review threads unresolved; resolve them; thepastaclaw left review threads unresolved; resolve them. |
HashEngineering
left a comment
There was a problem hiding this comment.
Kotlin SDK review (kotlin-sdk files only): approving.
Verified end to end:
- Native code 11 reaches Kotlin unchanged:
rs-unified-sdk-jniresults::throw_sdk_errorpasseserr.codethrough, and it can't collide with the +1000 platform-wallet range. - Both Rust FFIs zero
consensus_code/consensus_kindon unconfirmed results, soDashSdkError.consensusErroris 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 exhaustivewhenoverDashSdkErrorneeded a new branch.
Non-blocking suggestions:
- Code 20
userMessageparity with Swift. Swift givestransactionBroadcastUnconfirmedthe same "Submission result is unconfirmed. Check history and reconcile the original operation before submitting again." text as the SDK path. Kotlin'sPlatformWallet.TransactionBroadcastUnconfirmeddoesn't overrideuserMessage, 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 overridinguserMessagewith the same string asStateTransitionResultUnconfirmed. - 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 forPLATFORM_WALLET_CODE_OFFSETnow says "1–11, 99". - Optional hardening (nit).
shouldPreserveUnconfirmedSubmissionWithoutRetryingassertsconsensusErroris 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,StateTransitionResultUnconfirmedcould overrideconsensusErrorto return null.
|
/self-reviewed |
1 similar comment
|
/self-reviewed |
|
Ready for review — files with no dedicated owner: QuantumExplorer or shumkov · |
#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>
…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>
… 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>
…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>
…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>
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.
…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>
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;839bcba470a0312054a7e7e66c7d3f13588b2b22added the final WASM test expectations.383aa3bab632ad5dffc10d6f9c8eb0389999c124removes the reported-refusal shortcut described below.e87e9b498fbc8c67ded53eea08d75d8b15d9414dintegratesv5.1-dev(9766bab24a14af7cfbcafe33b466a777db8f868c) and resolves the vote confirmation conflict. The670324539c4a7ba67e87743489e534db1bc8ca56follow-up preserves uncertainty for unsigned wait errors and routes SDK recording replay through the existing classified loader:ExecutionError<E>carriespossibly_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.broadcast()is the single send path. RemovedBroadcastOutcome,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.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.StateTransitionResultUnconfirmednow 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.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
How Has This Been Tested?
Base integration after human review — 9 November
Validated merge commit
dced0c119f9d84f873b931aa84f2e4c4e5057ade, integratingv5.1-devat9b36712770c33b2870cbe078f8b386fccb512dccwithout rewriting history: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.66243c798e069de1f919a3d83c6c85a1c6ef1932on 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, integratingv5.1-devate0f21d7137bc7e8d710d1ae56082ce0419418dd0without rewriting history: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.cargo check --workspace --all-targets, rustfmt and diff checks: passed.Unsigned wait verdict and SDK recording loader — 5 November
Validated head
670324539c4a7ba67e87743489e534db1bc8ca56:MockDapiClient::load, preserving versioned classification instead of reclassifying serialized errors. Regression coverage exercises bothload_expectations_syncandSdkBuilder::with_dump_dir, connector failures, consensus metadata and both stored flag values. Handcrafted FFI recordings now use the actual request classifier before serialization.--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.Cache-processing and mock replay fixes — 5 November
Previously validated head
b1e529bc2fd4f8227b1648b5e3cf66fa62ed3ab4contains 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 base9766bab24a14af7cfbcafe33b466a777db8f868c: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.cargo check --workspace --all-targets: passed. rustfmt and PR diff whitespace checks: passed.Reported-refusal fix — 5 November
Validated commit
383aa3bab632ad5dffc10d6f9c8eb0389999c124:--all-features --all-targets -- -D warnings, rustfmt and diff checks pass.c35e4feartifacts; 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-up839bcba470a0312054a7e7e66c7d3f13588b2b22; no production source changed between these commits. The additional full-workspace all-target check also passed on839bcba470a0312054a7e7e66c7d3f13588b2b22:-D warningscargo check --workspace --all-targetsRegression 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-featuresis unchanged.Fresh mobile artifacts were built from production commit
c35e4fe4b8756e9f43c66403f38d3ce712cb6753(clean), with iOS #1254 baseline03f781c4e3d231e360c9345b4099dfaf5e4a3b61and a local SDK-pin override only:d71a932783698cca17197b6321431959f418bb3e65dd8a80cd4ac8dedc21aa93.dashpayarm64 simulator build passed; five actual Swift error-decoder/presentation tests linked to the rebuilt C FFI passed (5/5).95d21e654d6aa25ff009743117b890b92b449b0186a66d1f965b537dabf9d761.42b8bbbbd6d120291433f11f578b4b7189d6688f30fa01402aada46b17ac842c. Balance observation alone is not claimed as an exact-transition execution proof.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 requiredpossibly_acceptedfield, 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
No merge or application publication is authorized by this change.
Summary by CodeRabbit
New Features
Bug Fixes