Skip to content

fix(sdk): return errors for unsupported proof modes - #5387

Merged
shumkov merged 1 commit into
v5.0-devfrom
shumkov/audit-l1-proof-options-20261012
Oct 13, 2026
Merged

shumkov merged 1 commit into
v5.0-devfrom
shumkov/audit-l1-proof-options-20261012

Conversation

@shumkov

@shumkov shumkov commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator

Basic explanation

What this does: Unsupported SDK proof modes return a recoverable configuration error before sending a request.

Value: Rust callers receive an error and JavaScript callers receive a rejected promise; the SDK remains usable after the refusal.

Risks: Low: client-side error handling only, with no consensus or proof-verification changes. Currently supported proved, raw and forced-proof paths keep their behavior.

Issue being fixed or feature implemented

Audit provenance: L1 in the user-provided audit. The regression inputs were reconstructed from public APIs; private campaign scripts were not available.

Proof-disabled identity, contract, nonce and other unsupported queries panic in their encoders. The inverse unsupported proof-enabled quorum query also panics. In wasm32 these panics escape the async promise as an uncaught runtime trap.

What was done?

  • Replace exactly 40 negative and one inverse encoder guard with existing non-retryable Error::Config before transport.
  • Preserve supported request branches byte-for-byte, including signed-version/quorum handling, single-proof identity fetching, raw wire requests, explicit unproved APIs and document queries that force proofs.
  • Update proof-option documentation and the stale book Query example; add public Rust and actual JS/WASM regression/preservation tests.

The neighboring pass-through Fetch behavior remains: some requests send prove=false while the normal fetch parser still requires a proof, which can produce retryable missing-proof errors and node bans. This patch does not add universal raw support or change retry/ban policy. Existing shielded Generic refusals also remain unchanged.

How Has This Been Tested?

  • cargo test -p dash-sdk --test proof_options -j 2: baseline 47 real panic failures / 45 passing controls, fixed 92 passing, none ignored.
  • Real compressed-dist Mocha/Node WASM boundary: each entry point fails on the baseline with uncaught RuntimeError: unreachable; fixed 2 passing, checking Config/code/isRetriable, repeated refusals, usable instance and zero fetch calls.
  • SDK library 306 passing; unproved parser controls 31 passing; offline identity/contract/document vectors 18 passing. Three inherited vector tests remain ignored: two need missing recordings and one remains disabled for its existing text-decoding bug.
  • Strict targeted clippy, focused rustfmt, JS ESLint, strict generated-API TypeScript check and diff whitespace checks pass. All builds retain sccache and use at most two Cargo jobs.

Local validation used baseline 8ebfc8089d. Tests CI passed on final PR head 3db4cf1f merged with target 371a3b39 (synthetic merge 40eecb15): release WASM build, 92 Rust proof-option tests, and both new public WASM cases in Node and ChromeHeadless (481 passing per runtime). Rust workspace CI reported 19,319 passed / 1,395 skipped; native platform integration reported 95 passed / 17 pending. Executed build, lint, integration and functional jobs passed. Three configured jobs were skipped: Evo SDK lint, Rust wallet tests and ARM64 runner image validation. Skipped jobs and skipped/pending cases are not counted as executed. Local WASM validation used Node; browser/Karma and release-profile coverage comes from CI.

Breaking Changes

None. Existing Result signatures and error types are retained; unsupported modes return an error in place of a panic.

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have added "!" to the title and described breaking changes in the corresponding section if my code contains any
  • I have made corresponding changes to the documentation if needed
  • If I added or changed GroveDB structure, I described it in the area's structure.rs, regenerated grovedb-structure.json, and checked the structure viewer link posted on this pull request

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

Summary by CodeRabbit

  • Bug Fixes
    • Queries that require proofs now return a configuration error when proofs are disabled, rather than panicking.
    • Queries that do not support the selected proof setting now report a configuration error. Raw wire requests continue to use their own proof settings.
  • Documentation
    • Clarified proof-mode limitations, including which queries require proofs and how unsupported settings are handled.

PR Hygiene · 3db4cf1

  • Bots — coderabbitai ✓ · thepastaclaw ✓
  • Self-review — post /self-reviewed
  • Build green
  • Approvals — you own every area touched; none needed

When every merge requirement is met, the PR Hygiene check passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.

Replace 40 proof-disabled encoder panics and the inverse quorum proof-mode
panic with existing non-retryable Config errors before transport. Keep all
supported request branches byte-identical and document the limited flag.

Test would have caught this in CI: ✖ before fix, ✔ after.
Public Rust Query/Fetch tests: 47 runtime panic failures and 45 passing
controls before, all 92 passing after. Real WASM/Node identity entry points
trap before and reject with Config afterward; the instance remains usable
and no fetch calls occur. SDK library and raw parser controls also pass.

Three existing offline vector tests remain ignored for their prior reasons.
The neighboring pass-through Fetch missing-proof retry/ban behavior remains
out of scope; no raw decoding policy or trust-model change is introduced.
@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough

Walkthrough

The Query documentation now describes settings-based query conversion and proof-mode behavior. Query builders return Error::Config for unsupported proof settings instead of panicking. Rust and WASM tests cover query errors, request encoding, and fetch behavior.

Changes

Query Proof-Option Handling

Layer / File(s) Summary
Query contract and proof-mode documentation
book/src/sdk/fetch-traits.md, packages/rs-sdk/src/sdk.rs
The documentation describes QuerySettings by reference, behavior for proof-only builders and raw wire requests, and proof-mode limitations.
Proof-mode checks in query implementations
packages/rs-sdk/src/platform/query.rs, packages/rs-sdk/src/platform/tokens/token_pre_programmed_distributions.rs, packages/rs-sdk/src/platform/types/*
Query implementations return Error::Config for unsupported proof modes instead of panicking. GetCurrentQuorumsInfo returns an error when proofs are enabled and retains its no-proof request path.
Proof-option validation
packages/rs-sdk/tests/proof_options.rs, packages/wasm-sdk/tests/unit/proof-options.spec.ts
Tests cover configuration errors, request fields, protocol-version cases, raw wire requests, fetch behavior, and continued WASM SDK access.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Suggested reviewers: quantumexplorer


Merge Risk: ⚪ Minimal · up to 3db4c

The proof-mode change is mergeable after normal checks. The remaining suggestion is optional cleanup, not a demonstrated behavior problem.

Pre-merge checks · Passed 4 · Failed 1

Failed Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 23.81% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 63 functions across 7 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks (4 passed)
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: unsupported proof modes now return errors instead of panicking.

Full details: Docstring Coverage

Explanation

Docstring coverage is 23.81% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 63 functions across 7 files. (1 skipped: 1 unsupported.)


  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

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

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added this to the v5.0.0 milestone Oct 12, 2026
@github-actions

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — coderabbitai ✓ · thepastaclaw not yet. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@github-actions github-actions Bot added the waiting-bots Waiting for the review bots to report on this head label Oct 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📖 Book Preview built successfully.

Download the preview from the workflow artifacts.
To view locally: download the artifact, unzip, and open index.html.

Updated at 2026-10-12T17:16:34.706Z

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔇 Additional comments (8)
book/src/sdk/fetch-traits.md (1)

191-213: LGTM!

packages/rs-sdk/src/sdk.rs (1)

271-272: LGTM!

Also applies to: 1026-1027

packages/rs-sdk/src/platform/types/identity.rs (1)

58-60: LGTM!

packages/rs-sdk/src/platform/tokens/token_pre_programmed_distributions.rs (1)

41-43: LGTM!

packages/rs-sdk/src/platform/types/finalized_epoch.rs (1)

16-18: LGTM!

packages/rs-sdk/tests/proof_options.rs (1)

1-995: LGTM!

packages/wasm-sdk/tests/unit/proof-options.spec.ts (1)

1-48: LGTM!

packages/rs-sdk/src/platform/query.rs (1)

246-248: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

⚠️ Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.

Extract the repeated proof-required error into one helper.

This change repeats the same Error::Config literal about 35 times in this file. The same literal also appears in identity.rs, finalized_epoch.rs, and token_pre_programmed_distributions.rs. The tests compare the exact string through UNPROVED_MESSAGE. A future wording edit at one site can therefore drift from the other sites without notice. Add a helper such as pub(crate) fn require_proofs(prove: bool) -> Result<(), Error> and call it at each site.

The shielded queries at Lines 1374-1377 and the following lines still return Error::Generic. Callers therefore get different error kinds for the same refusal. Consider whether those queries should use the same helper.


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository: dashpay/platform/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 58027921-54a4-4d25-b938-7a3da0bf95cf
📥 Commits

Reviewing files that changed from the base of the PR and between 371a3b3 and 3db4cf1.

📒 Files selected for processing (8)
  • book/src/sdk/fetch-traits.md
  • packages/rs-sdk/src/platform/query.rs
  • packages/rs-sdk/src/platform/tokens/token_pre_programmed_distributions.rs
  • packages/rs-sdk/src/platform/types/finalized_epoch.rs
  • packages/rs-sdk/src/platform/types/identity.rs
  • packages/rs-sdk/src/sdk.rs
  • packages/rs-sdk/tests/proof_options.rs
  • packages/wasm-sdk/tests/unit/proof-options.spec.ts

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@thepastaclaw

thepastaclaw commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Final review complete — no blockers (commit 3db4cf1) · triage: normal

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final validation — Phase 1 + Phase 2

The proof-mode changes correctly replace unsupported-query panics with non-retryable configuration errors before transport while preserving supported proved, raw, and forced-proof paths. The added Rust and WASM regression coverage is consistent with the implementation, and no in-scope defects were identified.

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); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.1-sol (effort low) — This is a substantial SDK and Rust/WASM behavior change with broad regression coverage, but it does not modify consensus, cryptography, funds movement, network deserialization, or storage migrations.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity below 15% reserve: weekly 14% left, 5h 100% left), glm-5.3-flash (not used above high effort; tier asks max)
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — ffi-engineer (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort high); agent phase2-reviewer
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.

  • Align shielded proof-mode refusals with Error::Config — The pre-existing shielded query encoders in packages/rs-sdk/src/platform/query.rs still return Error::Generic when proofs are disabled, while the encoders changed by this PR return Error::Config. Both are non-retryable, but they expose different WasmSdkErrorKind values to JavaScript callers. The PR explicitly leaves shielded refusals unchanged, so this should be handled separately.
    • Follow-up: Create a separate SDK cleanup change to standardize shielded proof-only refusals on Error::Config, or document why their Generic classification is intentional.

@github-actions

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Bots are done — your move: post /self-reviewed.
Full checklist in the description.

@github-actions github-actions Bot added waiting-self-review Waiting for the author to post /self-reviewed and removed waiting-bots Waiting for the review bots to report on this head labels Oct 12, 2026
@shumkov
shumkov merged commit 3105f32 into v5.0-dev Oct 13, 2026
59 of 61 checks passed
@shumkov
shumkov deleted the shumkov/audit-l1-proof-options-20261012 branch October 13, 2026 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

waiting-self-review Waiting for the author to post /self-reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants