Skip to content

fix(platform-version): gate shielded-pool block methods to protocol v12#3782

Merged
QuantumExplorer merged 1 commit into
v3.1-devfrom
fix/gate-shielded-block-end-methods-to-v12
Jun 2, 2026
Merged

fix(platform-version): gate shielded-pool block methods to protocol v12#3782
QuantumExplorer merged 1 commit into
v3.1-devfrom
fix/gate-shielded-block-end-methods-to-v12

Conversation

@shumkov
Copy link
Copy Markdown
Collaborator

@shumkov shumkov commented Jun 2, 2026

Issue being fixed or feature implemented

drive 4.0.0-beta.1 cannot process any protocol-v11 block. A node syncing testnet on this build crash-loops in ProcessProposal with:

storage: grovedb: path parent layer not found: could not get key 4d for parent [ [hex: 34, str: 4],  ] of subtree: path key not found: key not found in Merk for get from storage: 4d

0x34 = RootTree::ShieldedBalances (52); 0x4d = MAIN_SHIELDED_CREDIT_POOL_KEY ("M"). The shielded credit pool subtree [52, "M"] is created only from protocol v12 onward (transition_to_version_12, or a v12 genesis via init structure v3). On a protocol-v11 state it does not exist.

Root cause: protocol v11 and v12 both reference the shared DRIVE_ABCI_METHOD_VERSIONS_V7. The Medusa shielded-pool PR (#3177, b33f8ec75b) added four shielded block-processing methods to V7 as Some(0):

  • store_nullifiers_to_recent_block_storage
  • cleanup_recent_block_storage_nullifiers
  • record_shielded_pool_anchor
  • prune_shielded_pool_anchors

Because V7 is shared, this silently turned them on for v11 too. They run on every block (independent of transactions) and unconditionally read [52, "M"], aborting consensus.

This was not introduced by #2920 (which switched v11 from V6→V7 for checkpoints): at release 3.0.1, V7 had no shielded fields, so v11 was fine. The rest of testnet runs dashpay/drive:3.0.1 and is unaffected — only the lone 4.0.0-beta.1 node broke.

Observed on testnet hp-masternode-7 at height 354892 — the first block the beta binary processed after it was deployed (the previous binary had committed cleanly up to 354891).

What was done?

  • Restored DRIVE_ABCI_METHOD_VERSIONS_V7 (the protocol-v11 method set) to its 3.0.1 behavior: the four shielded methods are back to None.
  • Added DRIVE_ABCI_METHOD_VERSIONS_V8 (= V7 plus the four shielded methods Some(0)) and pointed v12.rs at it.
  • v11.rs is unchanged (still references V7).

Net effect: shielded-pool block processing is gated to protocol v12+, where the [52, "M"] subtree is guaranteed to exist. The legitimately-v11 parts of V7 (checkpoints, address recent-block-storage from #2866) are untouched.

How Has This Been Tested?

New unit test platform-version::shielded_pool_gating_tests pins the invariant with a red→green transition against this exact bug:

  • before fix: PlatformVersion::get(11).drive_abci.methods.block_end.record_shielded_pool_anchor == Some(0) → test FAILS (left: Some(0), right: None)
  • after fix: v11 → None for all four methods; v12 → Some(0) → PASSES
cargo test -p platform-version --lib   # 7 passed, 0 failed
cargo fmt -p platform-version -- --check   # clean

Ground truth confirmed against the live network: every other testnet masternode runs dashpay/drive:3.0.1, whose V7 has no shielded fields — this change restores exact v11 parity with them.

Breaking Changes

None. This is a consensus-relevant version-map correction, but no chain state was ever produced under the buggy v11 rules (a v11 node with the bug crashes before it can commit), and the fix restores parity with the released 3.0.1 network. The shielded pool remains a v12 feature; the v12 upgrade migration (transition_to_version_12) is idempotent (grove_insert_if_not_exists per node) and creates [52, "M"] and its children when v12 activates.

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

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added shielded pool block-processing functionality for Protocol v12.
  • Tests

    • Added verification tests for shielded pool feature gating to Protocol v12.
  • Chores

    • Updated version management configuration to support Protocol v12 requirements.

Protocol v11 shared DRIVE_ABCI_METHOD_VERSIONS_V7 with v12. The Medusa shielded-pool PR (#3177, b33f8ec) added four shielded block-processing methods to V7 as Some(0): store_nullifiers_to_recent_block_storage, cleanup_recent_block_storage_nullifiers, record_shielded_pool_anchor, prune_shielded_pool_anchors. Because V7 is referenced by both v11.rs and v12.rs, this silently activated them on protocol v11 too.

These run every block and read the shielded credit pool subtree [ShieldedBalances 0x34, MAIN_SHIELDED_CREDIT_POOL_KEY 'M' 0x4d], which only exists from v12 onward (created by transition_to_version_12 or a v12 genesis). On a v11 state the subtree is absent, so the read aborts consensus with: 'storage: grovedb: path parent layer not found: could not get key 4d for parent [52]'.

Observed on testnet hp-masternode-7 (drive 4.0.0-beta.1): crash-looped in ProcessProposal on every v11 block starting at height 354892 (the first block it processed after the binary was deployed). The rest of testnet runs drive 3.0.1, whose V7 had no shielded fields, and was unaffected.

Fix: keep V7 as the v11 method set with the four shielded methods None (restores 3.0.1 v11 behavior); add DRIVE_ABCI_METHOD_VERSIONS_V8 (= V7 + shielded Some(0)) and point v12 at it. v11.rs is unchanged.

Regression test (platform-version shielded_pool_gating_tests) would have caught this in CI: before fix v11 record_shielded_pool_anchor == Some(0) -> FAILS (left=Some(0), right=None); after fix v11 == None and v12 == Some(0) -> PASSES.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@shumkov shumkov requested a review from QuantumExplorer as a code owner June 2, 2026 15:35
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 2, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4619bfe8-0458-45d2-a272-11639c5f1893

📥 Commits

Reviewing files that changed from the base of the PR and between e01b6a3 and 36f7f9e.

📒 Files selected for processing (5)
  • packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_method_versions/mod.rs
  • packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_method_versions/v7.rs
  • packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_method_versions/v8.rs
  • packages/rs-platform-version/src/version/protocol_version.rs
  • packages/rs-platform-version/src/version/v12.rs

📝 Walkthrough

Walkthrough

This PR gates four shielded-pool block-processing methods to protocol v12+ by disabling them in v7 (used by protocol v11), defining a new v8 method set with them enabled, wiring v12 to use v8, and validating the gating via tests that confirm the methods are inactive on v11 and active on v12.

Changes

Shielded Pool Method Gating

Layer / File(s) Summary
Protocol v11 gating: v7 method updates
packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_method_versions/v7.rs
Disables four shielded-pool block-processing methods (store_nullifiers_to_recent_block_storage, cleanup_recent_block_storage_nullifiers, record_shielded_pool_anchor, prune_shielded_pool_anchors) by setting them to None with documentation explaining that the underlying ShieldedBalances subtree does not exist on v11 and would cause a consensus panic if these methods were active.
Protocol v12 method set: v8 definition
packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_method_versions/v8.rs
Introduces DRIVE_ABCI_METHOD_VERSIONS_V8 constant with the same per-subsystem method versions as v7, but enables the four shielded-pool block-processing methods (set to Some(0)) for protocol v12 activation and beyond.
Module exposure and v12 configuration
packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_method_versions/mod.rs, packages/rs-platform-version/src/version/v12.rs
Exposes the v8 module and updates v12 platform configuration to use DRIVE_ABCI_METHOD_VERSIONS_V8 instead of v7, with inline documentation clarifying that v8 includes the newly activated shielded-pool methods.
Gating validation tests
packages/rs-platform-version/src/version/protocol_version.rs
Adds shielded_pool_gating_tests module with tests asserting that the four shielded block-processing methods are None on protocol v11 and Some(0) on protocol v12, confirming the gating invariant across the protocol version boundary.

🎯 3 (Moderate) | ⏱️ ~22 minutes

🐇 Four shielded methods, gated with care,
Resting silent on v11's air.
V12 awakens them with a cheer,
Tests confirm: the gates are clear! 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and clearly summarizes the primary change: gating shielded-pool block methods to protocol v12, which is the core fix addressing the crash issue on v11 nodes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/gate-shielded-block-end-methods-to-v12

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 and usage tips.

@thepastaclaw
Copy link
Copy Markdown
Collaborator

thepastaclaw commented Jun 2, 2026

✅ Review complete (commit 36f7f9e)

Copy link
Copy Markdown
Collaborator

@thepastaclaw thepastaclaw left a comment

Choose a reason for hiding this comment

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

Code Review

Targeted, correct consensus-safety fix. V7 (the method set used by PLATFORM_V11) is restored to its 3.0.1 behavior with the four shielded-pool block-processing methods set to None, and the new V8 struct (used only by PLATFORM_V12) carries the Some(0) activations. V7 vs V8 differ in exactly those four fields, no other protocol version references V8, and the added tests pin the invariant at both v11 and v12.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 2, 2026

✅ DashSDKFFI.xcframework built for this PR.

SwiftPM (host the zip at a stable URL, then use):

.binaryTarget(
  name: "DashSDKFFI",
  url: "https://your.cdn.example/DashSDKFFI.xcframework.zip",
  checksum: "277047132170cc569f5ba4932bec5c857537fe2723758b1b161c4d4a0ef87f05"
)

Xcode manual integration:

  • Download 'DashSDKFFI.xcframework' artifact from the run link above.
  • Drag it into your app target (Frameworks, Libraries & Embedded Content) and set Embed & Sign.
  • If using the Swift wrapper package, point its binaryTarget to the xcframework location or add the package and place the xcframework at the expected path.

@QuantumExplorer QuantumExplorer merged commit 76fc95a into v3.1-dev Jun 2, 2026
36 of 39 checks passed
@QuantumExplorer QuantumExplorer deleted the fix/gate-shielded-block-end-methods-to-v12 branch June 2, 2026 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants