36 major breaking releases

40.0.0 Sep 26, 2024
39.0.0 Jul 19, 2024
37.0.0 Jul 13, 2024
36.0.0 Jun 24, 2024
0.0.0 Nov 21, 2022

#51 in #pallet

Download history 932/week @ 2024-07-28 668/week @ 2024-08-04 1057/week @ 2024-08-11 1254/week @ 2024-08-18 877/week @ 2024-08-25 520/week @ 2024-09-01 917/week @ 2024-09-08 739/week @ 2024-09-15 1212/week @ 2024-09-22 1273/week @ 2024-09-29 1075/week @ 2024-10-06 1340/week @ 2024-10-13 1808/week @ 2024-10-20 1517/week @ 2024-10-27 1544/week @ 2024-11-03 19814/week @ 2024-11-10

24,811 downloads per month
Used in 24 crates (7 directly)

Apache-2.0 and maybe GPL-3.0-or-later…

3MB
45K SLoC

Release

Polkadot SDK stable2409


lib.rs:

Pallet State Trie Migration

Reads and writes all keys and values in the entire state in a systematic way. This is useful for upgrading a chain to sp-core::StateVersion::V1, where all keys need to be touched.

Migration Types

This pallet provides 2 ways to do this, each of which is suited for a particular use-case, and can be enabled independently.

Auto migration

This system will try and migrate all keys by continuously using on_initialize. It is only sensible for a relay chain or a solo chain, where going slightly over weight is not a problem. It can be configured so that the migration takes at most n items and tries to not go over x bytes, but the latter is not guaranteed.

For example, if a chain contains keys of 1 byte size, the on_initialize could read up to x - 1 bytes from n different keys, while the next key is suddenly :code:, and there is no way to bail out of this.

Signed migration

As a backup, the migration process can be set in motion via signed transactions that basically say in advance how many items and how many bytes they will consume, and pay for it as well. This can be a good safe alternative, if the former system is not desirable.

The (minor) caveat of this approach is that we cannot know in advance how many bytes reading a certain number of keys will incur. To overcome this, the runtime needs to configure this pallet with a SignedDepositPerItem. This is the per-item deposit that the origin of the signed migration transactions need to have in their account (on top of the normal fee) and if the size witness data that they claim is incorrect, this deposit is slashed.


Initially, this pallet does not contain any auto migration. They must be manually enabled by the ControlOrigin.

Dependencies

~18–66MB
~1M SLoC