Repository navigation
fix(platform): ask for quorum keys again when the SDK had not started yet - #1730
Conversation
… yet The first quorum lookups of a launch arrive a few seconds before the Kotlin SDK has started. The key cache recorded that empty answer as a fetch attempt and did not ask again for the 30 s retry interval, so every DAPI proof failed with "quorum not found", the old Platform client banned healthy nodes, and once its requests backed off nothing triggered another fetch for minutes. A fetcher that cannot ask at all now reports that, and the cache leaves the lookup unstamped so the next one asks again. A real failed or empty fetch is still rate-limited by the retry interval. Co-Authored-By: Claude Fable 5.2 <[email protected]>
One INFO line when the status changes (NOT_READY, SYNCING, READY), so a report of a balance stuck on "syncing" shows which state the pool was in. Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
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 45 minutes. View limit details
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. |
|
✅ Final review complete — no blockers (commit a71a7e0) · triage: low |
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 1 + Phase 2
The quorum cache now retries on the next lookup when no SDK handle was available, while preserving cached keys and the existing refresh and retry intervals for actual fetches. Shielded sync logging preserves the existing publication order and lifecycle guards; the only in-scope finding is a detached KDoc block. CI build and check passed, PastaClaw review is pending, and no local tests were run during this static review.
💬 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.2-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.2-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)
- Triage:
lowbygpt-6.2-sol(effort low) — The diff makes a contained change to quorum-cache retry timing and adds transition logging without changing key parsing or proof verification. - Phase 1 reviewers:
glm-5.3-flash— general (completed, effort high); agentphase1-reviewer - Phase 1 model:
glm-5.3-flash— zai quota: 5h 76% left, weekly 27% left; passed overgemini-3.8-flash-high(antigravity quota lookup failed) - Fresh verifier:
gpt-6.2-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-sol— general (completed, effort medium); agentphase2-reviewer,gpt-6.2-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 `wallet/src/de/schildbach/wallet/service/platform/sdk/SdkSourcedQuorums.kt`:
- [NITPICK] wallet/src/de/schildbach/wallet/service/platform/sdk/SdkSourcedQuorums.kt:139-163: Keep the retry and locking contract attached to the quorum cache
The new exception and its own KDoc sit between the cache's KDoc and `SdkQuorumKeyCache`. Kotlin associates only the nearest KDoc with a declaration, so the exception retains its short description but the cache loses its merge, retry, and single-flight contract, including the new rule for a lookup that could not make a fetch. Move the exception and its KDoc above the cache's KDoc.
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.
- Verify the provenance of legacy Platform quorum keys — The existing wallet bridge supplies quorum hash and threshold key pairs from
currentQuorumsInfo()to the legacy proof verifier. The available Platform source usesFetchUnprovedfor that query and does not verify those pairs against validator-set commitments on that path. This PR changes when the call is retried, not which keys the verifier trusts.- Follow-up: Open a separate issue to confirm the trust guarantees of the pinned SDK artifact and, if it does not independently authenticate the pairs, update the bridge to use quorum keys from authenticated validator-set data.
| * [retryIntervalMs]; a populated one refreshes after | ||
| * [refreshIntervalMs]. Failures keep the previous keys and stamp the | ||
| * attempt so the DAPI callback can never hammer the fetcher. | ||
| * - A fetcher that throws [QuorumSourceNotReadyException] asked nobody (the | ||
| * SDK is not running yet), so that lookup is NOT stamped as an attempt: | ||
| * the next lookup asks again. Stamping it made the first lookups of a | ||
| * launch, which arrive seconds before the SDK starts, lock the cache | ||
| * empty for a full [retryIntervalMs] while every DAPI proof failed and | ||
| * healthy nodes were banned. | ||
| * - [snapshot] may block (single-flight) on the SDK query; callers are | ||
| * rust DAPI worker threads that are blocking on the quorum callback | ||
| * anyway. | ||
| */ | ||
| /** | ||
| * Thrown by a quorum fetcher that could not ask at all because its source | ||
| * (the Kotlin SDK) is not running. See [SdkQuorumKeyCache]. | ||
| */ | ||
| internal class QuorumSourceNotReadyException : Exception("quorum source not ready") |
There was a problem hiding this comment.
✅ Resolved at
a71a7e0e; see the replies below.
💬 Nitpick: Keep the retry and locking contract attached to the quorum cache
The new exception and its own KDoc sit between the cache's KDoc and SdkQuorumKeyCache. Kotlin associates only the nearest KDoc with a declaration, so the exception retains its short description but the cache loses its merge, retry, and single-flight contract, including the new rule for a lookup that could not make a fetch. Move the exception and its KDoc above the cache's KDoc.
| * [retryIntervalMs]; a populated one refreshes after | |
| * [refreshIntervalMs]. Failures keep the previous keys and stamp the | |
| * attempt so the DAPI callback can never hammer the fetcher. | |
| * - A fetcher that throws [QuorumSourceNotReadyException] asked nobody (the | |
| * SDK is not running yet), so that lookup is NOT stamped as an attempt: | |
| * the next lookup asks again. Stamping it made the first lookups of a | |
| * launch, which arrive seconds before the SDK starts, lock the cache | |
| * empty for a full [retryIntervalMs] while every DAPI proof failed and | |
| * healthy nodes were banned. | |
| * - [snapshot] may block (single-flight) on the SDK query; callers are | |
| * rust DAPI worker threads that are blocking on the quorum callback | |
| * anyway. | |
| */ | |
| /** | |
| * Thrown by a quorum fetcher that could not ask at all because its source | |
| * (the Kotlin SDK) is not running. See [SdkQuorumKeyCache]. | |
| */ | |
| internal class QuorumSourceNotReadyException : Exception("quorum source not ready") | |
| /** | |
| * Thrown by a quorum fetcher that could not ask at all because its source | |
| * (the Kotlin SDK) is not running. See [SdkQuorumKeyCache]. | |
| */ | |
| internal class QuorumSourceNotReadyException : Exception("quorum source not ready") | |
| /** | |
| * Merge-on-fetch cache for SDK-sourced quorum threshold keys. | |
| * | |
| * - A quorum's public key is immutable for its hash, so every successful | |
| * fetch MERGES into the previous snapshot — quorums that rotate out | |
| * stay resolvable for proofs signed shortly before rotation. | |
| * - Refresh policy at access time: an empty snapshot retries after | |
| * [retryIntervalMs]; a populated one refreshes after | |
| * [refreshIntervalMs]. Failures keep the previous keys and stamp the | |
| * attempt so the DAPI callback can never hammer the fetcher. | |
| * - A fetcher that throws [QuorumSourceNotReadyException] asked nobody (the | |
| * SDK is not running yet), so that lookup is NOT stamped as an attempt: | |
| * the next lookup asks again. Stamping it made the first lookups of a | |
| * launch, which arrive seconds before the SDK starts, lock the cache | |
| * empty for a full [retryIntervalMs] while every DAPI proof failed and | |
| * healthy nodes were banned. | |
| * - [snapshot] may block (single-flight) on the SDK query; callers are | |
| * rust DAPI worker threads that are blocking on the quorum callback | |
| * anyway. | |
| */ |
source: glm-5.3-flash (phase1-reviewer: general); gpt-6.2-sol (phase2-reviewer: general, security-auditor)
There was a problem hiding this comment.
Fixed in a71a7e0: moved QuorumSourceNotReadyException and its KDoc above the cache's KDoc, so the merge, retry and single-flight contract is attached to SdkQuorumKeyCache again.
There was a problem hiding this comment.
Resolved (re-reviewed at a71a7e0e): Thanks—the move puts the exception and its KDoc before the cache’s KDoc, so the merge, retry, and single-flight contract now directly documents SdkQuorumKeyCache.
The not-ready exception sat between SdkQuorumKeyCache and its KDoc, so the cache lost its merge, retry and single-flight contract. Co-Authored-By: Claude Fable 5.2 <[email protected]>
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
New on this head: This revision moves QuorumSourceNotReadyException and its KDoc above the KDoc for SdkQuorumKeyCache, without changing runtime behavior. The build and check jobs passed at the reviewed head; PastaClaw was still pending.
🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(s)
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.2-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)
- Triage:
lowbygpt-6.2-sol(effort low) — The diff makes a contained change to quorum-cache retry timing, adds transition logging, and tests the affected cases without changing proof verification or which keys are accepted. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort high); 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(zai below 15% reserve: 5h 100% left, weekly 0% left) - Fresh verifier:
gpt-6.2-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-sol— general (completed, effort medium); agentphase2-reviewer,gpt-6.2-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.
| * [retryIntervalMs]; a populated one refreshes after | ||
| * [refreshIntervalMs]. Failures keep the previous keys and stamp the | ||
| * attempt so the DAPI callback can never hammer the fetcher. | ||
| * - A fetcher that throws [QuorumSourceNotReadyException] asked nobody (the | ||
| * SDK is not running yet), so that lookup is NOT stamped as an attempt: | ||
| * the next lookup asks again. Stamping it made the first lookups of a | ||
| * launch, which arrive seconds before the SDK starts, lock the cache | ||
| * empty for a full [retryIntervalMs] while every DAPI proof failed and | ||
| * healthy nodes were banned. | ||
| * - [snapshot] may block (single-flight) on the SDK query; callers are | ||
| * rust DAPI worker threads that are blocking on the quorum callback | ||
| * anyway. | ||
| */ | ||
| /** | ||
| * Thrown by a quorum fetcher that could not ask at all because its source | ||
| * (the Kotlin SDK) is not running. See [SdkQuorumKeyCache]. | ||
| */ | ||
| internal class QuorumSourceNotReadyException : Exception("quorum source not ready") |
There was a problem hiding this comment.
Resolved (re-reviewed at a71a7e0e): Thanks—the move puts the exception and its KDoc before the cache’s KDoc, so the merge, retry, and single-flight contract now directly documents SdkQuorumKeyCache.
QA run 52 — PASS, and run 50's unattributed failure is now attributed to this PRRun 50 (build 12000301, without this PR) ended with a failure it recorded but refused to blame: accepting an incoming contact request failed twice, each time sitting on "Accepting" for 2–4 minutes before showing "Contact request not accepted", with Build 12000303 adds this PR. The same operation, on the same kind of fixture:
The ban count is the evidence, not the pass. Your PR describes the old client banning nodes on Each accept broadcast cleanly and was reconciled from Platform: Scope. Four accepts on two wallets on testnet, over about half an hour. Contact payments were not re-run here (they already passed in run 50), and mainnet was not touched. How this was testedBuilds. Devices. Android 16 (API 36) emulators, testnet, release-signed builds. Platform protocol 14. Unit tests on 12000304: 4,779 tests across 330 classes, 0 failures, 0 errors, 1 skipped. Both SDK native libraries are byte-identical in size across the two builds, so differences between them come from the PRs and not from the SDK underneath. Full report: https://github.com/HashEngineering/dash-wallet-qa-report — run 52. |
…x/send-after-first-sync Brings in the squash of #1714 (1a30905), with its last fix to the invoice screen's observers, and the base's #1719 and #1730. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Problem
A mainnet beta tester (12.0.x) reported the wallet still "syncing" several minutes after reaching 100%. In his logs the L1 chain synced in about 20 s, but Platform was unavailable for about 2.4 minutes after each launch (
platform check: 2.478 min,2.385 min), and the old Platform client banned 12 DAPI nodes in three minutes. Nine of those bans wereProof verification error: quorum key unavailable ... quorum not found, on healthy nodes.Cause
Post-cutover, the old Platform client gets its quorum keys from
SdkQuorumKeyCache, which fetches them from the Kotlin SDK on a quorum lookup. The first lookups of a launch arrive a few seconds before the SDK has started. The cache recorded that empty answer as a fetch attempt and did not ask again for the 30 s retry interval, so every proof in that window failed and the node that served it was banned. Once the client's requests backed off, nothing triggered another fetch for a long time.From the log, second launch:
SDK quorum fetch skipped: SDK not started yetDash Platform SDK startedplatform check: 2.385 minFix
The fetcher now reports "the SDK is not running" (
QuorumSourceNotReadyException) instead of returning an empty answer, and the cache leaves that lookup unstamped, so the next lookup asks again. A real failed or empty fetch is still rate-limited by the retry interval. The "skipped" line is logged once per not-ready streak rather than once per lookup.Fetching the keys once at SDK start was the alternative. It needs a start hook from
DashSdkServiceImplinto the quorum source (which depends on it the other way round), and alone it would not help, because the first lookups come before the start.Also
One INFO line when the shielded pool sync status changes (
shielded sync status: SYNCING -> READY), transitions only. The tester most likely saw the Shielded screen's "syncing" text, but the pool state was not logged anywhere, so that could not be confirmed.Not covered
Testing
./gradlew :wallet:test_testNet3DebugUnitTestforSdkQuorumKeyCacheTest(8),ParseQuorumThresholdKeysTest(5),ShieldedBalanceServiceTest(155): all pass.🤖 Generated with Claude Code