-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Move PalletVersion
away from the crate version
#9165
Conversation
Before this pr, `PalletVersion` was referring to the crate version that hosted the pallet. This pr introduces a custom `package.metadata.frame` section in the `Cargo.toml` that can contain a `pallet-version` key value pair. While the value is expected to be a valid u16. If this key/value pair isn't given, the version is set to 1. It also changes the `PalletVersion` declaration. We now only have one `u16` that represents the version. Not a major/minor/patch version. As the old `PalletVersion` was starting with the `u16` major, decoding the old values will work.
nice |
Why is this useful and to which version (crate or pallet) do I refer to in my |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code looks good to me,
I don't have strong opinion between storage-version and pallet-version.
- storage-version makes it more close to its current usage: we bump it when storage is breaking and do some conditional with it in storage migrations
- pallet-version makes it more close to its original goal (as I understand it): having a stored number which can identifier clearly the pallet. So we can easily checkout the pallet code. But if we don't bump this number when the pallet behaviour changes, then the name is more misleading than helpful.
Also I agree 0 could make more sense when no version is defined https://github.com/paritytech/substrate/pull/9165/files#r655954312
Just FYI that this XCM PR currently assumes (major, minor, patch) for pallet versions: |
Hmm good point. Yeah, I don't know. I'm still seeing the "need" for this, but currently no one bumps any versions anyway... So, yeah... It is hard. |
Or we just keep the |
@kianenigma @thiolliere @athei what do you think? |
TBH I am only interested in this for storage migrations (see my linked issue), so that we can get rid of all the transient storage items. For that, a single version is enough. If the triplet is also useful in certain cases, we can
|
I think this should be named storage is either backwards compatible or not. afaik, there is not a need for minor and patch version numbers |
I agree with shawn and kian. We only need one number because this version seems to be about storage only (for everything else we have the crate version). We should name it |
Agree as well. Just linked the XCM PR to make sure that we adjust that once we change this. |
- Drop PalletVersion - Introduce StorageVersion - StorageVersion needs to be set in the crate and set for the macros - Added migration
Okay I have rewritten the entire thing.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs to fix the on genesis for decl_storage macro: #9165 (comment)
But otherwise it is good to me
Note for other about migration: The storage version is now stored under a different prefix than the old pallet version. To upgrade you can use /// Migrate from `PalletVersion` to the new `StorageVersion`
pub struct MigratePalletVersionToStorageVersion;
impl OnRuntimeUpgrade for MigratePalletVersionToStorageVersion {
fn on_runtime_upgrade() -> frame_support::weights::Weight {
frame_support::migrations::migrate_from_pallet_version_to_storage_version::<AllPalletsWithSystem>(
&RocksDbWeight::get()
)
}
} And add this struct to the generic Warning: The custom runtime upgrade happens before the pallet's runtime upgrede (defined inside hooks). Thus any hook who rely on the pallet version won't be triggered and migration must be done manually. in substrate repo, pallet-contracts is the only pallet which look into the stored pallet version. |
@thiolliere ty |
Co-authored-by: Guillaume Thiolliere <[email protected]>
Co-authored-by: Guillaume Thiolliere <[email protected]>
bot merge |
Waiting for commit status. |
* Companion for Substrate#9165 paritytech/substrate#9165 * update Substrate Co-authored-by: parity-processbot <>
* Remove VestingAccount * Fix chain specs * Update rust-toolchain * Update make test and benchmark * Update CI * Run `make format` and `make clippy` * Update CI * Quick fix * Support try-runtime * Remove pallet-randomness-collective-flip * Migrate elections-phragmen (paritytech/substrate#7040) * Migrate PalletVersion to StorageVersion (paritytech/substrate#9165) * Migrate pallet-babe epoch config (paritytech/substrate#8072) * Migrate frame-system AccountInfo to AccountInfoWithTripleRefCount (paritytech/substrate#8221) * Migrate prefix `GrandpaFinality` -> `Grandpa` * Migrate prefix `Instance1Collective` -> `Council` * Migrate prefix `Instance2Collective` -> `TechnicalCommittee` * Migrate prefix `Instance1Membership` -> `TechnicalMembership` * Migrate pallet-tips prefix from `Treasury` -> `Tips` * Migrate pallet-bounties prefix from `Treasury` -> `Bounties` * Migrate prefix from `PhragmenElection` -> `Elections` * Revert `dev` spec_name * Confirm migrations order * Use ChainX substrate patch for system migration * Run `make format` * Reset spec_name `dev` -> `chainx` * Add migrations.rs for mainnet and testnet * Bump ChainX version to `4.0.0` * Bump ChainX version to `4.0.0` * Update governance parameters for dev and malan * Update malan chainspec * Quick fix * Quick fix * Update generate_keys.sh * Adjust malan parameters * Update malan chainspec * Update malan chainspec * Update malan chainspec * Rename malan testnet name * Add bootnodes url * Run `make format` * Regenerate weights * Disable pre_release.yml CI * Regenerate benchmark weights * Run `make clippy` * Run `make format` Co-authored-by: icodezjb <[email protected]>
* Remove VestingAccount * Fix chain specs * Update rust-toolchain * Update make test and benchmark * Update CI * Run `make format` and `make clippy` * Update CI * Quick fix * Support try-runtime * Remove pallet-randomness-collective-flip * Migrate elections-phragmen (paritytech/substrate#7040) * Migrate PalletVersion to StorageVersion (paritytech/substrate#9165) * Migrate pallet-babe epoch config (paritytech/substrate#8072) * Migrate frame-system AccountInfo to AccountInfoWithTripleRefCount (paritytech/substrate#8221) * Migrate prefix `GrandpaFinality` -> `Grandpa` * Migrate prefix `Instance1Collective` -> `Council` * Migrate prefix `Instance2Collective` -> `TechnicalCommittee` * Migrate prefix `Instance1Membership` -> `TechnicalMembership` * Migrate pallet-tips prefix from `Treasury` -> `Tips` * Migrate pallet-bounties prefix from `Treasury` -> `Bounties` * Migrate prefix from `PhragmenElection` -> `Elections` * Revert `dev` spec_name * Confirm migrations order * Use ChainX substrate patch for system migration * Run `make format` * Reset spec_name `dev` -> `chainx` * Add migrations.rs for mainnet and testnet * Bump ChainX version to `4.0.0` * Bump ChainX version to `4.0.0` * Update governance parameters for dev and malan * Update malan chainspec * Quick fix * Quick fix * Update generate_keys.sh * Adjust malan parameters * Update malan chainspec * Update malan chainspec * Update malan chainspec * Rename malan testnet name * Add bootnodes url * Run `make format` * Regenerate weights * Disable pre_release.yml CI * Regenerate benchmark weights * Run `make clippy` * Run `make format` Co-authored-by: icodezjb <[email protected]>
* Companion for Substrate#9165 paritytech/substrate#9165 * update Substrate Co-authored-by: parity-processbot <>
* Companion for Substrate#9165 paritytech/substrate#9165 * update Substrate Co-authored-by: parity-processbot <>
Before this pr,
PalletVersion
was referring to the crate version thathosted the pallet. This pr introduces a custom
package.metadata.frame
section in the
Cargo.toml
that can contain apallet-version
keyvalue pair. While the value is expected to be a valid u16. If this
key/value pair isn't given, the version is set to 1.
It also changes the
PalletVersion
declaration. We now only have oneu16
that represents the version. Not a major/minor/patch version. Asthe old
PalletVersion
was starting with theu16
major, decoding theold values will work.
polkadot companion: paritytech/polkadot#3526