Uh oh!
There was an error while loading. Please reload this page.
refactor(rs-sdk-ffi): use the rs-sdk voting-key helpers instead of its own - #4341
Conversation
…s own #4340 moved the masternode voting-key facts into rs-sdk, but nothing removed the FFI's copies — so the tree carried two implementations of the same Platform behaviour, free to drift. This finishes that move. Deleted from the FFI and taken from `platform::transition::masternode_vote_keys`: key fabrication, `select_voting_key`, the failure gate, and the diagnosis. Net −340 lines. What stays is what this layer actually owns: pointer/CStr marshalling, the byte-order conversion at the boundary (callers pass wire order; the SDK takes a typed `ProTxHash`), signer construction, and turning the SDK's typed `VotingKeyProblem` into the sentence a host displays. That last split is the point — rs-sdk reports the fact, the binding phrases it, so no caller inherits English from the SDK. Tests follow the code. Selection, the gate and the diagnosis are covered in rs-sdk (10 tests); what remains here covers only the message rendering, including that both messages name their identifiers and contain no whitespace runs — the defect that once rendered them with blank gaps on device. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe FFI now uses shared rs-sdk helpers to construct voting keys and diagnose typed voting-key failures after broadcast errors. Local identity fetching, key selection, and failure classification were removed. Tests validate diagnostic message formatting. ChangesVoting-key diagnosis
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Uh oh!
There was an error while loading. Please reload this page.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@## v4.2-dev #4341 +/- ##
============================================
- Coverage 87.79% 87.61% -0.18%
============================================
Files 2677 2704 +27 Lines 342371 345211 +2840 ============================================
+ Hits 300578 302473 +1895 - Misses 41793 42738 +945
🚀 New features to boost your workflow:
|
Completes the move #4340 started. That PR added the masternode voting-key facts to
rs-sdkbut did not removers-sdk-ffi's copies, sov4.2-devcurrently carries two implementations of the same Platform behaviour — free to drift, and exactly the duplication #4340 existed to end.What moves
Deleted from the FFI, now taken from
platform::transition::masternode_vote_keys:select_voting_keyis_voting_key_failure(the diagnosis gate)diagnose_voting_key_failureNet −340 lines.
What stays
The FFI keeps what it actually owns:
CStrmarshalling and null checksvoter_identity_idtakes a typedProTxHash, so the conversion happens once, here, where the FFI's contract is definedsimple-signeris an FFI dependency, deliberately not an SDK one)VotingKeyProbleminto a user-facing sentenceThat last split is the point: rs-sdk reports the typed fact, the binding phrases it. Formatting in the SDK would hand every caller English they cannot localise.
Tests
Tests follow the code. Selection, the gate and the diagnosis are covered by #4340's 10 tests in rs-sdk. What remains here covers only what remains here — that both messages name their identifiers, and that neither contains whitespace runs, which is the defect that once rendered them with blank gaps mid-sentence on device.
5 tests in the module, fmt and clippy clean.
Risk
Behaviour-preserving. The fabricated key, the gate's three signature variants, and the diagnosis logic are the same code, now called rather than copied — verified by the surviving message tests and by the fact that votes cast successfully on the merged stack.
🤖 Generated with Claude Code
Summary by CodeRabbit