Skip to content

feat(platform)!: emergency switches the evonodes flip to pause or turn off a feature - #6395

Merged
QuantumExplorer merged 12 commits into
v5.2-devfrom
feat/emergency-switches
Nov 30, 2026
Merged

QuantumExplorer merged 12 commits into
v5.2-devfrom
feat/emergency-switches

Conversation

@QuantumExplorer

@QuantumExplorer QuantumExplorer commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

Basic explanation

What this does: Adds emergency switches: off switches for single Platform features that the evonodes flip by vote. When a quarter of the evonodes flip a switch, the feature it guards is paused for an hour. A half pauses it for six hours, two thirds for ten days, and three quarters turn it off until a later protocol version turns it back on. Each pause can happen only once per switch, ever. Switches are defined in code; nothing creates one at run time. This first version ships seven of them at protocol version 16: one that stops transfers of credits to Dash Core, one that stops spends from platform addresses, and one per identity key type (five today).

Value: If a signature scheme or the bridge to Core is found broken, the network can stop the damage in one block instead of waiting for a release and an upgrade vote. A minority can buy time (at most 1 hour under a half, 7 hours under two thirds, 10 days and 7 hours under three quarters, over the whole life of a switch) without being able to hold a feature hostage.

Risks: Medium. This is new consensus code at protocol version 16, which is unreleased, and nothing changes at earlier versions.

  • A switch that turns an identity key type off freezes every identity whose keys are all of that type, and only a later protocol version can bring them back. For ECDSA_SECP256K1 that is nearly every identity today. This is the intended effect of "this key type is broken", but it is severe.
  • Flips are signed with masternode voting keys, which are ECDSA_HASH160. If ECDSA is truly broken, votes can be forged. A forged vote can push a switch towards off, or withdraw a flip between pauses. It cannot bring back a feature that was turned off, because off is latched, and it cannot lower the share during a pause.
  • The evonode set is small, so each share is a small number of nodes. The cheapest tier costs the network one hour per switch.
  • The Swift wrappers were not compiled locally, and no flow was run against a live network.

Issue being fixed or feature implemented

Platform has no way to stop a feature quickly. A fix for a broken signature scheme, or for a problem with withdrawals to Core, needs a release and a protocol upgrade vote, which takes days at best.

What was done?

The rule

Share of the evonodes that flipped the switch Effect on the gated feature
at least 1/4 paused for 1 hour
at least 1/2 paused for 6 hours
at least 2/3 paused for 10 days
at least 3/4 off, latched
  • The network is the evonodes that are not PoSe-banned, one evonode one flip. Regular masternodes cannot flip a switch and are not counted.
  • Each pause tier fires once per switch, ever. A jump over several tiers in one block spends all of them and the longest pause runs. A pause is never shortened.
  • Off is latched: no vote changes it.
  • Every block advances every switch once, after the masternode list is updated and before the block's withdrawal steps and state transitions. A vote in block N takes effect in block N+1. The share is recounted in every block, so a banned, revived or removed evonode moves it without a new vote.
  • The shares, the durations and the change limit are in SystemLimits.

The switches

Switch Gates
StopTransfersToCore Identity, address and shielded withdrawals are refused. Queued withdrawals are not pooled, signed or re-signed until the pause ends. A transaction Core already holds is not recalled.
PlatformAddressSpends Every state transition that names a platform address as an input. Receiving to an address stays allowed.
KeyTypeEcdsaSecp256k1, KeyTypeBls12381, KeyTypeEcdsaHash160 State transitions signed with an identity key of that type, and adding one.
KeyTypeBip13ScriptHash, KeyTypeEddsa25519Hash160 Adding a key of that type (these sign nothing).

EmergencySwitch::for_key_type matches every key type, so a key type added later does not compile until its switch is decided. #6354 adds ML-DSA-65 keys: whichever of the two merges second adds that switch.

"ECDSA is broken" is three switches: both ECDSA key types and PlatformAddressSpends. The BLS switch covers identity keys only; quorum signatures, chain locks and instant locks are consensus and are not gated. Block execution keeps writing masternode identity keys of every type: a switch never gates what the system writes.

A flip

A flip is a masternode vote, Vote::EmergencySwitchVote { switch, flipped }, carried by the existing MasternodeVote state transition and signed with the voting key.

  • It is free: it answers no poll, so there is no fund to pay it from.
  • An evonode may change its flip of one switch at most 4 times, which bounds the free votes.
  • A flip cannot be withdrawn while the feature is paused.
  • A vote on a switch is exempt from every key type switch, or the first pause of KeyTypeEcdsaHash160 would stop the votes that escalate it.
  • The vote does not decode before protocol version 16.

What a client sees

Before: a withdrawal sent while transfers to Core are in trouble is accepted, queued and sent.

After, with StopTransfersToCore paused: the withdrawal is refused in check tx and never enters a block, without a fee:

StateTransitionRefusedByEmergencySwitchError (41400)
State transition is refused by emergency switch StopTransfersToCore: the feature it gates is paused until block time 1800003601000 ms

Reading the switches and voting (the values are an example):

const switches = await sdk.voting.emergencySwitches();
// [{ emergencySwitch: 'stopTransfersToCore', flippedEvonodes: 120, totalEvonodes: 450,
//    pauseTiersFired: 1, pausedUntilMs: 1800003601000n, off: false }, ...]

await sdk.voting.emergencySwitchVote({
  masternodeProTxHash, emergencySwitch: 'stopTransfersToCore', flipped: true, votingKey, signer,
});

By layer

  • Version tables: VOTING_VERSION_V4, DRIVE_VOTE_METHOD_VERSIONS_V5, DRIVE_VERIFY_METHOD_VERSIONS_V5, DRIVE_ABCI_METHOD_VERSIONS_V12 and DRIVE_ABCI_VALIDATION_VERSIONS_V12, selected by PLATFORM_V16 only. New SystemLimits fields, backfilled. v16 note 2 describes the feature.
  • rs-dpp: EmergencySwitch, EmergencySwitchStatus with the tier rule (advance), EmergencySwitchFlip, the vote variant, StateTransition::gating_emergency_switches (the one place that says what each switch gates), and seven consensus errors (41400 to 41406).
  • rs-drive: a new branch of the votes tree for statuses and flips, created at genesis and by the upgrade to 16 through one helper; register_identity_vote 2, remove_all_votes_given_by_identities 2; proofs and verifiers. Described in structure.rs, grovedb-structure.json regenerated.
  • rs-drive-abci: evaluate_emergency_switches, validate_emergency_switches (a new check in the processor and in check tx, first time and recheck), masternode vote transform_into_action 2, and a new generation of the three withdrawal steps. Statuses are kept in the platform state and read from Drive when it is loaded.
  • Queries: getEmergencySwitches and getEmergencySwitchFlips, with proofs, through rs-dapi, rs-dapi-client, the proof verifier, rs-sdk, wasm-sdk and js-evo-sdk. Generated gRPC clients regenerated.
  • Mobile: dash_sdk_emergency_switch* in rs-sdk-ffi, Swift and Kotlin wrappers. No example app screens.
  • Book: a new chapter, Architecture / Emergency Switches, with how to add a switch.

One thing found while building: with queued withdrawals held back by the switch, the node would have asked Tenderdash for an immediate next block on every block for the whole pause. The hint is now off while the switch blocks.

In-place changes to shipped generations

Each is unreachable before protocol version 16: no vote on an emergency switch decodes there (StateTransition::active_version_range), and every new method slot is None there.

  • run_block_proposal 0 (every version): calls evaluate_emergency_switches, an optional method whose dispatcher returns without reading or writing when its slot is None, and hands the block's platform state to the three withdrawal steps, whose earlier generations do not read it.
  • process_state_transition 0 and state_transition_to_execution_event_for_check_tx 0 (every version): call validate_emergency_switches, which returns valid without reading anything when its slot is None.
  • finalize_block_proposal 0 (every version): the next-block hint also reads whether StopTransfersToCore blocks. The hint changes no fee, state or app hash, and no switch exists before 16.
  • Masternode vote transform_into_action 0 and 1, validate_state 0 and 1, register_identity_vote 0, VoteResolver: an arm for the new variant that returns an internal error, or passes the action on (validate_state 1). The variant cannot be built before 16.
  • MasternodeVoteTransitionAction::into_high_level_drive_operations 0, ExecutionEvent::create_from_state_transition_action and uses_prefunded_specialized_balance_for_payment: a vote on a switch deducts from no fund and is a free event. Only the new variant takes these branches.
  • prove_state_transition 0, verify_state_transition_was_executed_with_proof 0 and Drive::verify_masternode_vote: an arm that proves and verifies the stored flip, off the block execution path.
  • fetch_platform_state dispatcher: after loading, reads the switch statuses from Drive when the loaded state's protocol version has any switch; nothing is read before 16.

Public interface changes

dapi-grpc (wire): two new RPCs, getEmergencySwitches and getEmergencySwitchFlips, with their request and response messages. Nothing existing changes.

rs-dpp

  • New: dpp::voting::emergency_switch::{EmergencySwitch, EmergencySwitchStatus, EmergencySwitchFlip, EvonodeEmergencySwitchFlip}, dpp::voting::votes::emergency_switch_vote::EmergencySwitchVote.
  • dpp::voting::votes::Vote gains the variant EmergencySwitchVote, appended. Code that matches Vote exhaustively no longer compiles until it adds the arm.
  • Vote::vote_poll_unique_id returns an error for the new variant (it answers no poll); Vote::specialized_balance_id returns None for it.
  • StateError gains seven variants, appended: discriminants 183 to 189, codes 41400 to 41406. Exhaustive matches on StateError need the arms.
  • New: StateTransition::gating_emergency_switches(signing_key_type: Option<KeyType>) -> BTreeSet<EmergencySwitch>.

rs-platform-version

  • SystemLimits gains emergency_switch_pause_tiers, emergency_switch_off_share_numerator, emergency_switch_off_share_denominator, max_emergency_switch_flip_changes_per_evonode, and the type EmergencySwitchPauseTier. Struct literals of SystemLimits need the fields.
  • New optional slots, None before 16, in DPPVotingVersions, DriveVoteMethodVersions (emergency_switch), DriveVerifyVoteMethodVersions, DriveAbciVotingMethodVersions, DriveAbciValidationVersions and DriveAbciQueryVotingVersions.
  • EMERGENCY_SWITCHES_INITIAL_PROTOCOL_VERSION = 16.

rs-drive

  • ResolvedVote gains EmergencySwitchVote(ResolvedEmergencySwitchVote); exhaustive matches need the arm.
  • New: Drive::{insert_emergency_switch_trees, register_emergency_switch_flip, register_emergency_switch_flip_operations, fetch_emergency_switch_flip, fetch_emergency_switch_flips, fetch_emergency_switch_statuses, store_emergency_switch_status, remove_emergency_switch_flips_given_by_identities, verify_masternode_emergency_switch_vote}, drive::query::emergency_switch_query::{EmergencySwitchStatusesDriveQuery, EmergencySwitchFlipsDriveQuery}, drive::drive::votes::emergency_switch::paths.

rs-drive-abci

  • PlatformState gains the public field emergency_switch_statuses, and PlatformStateV0Methods five methods. The saved record is unchanged.
  • Three dispatchers take one more parameter, the block's platform state:
// before
rebroadcast_expired_withdrawal_documents(block_info, last_committed_platform_state, transaction, platform_version)
dequeue_and_build_unsigned_withdrawal_transactions(validator_set_quorum_hash, block_info, transaction, platform_version)
pool_withdrawals_into_transactions_queue(block_info, last_committed_platform_state, transaction, platform_version)
// after
rebroadcast_expired_withdrawal_documents(block_info, last_committed_platform_state, block_platform_state, transaction, platform_version)
dequeue_and_build_unsigned_withdrawal_transactions(validator_set_quorum_hash, block_info, block_platform_state, transaction, platform_version)
pool_withdrawals_into_transactions_queue(block_info, last_committed_platform_state, block_platform_state, transaction, platform_version)

rs-sdk: new module dash_sdk::platform::emergency_switches (EmergencySwitchStatusesQuery, EmergencySwitchFlipsQuery, EmergencySwitchStatuses, EmergencySwitchFlips, Sdk::emergency_switch_vote). PutVote casts the new vote unchanged.

wasm-dpp2 / wasm-sdk / js-evo-sdk: Vote.emergencySwitch(name, flipped), the getters emergencySwitchName and flipped; getEmergencySwitches, getEmergencySwitchFlips (each also WithProofInfo) and emergencySwitchVote; sdk.voting.emergencySwitches(), emergencySwitchFlips(), emergencySwitchVote() and the WithProof forms. The VoteObject and VoteJSON types gain the emergencySwitchVote shape.

rs-sdk-ffi: dash_sdk_emergency_switches_get, dash_sdk_emergency_switch_flips_get, dash_sdk_emergency_switch_vote, dash_sdk_emergency_switch_vote_with_signer. Reads return JSON arrays; a pro tx hash is hex of the wire-order bytes, the orientation every pro tx hash argument of this FFI takes.

What stays the same: every stored byte, hash and proof at protocol versions 1 to 15; the saved platform state record; every existing RPC and SDK call. At protocol version 16 the genesis state gains the new branch of the votes tree, which moves the state root (ten pinned hashes in nullifier_batch_guard.rs were re-pinned).

How Has This Been Tested?

Targeted runs, all passing:

  • rs-dpp: 23 tests under emergency_switch (the tier rule at each threshold, tiers firing once, the jump over tiers, the latch, the list shrinking, an empty list, which transitions each switch gates, the decode gate at 15 and 16) and the frozen StateError discriminants.
  • rs-platform-version: the shares rise up to the off share in every version.
  • rs-drive: flips and statuses read, proved and verified; the flips of removed masternodes removed; the structure tests (the description matches a real GroveDB at every protocol version and every described node is reached).
  • rs-drive-abci: 10 behaviour tests that run votes and gated transitions through check tx and a block (an evonode's flip and withdrawal, a regular masternode refused, each pause once, off latched, a withdrawal held until the pause ends, the change limit, banned and removed evonodes not counted, a withdrawal to Core refused while paused and accepted after, the key type gate and the exemption of switch votes, statuses read back when the state is loaded, nothing happening at protocol version 15); the three withdrawal steps leaving withdrawals where they are while paused; the query handlers with proofs; the next-block hint.
  • These and the neighbouring suites together: 587 tests across masternode votes, withdrawals, protocol upgrade, platform state, check tx and block finalization. Also 59 strategy tests (upgrades, voting, withdrawals, identities and documents), voting_default_limits and nonunique_merged_proof.
  • dash-sdk, drive-proof-verifier, rs-dapi-client (request inventory), rs-sdk-ffi (7), rs-unified-sdk-jni (1), @dashevo/dapi-grpc unit tests (77), Kotlin EmergencySwitchModelsTest (4, with the SDK compiling).
  • cargo clippy --all-targets --all-features --locked -- --no-deps -D warnings on platform-version, dpp, drive, drive-abci, rs-dapi, rs-dapi-client, drive-proof-verifier, dash-sdk, wasm-dpp, wasm-dpp2, wasm-sdk, rs-sdk-ffi, rs-unified-sdk-jni; cargo fmt --all --check; cargo check --workspace --all-targets.

Not yet verified:

  • The Swift wrappers and their decoding tests were not compiled or run (no build_ios.sh or xcodebuild run).
  • The Kotlin JNI path was not exercised on a device: the native library was not rebuilt with the new exports.
  • The js-evo-sdk facade specs and the wasm32 builds were not run.
  • No flow was run against a live network, and no rs-sdk test vectors were generated.
  • Full package suites were not run locally.

Not done in this pull request

  • Dashmate: no status line for the switches. dashmate status reads Tenderdash and Docker only and has no DAPI query path today.
  • Dash Evo Tool: a flip screen belongs in its own repository once this is released. "ECDSA is broken" being three switches is worth one button there.
  • Example apps: no SwiftExampleApp or KotlinExampleApp screens.
  • Unproved reads: the two queries are served without proofs by the node, but the SDKs fetch them with proofs only.

Breaking Changes

Consensus changes at protocol version 16 only, which is unreleased: a new vote kind, a new branch of the votes tree at genesis and on upgrade, a new unpaid refusal of gated state transitions, and withdrawal steps that pause. Protocol versions 1 to 15 are unchanged.

Source-level: Vote, ResolvedVote and StateError gain variants and SystemLimits gains fields (see Public interface changes).

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 (described and regenerated; the viewer link is not checked yet)
  • 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 · f2b53c4

  • Bots — thepastaclaw ✓
  • Self-review — post /self-reviewed
  • Reviewer requests paused — your 5 review slots are occupied; this PR is excluded from reviewers' queues. Required approvals still count without a slot.
  • Build running
  • Approvals
    • files with no dedicated owner — you own it
    • sdk-parity — you own it
    • js-wasm-sdk (packages/js-evo-sdk/src/voting/facade.ts, packages/js-evo-sdk/tests/unit/facades/voting.spec.ts, packages/wasm-sdk/src/emergency_switches.rs and 1 more) — approved by shumkov
    • kotlin-sdk (packages/kotlin-sdk/PARITY_SUMMARY.md, packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/Sdk.kt, packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/ffi/EmergencySwitchesNative.kt and 5 more) — HashEngineering
    • rust-dapi (packages/rs-dapi/src/metrics.rs, packages/rs-dapi/src/services/platform_service/mod.rs) — approved by shumkov
    • dpp — you own it
    • rs-drive-abci — you own it
    • rs-drive — you own it
    • rust-sdk-ffi (packages/rs-sdk-ffi/src/emergency_switch/json.rs, packages/rs-sdk-ffi/src/emergency_switch/mod.rs, packages/rs-sdk-ffi/src/emergency_switch/queries.rs and 2 more) — approved by shumkov
    • rust-sdk (packages/rs-sdk/src/mock/requests.rs, packages/rs-sdk/src/mock/sdk.rs, packages/rs-sdk/src/platform.rs and 3 more) — approved by shumkov
    • swift-sdk (packages/swift-sdk/Sources/SwiftDashSDK/Voting/EmergencySwitch.swift, packages/swift-sdk/Sources/SwiftDashSDK/Voting/SDK+EmergencySwitches.swift, packages/swift-sdk/SwiftTests/SwiftDashSDKTests/EmergencySwitchDecodingTests.swift) — llbartekll or romchornyi

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.

@github-actions github-actions Bot added this to the v5.2.0 milestone Nov 30, 2026
@coderabbitai

coderabbitai Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Too many files!

This PR contains 217 files, which is 117 over the limit of 100.

To get a review, reduce the PR to 100 files or fewer by splitting it into smaller PRs or changing its base branch.

Upgrade to a paid plan to raise the limit.

This organization's CodeRabbit subscription is cancelled. Resubscribe in Billing to continue reviews beyond the free-tier limit.

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 46c3ca8 and f2b53c4.

Files selected for processing: 217

  • book/src/SUMMARY.md
  • book/src/architecture/emergency-switches.md
  • book/src/error-handling/error-codes.md
  • docs/sdk/sdk-parity-manifest.json
  • packages/dapi-grpc/build.rs
  • packages/dapi-grpc/clients/drive/v0/nodejs/drive_pbjs.js
  • packages/dapi-grpc/clients/platform/v0/java/org/dash/platform/dapi/v0/PlatformGrpc.java
  • packages/dapi-grpc/clients/platform/v0/nodejs/PlatformPromiseClient.js
  • packages/dapi-grpc/clients/platform/v0/nodejs/platform_pbjs.js
  • packages/dapi-grpc/clients/platform/v0/nodejs/platform_protoc.js
  • packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbobjc.h
  • packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbobjc.m
  • packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbrpc.h
  • packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbrpc.m
  • packages/dapi-grpc/clients/platform/v0/python/platform_pb2.py
  • packages/dapi-grpc/clients/platform/v0/python/platform_pb2_grpc.py
  • packages/dapi-grpc/clients/platform/v0/web/PlatformPromiseClient.js
  • packages/dapi-grpc/clients/platform/v0/web/platform_pb.d.ts
  • packages/dapi-grpc/clients/platform/v0/web/platform_pb.js
  • packages/dapi-grpc/clients/platform/v0/web/platform_pb_service.d.ts
  • packages/dapi-grpc/clients/platform/v0/web/platform_pb_service.js
  • packages/dapi-grpc/protos/platform/v0/platform.proto
  • packages/dapi-grpc/test/unit/clients/platform/v0/nodejs/PlatformPromiseClient.spec.js
  • packages/js-evo-sdk/src/voting/facade.ts
  • packages/js-evo-sdk/tests/unit/facades/voting.spec.ts
  • packages/kotlin-sdk/PARITY_SUMMARY.md
  • packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/Sdk.kt
  • packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/ffi/EmergencySwitchesNative.kt
  • packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/voting/EmergencySwitchModels.kt
  • packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/voting/EmergencySwitches.kt
  • packages/kotlin-sdk/sdk/src/test/kotlin/org/dashfoundation/dashsdk/voting/EmergencySwitchModelsTest.kt
  • packages/rs-dapi-client/src/transport/grpc.rs
  • packages/rs-dapi-client/tests/request_inventory.rs
  • packages/rs-dapi/src/metrics.rs
  • packages/rs-dapi/src/services/platform_service/mod.rs
  • packages/rs-dpp/src/errors/consensus/codes.rs
  • packages/rs-dpp/src/errors/consensus/state/emergency_switch/emergency_switch_already_off_error.rs
  • packages/rs-dpp/src/errors/consensus/state/emergency_switch/emergency_switch_does_not_exist_error.rs
  • packages/rs-dpp/src/errors/consensus/state/emergency_switch/emergency_switch_flip_change_limit_reached_error.rs
  • packages/rs-dpp/src/errors/consensus/state/emergency_switch/emergency_switch_flip_unchanged_error.rs
  • packages/rs-dpp/src/errors/consensus/state/emergency_switch/emergency_switch_flip_withdrawal_while_paused_error.rs
  • packages/rs-dpp/src/errors/consensus/state/emergency_switch/emergency_switch_voter_not_evonode_error.rs
  • packages/rs-dpp/src/errors/consensus/state/emergency_switch/mod.rs
  • packages/rs-dpp/src/errors/consensus/state/emergency_switch/state_transition_refused_by_emergency_switch_error.rs
  • packages/rs-dpp/src/errors/consensus/state/mod.rs
  • packages/rs-dpp/src/errors/consensus/state/state_error.rs
  • packages/rs-dpp/src/serialization/json/safe_fields.rs
  • packages/rs-dpp/src/state_transition/emergency_switches.rs
  • packages/rs-dpp/src/state_transition/mod.rs
  • packages/rs-dpp/src/voting/emergency_switch/flip/mod.rs
  • packages/rs-dpp/src/voting/emergency_switch/flip/v0/mod.rs
  • packages/rs-dpp/src/voting/emergency_switch/mod.rs
  • packages/rs-dpp/src/voting/emergency_switch/status/mod.rs
  • packages/rs-dpp/src/voting/emergency_switch/status/v0/mod.rs
  • packages/rs-dpp/src/voting/mod.rs
  • packages/rs-dpp/src/voting/votes/emergency_switch_vote/mod.rs
  • packages/rs-dpp/src/voting/votes/emergency_switch_vote/v0/mod.rs
  • packages/rs-dpp/src/voting/votes/mod.rs
  • packages/rs-drive-abci/src/abci/handler/finalize_block.rs
  • packages/rs-drive-abci/src/execution/engine/finalize_block_proposal/v0/mod.rs
  • packages/rs-drive-abci/src/execution/engine/run_block_proposal/v0/mod.rs
  • packages/rs-drive-abci/src/execution/platform_events/protocol_upgrade/perform_events_on_first_block_of_protocol_change/v0/mod.rs
  • packages/rs-drive-abci/src/execution/platform_events/voting/evaluate_emergency_switches/mod.rs
  • packages/rs-drive-abci/src/execution/platform_events/voting/evaluate_emergency_switches/v0/mod.rs
  • packages/rs-drive-abci/src/execution/platform_events/voting/mod.rs
  • packages/rs-drive-abci/src/execution/platform_events/withdrawals/build_untied_withdrawal_transactions_from_documents/v1/mod.rs
  • packages/rs-drive-abci/src/execution/platform_events/withdrawals/dequeue_and_build_unsigned_withdrawal_transactions/mod.rs
  • packages/rs-drive-abci/src/execution/platform_events/withdrawals/dequeue_and_build_unsigned_withdrawal_transactions/v0/mod.rs
  • packages/rs-drive-abci/src/execution/platform_events/withdrawals/dequeue_and_build_unsigned_withdrawal_transactions/v1/mod.rs
  • packages/rs-drive-abci/src/execution/platform_events/withdrawals/pool_withdrawals_into_transactions_queue/mod.rs
  • packages/rs-drive-abci/src/execution/platform_events/withdrawals/pool_withdrawals_into_transactions_queue/v2/mod.rs
  • packages/rs-drive-abci/src/execution/platform_events/withdrawals/pool_withdrawals_into_transactions_queue/v3/mod.rs
  • packages/rs-drive-abci/src/execution/platform_events/withdrawals/rebroadcast_expired_withdrawal_documents/mod.rs
  • packages/rs-drive-abci/src/execution/platform_events/withdrawals/rebroadcast_expired_withdrawal_documents/v3/mod.rs
  • packages/rs-drive-abci/src/execution/storage/fetch_platform_state/mod.rs
  • packages/rs-drive-abci/src/execution/types/execution_event/mod.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/check_tx_verification/v0/mod.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/processor/traits/emergency_switches.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/processor/traits/mod.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/processor/traits/prefunded_specialized_balance.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/processor/v0/mod.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/token/shielded/nullifier_batch_guard.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/emergency_switch_tests.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/mod.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/state/v0/mod.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/state/v1/mod.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/transform_into_action/mod.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/transform_into_action/v0/mod.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/transform_into_action/v1/mod.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/transform_into_action/v2/mod.rs
  • packages/rs-drive-abci/src/platform_types/platform_state/accessors.rs
  • packages/rs-drive-abci/src/platform_types/platform_state/mod.rs
  • packages/rs-drive-abci/src/platform_types/platform_state/platform_state_for_saving/v1/mod.rs
  • packages/rs-drive-abci/src/platform_types/platform_state/platform_state_for_saving/v2/mod.rs
  • packages/rs-drive-abci/src/query/service.rs
  • packages/rs-drive-abci/src/query/voting/emergency_switch_flips/mod.rs
  • packages/rs-drive-abci/src/query/voting/emergency_switch_flips/v0/mod.rs
  • packages/rs-drive-abci/src/query/voting/emergency_switches/mod.rs
  • packages/rs-drive-abci/src/query/voting/emergency_switches/v0/mod.rs
  • packages/rs-drive-abci/src/query/voting/mod.rs
  • packages/rs-drive-abci/tests/strategy_tests/verify_state_transitions.rs
  • packages/rs-drive-proof-verifier/src/proof.rs
  • packages/rs-drive-proof-verifier/src/proof/emergency_switches.rs
  • packages/rs-drive-proof-verifier/src/types.rs
  • packages/rs-drive-proof-verifier/src/types/emergency_switches.rs
  • packages/rs-drive/grovedb-structure.json
  • packages/rs-drive/src/drive/initialization/v5/mod.rs
  • packages/rs-drive/src/drive/votes/cleanup/remove_all_votes_given_by_identities/mod.rs
  • packages/rs-drive/src/drive/votes/cleanup/remove_all_votes_given_by_identities/v2/mod.rs
  • packages/rs-drive/src/drive/votes/emergency_switch/fetch_emergency_switch_flip/mod.rs
  • packages/rs-drive/src/drive/votes/emergency_switch/fetch_emergency_switch_flip/v0/mod.rs
  • packages/rs-drive/src/drive/votes/emergency_switch/fetch_emergency_switch_flips/mod.rs
  • packages/rs-drive/src/drive/votes/emergency_switch/fetch_emergency_switch_flips/v0/mod.rs
  • packages/rs-drive/src/drive/votes/emergency_switch/fetch_emergency_switch_statuses/mod.rs
  • packages/rs-drive/src/drive/votes/emergency_switch/fetch_emergency_switch_statuses/v0/mod.rs
  • packages/rs-drive/src/drive/votes/emergency_switch/insert_emergency_switch_trees.rs
  • packages/rs-drive/src/drive/votes/emergency_switch/mod.rs
  • packages/rs-drive/src/drive/votes/emergency_switch/paths.rs
  • packages/rs-drive/src/drive/votes/emergency_switch/register_emergency_switch_flip/mod.rs
  • packages/rs-drive/src/drive/votes/emergency_switch/register_emergency_switch_flip/v0/mod.rs
  • packages/rs-drive/src/drive/votes/emergency_switch/remove_emergency_switch_flips_given_by_identities/mod.rs
  • packages/rs-drive/src/drive/votes/emergency_switch/remove_emergency_switch_flips_given_by_identities/v0/mod.rs
  • packages/rs-drive/src/drive/votes/emergency_switch/store_emergency_switch_status/mod.rs
  • packages/rs-drive/src/drive/votes/emergency_switch/store_emergency_switch_status/v0/mod.rs
  • packages/rs-drive/src/drive/votes/insert/register_identity_vote/mod.rs
  • packages/rs-drive/src/drive/votes/insert/register_identity_vote/v0/mod.rs
  • packages/rs-drive/src/drive/votes/insert/register_identity_vote/v2/mod.rs
  • packages/rs-drive/src/drive/votes/mod.rs
  • packages/rs-drive/src/drive/votes/resolved/votes/mod.rs
  • packages/rs-drive/src/drive/votes/resolved/votes/resolve.rs
  • packages/rs-drive/src/drive/votes/resolved/votes/resolved_emergency_switch_vote/mod.rs
  • packages/rs-drive/src/drive/votes/structure.rs
  • packages/rs-drive/src/prove/prove_state_transition/v0/mod.rs
  • packages/rs-drive/src/query/emergency_switch_query.rs
  • packages/rs-drive/src/query/mod.rs
  • packages/rs-drive/src/state_transition_action/action_convert_to_operations/identity/masternode_vote_transition.rs
  • packages/rs-drive/src/structure/tests.rs
  • packages/rs-drive/src/verify/bounded_decode.rs
  • packages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs
  • packages/rs-drive/src/verify/voting/mod.rs
  • packages/rs-drive/src/verify/voting/verify_emergency_switch_flips_proof/mod.rs
  • packages/rs-drive/src/verify/voting/verify_emergency_switch_flips_proof/v0/mod.rs
  • packages/rs-drive/src/verify/voting/verify_emergency_switch_statuses_proof/mod.rs
  • packages/rs-drive/src/verify/voting/verify_emergency_switch_statuses_proof/v0/mod.rs
  • packages/rs-drive/src/verify/voting/verify_masternode_emergency_switch_vote/mod.rs
  • packages/rs-drive/src/verify/voting/verify_masternode_emergency_switch_vote/v0/mod.rs
  • packages/rs-drive/src/verify/voting/verify_masternode_vote/mod.rs
  • packages/rs-platform-version/src/version/dpp_versions/dpp_voting_versions/mod.rs
  • packages/rs-platform-version/src/version/dpp_versions/dpp_voting_versions/v1.rs
  • packages/rs-platform-version/src/version/dpp_versions/dpp_voting_versions/v2.rs
  • packages/rs-platform-version/src/version/dpp_versions/dpp_voting_versions/v4.rs
  • 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/v1.rs
  • packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_method_versions/v10.rs
  • packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_method_versions/v12.rs
  • packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_method_versions/v2.rs
  • packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_method_versions/v3.rs
  • packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_method_versions/v4.rs
  • packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_method_versions/v5.rs
  • packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_method_versions/v6.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/drive_abci_versions/drive_abci_method_versions/v9.rs
  • packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_query_versions/mod.rs
  • packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_query_versions/v0.rs
  • packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_query_versions/v1.rs
  • packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/mod.rs
  • packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v1.rs
  • packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v10.rs
  • packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v12.rs
  • packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v2.rs
  • packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v3.rs
  • packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v4.rs
  • packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v5.rs
  • packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v6.rs
  • packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v7.rs
  • packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v8.rs
  • packages/rs-platform-version/src/version/drive_abci_versions/drive_abci_validation_versions/v9.rs
  • packages/rs-platform-version/src/version/drive_versions/drive_verify_method_versions/mod.rs
  • packages/rs-platform-version/src/version/drive_versions/drive_verify_method_versions/v1.rs
  • packages/rs-platform-version/src/version/drive_versions/drive_verify_method_versions/v5.rs
  • packages/rs-platform-version/src/version/drive_versions/drive_vote_method_versions/mod.rs
  • packages/rs-platform-version/src/version/drive_versions/drive_vote_method_versions/v1.rs
  • packages/rs-platform-version/src/version/drive_versions/drive_vote_method_versions/v2.rs
  • packages/rs-platform-version/src/version/drive_versions/drive_vote_method_versions/v3.rs
  • packages/rs-platform-version/src/version/drive_versions/drive_vote_method_versions/v5.rs
  • packages/rs-platform-version/src/version/drive_versions/v11.rs
  • packages/rs-platform-version/src/version/feature_initial_protocol_versions.rs
  • packages/rs-platform-version/src/version/mocks/v2_test.rs
  • packages/rs-platform-version/src/version/mocks/v3_test.rs
  • packages/rs-platform-version/src/version/system_limits/mod.rs
  • packages/rs-platform-version/src/version/system_limits/v1.rs
  • packages/rs-platform-version/src/version/system_limits/v2.rs
  • packages/rs-platform-version/src/version/system_limits/v3.rs
  • packages/rs-platform-version/src/version/system_limits/v4.rs
  • packages/rs-platform-version/src/version/v16.rs
  • packages/rs-sdk-ffi/src/emergency_switch/json.rs
  • packages/rs-sdk-ffi/src/emergency_switch/mod.rs
  • packages/rs-sdk-ffi/src/emergency_switch/queries.rs
  • packages/rs-sdk-ffi/src/emergency_switch/transitions.rs
  • packages/rs-sdk-ffi/src/lib.rs
  • packages/rs-sdk/src/mock/requests.rs
  • packages/rs-sdk/src/mock/sdk.rs
  • packages/rs-sdk/src/platform.rs
  • packages/rs-sdk/src/platform/emergency_switches.rs
  • packages/rs-sdk/src/platform/query.rs
  • packages/rs-sdk/src/platform/transition/vote.rs
  • packages/rs-unified-sdk-jni/src/emergency_switches.rs
  • packages/rs-unified-sdk-jni/src/lib.rs
  • packages/swift-sdk/Sources/SwiftDashSDK/Voting/EmergencySwitch.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Voting/SDK+EmergencySwitches.swift
  • packages/swift-sdk/SwiftTests/SwiftDashSDKTests/EmergencySwitchDecodingTests.swift
  • packages/wasm-dpp/src/errors/consensus/consensus_error.rs
  • packages/wasm-dpp/src/voting/state_transition/masternode_vote_transition/mod.rs
  • packages/wasm-dpp2/src/voting/vote.rs
  • packages/wasm-sdk/src/emergency_switches.rs
  • packages/wasm-sdk/src/lib.rs

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

  • 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

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

🌳 GroveDB structure

This pull request changes the described GroveDB structure. Open it in the structure viewer: new nodes glow, removed ones stay as ghosts, and the tour walks through each change.

Added (5 nodes)

  • votes.emergency_switches

Changed (1 node)

  • votes

Compared 46c3ca8985 with f2b53c4a5e. Updated at 2026-11-30T08:28:53.489Z

@github-actions

github-actions Bot commented Nov 30, 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-30T08:29:25.342Z

@github-actions

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 f2b53c4) · 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

This change adds protocol-16 emergency switches across consensus validation, Drive storage and proofs, DAPI, SDKs, and mobile/WASM bindings. No code checks are failing in the available CI snapshot; the Kotlin build, NPM validation, changed-package detection, and PR Hygiene checks are still pending.

🟡 7 suggestion(s) | 💬 2 nitpick(s)

Approved: nothing here blocks the merge. The non-blocking findings are optional: fix them forward, in this PR or a follow-up, without waiting for another review round.

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

🟡 Suggestion: The transition-level balance gate still treats free emergency votes as paid
Impact: Any internal caller that invokes the masternode-vote balance validation directly for an emergency-switch vote receives a CorruptedCodeExecution error instead of the free-vote path.
packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/balance/mod.rs:48-50

The state-transition implementation correctly returns false for Vote::EmergencySwitchVote, but the MasternodeVoteTransition implementation returns true unconditionally. Its balance validator then calls specialized_balance_id(), which returns None for the free vote and is converted into a CorruptedCodeExecution error. The current production processor reaches the state-transition gate first, so this is not currently observable on the main path, but the two trait implementations disagree and future estimation, tooling, or tests can hit the failing path. Mirror the emergency-vote exemption in the transition-level method as well.

source: muse-spark-1.3-contributor (phase1-reviewer: general, rust-quality)

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: ffi-engineer); reviewer 4: gpt-6.2-astra (agent: phase2-reviewer, role: platform-versioning); 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: general); reviewer 8: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 9: gpt-6.2-astra (agent: phase2-reviewer, role: tenderdash-consensus-security); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.2-sol (effort low) — This large, cross-cutting diff changes consensus-critical emergency-switch rules, signature-backed voting and key gating, withdrawal/funds movement behavior, peer-facing serialization and persisted Drive state in files such as packages/rs-dpp/src/voting/emergency_switch/mod.rs, packages/rs-drive-abci/src/execution/platform_events/voting/evaluate_emergency_switches/v0/mod.rs, and packages/rs-drive/
  • 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, gpt-6.2-astra — tenderdash-consensus-security (completed, effort high); 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/state_transitions/masternode_vote/balance/mod.rs`:
- [SUGGESTION] packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/balance/mod.rs:48-50: The transition-level balance gate still treats free emergency votes as paid
  Impact: Any internal caller that invokes the masternode-vote balance validation directly for an emergency-switch vote receives a CorruptedCodeExecution error instead of the free-vote path.
  The state-transition implementation correctly returns false for `Vote::EmergencySwitchVote`, but the `MasternodeVoteTransition` implementation returns true unconditionally. Its balance validator then calls `specialized_balance_id()`, which returns `None` for the free vote and is converted into a CorruptedCodeExecution error. The current production processor reaches the state-transition gate first, so this is not currently observable on the main path, but the two trait implementations disagree and future estimation, tooling, or tests can hit the failing path. Mirror the emergency-vote exemption in the transition-level method as well.

In `packages/rs-drive-abci/src/execution/validation/state_transition/check_tx_verification/v0/mod.rs`:
- [SUGGESTION] packages/rs-drive-abci/src/execution/validation/state_transition/check_tx_verification/v0/mod.rs:542-552: Recheck keeps transactions signed with a paused key type in the mempool
  Impact: When a key-type switch is activated, mempools retain already-admitted transactions using that key type, causing proposers and validators to repeatedly process and strip them instead of evicting them during recheck.
  First-time check-tx loads the signing identity and applies the key-type emergency gate, but recheck deliberately passes `None` because it verifies no signature and loads no signing key. Consequently, `KeyTypeEcdsaSecp256k1` and the other signing-key switches are not checked during recheck. Block execution remains safe because it refuses the transition unpaid, but a large pre-existing mempool can repeatedly include these transactions during the emergency. Cache the signing key type or key id at admission and use it during recheck so key-type-gated transactions are evicted promptly.
- [SUGGESTION] packages/rs-drive-abci/src/execution/validation/state_transition/check_tx_verification/v0/mod.rs:245-252: Check-tx continues refusing transitions for one block after a pause expires
  Impact: Users submitting a gated transition immediately after the pause end can receive a mempool refusal even though the next block would accept the same transition.
  The check-tx path evaluates emergency-switch status using `platform.state.last_block_info().time_ms`, while block validation evaluates it using the candidate block's own `block_info.time_ms`. The status is also the last committed status, so after a pause expires between commits, check-tx remains fail-closed until the next block advances the committed state. This does not create a consensus split, but it causes a short liveness dip after every pause. Document the intentional one-block admission lag or use a fresher admission-time reference where available.

In `packages/wasm-sdk/src/emergency_switches.rs`:
- [NITPICK] packages/wasm-sdk/src/emergency_switches.rs:228-234: WASM flip paging does not document the required proTxHash byte orientation
  Impact: WASM users paging flips or combining a paging result with voting APIs can supply a differently oriented 32-byte hash and retrieve the wrong page or fail to address the intended evonode.
  The voting option documents that `masternodeProTxHash` is in ProTxHash order, but `startAfterProTxHash` is documented only as the last pro tx hash. The FFI, Swift, and Kotlin APIs explicitly describe their wire-order/display-order conversion, while the WASM paging comment does not. State the expected orientation for both WASM hash parameters and clarify how `Identifier` display parsing maps to it.

In `packages/rs-dpp/src/voting/emergency_switch/status/v0/mod.rs`:
- [SUGGESTION] packages/rs-dpp/src/voting/emergency_switch/status/v0/mod.rs:80-100: Pause-tier counters silently wrap if a future tier table exceeds 255 entries
  Impact: A future protocol configuration with more than 255 pause tiers would store an incorrect `pause_tiers_fired` value and could cause tiers to be revisited or skipped.
  Both `tiers.len() as u8` and `index as u8 + 1` rely on narrowing casts. The current `SystemLimits` table has three tiers, so these casts are inert today, but a future expansion can silently truncate rather than fail deterministically. Use checked `u8` conversions for both assignments and return a protocol error if the configured tier count cannot be represented.

In `packages/rs-sdk/src/platform/emergency_switches.rs`:
- [SUGGESTION] packages/rs-sdk/src/platform/emergency_switches.rs:29-32: The flips query fails against nodes configured with a lower default query limit
  Impact: An SDK user querying a node whose `default_query_limit` is below 100 receives an invalid-argument error for every flips fetch that omits an explicit limit.
  The SDK always writes `DEFAULT_EMERGENCY_SWITCH_FLIPS_LIMIT` as 100 because proof verification needs the actual limit in the request. The node independently rejects any limit greater than its operator-configured `default_query_limit`, so lowering that setting makes the SDK's ordinary flips query fail rather than return a page. Align the client and node limit contract where possible, or detect this invalid-argument response and expose a clear limit-mismatch error with a way to request a supported page size.

In `packages/rs-sdk-ffi/src/emergency_switch/mod.rs`:
- [NITPICK] packages/rs-sdk-ffi/src/emergency_switch/mod.rs:45-51: Every FFI switch lookup allocates and parses JSON for a fixed name set
  Impact: Each emergency-switch read or vote performs an avoidable string allocation and serde dispatch despite accepting only seven fixed camelCase names.
  The FFI already has the borrowed C string from `required_str`, but converts it to an owned `String`, wraps it in a JSON value, and deserializes it to select one of seven enum variants. A direct match makes the accepted names visible at the FFI boundary and avoids the extra allocation and serde work while preserving the same invalid-parameter behavior.

In `packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/transform_into_action/v2/mod.rs`:
- [SUGGESTION] packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/masternode_vote/transform_into_action/v2/mod.rs:111-123: Flip validation exposes consensus refusals through a nested Result type
  Impact: Future callers can mishandle a consensus refusal as an internal failure, or vice versa, because the function requires separate handling of two error layers.
  `previous_emergency_switch_flip_changes` returns `Result<Result<u16, ConsensusError>, Error>`, whereas neighboring validation helpers use a single `ConsensusValidationResult` to distinguish consensus-invalid input from internal errors. The current caller handles the nested result correctly, but every future caller must remember to map the inner error explicitly. Return the established validation-result type directly so the distinction is enforced by the API.

In `packages/rs-drive-abci/src/query/voting/emergency_switch_flips/v0/mod.rs`:
- [SUGGESTION] packages/rs-drive-abci/src/query/voting/emergency_switch_flips/v0/mod.rs:33-40: Nodes can accept flip queries for switch IDs inactive at the negotiated protocol version
  Impact: A node binary that knows a future switch but is running an older protocol version can accept that switch ID and return an empty result or proof instead of rejecting the request as inactive.
  The query validates `switch_id` only with `EmergencySwitch::from_storage_key`, which checks the enum values known to the binary but not whether the decoded switch is present in `EmergencySwitch::existing(platform_version)`. The same version-blind conversion exists in the proof verifier, and the SDK vote builder only checks that the protocol is at least 16. Once a later protocol adds a switch to the enum, a v16 node built with that later binary can expose the future ID through the query and proof surfaces, while a vote for it is rejected only after broadcast. Validate the decoded switch against the active protocol version at the DAPI and proof-verifier boundaries, and reject inactive switches when constructing SDK votes.

@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
…o the protocol version

Review fixes: a recheck reads the signing key while a switch refuses something, the flips query, its proof verifier and the SDK vote builder refuse a switch the protocol version does not have, tier counts use checked conversions, the flip validation returns a validation result, and the WASM docs state the pro tx hash order.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@github-actions

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 30, 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 2 only (queue backlog)

New on this head: This head adds protocol-version checks for emergency-switch queries and votes, hardens pause-tier counters, documents hash ordering and check-tx timing, and updates mempool recheck handling for newly gated key types. CI has no reported failed code checks; build and test checks are still queued or in progress.

🟡 1 suggestion(s)

Approved: nothing here blocks the merge. The non-blocking findings are optional: fix them forward, in this PR or a follow-up, without waiting for another review round.

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: ffi-engineer); reviewer 4: gpt-6.2-astra (agent: phase2-reviewer, role: platform-versioning); 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: gpt-6.2-astra (agent: phase2-reviewer, role: tenderdash-consensus-security); 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 diff that changes consensus-critical emergency-switch evaluation and state-transition validation in rs-drive-abci, cryptographic vote/key handling, peer-facing gRPC serialization, withdrawal processing, and persisted Drive state.
  • Phase 1 reviewers: not run (skipped for throughput: 12 PRs queued, above the 10 limit)
  • 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, gpt-6.2-astra — tenderdash-consensus-security (completed, effort high); 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/emergency_switches.rs`:
- [SUGGESTION] packages/rs-drive-abci/src/execution/validation/state_transition/processor/traits/emergency_switches.rs:140-158: Every active emergency pause makes identity-signed mempool rechecks read GroveDB
  Impact: While a non-key switch such as withdrawals or platform-address spends is paused, every retained identity-signed transaction incurs an unnecessary identity-key lookup on each mempool recheck.
  The recheck path performs a GroveDB lookup whenever any emergency switch blocks something, even when the active switch cannot depend on the transition's identity key type. `something_is_refused` is computed from all active statuses before checking whether a key-type switch is involved, so a `StopTransfersToCore` or `PlatformAddressSpends` pause causes ordinary identity-signed transactions to call `fetch_identity_keys_as_partial_identity` individually. Tenderdash rechecks retained transactions after blocks, multiplying these reads during an emergency when recheck latency is already important. Restrict the lookup to the presence of a currently blocking identity-key-type switch, while still running normal emergency-switch validation for non-key switches.

@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
…e switch refuses

A recheck read the signing key from storage whenever any emergency switch
refused something. Only the switch of a key type depends on that key, so a
pause of withdrawals or of platform address spends made every identity-signed
transaction in the mempool cost one more read per recheck for nothing. The
read now happens only while the switch of some key type refuses.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@github-actions

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 30, 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

New on this head: The incremental commit narrows mempool recheck identity lookups to active key-type emergency switches, avoiding reads for withdrawal and platform-address pauses while preserving the existing gate validation. No completed code check has failed at this head, but runner generation and contract/build checks remain queued or in progress.

🟡 1 suggestion(s)

Approved: nothing here blocks the merge. The non-blocking findings are optional: fix them forward, in this PR or a follow-up, without waiting for another review round.

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.2-astra (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.2-astra (agent: phase2-reviewer, role: architecture-layering); 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); reviewer 9: gpt-6.2-astra (agent: phase2-reviewer, role: tenderdash-consensus-security); 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 consensus change that modifies emergency-switch voting, state-transition validation, block finalization, withdrawals, identity key handling, cryptographic signatures, peer-facing serialization, and persisted Drive state.
  • 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, gpt-6.2-astra — tenderdash-consensus-security (completed, effort high); 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/emergency_switches.rs`:
- [SUGGESTION] packages/rs-drive-abci/src/execution/validation/state_transition/processor/traits/emergency_switches.rs:144-150: Emergency-switch votes still trigger identity reads during a key-type pause
  Impact: While any identity key-type switch is blocking, every recheck of an emergency-switch vote performs an unnecessary GroveDB signing-key lookup even though the vote is explicitly exempt and will be accepted.
  Emergency-switch votes can still incur a storage read on every mempool recheck during a key-type pause, adding avoidable work to the voting path needed to escalate or resolve an emergency. This predicate causes the lookup for every identity-signed transition whenever a key-type status blocks; only afterward does `validate_emergency_switches` call `StateTransition::gating_emergency_switches`, whose `EmergencySwitchVote` arm returns an empty set. Expose an owner-level indication that a transition can be gated by its signing key type, or otherwise avoid loading the key for exempt vote transitions without duplicating the complete gating rule in `rs-drive-abci`.

@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
…gency switch

No emergency switch gates a vote on a switch, but while a key type switch
refused, a recheck still read the vote's signing key before finding that out.
The exemption is now one function in rs-dpp,
`StateTransition::is_exempt_from_emergency_switches`, which
`gating_emergency_switches` uses and the recheck asks before it reads.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@github-actions

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 30, 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

New on this head: The final incremental commit centralizes the emergency-switch-vote exemption in rs-dpp and uses it before mempool recheck signing-key lookup, with targeted coverage for switch votes and ordinary votes. The CI snapshot shows no failed code checks; several build, generation, policy, and hygiene checks remain queued or in progress.

🔴 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.2-astra (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.2-astra (agent: phase2-reviewer, role: architecture-layering); 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); reviewer 9: gpt-6.2-astra (agent: phase2-reviewer, role: tenderdash-consensus-security); 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 directly modifies consensus rules, signature/key handling, peer-facing serialization, state transitions, and persisted Drive state across rs-dpp, rs-drive, 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.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, gpt-6.2-astra — tenderdash-consensus-security (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 30, 2026

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

agree with the idea

@QuantumExplorer
QuantumExplorer merged commit 58d2566 into v5.2-dev Nov 30, 2026
69 of 71 checks passed
@QuantumExplorer
QuantumExplorer deleted the feat/emergency-switches branch November 30, 2026 14:25
QuantumExplorer added a commit that referenced this pull request Nov 30, 2026
…dsa-65-keys

v5.2-dev gained the emergency switches (#6395), which give every identity
key type its own switch, and EmergencySwitch::for_key_type matches on
KeyType without a wildcard so that a new key type must decide its switch.

This merge adds that switch for ML_DSA_65: EmergencySwitch::KeyTypeMlDsa65,
id 7, appended to the switches of protocol version 16. It gates a state
transition signed with an ML_DSA_65 identity key and one adding such a key,
through the same code as the other key types. A switch nobody has voted on
stores nothing, so no state changes.

Conflicts: the feature_initial_protocol_versions import in
state_transition/mod.rs (both names kept) and the notes of v16.rs (the
emergency switches stay note 2, which the table comments cite; ML_DSA_65
keys become note 3).

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.

3 participants