Skip to content

fix(drive)!: classify shielded credit spend proofs as affected state - #5302

Closed
shumkov wants to merge 2 commits into
v5.0-devfrom
fix/credit-pool-proof-classification
Closed

shumkov wants to merge 2 commits into
v5.0-devfrom
fix/credit-pool-proof-classification

Conversation

@shumkov

@shumkov shumkov commented Oct 6, 2026 •

Copy link
Copy Markdown
Collaborator

Basic explanation

What this does: Reports shielded credit spend proofs as authenticated state, rather than confirmation that the exact requested payment executed. Keeps all verified data.

Value: Wallets and SDK consumers no longer receive an execution guarantee that these proofs cannot establish.

Risks: Intentional client compatibility change: strict execution waits now refuse these outcomes. Consensus and proof formats are unchanged. Tests use local state proofs without expensive Orchard proof generation or network calls.

Issue being fixed or feature implemented

Closes #5243. Spent-note markers do not identify the requested outputs. Unshield adds a current address balance; withdrawal adds a destination-bound document, but verification does not bind the requested amount or change outputs. These are affected-state proofs.

What was done?

  • Return AffectedState for Unshield, ShieldedTransfer and ShieldedWithdrawal, preserving queries, proof checks, authenticated results and errors.
  • Explain the evidence in the classifier and public verifier documentation.
  • Add genuine GroveDB-proof counterexamples for different outputs/amounts on PV12, PV13 and latest; compare exact returned data and committed roots. Withdrawal uses the normal gross-minus-Platform-fee document construction.
  • Preserve unspent/malformed-proof refusals and explicitly pin an unrelated identity-create proof as ExecutionProved.

In-place changes to shipped generations

The shared verifier classification is client-side and does not execute or validate blocks. Correcting it across historical client versions cannot modify consensus: execution, storage, proof generation, version tables and wire bytes are unchanged. Both verifier generations use this classifier.

How Has This Been Tested?

  • Actual RED → GREEN: all three new guarantee assertions failed on the original classifier at PV12/PV13/latest, then passed after the fix. The same proof bytes verify multiple requests; fixtures seed committed state and do not claim an Orchard transaction executed.
  • cargo test -p drive --lib verify::state_transition::verify_state_transition_was_executed_with_proof: 75 passed, 0 failed, 0 ignored, including all five new tests.
  • cargo check -p drive --lib --no-default-features --features verify: passed.
  • cargo fmt -p drive -- --check and git diff --check: passed.
  • cargo clippy -p drive --lib --tests -- -D warnings: passed.
  • Three independent agent code reviews: no must-fixes. Full workspace and integration CI remain external gates.

Breaking Changes

Strict SDK wait_for_response / broadcast_and_wait calls return ExecutionNotProved for these three families, including historical proofs. Use wait_for_affected_state / broadcast_and_wait_for_affected_state (JavaScript: waitForAffectedState / broadcastAndWaitForAffectedState) when authenticated snapshots are sufficient. These results do not prove that the submitted request executed; a strict wait error does not imply the broadcast failed. No wire or consensus change.

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

PR Hygiene · 0df7d9f

  • 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.

Summary by CodeRabbit

  • Documentation
    • Clarified that proofs for shielded credit spends confirm affected state, but do not prove that a specific requested execution occurred.
  • Tests
    • Added coverage for shielded credit spend proof verification, including mismatched spend details, unspent nullifiers, and incomplete proofs.

Spent nullifiers identify consumed notes, not the requested outputs.
Unshield adds a current balance snapshot; the withdrawal document binds
the destination but not the requested amount or change outputs. Retain
the authenticated results and roots while withdrawing the unsupported
execution guarantee for all three credit spend families.

Test would have caught this in CI: ✖ before fix, ✔ after. Three genuine
GroveDB-proof guarantee assertions failed as ExecutionProved instead of
AffectedState on protocol versions 12, 13 and latest before the fix.
The same assertions pass after it; the public verifier suite passes
75 tests with zero ignored. Unspent and malformed proof refusals and
an unrelated ExecutionProved positive control remain intact.

The in-place verifier correction affects client classification only;
consensus execution, version tables, queries and wire bytes are unchanged.

BREAKING CHANGE: strict execution waits reject Unshield, ShieldedTransfer
and ShieldedWithdrawal outcomes. Affected-state waits retain the verified
data as a snapshot, without claiming this specific request executed.

Closes #5243
@coderabbitai

coderabbitai Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: dashpay/platform/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f0bce5ab-221a-47f5-9d54-4a7f03d52053
📥 Commits

Reviewing files that changed from the base of the PR and between 659e39c and 0df7d9f.

📒 Files selected for processing (5)
  • packages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/mod.rs
  • packages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/credit_pool_tests.rs
  • packages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs
  • packages/rs-sdk/src/platform/transition/broadcast.rs
  • packages/wasm-sdk/src/state_transitions/broadcast.rs

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


📝 Walkthrough

Walkthrough

The proof classifier now treats Unshield, ShieldedTransfer, and ShieldedWithdrawal proofs as evidence of affected state, not proof of a specific execution. Tests cover these classifications and proof validation. The Rust and WASM SDK documentation describes the same guarantee.

Changes

Shielded credit proof guarantees

Layer / File(s) Summary
Classify and validate shielded credit proofs
packages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/..., packages/rs-sdk/src/platform/transition/broadcast.rs, packages/wasm-sdk/src/state_transitions/broadcast.rs
The classifier returns an affected-state guarantee for Unshield, ShieldedTransfer, and ShieldedWithdrawal proofs. Tests check matching spent-nullifier state, unspent nullifiers, and truncated proofs. SDK documentation describes the affected-state guarantee.

Priority: ➖ Normal

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

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: thepastaclaw, quantumexplorer

Merge Risk: 🔵 Low · up to 0df7d

Strict SDK waits for unshield, shielded transfer and shielded withdrawal now return ExecutionNotProved, including for historical proofs. The change is documented and intentional. Client owners should switch to affected-state waits where they need this behavior. A strict-wait error does not mean the broadcast failed. The change is mergeable.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 38.89% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 18 functions across 5 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely identifies the main change: classifying shielded credit spend proofs as affected-state proofs.
Linked Issues check ✅ Passed Issue #5243 asks whether each shielded credit proof binds the requested transition and requires a classification test for each arm. The verifier now returns AffectedState for Unshield, ShieldedTransfe…
Out of Scope Changes check ✅ Passed The verifier documentation and Rust and WASM SDK wait documentation explain the affected-state behavior introduced for issue #5243. The added proof tests validate the three classifications and guard a…
  • 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
  • Autopilot · 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 6, 2026
@github-actions

github-actions Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — coderabbitai not yet · 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 6, 2026
@thepastaclaw

thepastaclaw commented Oct 6, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Final review complete — no blockers (commit 0df7d9f) · 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

At head 3a16d68, the shared classifier correctly downgrades the three shielded credit-spend families without changing proof checks, authenticated results, or consensus execution. One documentation suggestion remains: the SDK's strict-wait family list omits the newly rejected families; the additional classifier-table test request is redundant with the new proof-based regression tests. Verification was static only; Rust workspace tests and PR Hygiene were still pending in the supplied CI snapshot.

🟡 1 suggestion(s)

1 finding(s) not shown inline (the lines are not part of this PR's diff)

🟡 Suggestion: Document shielded credit spends in the strict-wait API
packages/rs-sdk/src/platform/transition/broadcast.rs:46-50

The classifier now returns AffectedState for Unshield, ShieldedTransfer, and ShieldedWithdrawal, and wait_for_response_with_metadata passes those outcomes through require_execution_proved, which returns ExecutionNotProved. This public documentation lists the families requiring affected-state waits but omits all three newly reclassified families, leaving users without the migration guidance at the API they call. Add the three names here and to the parallel strict-wait explanation in packages/wasm-sdk/src/state_transitions/broadcast.rs:238-244. The related example lists in packages/js-evo-sdk/src/state-transitions/facade.ts:36-39, packages/rs-dpp/src/state_transition/proof_result.rs:244-246, and packages/rs-drive-proof-verifier/src/proof.rs:1532-1534 can be updated consistently; those illustrative lists are not themselves exhaustive contracts.

    /// only authenticate the affected state (balance top-ups, credit
    /// transfers and withdrawals, address funds movements, shields,
    /// shielded credit spends (Unshield, ShieldedTransfer, and
    /// ShieldedWithdrawal), no-history token operations, key limits
    /// updates, contract updates, contract moderation and fee claims,
    /// and creates and deletes of indexOnly documents), this returns

source: glm-5.3-flash (phase1-reviewer: general, rust-quality)

Review provenance

Source: reviewer 1: glm-5.3-flash (agent: phase1-reviewer, role: general); reviewer 2: glm-5.3-flash (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: platform-versioning); 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: low by gpt-6.1-sol (effort low) — The production change is a contained three-arm classification correction with extensive regression tests, leaving proof verification, consensus, storage and wire formats unchanged.
  • Phase 1 reviewers: glm-5.3-flash — general (completed, effort high); agent phase1-reviewer, glm-5.3-flash — rust-quality (completed, effort high); agent phase1-reviewer
  • Phase 1 model: glm-5.3-flash — zai quota: 5h 99% left, weekly 98% left; passed over gemini-3.8-flash-high (antigravity below 15% reserve: weekly 15% left, 5h 100% left)
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort medium); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort medium); agent phase2-reviewer, gpt-6.1-sol — platform-versioning (completed, effort medium); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort medium); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort medium); agent phase2-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`:
- [SUGGESTION] packages/rs-sdk/src/platform/transition/broadcast.rs:46-50: Document shielded credit spends in the strict-wait API
  The classifier now returns AffectedState for Unshield, ShieldedTransfer, and ShieldedWithdrawal, and wait_for_response_with_metadata passes those outcomes through require_execution_proved, which returns ExecutionNotProved. This public documentation lists the families requiring affected-state waits but omits all three newly reclassified families, leaving users without the migration guidance at the API they call. Add the three names here and to the parallel strict-wait explanation in packages/wasm-sdk/src/state_transitions/broadcast.rs:238-244. The related example lists in packages/js-evo-sdk/src/state-transitions/facade.ts:36-39, packages/rs-dpp/src/state_transition/proof_result.rs:244-246, and packages/rs-drive-proof-verifier/src/proof.rs:1532-1534 can be updated consistently; those illustrative lists are not themselves exhaustive contracts.

@github-actions

github-actions Bot commented Oct 6, 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 bot-review-skipped A required review bot did not report; it was skipped by the window or by a person. and removed waiting-bots Waiting for the review bots to report on this head labels Oct 6, 2026
Document Unshield, ShieldedTransfer, and ShieldedWithdrawal at the Rust and WASM strict-wait APIs so callers can select affected-state waits after the proof classification correction.

Documentation only; no behavior change, so RED/GREEN tests are omitted. Formatting and whitespace checks pass, and all non-documentation source is unchanged.
@shumkov

shumkov commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator Author

Addressed the strict-wait documentation suggestion in 0df7d9f730: the Rust and WASM API documentation now names Unshield, ShieldedTransfer, and ShieldedWithdrawal and points callers to affected-state waits. Only documentation changed; formatting and whitespace checks passed, and all non-documentation source is unchanged.

The preceding Rust CI job exceeded its 90-minute limit during the shielded phase. Clippy, feature-cut checks, and non-shielded tests passed; the cancelled shielded phase is not counted as passing. The push starts a fresh CI run.

@github-actions

github-actions Bot commented Oct 6, 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 waiting-bots Waiting for the review bots to report on this head and removed waiting-self-review Waiting for the author to post /self-reviewed bot-review-skipped A required review bot did not report; it was skipped by the window or by a person. labels Oct 6, 2026

@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.

Re-review — Final validation — Phase 1 + Phase 2

Independently reviewed the complete PR diff at the exact head and found no in-scope defects. The shared classifier correctly downgrades Unshield, ShieldedTransfer, and ShieldedWithdrawal to AffectedState across both verifier generations without changing proof checks, authenticated results, or consensus behavior; the genuine-proof counterexamples and updated Rust/WASM documentation support the intended compatibility change. This was a static review with no local builds or tests: the supplied CI snapshot reports Rust workspace tests passing, while the main Test Suite, browser shard 1, and PR Hygiene remain 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: 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: platform-versioning); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 7: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 8: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 9: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 10: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 11: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 12: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.1-sol (effort low) — The diff changes a contained client-side proof guarantee classification and adds substantial regression tests, but does not make large or intricate changes to consensus, funds movement, cryptography, or proof verification mechanics.
  • 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 15% left, 5h 100% left), glm-5.3-flash (not used above high effort; tier asks max)
  • Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
  • 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 — platform-versioning (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort high); agent phase2-reviewer, 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 — platform-versioning (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort high); agent phase2-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.

@github-actions

github-actions Bot commented Oct 6, 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 6, 2026
@shumkov shumkov closed this Oct 6, 2026
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.

Shielded credit pool proofs may classify spent nullifiers as proof of a particular transition

2 participants