Skip to main content
12 votes

How to perform a large migration?

This is basically the correct approach. There isn't actually any need to record the position: you should be removing items from OldLocks and inserting equivalents into NewLocks. You can stop the ...
Gav's user avatar
  • 2,681
7 votes
Accepted

Migrate keytype of StorageMap without breakin API

First of all, there's a misunderstanding here. Defining something like #[pallet::storage] pub type MyMap = StorageMap<_, Blake2_128Concat, KeyTypeOld, V>; #[pallet::storage] pub type MyMapNew = ...
kianenigma's user avatar
  • 2,799
7 votes
Accepted

Testing a migration with `try-runtime`

Good question! try-runtime is the right idea indeed. (Note for Parity devs at the end) Currently the try-runtime CLI scraps the chain state from the an RPC node. Using the public node is probably ...
Oliver Tale-Yazdi's user avatar
6 votes
Accepted

Where should pallet migrations be executed?

What is the current best practice to execute migrations? What should devs put their attention towards when applying this method? Are there pitfalls? When you are developing a Pallet for external ...
bkchr's user avatar
  • 11.5k
6 votes
Accepted

How do I fix "SpecVersionNeedsToIncrease" error?

Increment spec_version in the code, rebuild the WASM and perform the upgrade. When upgrading the check will be done on the actual WASM blob to ensure that the version has been increased. (This is the ...
Jaco's user avatar
  • 5,865
5 votes
Accepted

Potential storage issue with try-runtime tool

There is no magic involved here. The key of the storage location is Twox128(Prefix::pallet_prefix()) ++ Twox128(Prefix::STORAGE_PREFIX) (explained here) In your case the old storage hash and the new ...
Oliver Tale-Yazdi's user avatar
5 votes
Accepted

Forked Parity pallet, didn't migrate storage, deployed to chain. How to clear original storage from the live chain?

You can use remove_storage_prefix: remove_storage_prefix("OldPalletNameInYourRuntime", "LastAuthoredBlock", &[]); You need to place this into a runtime migration. The last ...
bkchr's user avatar
  • 11.5k
5 votes
Accepted

Is there a canonical resource describing when migrations are needed

Is there a standard definition of when storage migrations are required? I believe the most concise answer to this is to consider your blockchain two separate parts that need to work together: The ...
Shawn Tabrizi's user avatar
  • 16.1k
5 votes
Accepted

Sync error while upgrading Polkadot SDK from 1.0 to 1.6

Your problem is that you did not bump the spec_version. So, when the node reaches this block it assumes that the native runtime is compatible and tries to use it. However, it isn't compatible and it ...
bkchr's user avatar
  • 11.5k
4 votes
Accepted

Perform large migration between substrate versions

In general the complexity of your migration depends on how old your current Substrate instance is from the current Substrate instance. Substrate / Polkadot provides migration logic for each new ...
Shawn Tabrizi's user avatar
  • 16.1k
4 votes

using String in ink version 4

EDIT: this is not completely correct answer anymore. Openbrush is using String type from ink! prelude since version 3.0.0 pub type String = ink::prelude::string::String; When you look at the ...
Maario's user avatar
  • 659
4 votes
Accepted

Need to migrate u32 to Vec<T::AccountId>

You can check how Substrate migrates the account references. https://github.com/paritytech/substrate/pull/8221/files#diff-68096a50d12854e07693a4828590517bb81fea37a9253640278ecdc5b93b6992 The link ...
AurevoirXavier's user avatar
  • 10.6k
3 votes
Accepted

How to add storage migration in parachain?

I have solved this issue by using compact.compressed wasm.
Deepak Chaudhary's user avatar
3 votes

I'm getting some issue during storage migration

This is not the way to perform runtime upgrade on parachain. Runtime upgrade process is different in solochain and parachain. Please refer this https://docs.substrate.io/reference/how-to-guides/...
Ayush Mishra's user avatar
3 votes
Accepted

Pallet declares internal migrations (which *might* execute). On-chain `StorageVersion(0)` vs current storage version `StorageVersion(0)`

Whenever a runtime upgrade happens, if the runtime contains some pallet that implements on_runtime_upgrade (like ethereum pallet does), these warnings will show up. These warnings can be safely ...
Bernardo Rodrigues's user avatar
3 votes

Migrating storage without creating a new storage item

Maybe, there are several ways to achieve this target. First, you can define a new Storage(or prefix) which we call it tmp, after you write all the data into this tmp storage, you can use move_prefix ...
ironman_ch_parami's user avatar
3 votes
Accepted

Should I do storage migration after remove fields from storage struct type?

Yes, you should. The key thing to know is that you already have some encoded bytes of your struct in storage, and whenever a storage read operation is done on your map, the pallet needs to know how to ...
Keith Yeung's user avatar
  • 2,121
3 votes
Accepted

Reclaim used space of a removed StorageItem on a live chain

Yes, you will need to kill/drain the old storage items. There is no way the chain can detect that storage items are unused and prune them automatically.
bkchr's user avatar
  • 11.5k
3 votes

How to export the current running chain data and import it in a new chain?

Substrate already has a export-state sub-command that exports the state of a running chain at a given block into a chain-spec. Then you can run a new chain, with the --chain pointing to this newly ...
kianenigma's user avatar
  • 2,799
3 votes

How do I do a multi-block migration?

Here is a real-world example. https://github.com/darwinia-network/darwinia-common/pull/673/files#diff-02470251f30c921643bfe724902ce5cc7a76ebac129128e1328c061295e66034R123-R148 In the past, our MMR ...
AurevoirXavier's user avatar
  • 10.6k
3 votes
Accepted

How to migrate from Kusama to Polkadot?

A migration from Kusama to Polkadot is possible. Done properly, the migration happens almost seamlessly; all the blocks, the state and the runtime are maintained. It is also possible to migrate from ...
sea212's user avatar
  • 549
3 votes
Accepted

Encoded error while performing a storage migration

In the pre_upgrade() and in the on_runtime_upgrade() functions there is an issue with the: let prev_count = NameOf::<T>::iter().count(); Because you are reading the data from the new ...
Alex Bean's user avatar
  • 5,747
3 votes
Accepted

Querying events from storage migration

You cannot query events from within the runtime. Events are meant to be pieces of information that the runtime emits outwards for the off-chain world to get easy introspection for what is happening ...
Oliver Tale-Yazdi's user avatar
2 votes

Storage Migration Guide Using #[pallet::storage]

in your code you are trying to replace an expected BoundedVec<u8, T::MaxLength> with your NickName's struct. #[derive(Encode, Decode, MaxEncodedLen, TypeInfo)] pub struct ...
Pablo Buitrago's user avatar
2 votes
Accepted

Parachain large migration best practices

you can refact the huge runtime migration to an temporarily extrinsic which can be executed multiple times and each time just migrate part of the data which not exceed max weight in one block
Ron's user avatar
  • 608
2 votes

How to export the current running chain data and import it in a new chain?

Yes it is possible and as @kianenigma mentioned, Substrate has the export-state command to do it. To export the chain state from a specific block number: ./target/release/parachain-template-node ...
Alex Bean's user avatar
  • 5,747
2 votes
Accepted

How do I know if I will need a storage migration along a forkless upgrade?

As far as I know, you have two ways to do this. First: you can check these pull-requests include runtime upgrade, and then pick pull requests between your old version and your new version, check those ...
ironman_ch_parami's user avatar
2 votes
Accepted

Removal of storage prefix from database

Using the frame support iterators on pallet maps when available could be the better approach. If not using frame support (or storage structure do not allow iteration), one can use sp_io primitives (...
cheme's user avatar
  • 456
2 votes
Accepted

Does changing an enum require a storage migration? What about `Error` and `Event`

A storage migration is needed whenever the encoded representation of the storage changes. In the case of an enum, it is represented as one byte. In the original enum: Enum::V0 == 0x00 Enum::V1 == 0x01 ...
Shawn Tabrizi's user avatar
  • 16.1k
2 votes
Accepted

I'm getting some issue during storage migration

You can try use compact.compressed.wasm instead of compact.wasm.
Pankaj's user avatar
  • 2,021

Only top scored, non community-wiki answers of a minimum length are eligible