Skip to content

fix(swift-sdk): seed testnet at the per-network protocol-version floor instead of pinning PV11#3944

Merged
QuantumExplorer merged 1 commit into
v3.1-devfrom
claude/fix-testnet-pv-floor
Jun 20, 2026
Merged

fix(swift-sdk): seed testnet at the per-network protocol-version floor instead of pinning PV11#3944
QuantumExplorer merged 1 commit into
v3.1-devfrom
claude/fix-testnet-pv-floor

Conversation

@QuantumExplorer

Copy link
Copy Markdown
Member

Issue being fixed or feature implemented

SDK.init(network:platformVersion:) in SwiftDashSDK hardcoded platformVersion = 11 for .mainnet/.testnet when the caller passed 0 (the default). That pinned the SDK via SdkBuilder::with_version(11), which disables auto-detect, so the SDK kept speaking the V0 getDocuments wire even though testnet has rolled forward to Platform v3.1 (protocol version 12).

The visible symptom: V1-only features — document sum/average aggregation (QA tests DOC-13/14, added in #3942) — were rejected client-side with:

SDK misconfigured: select=Sum requires Platform v3.1+ (V1 documents wire); pin/upgrade to a v3.1+ network

The 11 pin was a deliberate workaround (with a TODO(platform-version-bump)) from when the public networks were on pre-v3.1 drive-abci. Previously a construction-time floor clamp in rs-sdk (initial = self.version.protocol_version.max(min_protocol_version(network)), "applies to pinned and auto-detect SDKs alike") silently raised the sub-floor pin up to the network floor (testnet 12), so the app actually spoke V1. #3900 ("per-network protocol-version floor + version_pinned unification") changed the floor into a seed-only default for the unpinned case (its doc now reads "Not a runtime clamp"), so the stale 11 pin now sticks → V0 → V1 features break.

What was done?

In the platformVersion == 0 (default) path, stop mapping to a Swift-side per-network constant and pass 0 straight through to config.platform_version. The FFI apply_version(builder, 0) returns the builder unpinned, so rs-sdk seeds at the per-network min_protocol_version floor — mainnet 11, testnet/devnet/regtest 12 — with auto-detect on, and ratchets upward as the network reports newer versions. The network→version decision now lives entirely in rs-sdk.

A non-zero platformVersion still pins via with_version, unchanged.

Net effect:

  • testnet → PV12 (V1 wire) — sum/avg and other V1 features work, matching the live network.
  • mainnet → PV11 (V0 wire) — correct until mainnet upgrades, then auto-detect ratchets up on its own.

13 insertions / 28 deletions in one file (SDK.swift); the deleted block is the hardcoded switch network version map and its stale rationale comment.

How Has This Been Tested?

Rebuilt the iOS xcframework + app (./build_ios.sh --target sim --profile dev) and re-ran the SwiftExampleApp Sum / Average Documents view on testnet against a summable fixture contract (metric doc type, documentsSummable: "value", seeded values 10/20/40/50):

  • Before the change: both ops failed with the requires Platform v3.1+ (V1 documents wire) error.
  • After: sum = 120, average = 30.0000 — proof-verified, matching the seeded data (DOC-13/DOC-14 green).

Regular identity/contract/document reads continued to work on testnet after the change (the app is now on the V1 wire the live network expects).

Breaking Changes

None. No public API signature change — same initializer, different default-version resolution. Not consensus-affecting.

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have added "!" to the title and described breaking changes in the corresponding section if my code contains any
  • I have made corresponding changes to the documentation if needed

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

…r instead of pinning PV11

SDK.init(network:platformVersion:) hardcoded platformVersion 11 for
mainnet/testnet when the caller passed 0 (the default). That pinned the
SDK via SdkBuilder::with_version(11), disabling auto-detect, so the SDK
spoke the V0 getDocuments wire even after testnet rolled forward to
Platform v3.1 (PV12). V1-only features — document sum/average
aggregation — were then rejected client-side with "select=Sum requires
Platform v3.1+ (V1 documents wire)".

The 11 pin was a workaround from when the public networks were on
pre-v3.1 drive-abci. Previously a construction-time floor clamp in
rs-sdk silently raised the sub-floor pin to the network floor, but #3900
made the per-network floor a seed-only default (no longer a runtime
clamp), so the stale pin now sticks.

Pass platform_version=0 straight through instead of mapping it to a
Swift-side per-network constant. apply_version(builder, 0) leaves the
builder unpinned, so rs-sdk seeds at the per-network min_protocol_version
floor (mainnet 11, testnet/devnet/regtest 12) with auto-detect on and
ratchets upward as the network reports newer versions. The
network->version decision now lives entirely in rs-sdk. A non-zero
platformVersion still pins via with_version, unchanged.

Verified on testnet: document sum/average (DOC-13/14) now return
proof-verified results in SwiftExampleApp (sum 120, average 30 over a
summable fixture) where they previously failed with the V1-wire error.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@QuantumExplorer, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 6 minutes and 55 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9628170b-ea4a-42e5-9619-7d300b03d4ef

📥 Commits

Reviewing files that changed from the base of the PR and between fa1085c and af9568a.

📒 Files selected for processing (1)
  • packages/swift-sdk/Sources/SwiftDashSDK/SDK.swift
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/fix-testnet-pv-floor

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@thepastaclaw

thepastaclaw commented Jun 20, 2026

Copy link
Copy Markdown
Collaborator

✅ Review complete (commit af9568a)

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

Code Review

Narrow Swift SDK fix that drops a stale Swift-side network→protocol-version map and forwards platformVersion=0 to the FFI so rs-sdk seeds at the per-network min_protocol_version floor (mainnet 11, testnet/devnet/regtest 12) with auto-detect enabled, restoring V1-wire features on testnet. Both reviewers independently verified the FFI/rs-sdk semantics (apply_version(_,0) leaves the builder unpinned; non-zero still pins via with_version), found no in-scope issues, and the change is not consensus-affecting. No CodeRabbit findings.

@QuantumExplorer QuantumExplorer merged commit 0132742 into v3.1-dev Jun 20, 2026
16 checks passed
@QuantumExplorer QuantumExplorer deleted the claude/fix-testnet-pv-floor branch June 20, 2026 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants