paritytech / polkadot-sdk

The Parity Polkadot Blockchain SDK
https://polkadot.com/
1.92k stars 709 forks source link

[MBM] Expose migrating keys #6128

Open ggwpez opened 1 month ago

ggwpez commented 1 month ago

Multi Block Migrations can cause chain indexers and explorers to not be able to decode specific storage prefixes since their storage layout is changing. There is currently no way for the outside world to know what keys the runtime is migrating.

One way to achieve this would be to add a function to the SteppedMigration trait:

pub trait SteppedMigration {
    fn migrating_prefixes() -> impl IntoIterator<Item = Vec<u8>> {
    core::iter::empty()
    }
}

This will then be aggregated into the SteppedMigrations trait with a nth_migrating_prefixes function that returns the prefix iterator for the nth migration.

To expose this information to the public, a Runtime API can be provided (if we dont have view functions then). It would query the Migrations::Cursor and then lookup the nth iterator and return all keys into a collected vector.
This should not need any modifications to the migrations pallet or frame-executive. Eventually, we can wrap the more pallet-centric aspects of MBMs into a PalletMBM trait and populate this automatically with the pallet prefix.

lean-apple commented 1 month ago

Hello @ggwpez, can I work on this issue ?

ggwpez commented 1 month ago

Yes sure 😄 , please write here if there are Qs coming up.

lean-apple commented 4 weeks ago

Yes sure 😄 , please write here if there are Qs coming up.

Thanks I would like to clarify the different steps to enable to access to the migration keys :

ggwpez commented 4 weeks ago

Yes sounds good.