fix(drive): wire v1 dispatcher for deduct_from_prefunded_specialized_balance#3510
fix(drive): wire v1 dispatcher for deduct_from_prefunded_specialized_balance#3510QuantumExplorer wants to merge 1 commit into
Conversation
…balance The top-level `Drive::deduct_from_prefunded_specialized_balance` dispatcher only matched version 0, but platform versions v3-v7 set the `deduct_from_prefunded_specialized_balance` feature version to 1, causing the helper to unconditionally return `UnknownVersionMismatch` on any v3+ platform. The helper currently has no production callers (the real state transition path goes through the `_operations` sibling, which already handles both v0 and v1), so this has not impacted consensus, but the helper is part of the public `Drive` API and is effectively dead on all recent platform versions. This adds a v1 impl mirroring v0 (v0's body is already version-agnostic, since version selection for the actual deduction logic happens inside the `_operations` dispatcher it delegates to) and wires the match arm. Also corrects the stale `known_versions: vec![0]` in the `_operations` dispatcher error arm to `vec![0, 1]`, since it has handled both versions since #2422. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe pull request adds version 1 support for the Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 GateCommit:
|
Codecov Report❌ Patch coverage is ❌ Your patch status has failed because the patch coverage (0.00%) is below the target coverage (50.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## v3.1-dev #3510 +/- ##
============================================
+ Coverage 85.30% 85.44% +0.13%
============================================
Files 2476 2477 +1
Lines 270705 272920 +2215
============================================
+ Hits 230938 233187 +2249
+ Misses 39767 39733 -34
🚀 New features to boost your workflow:
|
|
No, we removed the method instead |
Issue being fixed or feature implemented
The top-level `Drive::deduct_from_prefunded_specialized_balance` dispatcher in
`packages/rs-drive/src/drive/prefunded_specialized_balances/deduct_from_prefunded_specialized_balance/mod.rs` only matches
feature version `0`, but platform versions v3–v7 set
`DrivePrefundedSpecializedMethodVersions::deduct_from_prefunded_specialized_balance` to `1`
(see v3.rs:100, v4.rs:100, v5.rs:102, v6.rs:104, v7.rs:102). On any v3+ platform the helper
unconditionally returned:
```
Error::Drive(DriveError::UnknownVersionMismatch {
method: "deduct_from_prefunded_specialized_balance",
known_versions: vec![0],
received: 1,
})
```
Production impact
None observed. A grep of the workspace shows the helper has no production callers —
the real state-transition path is routed through
`deduct_from_prefunded_specialized_balance_operations` (from `util/batch/drive_op_batch/prefunded_specialized_balance.rs:56`),
which already handles both v0 and v1 and has been correct since #2422. However, the helper is
part of the public `Drive` API, so any external `rs-drive` consumer who did call it on v3+
would hit an `UnknownVersionMismatch` error.
Adjacent latent issue (not fixed here)
While investigating, I noticed the `_operations` dispatcher reads the wrong platform-version field:
```rust
// deduct_from_prefunded_specialized_balance_operations/mod.rs:41-45
match platform_version
.drive
.methods
.prefunded_specialized_balances
.deduct_from_prefunded_specialized_balance // <-- the top-level field, not _operations
```
Compare to the `add` sibling, which correctly reads `.add_prefunded_specialized_balance_operations`. This
misread is likely why v3+ bumped the top-level field to `1` rather than the `_operations` field —
it was the de facto control knob for `_operations` dispatch.
Fixing this properly requires swapping the `1` from the top-level to `_operations` across
v3–v7, which is consensus-adjacent (same observable `_operations` behavior — both read the
same value either way — but I did not want to bundle a platform-version edit into this PR).
Happy to open a follow-up if reviewers agree it should be cleaned up.
What was done?
is already version-agnostic: it delegates to `deduct_from_prefunded_specialized_balance_operations`,
which dispatches to `_operations_v0` / `_operations_v1` based on the platform version. So v1 just
collects those operations and applies the resulting grovedb batch.
has handled both versions since feat(platform)!: distribute prefunded specialized balances after vote #2422 and the error message was stale.
No platform-version files were touched, so there is no consensus risk.
How Has This Been Tested?
Did not add a unit test because the helper is not called from production or any existing test
harness; setting up a Drive fixture purely to round-trip the dispatcher would be out of proportion
to the fix. The match statement's compile-time coverage plus the existing `_operations` test
coverage (which the v0/v1 top-level bodies both delegate to) guard against regression.
Breaking Changes
None. This restores previously expected behavior of a public method that was broken on v3+ and
keeps behavior identical on v0–v2.
Checklist:
🤖 Generated with Claude Code
Summary by CodeRabbit