fix(rs-sdk-ffi): don't export ContestedResourceVoteChoiceFFI to the C header#3892
Conversation
… header PR #3883 force-exported the `#[repr(u8)]` `ContestedResourceVoteChoiceFFI` enum to the generated C header via the cbindgen `[export] include` list. With `cpp_compat = true`, cbindgen emits such an enum twice — once as `enum ContestedResourceVoteChoiceFFI { ... }` and once as `typedef uint8_t ContestedResourceVoteChoiceFFI;` (under `#ifndef __cplusplus`). When Swift imports the header the name is ambiguous, so `ContestVoteState.swift`'s `var ffiTag: ContestedResourceVoteChoiceFFI` failed to compile ("'ContestedResourceVoteChoiceFFI' is ambiguous for type lookup in this context"), breaking both the SwiftDashSDK target and any SwiftExampleApp build. It was latent because the committed xcframework predated #3883 and hadn't been rebuilt. The enum is not used in any FFI signature — `dash_sdk_contested_resource_cast_vote` takes a plain `u8` — and the Swift side already hardcodes 0/1/2, so the "header source of truth" never paid off while it broke the build. Fix, matching the existing `TokenConfigChange.ffiTag` precedent: - Remove the enum from cbindgen's `[export] include` so neither the enum nor the typedef is emitted; it stays a Rust-internal source of truth still used by `cast_vote_inner`. - Change `ContestVoteState.ffiTag` to return a plain `UInt8` (0/1/2), transparent at the call site which feeds the `u8` FFI param. - Update the now-stale doc comments in both files. Verified with `cd packages/swift-sdk && ./build_ios.sh --target sim` → ** BUILD SUCCEEDED ** (compiles with -warnings-as-errors), and the regenerated header no longer contains the enum or typedef. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Warning Review limit reached
More reviews will be available in 27 minutes and 54 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 We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. 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 (3)
✨ 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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## v3.1-dev #3892 +/- ##
=============================================
- Coverage 87.22% 71.20% -16.03%
=============================================
Files 2641 20 -2621
Lines 328569 2837 -325732
=============================================
- Hits 286597 2020 -284577
+ Misses 41972 817 -41155
🚀 New features to boost your workflow:
|
Issue being fixed or feature implemented
Rebuilding the iOS xcframework from this branch (
packages/swift-sdk/build_ios.sh --target sim) produced anrs-sdk-ffi.hin which cbindgen emittedContestedResourceVoteChoiceFFItwice: once asenum ContestedResourceVoteChoiceFFI { ... }and once astypedef uint8_t ContestedResourceVoteChoiceFFI;(under#ifndef __cplusplus, an artifact ofcpp_compat = true). When the Swift SDK imports the header the name is ambiguous, soContestVoteState.swift'svar ffiTag: ContestedResourceVoteChoiceFFIfails to compile:This blocks both the
SwiftDashSDKtarget and anySwiftExampleAppbuild from this branch.It was introduced by #3883 (
feat(rs-sdk-ffi): add masternode contested-resource vote broadcast), which force-exported the enum to the header via cbindgen's[export] includelist. It stayed latent because the committed xcframework predated #3883 and hadn't been rebuilt.The enum is not used in any FFI signature —
dash_sdk_contested_resource_cast_votetakes a plainu8(vote_choice) — and the Swift side already hardcoded0/1/2, so the intended "single source of truth in the header" never actually paid off while it broke the build.What was done?
Removed the header export and aligned the Swift bridge with the existing
TokenConfigChange.ffiTagprecedent (a sibling enum that maps to a plainu8FFI param the same way):packages/rs-sdk-ffi/cbindgen.toml— dropped"ContestedResourceVoteChoiceFFI"from[export] include. It was only emitted because it was force-listed there; nothing references it in a signature, so cbindgen now emits neither the enum nor the typedef. The enum stays in Rust as the internal source of truth, still used bycast_vote_inner(... as u8).packages/swift-sdk/.../ContestVoteState.swift— changedffiTagfromContestedResourceVoteChoiceFFIto a plainUInt8(returning0/1/2), matchingTokenConfigChange.ffiTag. Transparent at the call site, which feeds the value straight into theu8FFI param.cast_vote.rsandContestVoteState.swift.How Has This Been Tested?
cargo fmt --all— no changes.cargo check -p rs-sdk-ffi— clean, no warnings (the enum is still referenced internally, so it is not flagged unused).cd packages/swift-sdk && ./build_ios.sh --target sim—** BUILD SUCCEEDED **(compiles Swift with-warnings-as-errors).rs-sdk-ffi.hno longer contains theenumdeclaration or thetypedef uint8_tforContestedResourceVoteChoiceFFI(only a prose doc-comment mention remains, which cannot cause type-lookup ambiguity).Breaking Changes
None in the consensus sense. This removes a brand-new (#3883, unreleased) symbol from the generated C header that was never usable from Swift anyway and is not part of any FFI function signature.
Checklist:
For repository code-owners and collaborators only