-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Improve storage_alias
and make UnlockAndUnreserveAllFunds
independent of the pallet
#14773
Improve storage_alias
and make UnlockAndUnreserveAllFunds
independent of the pallet
#14773
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some nits
/// | ||
/// If generics are passed, this is assumed to be a pallet and the pallet name should be used. | ||
/// Otherwise use the verbatim passed name as prefix. | ||
Backwards, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Legacy
or Compatibility
? Otherwise it sounds like it interprets something backwards.
|
||
#[docify::export] | ||
#[test] | ||
fn storage_alias_guess() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe one test that the backwards compatibility works?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
found a bunch of minor grammar/wording nits. Might need to re-wrap a few of the doc paragraphs if you accept them
frame/democracy/src/migrations/unlock_and_unreserve_all_funds.rs
Outdated
Show resolved
Hide resolved
frame/democracy/src/migrations/unlock_and_unreserve_all_funds.rs
Outdated
Show resolved
Hide resolved
frame/democracy/src/migrations/unlock_and_unreserve_all_funds.rs
Outdated
Show resolved
Hide resolved
frame/democracy/src/migrations/unlock_and_unreserve_all_funds.rs
Outdated
Show resolved
Hide resolved
frame/democracy/src/migrations/unlock_and_unreserve_all_funds.rs
Outdated
Show resolved
Hide resolved
Co-authored-by: Sam Johnson <[email protected]>
bot fmt |
@bkchr https://gitlab.parity.io/parity/mirrors/substrate/-/jobs/3395811 was started for your command Comment |
@bkchr Command |
bot merge |
Waiting for commit status. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect, thank you!
I have implemented and tested this on my Gov V1 unlock PR (commit with changes:
paritytech/polkadot@5e440c1) and it works great.
Additional benefit: we can wipe the pallet storage in the same migration we unlock the funds.
storage_alias
and make UnlockAndUnreserveAllFunds
indepenend of the palletstorage_alias
and make UnlockAndUnreserveAllFunds
independent of the pallet
…dent of the pallet (#14773) * Make `storage_alias` more generic over the `prefix` * Make `UnlockAndUnreserveAllFunds` indepenend from the pallet * FMT * Fix error reporting * Rename prefix type * Add test * Apply suggestions from code review Co-authored-by: Sam Johnson <[email protected]> * ".git/.scripts/commands/fmt/fmt.sh" --------- Co-authored-by: Sam Johnson <[email protected]> Co-authored-by: command-bot <>
This pull request is doing two things:
It improve
storage_alias
by making it more generic over the prefix to use. Currentlystorage_alias
tries to guess based on the generics if the user wants to use the pallet name or a fixed identifier as prefix. This pull requests changes the macro to take an additional attribute that tells it what prefix type the user wants. Besides that a third prefix type is added, a type that implementsGet<&'static str>
can also be provided as prefix. See the docs in the code for more information on how this works.pallet_democracy::UnlockAndUnreserveAllFunds
is made independent of the presence of thepallet-democracy
pallet. This means that the migration can be used without the pallet still being used in the runtime. The user only needs to implement theUnlockConfig
for some type that is then passed toUnlockAndUnreserveAllFunds
to forward certain information that are required by the migration.Besides this the pull request also puts some tests in
frame-support
into their own file to clean up thelib.rs
.