2

We started a chain using pallet_collator_selection and later forked it. Both the original and the forked pallet use the LastAuthoredBlock StorageItem. We did not execute a storage migration from the original to the forked pallet.

The storage docs state that a storage key is made up of the pallet name and the item name, implying that our forked pallet actually created its own storage key hash(forked_collator_selection)hash(LastAuthoredBlock) instead of reusing hash(pallet_collator_selection)hash(LastAuthoredBlock), rendering the latter unused memory.

Is there a way to free the memory of the old, now unreferenced hash(pallet_collator_selection)hash(LastAuthoredBlock) StorageItem on the live chain after the forked pallet has been deployed without migrating storage at the time?

Corollary question to: Reclaim used space of a removed StorageItem on a live chain

1 Answer 1

5

You can use remove_storage_prefix:

remove_storage_prefix("OldPalletNameInYourRuntime", "LastAuthoredBlock", &[]);

You need to place this into a runtime migration. The last parameter hash is empty here because you don't have a map here (the function is generic over storage items and maps).

Or you could also send a transaction to your chain kill_storage. Be aware that this call requires root. As argument you pass a vector with the only element being the raw key of the old storage item (hash(pallet_collator_selection)hash(LastAuthoredBlock)).

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.