Skip to content

feat(platform)!: token pool transitions paid from the credit pool bind their fee bundle (PV15) - #5969

Merged
shumkov merged 3 commits into
v5.1-devfrom
shumkov/v51-shielded-fee-binding
Nov 18, 2026
Merged

shumkov merged 3 commits into
v5.1-devfrom
shumkov/v51-shielded-fee-binding

Conversation

@shumkov

@shumkov shumkov commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Issue being fixed or feature implemented

TokenShieldedTransferWithShieldedFee (26), TokenUnshieldWithShieldedFee (27) and TokenPurchaseFromShieldedPool (28) carry a token bundle and a credit pool bundle that pays the fee. Their doc comments say that neither bundle can be paired with another. The fee bundle's sighash binds a digest of the token bundle's actions, but the token bundle's sighash binds only the type, the token and the transparent fields, so only one direction held.

From protocol version 15 the token bundle also binds its fee bundle's Orchard commitment, so neither bundle can be paired with a bundle of different effects. Protocol version 14 keeps today's behaviour.

The SDK's outcome judge now reports a 26/27/28 whose token bundle is spent as executed or superseded, whatever its fee bundle shows: the token bundle carries the transition's effect.

What was done?

Consensus (PV15 only)

  • rs-platform-version: new dpp.methods.token_pool_paid_fee_binding (OptionalFeatureVersion). It is None in DPP_METHOD_VERSIONS_V1–V3 and Some(0) in the new DPP_METHOD_VERSIONS_V4, which only PLATFORM_V15 selects. DRIVE_ABCI_VALIDATION_VERSIONS_V11 (PV15 only, unreleased) now selects validate_shielded_proof: 2. v15.rs gets note 47.

  • rs-dpp sighash: token_pool_paid_fee_binding_extra_sighash_data returns the kind's layout unchanged at None, and at Some(0) the layout followed by the fee bundle's commitment (32 bytes; the frozen _v0). The token-bundle preimages at PV15 are:

    • 26: 0x1A || token_id || fee_commitment (65 bytes)
    • 27: 0x1B || token_id || recipient_id || amount || fee_commitment (105 bytes)
    • 28: 0x1C || token_id || token_count || price || fee_commitment (81 bytes)

    The fee bundle's preimage is unchanged.

  • rs-dpp builders: each of the three builders runs prove_and_sign_with_fee_bundle, which:

    1. builds the token bundle and the fee bundle unproven;
    2. takes the fee bundle's commitment (effecting data only, so there is no circularity);
    3. proves and signs the token bundle over the bound preimage;
    4. proves and signs the fee bundle over the token bundle's signed actions;
    5. checks that the signed fee bundle still has that commitment.

    The builders use one path for every protocol version; at PV14 the binding returns the shipped layout. spend_builder is extracted from build_spend_bundle_with without a behaviour change.

  • rs-drive-abci: validate_shielded_proof_v2 is a copy of v1 with only the three arms changed. Each arm reconstructs the fee bundle first, then verifies the token bundle over its preimage followed by the fee bundle's commitment, then verifies the fee bundle. The binding is a constant of v2: v2 calls the frozen _v0 layout, so it never verifies the unbound preimage. v0 and v1 are unchanged. An agreement test ties token_pool_paid_fee_binding, which clients read, to validate_shielded_proof >= 2 at every protocol version.

SDK and docs

  • Sdk::state_transition_outcome: for 26/27/28, a partial spend whose token bundle is entirely spent is ExecutedOrSuperseded rather than CannotExecute(InputUsed). This is a guard on the Partial case only; All, Unordered, the anchor rules and consumed_by_height are unchanged.
  • The outcome docs now cover retrying these transitions under protocol version 14 (re-spend the same token notes), releasing fee notes proven unspent once the token bundle is spent, and admission refusals, which are not a reason to pay again with other notes.
  • Also updated: the three transitions' doc comments, validate_token_pool_outputs, the book's token shielded pools page and the wasm-dpp2 computePlatformSighash doc.

Cost
No extra Orchard commitment hash: v2 reconstructs the fee bundle once and computes its commitment once, then uses that one value both in the token bundle's preimage and in the fee bundle's own sighash, so each bundle's commitment is computed once, as under v1. The only added hashing is 32 bytes more in the token bundle's SHA-256 sighash preimage. Still exactly two proof verifications per transition. A token bundle paired with another fee bundle fails verification of the token bundle and is refused unpaid, like any invalid proof today, under the existing CheckTx limiter and the DAPI shielded proof failure budget. Orchard checks signatures before proofs, so it is refused before any Halo 2 work. A malformed fee bundle is refused before any proof verification. The transition's bytes, its fees and its paid/unpaid classification are unchanged. No new DoS surface.

Activation boundary
The first PV15 block runs every transition under v2. A 26/27/28 signed for PV14 and still in a mempool is then refused unpaid, before any write; proposers drop it, and the same notes rebuilt for PV15 execute. A transition built for PV15 is refused by a PV14 node at admission, and the same bytes become valid once PV15 activates. 0 transitions of these types exist on mainnet or testnet today.

In-place changes to shipped generations

  • reconstruct_and_verify_bundle (every shielded type, PV12+): split into reconstruct_bundle and verify_bundle (which verifies over a sighash its caller computed) and recomposed under the same signature: it reconstructs, computes the commitment and the sighash, then verifies. It cannot change consensus: the checks, their order and the error messages are the same. The only thing that moved is the call to get_verifying_key(), a cached constant that cannot fail. OsRng is still used only inside BatchValidator, for one bundle per call.
  • DPP_METHOD_VERSIONS_V1–V3: the new field is backfilled with None, which selects the shipped preimage.
  • DRIVE_ABCI_VALIDATION_VERSIONS_V11 and PLATFORM_V15's dpp method table: amended in place. Only PV15 selects them. PV15 is not activated on testnet or mainnet and not released as stable; 5.1.0-dev.1 is a prerelease, so it differs from 5.1.0-dev.1 and needs no migration.
  • rs-dpp builders (spend_builder extraction, prove_and_sign_with_fee_bundle): client side, not consensus. A transition built for protocol version 14 still verifies under v1, as should_verify_each_token_pool_paid_kind_only_under_the_binding_it_was_built_for pins.
  • validate_shielded_proof v0 and v1: untouched (byte-identical).

How Has This Been Tested?

Tests first, on 5b73d83 with only the tests added (red), then with the change (green):

Test Before After
should_refuse_a_token_shielded_transfer_bundle_paired_with_another_fee_bundle ✖ CheckTx admits the pair ✔
should_refuse_a_token_unshield_bundle_paired_with_another_fee_bundle ✖ ✔
should_refuse_a_token_purchase_bundle_paired_with_another_fee_bundle ✖ ✔
should_refuse_a_token_bundle_paired_with_a_second_fee_bundle_over_the_same_notes ✖ ✔
should_verify_each_token_pool_paid_kind_only_under_the_binding_it_was_built_for (also: a fee bundle that does not reconstruct, or whose binding signature fails, is refused at 14 and at latest) ✖ a PV14 build verifies at latest ✔
should_refuse_a_token_payment_built_for_protocol_version_14_on_the_first_block_after_it ✖ it executes on the first PV15 block ✔
should_refuse_a_fee_bound_token_payment_at_14_and_execute_the_same_bytes_after_it ✖ PV14 CheckTx admits it ✔
should_report_a_spent_token_bundle_as_executed_or_superseded_whatever_the_fee_bundle_shows (SDK) ✖ CannotExecute(InputUsed) ✔
should_report_a_purchase_whose_token_bundle_landed_in_another_purchase_as_executed_or_superseded (SDK, renamed and flipped) ✖ ✔
the three test_a_purchase_from_shielded_pool_* copy tests, pinned at protocol version 14 ✔ ✔ (assertions unchanged)

Also added:

  • should_append_the_fee_bundle_commitment_to_the_token_layouts_from_protocol_version_15 and should_refuse_an_unknown_fee_binding_version (byte layouts through the dispatcher at 14 and at latest);
  • token_pool_paid_fee_binding_should_agree_with_the_selected_verifier_at_every_protocol_version;
  • six judge unit tests.

The test helpers in the token shielded tests module now process and run CheckTx at the platform's own protocol version rather than PlatformVersion::latest(). That is identical for every existing caller, which all use latest platforms.

Commands, all run locally:

  • cargo test -p dpp --all-features --lib -- shielded
  • RUST_MIN_STACK=4194304 cargo test -p drive-abci --lib -- shield
  • cargo test -p platform-version
  • cargo test -p dash-sdk --features mocks --lib -- transition::outcome
  • cargo clippy -p platform-version -p dpp -p drive-abci -p dash-sdk --all-features --all-targets -- -D warnings
  • rustfmt on the changed files
  • cargo check --workspace --all-targets

Results on this branch, rebased on v5.1-dev 4505fc5 (the last two v5.1-dev commits, 9da740b and 18e26d9, were rebased onto afterwards; they change doc comments in the version tables, and the focused tests below were re-run on them):

  • clippy: clean.
  • cargo test -p dpp --all-features --lib -- shielded: 365 passed.
  • cargo test -p dash-sdk --features mocks --lib -- transition::outcome: 65 passed.
  • cargo test -p platform-version: passed.
  • RUST_MIN_STACK=4194304 cargo test -p drive-abci --lib -- shield: 427 passed, 0 failed, 3 ignored (existing benchmarks).
  • cargo check --workspace --all-targets: clean.

Not added: a strategy test across a real PV14 → PV15 upgrade. The strategy harness has no operation for these types yet. Instead, the boundary tests run the proposer path (proposing = true, non-genesis height) on a PV15 candidate state after perform_events_on_first_block_of_protocol_change, the way the existing PV14 boundary test does.

Breaking Changes

Consensus change at protocol version 15 only: a 26/27/28 must be built for the protocol version it is validated at (the builders take platform_version). Protocol version 14 is unchanged.

Checklist:

  • I have performed a self-review of my own code
  • My Rust, FFI, WASM, Swift or Kotlin changes follow the coding conventions
  • 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
  • If I added or changed a system contract's document schemas, I checked the contract viewer link posted on this pull request

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

🤖 Generated with Claude Code

PR Hygiene · 742de35

  • Bots — thepastaclaw ✓
  • Self-review — post /self-reviewed
  • Build failed
  • 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

  • New Features
    • From protocol version 15, shielded token transfers, unshields, and purchases paid with credit fees are cryptographically linked to their fee bundle. This prevents pairing a token bundle with a different fee bundle.
    • Updated transaction outcome reporting to better distinguish when token effects have been consumed, even if fee inputs remain unused.
  • Documentation
    • Clarified protocol-version differences in shielded transaction validation, fee binding, and transaction outcomes.

@shumkov shumkov added this to the v5.1.0 milestone Nov 17, 2026
@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Protocol v15 binds identity-less token-pool transition token bundles to their fee-bundle commitments. The change adds versioned bundle construction and proof validation, updates SDK outcome judging, and adds tests for binding behavior and protocol-version transitions.

Changes: Shielded token-pool fee binding

Layer / File(s) Summary
Binding contract and protocol activation
packages/rs-dpp/src/shielded/sighash.rs, packages/rs-dpp/src/shielded/mod.rs, packages/rs-platform-version/src/version/dpp_versions/dpp_method_versions/*, packages/rs-platform-version/src/version/v15.rs, packages/rs-dpp/src/state_transition/state_transitions/shielded/*/v0/mod.rs, packages/rs-dpp/src/execution/validation/state_transition/state_transitions/token_pool_paid_common/mod.rs, book/src/data-model/token-shielded-pools.md, packages/wasm-dpp2/src/shielded/mod.rs
The sighash helper appends the fee commitment for binding version 0 and rejects unsupported versions. Protocol v15 enables this setting. The documentation describes the version-specific binding.
Build and sign paired bundles
packages/rs-dpp/src/shielded/builder/mod.rs, packages/rs-dpp/src/shielded/builder/token_pool_paid.rs
The shared builder flow creates the fee bundle before signing the token bundle with the fee commitment. It signs the fee bundle against the token actions and is used by transfer, unshield, and purchase builders.
Reconstruct and verify bound bundles
packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/shielded_common/mod.rs, packages/rs-drive-abci/src/execution/validation/state_transition/processor/traits/shielded_proof.rs, packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v11.rs, packages/rs-platform-version/src/version/v15.rs, book/src/data-model/key-limits.md, packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_create_from_shielded_pool/tests.rs
Proof-validation version 2 reconstructs the fee bundle first, verifies the token bundle using its commitment, and then verifies the fee bundle. Version configuration and related validation comments reflect version 2.
Judge token-bundle consumption
packages/rs-sdk/src/platform/transition/outcome/judge.rs, packages/rs-sdk/src/platform/transition/outcome/mod.rs, packages/rs-sdk/src/platform/transition/outcome/inputs.rs
The SDK judge receives token-bundle nullifier reads separately. It returns ExecutedOrSuperseded when all token-bundle nullifiers are consumed, including when fee-bundle inputs remain unspent.
Version and transition regression coverage
packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/token/shielded/*
Tests cover fee-bundle substitution, proof validation across protocol versions, protocol-upgrade behavior, and test processing at the platform’s configured version.

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant TokenPoolPaidBuilder
  participant FeeBundle
  participant TokenBundle
  participant validate_shielded_proof_v2
  TokenPoolPaidBuilder->>FeeBundle: Build unproven fee bundle and obtain commitment
  TokenPoolPaidBuilder->>TokenBundle: Sign token bundle with fee commitment in sighash
  TokenPoolPaidBuilder->>FeeBundle: Sign fee bundle against signed token actions
  validate_shielded_proof_v2->>FeeBundle: Reconstruct fee bundle
  validate_shielded_proof_v2->>TokenBundle: Verify token bundle using fee commitment
  validate_shielded_proof_v2->>FeeBundle: Verify fee bundle against platform sighash
Loading

Suggested reviewers: quantumexplorer, thepastaclaw

Merge Risk: Minimal · up to 742de

From protocol version 15, the token bundle in shielded token transfers, unshields and purchases paid from the credit pool is tied to its own fee bundle, so the bundles can no longer be mixed and matched. Wallets also now report a spent token bundle as executed. The builder, verifier and version tables agree, and tests cover the version boundary. PV15 is not yet active on any network. No outstanding defect has been identified, though an earlier blocking concern from another reviewer could not be checked because its details were not available.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: identity-less token pool transitions paid from the credit pool (types 26, 27, 28) now bind their fee bundle at protocol version 15. The raw summary confirms this: the …
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.
Full details: Title check

Explanation

The title names the main change: identity-less token pool transitions paid from the credit pool (types 26, 27, 28) now bind their fee bundle at protocol version 15. The raw summary confirms this: the token bundle's sighash now includes the fee bundle's Orchard commitment from PV15, a new token_pool_paid_fee_binding setting and validate_shielded_proof v2 were added, and the three builders were updated. The title is specific and concise, and the "feat(platform)!" prefix with "(PV15)" is a conventional marker of a breaking feature change.

Finishing Touches

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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between ff02d30 and 742de35.

Files selected for processing: 26

  • book/src/data-model/key-limits.md
  • book/src/data-model/token-shielded-pools.md
  • packages/rs-dpp/src/shielded/builder/mod.rs
  • packages/rs-dpp/src/shielded/builder/token_pool_paid.rs
  • packages/rs-dpp/src/shielded/mod.rs
  • packages/rs-dpp/src/shielded/sighash.rs
  • packages/rs-dpp/src/state_transition/state_transitions/shielded/token_purchase_from_shielded_pool_transition/v0/mod.rs
  • packages/rs-dpp/src/state_transition/state_transitions/shielded/token_shielded_transfer_with_shielded_fee_transition/v0/mod.rs
  • packages/rs-dpp/src/state_transition/state_transitions/shielded/token_unshield_with_shielded_fee_transition/v0/mod.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/processor/traits/shielded_proof.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/token/shielded/mod.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/token/shielded/token_pool_paid_fee_binding.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_create_from_shielded_pool/tests.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/shielded_common/mod.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/token_pool_paid_common/mod.rs
  • packages/rs-platform-version/src/version/dpp_versions/dpp_method_versions/mod.rs
  • packages/rs-platform-version/src/version/dpp_versions/dpp_method_versions/v1.rs
  • packages/rs-platform-version/src/version/dpp_versions/dpp_method_versions/v2.rs
  • packages/rs-platform-version/src/version/dpp_versions/dpp_method_versions/v3.rs
  • packages/rs-platform-version/src/version/dpp_versions/dpp_method_versions/v4.rs
  • packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v11.rs
  • packages/rs-platform-version/src/version/v15.rs
  • packages/rs-sdk/src/platform/transition/outcome/inputs.rs
  • packages/rs-sdk/src/platform/transition/outcome/judge.rs
  • packages/rs-sdk/src/platform/transition/outcome/mod.rs
  • packages/wasm-dpp2/src/shielded/mod.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.

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — 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 Nov 17, 2026
@thepastaclaw

thepastaclaw commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Final review complete — no blockers (commit 742de35) · triage: critical

@github-actions

github-actions Bot commented Nov 17, 2026 •

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-11-18T03:46:54.588Z

@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 PV15 binding change is correctly version-gated and the token/fee preimages are consistent. However, the new verifier computes the fee bundle commitment once to bind the token bundle and then computes it again while verifying the fee bundle; this adds unpriced consensus-path CPU work beyond the existing shielded fee formula. CI shows Rust and wasm checks passing, with JS, Swift, Docker, and hygiene checks still pending and no failed code checks reported.

🔴 1 blocking | 💬 1 nitpick(s)

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (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: platform-versioning); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); 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: critical by gpt-6.1-sol (effort low) — This is a large, intricate change to consensus-critical cryptographic signatures and proof validation, including protocol-version-gated token/fee bundle binding in rs-dpp and rs-drive-abci.
  • 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 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; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — platform-versioning (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-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-drive-abci/src/execution/validation/state_transition/processor/traits/shielded_proof.rs`:
- [BLOCKING] packages/rs-drive-abci/src/execution/validation/state_transition/processor/traits/shielded_proof.rs:1981-1995: Account for or eliminate the extra fee-bundle commitment hash
  The verifier computes `fee_bundle.commitment()` at line 1981 so the commitment can be added to the token bundle sighash. It then calls `verify_bundle(&fee_bundle, ...)` at line 1995, whose implementation computes `bundle.commitment()` again before constructing the fee bundle sighash. Consequently, every PV15 type 26/27/28 transition performs a second full Orchard commitment pass over the fee actions, whereas the prior verifier computed that commitment only once. The existing `compute_token_pool_paid_shielded_fee` formula charges the two bundle verification costs and per-action work, but neither the `PaidFromShieldedPool` event nor another cost operation accounts for this additional hashing. This creates a consensus-path cost/fee mismatch and an underpriced verification workload. Pass the already computed commitment into a verification helper, or add a protocol-versioned fee/cost component for the extra hash.

In `packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/token/shielded/token_pool_paid_fee_binding.rs`:
- [NITPICK] packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/token/shielded/token_pool_paid_fee_binding.rs:266-274: Use the platform's active version in the nullifier test helper
  `credit_nullifier_is_spent` accepts a platform whose state can be at a protocol version different from `PlatformVersion::latest()`, but it always performs `has_nullifier` with the latest version. The helper's callers currently use latest-version platforms, so the behavior is identical today, but the surrounding shielded test helpers were migrated to `current_platform_version(platform)` specifically for protocol-boundary tests. Use the active platform version here as well so a future PV14 or other historical-version caller cannot query the GroveDB state with the wrong version.

@github-actions

Copy link
Copy Markdown
Contributor

Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix; thepastaclaw left review threads unresolved; resolve them.
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 Nov 17, 2026
shumkov and others added 3 commits November 18, 2026 10:22
…d their fee bundle (PV15)

From protocol version 15 the token bundle of TokenShieldedTransferWithShieldedFee,
TokenUnshieldWithShieldedFee and TokenPurchaseFromShieldedPool binds its fee bundle's
Orchard commitment into its sighash, after its own layout. The fee bundle already binds a
digest of the token bundle's actions, so neither bundle can be paired with a bundle of
different effects, as the transitions already document.

- rs-platform-version: dpp.methods.token_pool_paid_fee_binding, None in
  DPP_METHOD_VERSIONS_V1 to V3 and Some(0) in the new DPP_METHOD_VERSIONS_V4, which only
  PV15 selects; DRIVE_ABCI_VALIDATION_VERSIONS_V11 (PV15 only) selects
  validate_shielded_proof 2.
- rs-dpp: token_pool_paid_fee_binding_extra_sighash_data and its frozen v0 layout. The
  three builders build the fee bundle before the token bundle is signed, take its
  commitment, sign the token bundle over the bound preimage, then sign the fee bundle over
  the token bundle's signed actions. One path for every protocol version: at PV14 the
  binding returns the shipped layout. spend_builder is extracted from
  build_spend_bundle_with without a behaviour change.
- rs-drive-abci: validate_shielded_proof v2 is v1 with the three arms changed: the fee
  bundle is reconstructed first and the token bundle is verified over its preimage followed
  by the fee bundle's commitment, a constant of v2 (it calls the frozen v0 binding, so it
  never verifies the unbound preimage). v1 is unchanged. reconstruct_and_verify_bundle is split
  into reconstruct_bundle and verify_bundle and recomposed: same checks, order and messages.

PV14 keeps validate_shielded_proof 1, DPP_METHOD_VERSIONS_V3 and the unbound preimage.

Tests (red on 5b73d83 with only the tests added, green with the change):
✖ → ✔ should_refuse_a_token_shielded_transfer_bundle_paired_with_another_fee_bundle
✖ → ✔ should_refuse_a_token_unshield_bundle_paired_with_another_fee_bundle
✖ → ✔ should_refuse_a_token_purchase_bundle_paired_with_another_fee_bundle
✖ → ✔ should_refuse_a_token_bundle_paired_with_a_second_fee_bundle_over_the_same_notes
✖ → ✔ should_verify_each_token_pool_paid_kind_only_under_the_binding_it_was_built_for
  (it also refuses, at 14 and at latest, a fee bundle that does not reconstruct or whose
  binding signature fails)
✖ → ✔ should_refuse_a_token_payment_built_for_protocol_version_14_on_the_first_block_after_it
✖ → ✔ should_refuse_a_fee_bound_token_payment_at_14_and_execute_the_same_bytes_after_it
✔ → ✔ the three test_a_purchase_from_shielded_pool_* copy tests, now pinned at protocol
  version 14, where their assertions still hold unchanged
New: should_append_the_fee_bundle_commitment_to_the_token_layouts_from_protocol_version_15,
should_refuse_an_unknown_fee_binding_version,
token_pool_paid_fee_binding_should_agree_with_the_selected_verifier_at_every_protocol_version.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…as executed or superseded

The token bundle of TokenShieldedTransferWithShieldedFee, TokenUnshieldWithShieldedFee and
TokenPurchaseFromShieldedPool carries the transition's effect; the credit pool bundle pays
its fee. When every nullifier of the token bundle is proven spent and a fee nullifier is
still free, the outcome judge now answers ExecutedOrSuperseded instead of
CannotExecute(InputUsed), with consumed_by_height taken from the token bundle's reads. The rule is a guard on the Partial case only, so every other answer
and consumed_by_height keep their meaning.

Docs: the outcome guidance says how to retry these transitions under protocol version 14,
where the token bundle does not commit to its fee bundle, and that an admission refusal is
not a reason to pay again with other notes; the three transitions' doc comments, the
book's token shielded pools page, validate_token_pool_outputs and the wasm-dpp2
computePlatformSighash doc describe the protocol version 15 binding.

Tests (red on 5b73d83 with only the tests added, green with the change):
✖ → ✔ should_report_a_spent_token_bundle_as_executed_or_superseded_whatever_the_fee_bundle_shows
✖ → ✔ should_report_a_purchase_whose_token_bundle_landed_in_another_purchase_as_executed_or_superseded
  (renamed from ..._as_input_used, whose expectation it reverses)
New judge unit tests: the guard fires only on a partial spend, takes its height from the
token bundle's reads, leaves the all-consumed answer at the lowest height of any bundle,
and does not fire for a partly spent token bundle, a spent fee bundle
beside a free token bundle, or a spend with no token bundle.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…r its one commitment

validate_shielded_proof v2 computed the fee bundle's Orchard commitment for the token bundle's
preimage and then again inside verify_bundle for the fee bundle's own sighash. verify_bundle
now takes the sighash its caller computed: reconstruct_and_verify_bundle computes the
commitment and the sighash as before, and v2 uses its one fee commitment for both, so each
bundle's commitment is computed once, as under v1. What is verified is unchanged.

The token pool fee binding tests' credit nullifier helper reads the platform's protocol
version, like the other shielded test helpers.

No new test: no behaviour changes (the type 26/27/28 binding, refusal and boundary tests and
the whole shielded suite pass unchanged).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@shumkov
shumkov force-pushed the shumkov/v51-shielded-fee-binding branch from 92f6638 to 742de35 Compare November 18, 2026 03:46
@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — 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 labels Nov 18, 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

The current head correctly confines the fee-bundle binding to protocol version 15, preserves the earlier verifier generations, and reuses the reconstructed fee commitment for both sighashes. The SDK outcome logic consistently treats a fully spent token bundle as settled for the affected transitions, and no new in-scope defects were identified. The Rust workspace and test-suite checks were still running; the unrelated Dashmate local-network E2E check was failing, while the other completed relevant checks passed.

🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(s)

Review provenance

Source: reviewer 1: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.2-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 3: gpt-6.2-astra (agent: phase2-reviewer, role: platform-versioning); reviewer 4: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 5: gpt-6.2-astra (agent: phase2-reviewer, role: rust-quality); reviewer 6: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); reviewer 7: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 8: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 9: gpt-6.2-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 10: gpt-6.2-astra (agent: phase2-reviewer, role: platform-versioning); reviewer 11: gpt-6.2-astra (agent: phase2-reviewer, role: rust-quality); reviewer 12: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.2-sol (effort low) — This is a large, intricate change that modifies consensus validation and cryptographic sighash/signature binding for token-pool transitions, directly affecting funds movement and proof soundness in rs-drive-abci and rs-dpp.
  • 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 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 final gate: an independent Phase-2 review ran after iterative findings were reconciled
  • Fresh verifier: gpt-6.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-astra — general (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — platform-versioning (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — rust-quality (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — security-auditor (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — general (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — platform-versioning (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — rust-quality (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — 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

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 Nov 18, 2026
@shumkov
shumkov merged commit b4e422a into v5.1-dev Nov 18, 2026
95 of 98 checks passed
@shumkov
shumkov deleted the shumkov/v51-shielded-fee-binding branch November 18, 2026 05:32
shumkov added a commit that referenced this pull request Nov 18, 2026
…t's values alone (PV15)

The exemption a contested create got from chooseFirst required validWhen to
read at least the contested index properties. A commitment to the contest's
values and more (an answer beside a name) then had its order skipped, though
that order decides something the contest does not.

commits_to_its_contest_values (formerly contest_takes_every_competitor) now
requires validWhen, and so the findBy function filling among, to read exactly
the contested index properties, beside a contest decided by its index values.
A valid competitor then committed to exactly the create's index values, so the
commitments the order would rank are the contest's would-be contenders. Any
other chooseFirst keeps its scan. The rule reads only the contract's
declarations. DPNS v3 commits to exactly its contested label and parent and
keeps the exemption.

Docs: v15 note 48 (renumbered after the rebase; #5969 holds 47) and notes 3
and 11, the V11 validation notes, the book's chooseFirst and contest pages
(the earliest contender within a block is the lower document id; the per-name
cap keeps rivals out of a contest), and the LookupChooseFirst and wasm docs.

Test would have caught this in CI: ✖ before fix, ✔ after:
- commit_reveal_lookup::should_hold_a_contested_reveal_to_the_order_where_its_commitment_holds_more_than_the_contested_values
  (accepted at 65010fe; 40149 after, at 14 and 15)
Guards: should_hold_a_contested_reveal_to_the_order_where_its_contest_reads_outside_its_index
fails if the rule drops the decided-by-index-values condition (checked by
mutation); dpns_v3::should_refuse_a_reveal_in_the_block_of_its_preorder now
also runs on a contested name, pinning minimumAgeBlocks there; the label-only
commitment test now runs at 14 and 15.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
shumkov added a commit that referenced this pull request Nov 18, 2026
…t's values alone (PV15)

The exemption a contested create got from chooseFirst required validWhen to
read at least the contested index properties. A commitment to the contest's
values and more (an answer beside a name) then had its order skipped, though
that order decides something the contest does not.

commits_to_its_contest_values (formerly contest_takes_every_competitor) now
requires validWhen, and so the findBy function filling among, to read exactly
the contested index properties, beside a contest decided by its index values.
A valid competitor then committed to exactly the create's index values, so the
commitments the order would rank are the contest's would-be contenders. Any
other chooseFirst keeps its scan. The rule reads only the contract's
declarations. DPNS v3 commits to exactly its contested label and parent and
keeps the exemption.

Docs: v15 note 48 (renumbered after the rebase; #5969 holds 47) and notes 3
and 11, the V11 validation notes, the book's chooseFirst and contest pages
(the earliest contender within a block is the lower document id; the per-name
cap keeps rivals out of a contest), and the LookupChooseFirst and wasm docs.

Test would have caught this in CI: ✖ before fix, ✔ after:
- commit_reveal_lookup::should_hold_a_contested_reveal_to_the_order_where_its_commitment_holds_more_than_the_contested_values
  (accepted at 65010fe; 40149 after, at 14 and 15)
Guards: should_hold_a_contested_reveal_to_the_order_where_its_contest_reads_outside_its_index
fails if the rule drops the decided-by-index-values condition (checked by
mutation); dpns_v3::should_refuse_a_reveal_in_the_block_of_its_preorder now
also runs on a contested name, pinning minimumAgeBlocks there; the label-only
commitment test now runs at 14 and 15.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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