Skip to content

fix(wallet): pin the protocol version per network instead of globally - #915

Merged
romchornyi merged 1 commit into
swift-sdk-integrationfrom
fix/bug-22-platform-version-pin-per-network
Aug 4, 2026
Merged

romchornyi merged 1 commit into
swift-sdk-integrationfrom
fix/bug-22-platform-version-pin-per-network

Conversation

@romchornyi

Copy link
Copy Markdown
Contributor

Issue being fixed or feature implemented

BUG-22. The Platform-address balance never populates on mainnet. The SDK logs, per sync cycle, retried across three separate nodes and then given up on:

ExecutionError { inner: Proof(DriveError { error:
  "proof: corrupted error: compacted address balance proof contains trailing bytes" }) }

Root cause: the SDK was built with platformVersion: 13 for every network. That value was picked for testnet — v13 changed the shielded identity-create exit denominations, and pinning it fixed contested username creation — but it was applied unconditionally.

Platform v13 (DRIVE_VERSION_V8) switches the compacted address-balance proof to the two-proof CompactedAddressBalanceProof bincode envelope, while "nodes and clients on v12 and below keep the legacy single GroveDB proof" (rs-platform-version version/v13.rs). The verifier dispatches on that same feature version (verify_compacted_address_balance_changes/mod.rs). So a pinned-v13 client decodes mainnet's legacy proof as the envelope, consumes the structure, and trips on what is left.

Measured on device with this change applied:

2026-08-03T22:25:23  dash_sdk::protocol_version:
    ratcheting protocol version upward from=11 to=12

Mainnet reports protocol version 12 — one below the format boundary. That confirms the mismatch directly rather than by inference.

Worth noting the hard pin was also suppressing this very diagnostic: refreshProtocolVersion() is documented as a no-op while pinned, so the client never ratcheted and never logged the network's real version.

What was done?

SwiftDashSDKHost now chooses the version per network:

static func platformVersion(for network: Network) -> UInt32 {
    network == .testnet ? 13 : 0
}
  • Testnet keeps the explicit 13, so the shielded-denomination fix and the ratchet-race avoidance it was introduced for are unchanged.
  • Mainnet passes 0 — what the SDK is designed for: it seeds at the per-network min_protocol_version floor (mainnet 11, testnet 12) with auto-detect on and ratchets up as the network reports newer versions, "so this picks the right wire without a Swift-side network→version map" (SDK.init(network:platformVersion:)).
  • Devnet follows mainnet's auto-detect; regtest is rejected by makeRuntime regardless.

The stage-1 log now reports which mode is in effect.

How Has This Been Tested?

xcodebuild … -scheme dashpay … ARCHS=arm64 build → BUILD SUCCEEDED.

Run on a mainnet device (iPhone 13 Pro, iOS 18.7.8), session covering both networks:

HOST :: stage 1/4 SDK created for 0, protocol auto-detect   ← mainnet
HOST :: stage 1/4 SDK created for 1, protocol pinned v13    ← testnet
dash_sdk::protocol_version: ratcheting protocol version upward from=11 to=12

Mainnet negotiated v12 and matched the network; testnet behaviour is untouched. No new errors — the Failed to find quorum: Quorum not found for type 4 warnings present in that run also appear on the older pinned build (2026-07-31 mainnet export), so they are pre-existing and unrelated.

Not yet exercised end-to-end: the compacted query itself did not run in that session. need_compacted is only true when the recent proof's last boundary is below the checkpoint height, or boundary extraction fails (rs-sdk/src/platform/address_sync/mod.rs:602-643); the recent tree was empty, so the path was skipped. To close that last step: Menu → Sync Info → Platform Sync → Clear, then Sync Now on mainnet, and confirm the compacted phase completes without the decode error.

Breaking Changes

None for testnet — the pin it depends on is preserved verbatim. Mainnet changes from a hard v13 to the SDK's intended auto-detect, which is what makes it interoperate.

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 made corresponding changes to the documentation

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

🤖 Generated with Claude Code

The SDK was built with `platformVersion: 13` for every network. That value was
chosen for testnet — v13 changed the shielded identity-create exit
denominations, and pinning it fixed contested username creation — but it was
applied unconditionally, which put the client two versions ahead of mainnet.

Platform v13 (`DRIVE_VERSION_V8`) switches the compacted address-balance proof
to the two-proof `CompactedAddressBalanceProof` bincode envelope, while "nodes
and clients on v12 and below keep the legacy single GroveDB proof"
(rs-platform-version `version/v13.rs`). The verifier dispatches on that same
feature version (`verify_compacted_address_balance_changes/mod.rs`), so a
pinned-v13 client decodes mainnet's legacy proof as the envelope, consumes the
structure and trips on what is left:

    proof: corrupted error: compacted address balance proof contains trailing bytes

A mainnet device logged that 20× across three separate nodes, retrying and then
giving up, while a testnet device on the same build was clean. The Platform
address balance never populates on mainnet as a result (BUG-22).

Mainnet now passes `0`, which is what the SDK is designed for: it seeds at the
per-network `min_protocol_version` floor (mainnet 11, testnet 12) with
auto-detect on and ratchets up as the network reports newer versions — "so this
picks the right wire without a Swift-side network→version map"
(`SDK.init(network:platformVersion:)`). The hard pin also disabled
`refreshProtocolVersion()`, documented as a no-op while pinned, so the client
had no way to learn the network's real version.

Testnet keeps the explicit 13, so the shielded-denomination fix and the
ratchet-race avoidance it was introduced for are unchanged. Devnet follows
mainnet's auto-detect; regtest is rejected by `makeRuntime` regardless.

Co-Authored-By: Claude Opus 5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 03c371fe-1667-476b-8607-abb0534530af

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

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

@romchornyi romchornyi changed the title fix(platform): pin the protocol version per network instead of globally fix(wallet): pin the protocol version per network instead of globally Aug 3, 2026
@romchornyi
romchornyi merged commit 24ecde5 into swift-sdk-integration Aug 4, 2026
2 checks passed
@romchornyi
romchornyi deleted the fix/bug-22-platform-version-pin-per-network branch August 4, 2026 06:18
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.

2 participants