Skip to content

fix(rs-sdk-ffi): don't export ContestedResourceVoteChoiceFFI to the C header#3892

Merged
QuantumExplorer merged 1 commit into
v3.1-devfrom
claude/friendly-swirles-b9eb8e
Jun 14, 2026
Merged

fix(rs-sdk-ffi): don't export ContestedResourceVoteChoiceFFI to the C header#3892
QuantumExplorer merged 1 commit into
v3.1-devfrom
claude/friendly-swirles-b9eb8e

Conversation

@QuantumExplorer

Copy link
Copy Markdown
Member

Issue being fixed or feature implemented

Rebuilding the iOS xcframework from this branch (packages/swift-sdk/build_ios.sh --target sim) produced an rs-sdk-ffi.h in which cbindgen emitted ContestedResourceVoteChoiceFFI twice: once as enum ContestedResourceVoteChoiceFFI { ... } and once as typedef uint8_t ContestedResourceVoteChoiceFFI; (under #ifndef __cplusplus, an artifact of cpp_compat = true). When the Swift SDK imports the header the name is ambiguous, so ContestVoteState.swift's var ffiTag: ContestedResourceVoteChoiceFFI fails to compile:

error: 'ContestedResourceVoteChoiceFFI' is ambiguous for type lookup in this context

This blocks both the SwiftDashSDK target and any SwiftExampleApp build 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] include list. It stayed latent because the committed xcframework predated #3883 and hadn't been rebuilt.

The enum is not used in any FFI signaturedash_sdk_contested_resource_cast_vote takes a plain u8 (vote_choice) — and the Swift side already hardcoded 0/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.ffiTag precedent (a sibling enum that maps to a plain u8 FFI 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 by cast_vote_inner (... as u8).
  • packages/swift-sdk/.../ContestVoteState.swift — changed ffiTag from ContestedResourceVoteChoiceFFI to a plain UInt8 (returning 0/1/2), matching TokenConfigChange.ffiTag. Transparent at the call site, which feeds the value straight into the u8 FFI param.
  • Updated the now-stale doc comments in both cast_vote.rs and ContestVoteState.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).
  • Verified the regenerated rs-sdk-ffi.h no longer contains the enum declaration or the typedef uint8_t for ContestedResourceVoteChoiceFFI (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:

  • 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

… 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>
@coderabbitai

coderabbitai Bot commented Jun 14, 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 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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: aef44dc0-1c50-48d9-ab5d-d61f534c3fbd

📥 Commits

Reviewing files that changed from the base of the PR and between defc1d5 and 7041502.

📒 Files selected for processing (3)
  • packages/rs-sdk-ffi/cbindgen.toml
  • packages/rs-sdk-ffi/src/contested_resource/transitions/cast_vote.rs
  • packages/swift-sdk/Sources/SwiftDashSDK/PlatformWallet/ContestVoteState.swift
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/friendly-swirles-b9eb8e

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.

@codecov

codecov Bot commented Jun 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.20%. Comparing base (65042eb) to head (7041502).
⚠️ Report is 14 commits behind head on v3.1-dev.

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     
Components Coverage Δ
dpp ∅ <ø> (∅)
drive ∅ <ø> (∅)
drive-abci ∅ <ø> (∅)
sdk ∅ <ø> (∅)
dapi-client ∅ <ø> (∅)
platform-version ∅ <ø> (∅)
platform-value ∅ <ø> (∅)
platform-wallet ∅ <ø> (∅)
drive-proof-verifier ∅ <ø> (∅)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

1 participant