Repository navigation
fix(swift-sdk): run identityGet and dpnsGetUsername off the main actor - #5862
Conversation
Both were @mainactor and called synchronous FFI exports that block on the network fetch, so an app awaiting them froze its UI for the whole round trip, timeouts included. They are now nonisolated and run the blocking call through performBlockingQuery, as documentList does; their signatures stay async throws. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 34 minutes. View limit details
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
|
✅ Final review complete — no blockers (commit da4773c) · triage: low |
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 1 + Phase 2
At head 2df354f, both queries correctly reuse the off-main executor while preserving FFI ownership, error handling, and absence semantics. Static verification confirms two non-blocking suggestions: track the remaining instances of the same blocking-query pattern and strengthen the new test's error assertions. The Swift CI log reports 937 SDK tests with one skipped and no failures; the overall Swift check failed later because the simulator could not launch the SwiftExampleApp test runner, not because of an identified defect in this diff.
🟡 2 suggestion(s)
Approved: nothing here blocks the merge. The non-blocking findings are optional: fix them forward, in this PR or a follow-up, without waiting for another review round.
1 finding(s) not shown inline (the lines are not part of this PR's diff)
🟡 Suggestion: Track the remaining main-actor blocking query wrappers
packages/swift-sdk/Sources/SwiftDashSDK/FFI/PlatformQueryExtensions.swift:232-239
The same blocking pattern remains in sibling methods: identityGetKeys, identityGetNonce, identityGetBalance, dpnsResolve, and dpnsSearch, among others, inherit main-actor isolation from this extension and directly invoke Rust exports that synchronously call runtime.block_on. Awaiting those methods from UI code therefore still freezes the main thread during the network round trip. Limiting this fix to the two reported reads is reasonable, but the missed instances need a linked tracking issue before being deferred. Issue #5303 covers error assertions, error mapping, and executor consolidation rather than these migrations; closed issue #5145 targets the previously converted document and contest queries. Link a dedicated follow-up covering the remaining wrappers, or migrate them here.
source: glm-5.3-flash (phase1-reviewer: general)
Review provenance
Source: reviewer 1: glm-5.3-flash (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
lowbygpt-6.1-sol(effort low) — This is a small, contained change that moves two blocking reads onto an existing off-main execution helper and adds a focused regression test without changing critical protocol or financial logic. - Phase 1 reviewers:
glm-5.3-flash— general (completed, effort high); agentphase1-reviewer - Phase 1 model:
glm-5.3-flash— zai quota: 5h 92% left, weekly 79% left; passed overgemini-3.8-flash-high(antigravity quota lookup failed) - Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort medium); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort medium); agentphase2-reviewer,gpt-6.1-sol— ffi-engineer (completed, effort medium); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort medium); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.
In `packages/swift-sdk/Sources/SwiftDashSDK/FFI/PlatformQueryExtensions.swift`:
- [SUGGESTION] packages/swift-sdk/Sources/SwiftDashSDK/FFI/PlatformQueryExtensions.swift:232-239: Track the remaining main-actor blocking query wrappers
The same blocking pattern remains in sibling methods: `identityGetKeys`, `identityGetNonce`, `identityGetBalance`, `dpnsResolve`, and `dpnsSearch`, among others, inherit main-actor isolation from this extension and directly invoke Rust exports that synchronously call `runtime.block_on`. Awaiting those methods from UI code therefore still freezes the main thread during the network round trip. Limiting this fix to the two reported reads is reasonable, but the missed instances need a linked tracking issue before being deferred. Issue #5303 covers error assertions, error mapping, and executor consolidation rather than these migrations; closed issue #5145 targets the previously converted document and contest queries. Link a dedicated follow-up covering the remaining wrappers, or migrate them here.
In `packages/swift-sdk/SwiftTests/SwiftDashSDKTests/PlatformQueryOffMainTests.swift`:
- [SUGGESTION] packages/swift-sdk/SwiftTests/SwiftDashSDKTests/PlatformQueryOffMainTests.swift:73-82: Reject pre-FFI failures in the new regression test
Both bare catches accept `SDKError.invalidState`, including the error thrown by `performBlockingQuery` before it invokes the FFI closure. A regression that makes handle acquisition fail would therefore let this test pass while neither query reaches Rust, despite the test's stated invariant. The main-thread timing assertion remains useful, but it should be paired with an assertion that these calls did not fail before entering the FFI. This is the same weakness documented in issue #5303; avoid adding two more instances in the new test.
|
Bots are done — your move: post |
|
Re the suggestion to track the remaining main-actor blocking query wrappers: deferred, tracked in #5867 (the 12 sibling reads in |
…ver reaches the FFI Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
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
At 5d99479, both regression-test calls now reject pre-FFI invalidState failures, and the off-main query changes preserve FFI ownership and existing result semantics. One minor test-handshake robustness issue remains; no blocking defects were confirmed. Static verification and current CI show passing Swift SDK build/tests and frozen-schema checks, with review and PR Hygiene checks pending.
💬 1 nitpick(s)
Approved: nothing here blocks the merge. The non-blocking findings are optional: fix them forward, in this PR or a follow-up, without waiting for another review round.
Review provenance
Source: reviewer 1: glm-5.3-flash (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
lowbygpt-6.1-sol(effort low) — This is a small, contained change moving two blocking reads onto an existing query execution pattern, with focused regression coverage and no changes to critical protocol or financial logic. - Phase 1 reviewers:
glm-5.3-flash— general (completed, effort high); agentphase1-reviewer - Phase 1 model:
glm-5.3-flash— zai quota: 5h 84% left, weekly 77% left; passed overgemini-3.8-flash-high(antigravity quota lookup failed) - Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort medium); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort medium); agentphase2-reviewer,gpt-6.1-sol— ffi-engineer (completed, effort medium); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort medium); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.
In `packages/swift-sdk/SwiftTests/SwiftDashSDKTests/PlatformQueryOffMainTests.swift`:
- [NITPICK] packages/swift-sdk/SwiftTests/SwiftDashSDKTests/PlatformQueryOffMainTests.swift:66-71: Bound the wait for the main-thread hold to start
The five-second timeout only starts after the main-queue block executes. The initial mainHeld.wait() has no deadline, so if the test host stops servicing the main queue before that block starts, this continuation never resumes and the test waits for an external runner timeout instead of reporting a local failure. This is test robustness rather than a defect in the query implementation. Give the handshake a bounded wait and report a test failure on timeout; use a throwing continuation if propagating that failure as an error.
|
Bots are done — your move: post |
The wait for the main queue to start the hold had no deadline, so a host that never serviced the main queue made the test hang instead of fail. Wait at most 5 seconds, release the hold, and throw an error saying the main queue never ran it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
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
Static verification at da4773c found no new actionable defects in the off-main query wrappers or current-head test changes. The reported identity-not-found message regression does not occur because the old null-pointer branch was unreachable. Current CI reports successful Swift SDK build/tests and frozen-schema checks, with no failed code checks; PR Hygiene and PastaClaw review remain pending.
🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(s)
Review provenance
Source: reviewer 1: glm-5.3-flash (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
lowbygpt-6.1-sol(effort low) — This is a small, contained change moving two blocking reads onto an existing off-main execution helper, with focused regression tests and no changes to critical protocol or financial logic. - Phase 1 reviewers:
glm-5.3-flash— general (completed, effort high); agentphase1-reviewer - Phase 1 model:
glm-5.3-flash— zai quota: 5h 87% left, weekly 66% left; passed overgemini-3.8-flash-high(antigravity quota lookup failed) - Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort medium); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort medium); agentphase2-reviewer,gpt-6.1-sol— ffi-engineer (completed, effort medium); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort medium); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify the current code and confirm that no unresolved issues remain.
No unresolved findings remain from the prior review on this head.
|
Bots are done — your move: post |
|
/self-reviewed |
|
Policy satisfied — this can merge. |
llbartekll
left a comment
There was a problem hiding this comment.
Read the diff and the surrounding helpers; no bugs found.
- Behaviour is unchanged:
identityGetstill throwsnotFoundon an empty result,dpnsGetUsernamestill returns[], and FFI errors keep their typed mapping. - FFI ownership is right: the string and error are copied and freed inside the closure on the query queue, and
performBlockingQueryretainsselffor the duration of the call. - The new test holds the main thread across both calls and rejects
invalidState, so a regression back to@MainActorwould be caught.
I did not run the tests locally; CI is green.
Issue being fixed or feature implemented
SDK.identityGet(identityId:)andSDK.dpnsGetUsername(identityId:limit:)are@MainActorand call synchronous FFI exports (dash_sdk_identity_fetch, the DPNS username query) that block on the network fetch. An app that awaits them from its UI freezes the main thread for the whole round trip, including slow-network timeouts. Dash Wallet iOS hits this when it checks an Identity ID typed into its Send flow (dashpay/dashwallet-ios#1358).What was done?
identityGetanddpnsGetUsernameare nownonisolatedand run the blocking FFI call throughperformBlockingQuery, the patterndocumentListalready uses in the same file; their results are returned assendingvalues. Signatures stayasync throws, so callers compile unchanged.printlines inidentityGetare removed.PlatformQueryExtensions.swiftwith the same blocking shape (identityGetKeys,identityGetNonce,identityGetContractNonce,identityGetBalance,identityGetBalanceAndRevision,identityGetByPublicKeyHash,identityGetByNonUniquePublicKeyHash,dataContractGet,dataContractGetHistory,documentGet,dpnsResolve,dpnsSearch). They can follow the same pattern separately.How Has This Been Tested?
PlatformQueryOffMainTests.testIdentityReadsDoNotNeedTheMainActor: runs on no actor, holds the main thread, calls both reads against the FFI mock and asserts they return while the main thread is still held. A variant that runs the FFI on the main actor fails it (≈5.8 s wait).xcodebuild test -scheme SwiftDashSDK -only-testing:SwiftDashSDKTests(iPhone 17 simulator): 937 tests, 1 skipped, 2 failures — both inKeychainSignerAdditionalSigningKeysTests(XCTUnwrapon a keychain write), which fail the same way without this change.SwiftExampleAppbuild-for-testing succeeds.Breaking Changes
None. Isolation is relaxed; the public signatures are unchanged.
Checklist:
structure.rs, regeneratedgrovedb-structure.json, and checked the structure viewer link posted on this pull requestFor repository code-owners and collaborators only
🤖 Generated with Claude Code
PR Hygiene ·
da4773cWhen every merge requirement is met, the
PR Hygienecheck passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.Summary by CodeRabbit