Repository navigation
fix(wallet): pin the protocol version per network instead of globally - #915
Merged
romchornyi merged 1 commit intoAug 4, 2026
Merged
romchornyi merged 1 commit into
romchornyi merged 1 commit into
Conversation
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]>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
This was referenced Oct 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
Root cause: the SDK was built with
platformVersion: 13for 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-proofCompactedAddressBalanceProofbincode envelope, while "nodes and clients on v12 and below keep the legacy single GroveDB proof" (rs-platform-versionversion/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:
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?
SwiftDashSDKHostnow chooses the version per network:0— what the SDK is designed for: it seeds at the per-networkmin_protocol_versionfloor (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:)).makeRuntimeregardless.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:
Mainnet negotiated v12 and matched the network; testnet behaviour is untouched. No new errors — the
Failed to find quorum: Quorum not found for type 4warnings 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_compactedis 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:
For repository code-owners and collaborators only
🤖 Generated with Claude Code