6

There are a few other questions related to this topic:

  1. removal of storage prefix

  2. clearing the storage

In terms of functions related to these actions, I found the following:

  1. remove_storage_prefix
  2. kill_storage
  3. kill_prefix

Also, I wanted to note that the overall goal is to upgrade from v2.0.1 to v3.0.

What would be the best way to remove an existing pallet from the storage? Do we have to kill_storage first, and then kill_prefix?

1
  • As the chain state goes larger and larger, it gets hard to export/fetch the chain state. Are there any other tools aside from fork-off-substrate and try-runtime for performing a runtime migration? runtime Aug 3, 2022 at 18:29

1 Answer 1

4

The behavior of how FRAME generates storage keys leads to the fact that all pallets have their storage under a shared prefix-trie:

enter image description here

All the storage keys are in the format:

hash(name) ++ hash(name) ++ hash(name) ++ ...

For example:

twox128(pallet_name) + twox128(storage_name) + ...

So if you call remove_storage_prefix or kill_prefix with the appropriate pallet prefix, you will remove all the storage for that pallet.

2
  • What if I use move_prefix (move a large pallet to a new prefix)? Is that an O(1) operation? Aug 4, 2022 at 9:06
  • 1
    No. None of these operations would be O(1). You need to remove or move all items in the database under this prefix, which will be O(n * log(n)). It is VERY expensive.
    – Shawn Tabrizi
    Aug 4, 2022 at 9:08

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.