pallet-referenda: Migrate from Currency reserves to fungible holds #10701
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR migrates
pallet-referendafrom the deprecatedCurrencytrait with anonymous reserves to the modernfungibletraits with typed holds, bumping the storage version from v1 to v2. This is part of the umbrella task #226.Changes
Config Updates
CurrencywithNativeBalanceusing the new fungible traits:fungible::Inspectfungible::Mutatefungible::Balancedfungible::InspectHoldfungible::MutateHoldHoldReason::DecisionDepositcomposite enum for tracking deposit holds with a specific reasonStorage Migration (v1 → v2)
Added
MigrateV1ToV2<T, I, OldCurrency>migration that:ReservableCurrencytraitHoldReason::DecisionDepositusing the newMutateHoldtraitThe migration gracefully handles edge cases:
Killedreferenda (no deposits to migrate)try-runtimehooks for pre/post upgrade verificationRuntime Integration
To use this migration in your runtime:
Testing
Added comprehensive test coverage:
migration_v1_to_v2_works- Tests full migration flow with multiple referendum types (Ongoing, Approved, TimedOut)migration_v1_to_v2_skips_if_not_v1- Verifies migration is skipped when not on version 1migration_v1_to_v2_handles_killed_referendum- Tests handling of killed referenda with no depositsChecklist
Trequired)/cmd label <label-name>to add labels