Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move migrations to versioned tuples #2030

Closed
wants to merge 42 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
34c93d7
Move migrations to versioned tuples
chevdor Oct 25, 2023
22cf84c
Add PRDoc
chevdor Oct 25, 2023
1c60daf
fmt
chevdor Oct 25, 2023
2071731
Merge branch 'master' into wk-231025-version-migrations
chevdor Oct 30, 2023
5668f66
Remove prdoc
chevdor Oct 30, 2023
faee788
Merge branch 'master' into wk-231025-version-migrations
chevdor Nov 2, 2023
530e69d
Merge branch 'master' into wk-231025-version-migrations
chevdor Nov 2, 2023
0349e9d
Merge branch 'master' into wk-231025-version-migrations
chevdor Nov 4, 2023
2a66661
Fix migrations
chevdor Nov 7, 2023
c8b5b25
Add CI check for migrations
chevdor Nov 7, 2023
49665e1
Merge branch 'master' into wk-231025-version-migrations
chevdor Nov 7, 2023
92bcb1d
fmt
chevdor Nov 7, 2023
0fdfb4b
Merge branch 'master' into wk-231025-version-migrations
chevdor Nov 8, 2023
21980a8
Merge branch 'master' into wk-231025-version-migrations
chevdor Nov 22, 2023
e7d36d5
Missing brackets
chevdor Nov 22, 2023
29f1ca4
1.4.0 is out, preparing for the next
chevdor Nov 22, 2023
690fc7c
Merge branch 'master' into wk-231025-version-migrations
chevdor Nov 22, 2023
e7c44f1
fmt
chevdor Nov 23, 2023
5a4e9d5
Fix conflicting naming
chevdor Nov 23, 2023
8281047
Documentation
chevdor Nov 23, 2023
23edaa2
Merge branch 'master' into wk-231025-version-migrations
chevdor Nov 23, 2023
a48a23f
Merge branch 'master' into wk-231025-version-migrations
liamaharon Nov 23, 2023
6b9424c
Update .github/workflows/check-migrations.yml
chevdor Nov 23, 2023
32cade2
Add submig doc
chevdor Nov 23, 2023
af02634
Move migrations to versioned tuples
chevdor Oct 25, 2023
7e27960
Add PRDoc
chevdor Oct 25, 2023
234c6ec
fmt
chevdor Oct 25, 2023
635be8b
Remove prdoc
chevdor Oct 30, 2023
cfe6da8
Add CI check for migrations
chevdor Nov 7, 2023
4d894e6
Missing brackets
chevdor Nov 22, 2023
d27b21f
1.4.0 is out, preparing for the next
chevdor Nov 22, 2023
f9fe49f
fmt
chevdor Nov 23, 2023
e7e3eea
Fix conflicting naming
chevdor Nov 23, 2023
d81ce63
Documentation
chevdor Nov 23, 2023
95aecea
Update .github/workflows/check-migrations.yml
chevdor Nov 23, 2023
737913a
Add submig doc
chevdor Nov 23, 2023
730d133
Add missing V1_04_00 migrations
chevdor Dec 6, 2023
f197892
Merge branch 'wk-231025-version-migrations' of https://github.com/par…
chevdor Dec 6, 2023
3fa00eb
Fix some urls
chevdor Dec 6, 2023
ca756f5
Add lychee exclusions and fix typos
chevdor Dec 7, 2023
a037151
Merge branch 'master' into wk-231025-version-migrations
chevdor Dec 13, 2023
dab10ec
Merge branch 'master' into wk-231025-version-migrations
chevdor Dec 13, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .config/lychee.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,11 @@ exclude = [
"https://w3f.github.io/parachain-implementers-guide/node/index.html",
"https://w3f.github.io/parachain-implementers-guide/protocol-chain-selection.html",
"https://w3f.github.io/parachain-implementers-guide/runtime/session_info.html",

# Private or unaccessible repos
"https://github.com/paritytech/ci_cd/.*",
"https://iohk.io/en/blog/.*",

# Not checking websockets
"wss?://.*"
]
31 changes: 31 additions & 0 deletions .github/workflows/check-migrations-tuples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Lint Migration Tuples

# This GHA uses https://crates.io/crates/submig to check the namingg and the
# syntax of the migrations, ensuring they are versioning. `submig` parses the code
# and checks that all runtimes found comply with the pattern.

on:
pull_request:
types: [labeled, opened, synchronize, unlabeled]

jobs:
check-migrations:
runs-on: ubuntu-latest
steps:
- name: Rust Cache
uses: Swatinem/rust-cache@3cf7f8cc28d1b4e7d01e3783be10a97d55d483c8 # v2.7.1
with:
cache-on-failure: true

- name: Install submig
run: |
cargo install submig
submig --version

- name: Checkout repo
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1

- name: Check migrations
continue-on-error: false
run: |
submig list .
20 changes: 10 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions bridges/primitives/runtime/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl<ChainCall: Encode> Encode for EncodedOrDecodedCall<ChainCall> {
/// Minimal Substrate-based chain representation that may be used from no_std environment.
pub trait Chain: Send + Sync + 'static {
/// A type that fulfills the abstract idea of what a Substrate block number is.
// Constraits come from the associated Number type of `sp_runtime::traits::Header`
// Constrains come from the associated Number type of `sp_runtime::traits::Header`
// See here for more info:
// https://crates.parity.io/sp_runtime/traits/trait.Header.html#associatedtype.Number
//
Expand All @@ -113,7 +113,7 @@ pub trait Chain: Send + Sync + 'static {
+ MaxEncodedLen;

/// A type that fulfills the abstract idea of what a Substrate hash is.
// Constraits come from the associated Hash type of `sp_runtime::traits::Header`
// Constrains come from the associated Hash type of `sp_runtime::traits::Header`
// See here for more info:
// https://crates.parity.io/sp_runtime/traits/trait.Header.html#associatedtype.Hash
type Hash: Parameter
Expand All @@ -129,9 +129,9 @@ pub trait Chain: Send + Sync + 'static {
+ AsMut<[u8]>
+ MaxEncodedLen;

/// A type that fulfills the abstract idea of what a Substrate hasher (a type
/// A type that fulfills the abstract idea of what a Substrate `Hasher`` (a type
/// that produces hashes) is.
// Constraits come from the associated Hashing type of `sp_runtime::traits::Header`
// Constrains come from the associated Hashing type of `sp_runtime::traits::Header`
// See here for more info:
// https://crates.parity.io/sp_runtime/traits/trait.Header.html#associatedtype.Hashing
type Hasher: HashT<Output = Self::Hash>;
Expand Down
65 changes: 60 additions & 5 deletions cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -944,14 +944,42 @@ pub type SignedExtra = (
/// Unchecked extrinsic type as expected by this runtime.
pub type UncheckedExtrinsic =
generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, SignedExtra>;
/// Migrations to apply on runtime upgrade.

/// All migrations that will run on the next runtime upgrade.
///
/// This contains the combined migrations of the last 10 releases. It allows to skip runtime
/// upgrades in case governance decides to do so. THE ORDER IS IMPORTANT.
#[rustfmt::skip]
pub type Migrations = (
pallet_collator_selection::migration::v1::MigrateToV1<Runtime>,
InitStorageVersions,
// unreleased
cumulus_pallet_xcmp_queue::migration::v4::MigrationToV4<Runtime>,
migrations::V1_04_00,
migrations::V1_05_00,
migrations::Unreleased
);

/// The runtime migrations per release.
#[allow(deprecated, missing_docs)]
pub mod migrations {
use super::*;

pub type V1_04_00 = ();

pub type V1_05_00 = ();

/// New migrations should be added here in the `Unreleased` tuple.
/// During the release process for release `x.y.z``, the `Unreleased` migrations
/// will be moved to a new tuple named `Vx_y_z` and added to the migration
/// to execute. The `Unreleased` tuple will then be cleared.
/// This allows keeping track of the migrations that have been applied to the
/// runtime *per version*.
// Do not remove `#[rustfmt::skip]` or the empty tuple, even if it appears
// to be *temporarily* not needed. Keep a single migration per line.
#[rustfmt::skip]
pub type Unreleased = (
pallet_collator_selection::migration::v1::MigrateToV1<Runtime>,
InitStorageVersions,
);
}

/// Migration to initialize storage versions for pallets added after genesis.
///
/// This is now done automatically (see <https://github.com/paritytech/polkadot-sdk/pull/1297>),
Expand Down Expand Up @@ -1004,6 +1032,33 @@ impl frame_support::traits::OnRuntimeUpgrade for InitStorageVersions {
}
}

/// All migrations that will run on the next runtime upgrade.
///
/// This contains the combined migrations of the last 10 releases. It allows to skip runtime
/// upgrades in case governance decides to do so. THE ORDER IS IMPORTANT.
#[rustfmt::skip]
pub type Migrations = (
migrations::V1_04_00,
migrations::V1_05_00,
migrations::Unreleased,
);

/// The runtime migrations per release.
#[allow(deprecated, missing_docs)]
pub mod migrations {
use super::*;

pub type V1_04_00 = ();

pub type V1_05_00 = ();

pub type Unreleased = (
pallet_collator_selection::migration::v1::MigrateToV1<Runtime>,
InitStorageVersions,
cumulus_pallet_xcmp_queue::migration::v4::MigrationToV4<Runtime>,
);
}

/// Executive: handles dispatch to the various modules.
pub type Executive = frame_executive::Executive<
Runtime,
Expand Down
88 changes: 72 additions & 16 deletions cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -918,24 +918,47 @@ pub type SignedExtra = (
pub type UncheckedExtrinsic =
generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, SignedExtra>;

/// Migrations to apply on runtime upgrade.
/// All migrations that will run on the next runtime upgrade.
///
/// This contains the combined migrations of the last 10 releases. It allows to skip runtime
/// upgrades in case governance decides to do so. THE ORDER IS IMPORTANT.
#[rustfmt::skip]
pub type Migrations = (
// v9420
pallet_nfts::migration::v1::MigrateToV1<Runtime>,
// unreleased
pallet_collator_selection::migration::v1::MigrateToV1<Runtime>,
// unreleased
migrations::NativeAssetParents0ToParents1Migration<Runtime>,
// unreleased
pallet_multisig::migrations::v1::MigrateToV1<Runtime>,
// unreleased
InitStorageVersions,
// unreleased
DeleteUndecodableStorage,
// unreleased
cumulus_pallet_xcmp_queue::migration::v4::MigrationToV4<Runtime>,
migrations::V0_09_20,
migrations::V1_04_00,
migrations::V1_05_00,
migrations::Unreleased
);

/// The runtime migrations per release.
#[allow(deprecated, missing_docs)]
pub mod migrations {
use super::*;

pub type V0_09_20 = (pallet_nfts::migration::v1::MigrateToV1<Runtime>,);

pub type V1_04_00 = ();

pub type V1_05_00 = ();

/// New migrations should be added here in the `Unreleased` tuple.
/// During the release process for release `x.y.z``, the `Unreleased` migrations
/// will be moved to a new tuple named `Vx_y_z` and added to the migration
/// to execute. The `Unreleased` tuple will then be cleared.
/// This allows keeping track of the migrations that have been applied to the
/// runtime *per version*.
// Do not remove `#[rustfmt::skip]` or the empty tuple, even if it appears
// to be *temporarily* not needed. Keep a single migration per line.
#[rustfmt::skip]
pub type Unreleased = (
pallet_collator_selection::migration::v1::MigrateToV1<Runtime>,
asset_hub_westend_migrations::NativeAssetParents0ToParents1Migration<Runtime>,
pallet_multisig::migrations::v1::MigrateToV1<Runtime>,
InitStorageVersions,
DeleteUndecodableStorage,
);
}

/// Asset Hub Westend has some undecodable storage, delete it.
/// See <https://github.com/paritytech/polkadot-sdk/issues/2241> for more info.
///
Expand Down Expand Up @@ -1005,6 +1028,39 @@ impl frame_support::traits::OnRuntimeUpgrade for DeleteUndecodableStorage {
}
}

/// All migrations that will run on the next runtime upgrade.
///
/// This contains the combined migrations of the last 10 releases. It allows to skip runtime
/// upgrades in case governance decides to do so. THE ORDER IS IMPORTANT.
#[rustfmt::skip]
pub type Migrations = (
migrations::V0_09_20,
migrations::V1_04_00,
migrations::V1_05_00,
migrations::Unreleased,
);

/// The runtime migrations per release.
#[allow(deprecated, missing_docs)]
pub mod migrations {
use super::*;

pub type V0_09_20 = (pallet_nfts::migration::v1::MigrateToV1<Runtime>,);

pub type V1_04_00 = ();

pub type V1_05_00 = ();

pub type Unreleased = (
pallet_collator_selection::migration::v1::MigrateToV1<Runtime>,
migrations::NativeAssetParents0ToParents1Migration<Runtime>,
pallet_multisig::migrations::v1::MigrateToV1<Runtime>,
InitStorageVersions,
DeleteUndecodableStorage,
cumulus_pallet_xcmp_queue::migration::v4::MigrationToV4<Runtime>,
);
}

/// Migration to initialize storage versions for pallets added after genesis.
///
/// Ideally this would be done automatically (see
Expand Down Expand Up @@ -1692,7 +1748,7 @@ cumulus_pallet_parachain_system::register_validate_block! {
BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,
}

pub mod migrations {
pub mod asset_hub_westend_migrations {
use super::*;
use frame_support::{
pallet_prelude::Get,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,43 @@ pub type SignedExtra = (
pub type UncheckedExtrinsic =
generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, SignedExtra>;

/// Migrations to apply on runtime upgrade.
/// All migrations that will run on the next runtime upgrade.
///
/// This contains the combined migrations of the last 10 releases. It allows to skip runtime
/// upgrades in case governance decides to do so. THE ORDER IS IMPORTANT.
#[rustfmt::skip]
pub type Migrations = (
pallet_collator_selection::migration::v1::MigrateToV1<Runtime>,
pallet_multisig::migrations::v1::MigrateToV1<Runtime>,
InitStorageVersions,
cumulus_pallet_xcmp_queue::migration::v4::MigrationToV4<Runtime>,
migrations::V1_04_00,
migrations::V1_05_00,
migrations::Unreleased,
);

/// The runtime migrations per release.
#[allow(deprecated, missing_docs)]
pub mod migrations {
use super::*;

pub type V1_04_00 = ();

pub type V1_05_00 = ();

/// New migrations should be added here in the `Unreleased` tuple.
/// During the release process for release `x.y.z``, the `Unreleased` migrations
/// will be moved to a new tuple named `Vx_y_z` and added to the migration
/// to execute. The `Unreleased` tuple will then be cleared.
/// This allows keeping track of the migrations that have been applied to the
/// runtime *per version*.
// Do not remove `#[rustfmt::skip]` or the empty tuple, even if it appears
// to be *temporarily* not needed. Keep a single migration per line.
#[rustfmt::skip]
pub type Unreleased = (
pallet_collator_selection::migration::v1::MigrateToV1<Runtime>,
pallet_multisig::migrations::v1::MigrateToV1<Runtime>,
InitStorageVersions,
liamaharon marked this conversation as resolved.
Show resolved Hide resolved
cumulus_pallet_xcmp_queue::migration::v4::MigrationToV4<Runtime>,
);
}

/// Migration to initialize storage versions for pallets added after genesis.
///
/// Ideally this would be done automatically (see
Expand Down
Loading
Loading