fix(swift-sdk): seed testnet at the per-network protocol-version floor instead of pinning PV11#3944
Conversation
…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>
|
Warning Review limit reached
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 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 configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
|
✅ Review complete (commit af9568a) |
thepastaclaw
left a comment
There was a problem hiding this comment.
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.
Issue being fixed or feature implemented
SDK.init(network:platformVersion:)inSwiftDashSDKhardcodedplatformVersion = 11for.mainnet/.testnetwhen the caller passed0(the default). That pinned the SDK viaSdkBuilder::with_version(11), which disables auto-detect, so the SDK kept speaking the V0getDocumentswire 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:
The
11pin was a deliberate workaround (with aTODO(platform-version-bump)) from when the public networks were on pre-v3.1 drive-abci. Previously a construction-time floor clamp inrs-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 stale11pin 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 pass0straight through toconfig.platform_version. The FFIapply_version(builder, 0)returns the builder unpinned, sors-sdkseeds at the per-networkmin_protocol_versionfloor — 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 inrs-sdk.A non-zero
platformVersionstill pins viawith_version, unchanged.Net effect:
13 insertions / 28 deletions in one file (
SDK.swift); the deleted block is the hardcodedswitch networkversion 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 (metricdoc type,documentsSummable: "value", seeded values 10/20/40/50):requires Platform v3.1+ (V1 documents wire)error.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:
For repository code-owners and collaborators only