5

I'm planning to reset a pallet. To do this, I've developed a migration process aimed at clearing all storage associated with the MyPallet key. Additionally, I've followed up by renaming the pallet. I'm seeking guidance to confirm whether this approach is the recommended method. Furthermore, I have some conceptual inquiries I'd like to address.

  • Can I keep the pallet's name while also maintaining its previous index?
  • On the topic of migration: I'm using clear_prefix. How can I calculate the "limit" value to ensure my migration doesn't exceed the maximum weight?

1 Answer 1

1

Check RemovePallet, is a utility struct used to remove all storage items associated with a specific pallet. See the code and an example of how to use it here: https://github.com/paritytech/polkadot-sdk/blob/master/substrate/frame/support/src/migrations.rs#L296

But important check the warning on the comments:

/// WARNING: `RemovePallet` has no guard rails preventing it from bricking the chain if the
/// operation of removing storage for the given pallet would exceed the block weight limit.
///
/// If your pallet has too many keys to be removed in a single block, it is advised to wait for
/// a multi-block scheduler currently under development which will allow for removal of storage
/// items (and performing other heavy migrations) over multiple blocks
/// (see <https://github.com/paritytech/substrate/issues/13690>).

This is what was used to remove the governance v1 pallets when it was migrated to OpenGov2, see the PR: migration: unlock/unreserve Gov v1 balances, remove Gov V1 pallets from polkadot runtime, and remove Gov V1 pallet key/values from storage

0

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.