3

I want to rename one of our collective pallet instances to be visible in the PolkaddotJs App.

I think the best option would be to migrate raw data.

I assume that all pallet data has the same trie path prefix.

So I can do a copy of all keys with this prefix.

Will this approach work?

Rename could be a common operation. Could anybody refer relevant examples?

Another alternative is to have two pallets instances running, filter out calls to old pallet. Migrate each storage using typed interface. I think this approach is overkill. I need actually do this for 2 pallets.

2 Answers 2

2

I assume that all pallet data has the same trie path prefix.

Yes, this makes it much easier to migration.
There are move_pallet and move_storage_from_pallet which can help.

There is even a test in the collective pallet to test these functions here. Something like:

let old_pallet = "OldCollective";
let new_pallet = <Collective as PalletInfoAccess>::name();
frame_support::storage::migration::move_pallet(
    new_pallet.as_bytes(),
    old_pallet.as_bytes(),
);

Maybe someone else can point you to best-practices when it comes to renaming pallets.
The only thing that comes to my mind now is that: If you are doing this on a para-chain; it is important that the migration stays within the block weight limit. The try-runtime command prints the consumed weight relative to the block weight on completion so you can use that as indication but should still over-estimate.

2
  • 1
    AFAIK, there are only a few keys in the collective storage. I think the weight is totally fine. Dec 2, 2022 at 13:30
  • 1
    Yea but it all goes into the PoV - so if the maps hold a lot of values this will increase. Dec 2, 2022 at 13:33
2

This is a Substrate/Polkadot "official" pallet prefix migration example.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.