Repository navigation
feat(sdk): back SPV up with the trusted quorum service in Auto mode - #5882
Conversation
The crate's routing tests (the SPV slot, the strict SPV provider and the adaptive provider) were compiled by clippy but never run: the package was missing from the nextest list. Add it next to dash-sdk. Locally `cargo test -p dash-context-provider --all-features --locked` passes on the base (22 tests). Co-Authored-By: Claude Opus 5.5 <[email protected]>
In Auto mode the adaptive context provider asked the trusted provider only while the SPV client was not ready. Once SPV synced, a key it could not serve failed the request: a quorum SPV had not seen yet banned the honest node that named it, and one it held unverified failed the request. Now, while SPV is ready, a lookup SPV cannot serve goes to the trusted provider, and the trusted provider can only turn that failure into a key: - When it fails too, the lookup reports SPV's error. The SDK's fetch is the trusted provider's, and when that cannot help either, SPV, asked again, decides the verdict: a quorum it does not hold resolves to "unknown", which bans the node as before, and one it cannot judge to its error, which does not. A trusted service that is down therefore cannot spare a node SPV would ban. - A key SPV serves stays final: a signature that fails with it is the node's fault and is never retried with the trusted key. - A quorum type other than the network's Platform type never falls back. SPV refuses those so a lower-threshold quorum cannot vouch for Platform state, and the trusted provider looks quorums up by hash alone. - Strict SPV mode is unchanged and fails closed. While SPV is not ready, Auto is the trusted provider alone, as before. - Each fallback is logged at warn level with the quorum and both sources' errors. Auto is therefore only as strong as the trusted quorum service: someone who controls that service and a node can have a proof accepted that names a quorum SPV does not hold. The docs say so and point strict clients to SPV mode. ContextProvider::quorum_source now documents the source asked first. Tests, red before the change (dash-context-provider): - should_answer_from_trusted_when_a_ready_spv_source_cannot_serve_the_key - should_report_spvs_error_when_trusted_cannot_serve_the_key_either - should_fetch_missing_quorum_keys_from_trusted_except_in_spv_mode - should_let_spv_decide_the_verdict_when_the_trusted_fetch_cannot_help - should_keep_the_trusted_verdict_when_spv_stops_being_ready_during_a_fetch ✖ 5 failed on the base, ✔ pass after. - should_not_fall_back_for_a_quorum_type_other_than_platforms passes on the base; ✖ it failed against the fallback without the type pin, ✔ passes with it. - dash-sdk should_verify_a_proof_whose_quorum_spv_has_not_seen_with_the_trusted_key verifies a recorded proof through a local trusted quorum service with a synced SPV client that lacks the quorum: ✖ Error::Proof (a ban) with the old provider, ✔ verified after. should_not_retry_a_ready_spv_miss_against_trusted pinned the old behaviour and is replaced. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…fallback logs and tests Review follow-ups to the Auto fallback: - `dash_context_provider::is_platform_quorum_type` is now the one check that a quorum type is the network's Platform type; platform-wallet's SPV source and the adaptive provider's fallback both call it, so the two pins cannot drift. - A fallback the trusted provider serves is logged at info level: it is the designed path while SPV lags a new quorum and would otherwise warn on every verification. A lookup or fetch neither source can serve still warns, with both sources' errors under the same field names. - The SDK's "unknown quorum" log and docs, the status JSON's `quorumSource`, `QuorumKeySource` and the FFI docs say "the provider's source" and "the source asked first", which hold in Auto too, and platform-wallet's `serve_spv_quorums` doc covers the adaptive provider. - Tests: a lookup of LLMQ_50_60 (the type the pin exists for) still goes to the trusted provider while SPV is not ready; an `InvalidQuorum` SPV answer to the fetch's re-ask resolves to unknown; the "trusted cannot fetch" case is its own test; and the dash-sdk end-to-end test checks that SPV was asked first (twice, failing with the error platform-wallet reports for a missing quorum) before the trusted key verified. Co-Authored-By: Claude Opus 5.5 <[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 19 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. |
|
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
|
✅ Final review complete — no blockers (commit 8bbb3d0) |
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 1 + Phase 2
The Auto fallback preserves SPV-first lookup, strict SPV behavior, and the Platform quorum-type guard. One nonblocking regression remains: existing Swift diagnostics still describe the reported source as trustless proof provenance, although it now identifies only the first source asked. This was a static review of 8bbb3d0; current code checks pass, including Rust workspace, wasm32, Swift, and Kotlin checks, while review and hygiene gates remain pending.
🟡 1 suggestion(s)
Approved: nothing here blocks the merge. The non-blocking findings are optional: fix them forward, in this PR or a follow-up, without waiting for another review round.
Review provenance
Source: reviewer 1: 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: rust-quality); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 6: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 7: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); 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 quorum-key sourcing that alters the trust boundary for proof verification and can affect signature acceptance and node-banning decisions in the SDK. - 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 (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.
In `packages/rs-sdk-ffi/src/sdk.rs`:
- [SUGGESTION] packages/rs-sdk-ffi/src/sdk.rs:763-766: Update the existing Swift trust indicator with Auto's new semantics
This diagnostic now reports SPV even when Auto verifies a proof with a trusted-service key. However, SDK.swift:393-419 still documents it as the source verification currently uses, and OptionsView.swift:424-441 displays `.spv` as a green `SPV (trustless)` indicator. This already affects the example app because AppState.makeSdk explicitly constructs an adaptive SDK; it does not depend on the default-provider change in #5883. The linked https://github.com/dashpay/platform/pull/5883 contains the appropriate documentation and indicator changes, but this head independently introduces the misleading trust claim. Include those consumer wording changes here, or deliver them atomically with this behavior change. Describing the value as the first source asked, with possible trusted fallback, is sufficient; Swift should not reconstruct proof provenance from readiness or callback timing.
|
Bots are done — your move: post |
|
/self-reviewed |
|
Ready for review — |
Merge v5.1-dev at d9d5689, which carries the squashed lifecycle PR (#4657) and the adaptive context provider work (#5882, #5883, #5884) plus #5830. Merge attributes were disabled; the merge is clean. Audit: the merge delta onto 1073d2e is byte-identical to the v5.1-dev delta onto the merged lifecycle head 84ac1e7 (47 files), so the squash reproduces the lifecycle content exactly and nothing of the mobile delta changes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Bottom of GitHub Stack #5885 (this → #5883 → #5884)
Issue being fixed or feature implemented
In Auto mode the adaptive context provider (#3417) asked the trusted quorum service only while the SPV client was not ready. Once SPV synced, a quorum key it could not serve failed the request:
The trusted service is meant to back SPV up when SPV has problems. This matters now that the Swift and Kotlin SDKs move to Adaptive/Auto by default (#5883, #5884).
What was done?
AdaptiveContextProvider, Auto mode only:SPV not ready: every lookup goes to the trusted provider, as before (Trusted mode).
SPV ready, SPV answers: SPV's key is final. A signature that fails with it bans the node, as before, and is never retried with the trusted key: an honest SPV client and an honest trusted service cannot disagree on a quorum's key.
SPV ready, SPV cannot serve the key: the lookup goes to the trusted provider. The trusted provider can only turn that failure into a key, never into another verdict:
So an unreachable trusted service cannot spare a node SPV would ban, and every ban today is still a ban.
Quorum type other than the network's Platform type: never falls back. SPV refuses those so a lower-threshold LLMQ cannot vouch for Platform state, and the trusted provider looks quorums up by hash alone (types with the same DKG interval share hashes).
Strict Spv mode and
SpvContextProvider: unchanged, fail closed.Logging: a fallback the trusted provider serves logs at info level, with the quorum and SPV's error; one neither source can serve warns, with both sources' errors.
One type check:
dash_context_provider::is_platform_quorum_typeis now the single check that a quorum type is the network's Platform type, shared by platform-wallet's SPV source and the fallback.Docs:
ContextProvider::quorum_sourcenow documents the source asked first. The adaptive provider,ContextProviderMode::Autoand the rs-sdk-ffi entry points say Auto is only as strong as the trusted service.What this does and does not change:
dash-context-providerwas missing from CI's nextest list, so its routing tests (including #3417's) never ran in CI; it is added.How Has This Been Tested?
Test-first, red → green locally:
dash-context-provider, red on the base, green after (5 tests):should_answer_from_trusted_when_a_ready_spv_source_cannot_serve_the_keyshould_report_spvs_error_when_trusted_cannot_serve_the_key_eithershould_fetch_missing_quorum_keys_from_trusted_except_in_spv_modeshould_let_spv_decide_the_verdict_when_the_trusted_fetch_cannot_helpshould_keep_the_trusted_verdict_when_spv_stops_being_ready_during_a_fetchshould_not_fall_back_for_a_quorum_type_other_than_platforms(LLMQ_50_60) failed against the fallback without the type pin and passes with it. Guard tests check that:dash-sdkshould_verify_a_proof_whose_quorum_spv_has_not_seen_with_the_trusted_key: a recorded proof, a local trusted quorum service with a cold cache, and a synced SPV client that lacks the quorum. It checks that SPV was asked first.Error::Proof(a ban) with the old provider; verified after.cargo test -p dash-context-provider --all-features(30 pass);cargo clippy -D warningson dash-context-provider, dash-sdk and rs-sdk-ffi;rs-dapi-clientsocks5_proxy::should_bound_the_tunnel_and_tls_by_one_connect_deadline, is a timing assertion under full parallel load; it passes on its own (14/14), and this stack does not touch that crate.Breaking Changes
None. Auto mode's behaviour changes as described; no public type, signature or ABI changes.
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 ·
8bbb3d0github(.github/workflows/tests-rs-workspace.yml) — ktechmidasrs-platform-wallet(packages/rs-platform-wallet/src/manager/spv_quorums.rs,packages/rs-platform-wallet/src/spv_context_provider.rs) — HashEngineering or ZocoLini or llbartekll or romchornyirust-sdk-ffi— you own itrust-sdk— you own itWhen every merge requirement is met, the
PR Hygienecheck passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.