Skip to content

feat(platform)!: an emergency switch for the shielded pools - #6410

Merged
QuantumExplorer merged 1 commit into
v5.2-devfrom
feat/shielded-pool-emergency-switch
Nov 30, 2026
Merged

QuantumExplorer merged 1 commit into
v5.2-devfrom
feat/shielded-pool-emergency-switch

Conversation

@QuantumExplorer

@QuantumExplorer QuantumExplorer commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

Basic explanation

What this does: Adds one more emergency switch, ShieldedPools. Emergency switches (#6395) let the evonodes pause a Platform feature by vote, and turn it off at three quarters. This one covers everything that moves value into, inside or out of a shielded pool: the main credit pool and the shielded pool of every token. While it is paused or off, every such transaction is refused without a fee.

Value: The shielded pools rest on zero-knowledge proofs. If a flaw is ever found in the proof system or in how Platform checks it, the damage (value created from nothing, or taken from the pool) cannot be seen from outside, and a fix needs a release and an upgrade vote. With this switch a quarter of the evonodes can stop all shielded activity for an hour within one block, and larger shares for longer, while the fix is prepared. Nothing inside a pool is touched, and everything else on Platform keeps working.

Risks: Low to medium. The rule itself is small: one new entry in a list, and one function that says which transactions carry a shielded bundle. The risk is in using it. Three quarters of the evonodes turning it off locks every shielded note, credits and tokens, until a later protocol version turns the pools back on or gives a way out; no such code exists yet. A quarter of the evonodes can stop shielded activity for one hour, once in the life of the switch. Protocol version 16 is not released, so no running network changes.

Issue being fixed or feature implemented

Follow-up to #6395. The first set of switches covers transfers to Core, platform address spends and the identity key types. Nothing covered the shielded pools, where a broken proof check is both the most damaging failure and the hardest to notice.

What was done?

The switch. EmergencySwitch::ShieldedPools, id 7, appended to the enum and to the list of switches of protocol version 16. It is voted on, counted, stored and queried like every other switch; no storage, vote, query or error code is new.

What it gates. StateTransition::gating_emergency_switches in rs-dpp stays the one place that decides. A state transition is gated when it carries a shielded bundle:

Kind Gated
Shield, ShieldFromAssetLock, ShieldFromIdentity yes
ShieldedTransfer yes
Unshield, ShieldedWithdrawal yes (ShieldedWithdrawal is also gated by StopTransfersToCore)
IdentityCreateFromShieldedPool, IdentityTopUpFromShieldedPool yes
TokenShieldedTransferWithShieldedFee, TokenUnshieldWithShieldedFee, TokenPurchaseFromShieldedPool yes
PrivateDocumentCreateFromShieldedPool yes
A batch with a token action on a token's pool: shield, unshield, shielded transfer, mint to pool, burn from pool, claim to pool, direct purchase to pool yes
A batch with a document whose token cost is paid from a token's pool yes
Every other transition, every other token action, a document paid from a balance no

The top-level list is an exhaustive match, so a new state transition does not compile until it is put on one side. Inside a batch the answer comes from the existing TokenTransition::shielded_pool_actions and TokenPaymentInfo::shielded_payment, which already say which kinds touch a pool.

Decisions worth a look:

  • One switch for all pools. The credit pool and the token pools share the proof system, so a flaw in it is a flaw in all of them.
  • Deposits are gated too. Value sent into a pool whose proofs cannot be trusted is not safe either, and several deposits (mint to pool, claim to pool) create notes directly.
  • Nothing a block does by itself is gated. The anchor bookkeeping at the end of a block has nothing to record while nothing moves, and pruning already keeps each pool's latest anchor while the pool is idle, so a note is spendable again when a pause ends.
  • Reads stay open, so wallets keep syncing during a pause.
  • Declaring a token with a shielded pool is not gated. It creates an empty pool that nothing can move into while the switch refuses.

Where the refusal happens. No change: the existing check in check tx and in block processing reads the new switch through the gating function. In a block it runs before the bundle's proof is verified and before an asset lock is used, so a refused shielded transition costs nothing and a lock that was to be shielded stays unspent.

Before and after, for a ShieldedTransfer sent while a quarter of the evonodes have the switch flipped:

  • Before: no switch exists for it. The transfer is checked and executed as usual.
  • After: refused with StateTransitionRefusedByEmergencySwitchError (41400), naming ShieldedPools and the block time the pause ends at. Not charged; the nullifiers are not spent.

Around it:

  • wasm-dpp2: "shieldedPools" added to the hand-written EmergencySwitchName TypeScript type, and a test that every switch rs-dpp has is named in it.
  • Book chapter architecture/emergency-switches.md: the new row and what to know before flipping it.
  • The protocol version 16 note in rs-platform-version.

Public interface changes

  • Rust: new variant dpp::voting::emergency_switch::EmergencySwitch::ShieldedPools. Code that matches the enum exhaustively needs an arm.
  • Wire and storage: switch id 7, storage key 0x0007. getEmergencySwitches returns one more status at protocol version 16.
  • JS, WASM, Swift, Kotlin, FFI: the switch is named "shieldedPools". These layers pass switch names through to Rust, so the reads and the vote accept it with no other change: sdk.voting.emergencySwitchVote({ emergencySwitch: 'shieldedPools', flipped: true, ... }).
  • TypeScript: EmergencySwitchName gains "shieldedPools".

How Has This Been Tested?

  • rs-dpp (27 emergency switch tests, 4 new): every one of the 12 shielded state transitions is gated; a shielded transfer by this switch alone and a shielded withdrawal by this one and StopTransfersToCore; each of the 7 token actions on a pool gates its batch and a transparent burn or transfer does not; a document paid from a pool gates its batch, one paid from a balance or not paid in tokens does not.
  • rs-drive-abci (18 emergency switch tests, 1 new): a well-formed shielded transfer with a proof that proves nothing reaches the pool's own checks before the flip; with one of four evonodes flipped it is refused by the switch in check tx at both levels and in a block, with the pause end in the error; after the pause it reaches the pool's checks again.
  • wasm-dpp2: the TypeScript name list covers every switch.
  • Existing emergency switch tests of drive, dash-sdk and rs-sdk-ffi pass unchanged.
  • cargo clippy --all-targets --all-features --locked -- --no-deps -D warnings on dpp, drive-abci, wasm-dpp2 and platform-version.

Not done: no run on a live network, and no test that flips the switch with real proofs in flight.

Breaking Changes

Consensus changes at protocol version 16 only: a new switch exists there, and once enough evonodes flip it shielded transitions are refused. Earlier protocol versions are untouched.

The list of switches (EmergencySwitch::existing generation 0) is edited in place. It is selected only by protocol version 16, which has not been released as stable or activated on testnet or mainnet, so no shipped generation changes.

#6354 (ML-DSA-65 identity keys) also appends a switch with id 7, KeyTypeMlDsa65. Whichever of the two merges second takes id 8; the enum conflicts textually, so it cannot merge unnoticed.

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 · 9d675be

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

Adds `EmergencySwitch::ShieldedPools` (id 7) to the switches of protocol
version 16. While it is paused or off, every state transition that carries a
shielded bundle is refused without a fee: the twelve shielded state
transitions, a batch with a token action on a token's pool, and a batch with a
document whose token cost is paid from one. It is one switch for the credit
pool and every token's pool, and it refuses deposits as well as spends.

The existing check in check tx and in block processing reads the new switch
through `StateTransition::gating_emergency_switches`; in a block it runs
before the bundle's proof is verified. Nothing a block does by itself is
gated: pruning already keeps each pool's latest anchor while a pool is idle.

The list of switches is edited in place: only protocol version 16 selects it,
and that version is not released.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@QuantumExplorer QuantumExplorer added this to the v5.2.0 milestone Nov 30, 2026
@coderabbitai

coderabbitai Bot commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 53 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 58d2566 and 9d675be.

Files selected for processing: 6

  • book/src/architecture/emergency-switches.md
  • packages/rs-dpp/src/state_transition/emergency_switches.rs
  • packages/rs-dpp/src/voting/emergency_switch/mod.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/emergency_switch_tests.rs
  • packages/rs-platform-version/src/version/v16.rs
  • packages/wasm-dpp2/src/voting/vote.rs
  • 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

@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-11-30T14:49:10.370Z

@github-actions

github-actions Bot commented Nov 30, 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 30, 2026
@thepastaclaw

thepastaclaw commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Final review complete — no blockers (commit 9d675be) · triage: critical

@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

Adds the protocol-16 ShieldedPools emergency switch and routes all currently defined shielded credit, token-pool, and shielded token-payment transitions through the existing emergency-switch validation path. The transition and token classifiers are exhaustive and reuse established helpers; no in-scope defect was found. CI checks are still in progress, with completed checks successful and no failed code checks reported.

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.2-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 4: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 5: gpt-6.2-astra (agent: phase2-reviewer, role: ffi-engineer); reviewer 6: gpt-6.2-astra (agent: phase2-reviewer, role: platform-versioning); reviewer 7: gpt-6.2-astra (agent: phase2-reviewer, role: rust-quality); reviewer 8: 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) — The change is a substantial consensus-critical modification to state-transition gating and protocol-version emergency-switch dispatch that directly controls shielded-pool value movement, including the StateTransition::gating_emergency_switches logic and PlatformVersion v16 tables.
  • 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.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 — ffi-engineer (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

@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 30, 2026
@QuantumExplorer
QuantumExplorer merged commit d86d80f into v5.2-dev Nov 30, 2026
36 of 37 checks passed
@QuantumExplorer
QuantumExplorer deleted the feat/shielded-pool-emergency-switch branch November 30, 2026 23:08
QuantumExplorer added a commit that referenced this pull request Nov 30, 2026
…dsa-65-keys

v5.2-dev gained the emergency switch for the shielded pools (#6410),
EmergencySwitch::ShieldedPools, which holds id 7. The ML_DSA_65 switch this
branch added held the same id, so it moves to id 8, after it:
EmergencySwitch::KeyTypeMlDsa65 = 8. Neither id has shipped.

Conflicts: the switch enum, its list and its names in
voting/emergency_switch/mod.rs, the EmergencySwitchName type of wasm-dpp2,
and the table of the book chapter. Both switches are kept in each, in id
order.

Co-Authored-By: Claude Fable 5.2 <[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