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

Fix migrations and add CI check for new system chains #2336

Merged
merged 6 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
25 changes: 25 additions & 0 deletions .gitlab/pipeline/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,31 @@ check-runtime-migration-asset-hub-westend:
PACKAGE: "asset-hub-westend-runtime"
WASM: "asset_hub_westend_runtime.compact.compressed.wasm"
URI: "wss://westend-asset-hub-rpc.polkadot.io:443"

check-runtime-migration-asset-hub-rococo:
stage: check
extends:
- .docker-env
- .test-pr-refs
- .check-runtime-migration
variables:
NETWORK: "asset-hub-rococo"
PACKAGE: "asset-hub-rococo-runtime"
WASM: "asset_hub_rococo_runtime.compact.compressed.wasm"
URI: "wss://rococo-asset-hub-rpc.polkadot.io:443"

# Check runtime migrations for Parity managed bridge hub chains
check-runtime-migration-bridge-hub-westend:
stage: check
extends:
- .docker-env
- .test-pr-refs
- .check-runtime-migration
variables:
NETWORK: "bridge-hub-westend"
PACKAGE: "bridge-hub-westend-runtime"
WASM: "bridge_hub_westend_runtime.compact.compressed.wasm"
URI: "wss://westend-bridge-hub-rpc.polkadot.io:443"

check-runtime-migration-bridge-hub-rococo:
stage: check
Expand Down
59 changes: 57 additions & 2 deletions cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ use sp_api::impl_runtime_apis;
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys,
traits::{AccountIdConversion, AccountIdLookup, BlakeTwo256, Block as BlockT, Verify},
traits::{
AccountIdConversion, AccountIdLookup, BlakeTwo256, Block as BlockT, Saturating, Verify,
},
transaction_validity::{TransactionSource, TransactionValidity},
ApplyExtrinsicResult, Permill,
};
Expand Down Expand Up @@ -959,7 +961,60 @@ pub type SignedExtra = (
pub type UncheckedExtrinsic =
generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, SignedExtra>;
/// Migrations to apply on runtime upgrade.
pub type Migrations = (pallet_collator_selection::migration::v1::MigrateToV1<Runtime>,);
pub type Migrations =
(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>),
/// but some pallets had made it in and had storage set in them for this parachain before it was
/// merged.
pub struct InitStorageVersions;

impl frame_support::traits::OnRuntimeUpgrade for InitStorageVersions {
fn on_runtime_upgrade() -> Weight {
use frame_support::traits::{GetStorageVersion, StorageVersion};

let mut writes = 0;

if PolkadotXcm::on_chain_storage_version() == StorageVersion::new(0) {
PolkadotXcm::current_storage_version().put::<PolkadotXcm>();
writes.saturating_inc();
}

if Multisig::on_chain_storage_version() == StorageVersion::new(0) {
Multisig::current_storage_version().put::<Multisig>();
writes.saturating_inc();
}

if Assets::on_chain_storage_version() == StorageVersion::new(0) {
Assets::current_storage_version().put::<Assets>();
writes.saturating_inc();
}

if Uniques::on_chain_storage_version() == StorageVersion::new(0) {
Uniques::current_storage_version().put::<Uniques>();
writes.saturating_inc();
}

if Nfts::on_chain_storage_version() == StorageVersion::new(0) {
Nfts::current_storage_version().put::<Nfts>();
writes.saturating_inc();
}

if ForeignAssets::on_chain_storage_version() == StorageVersion::new(0) {
ForeignAssets::current_storage_version().put::<ForeignAssets>();
writes.saturating_inc();
}

if PoolAssets::on_chain_storage_version() == StorageVersion::new(0) {
PoolAssets::current_storage_version().put::<PoolAssets>();
writes.saturating_inc();
}

<Runtime as frame_system::Config>::DbWeight::get().reads_writes(7, writes)
}
}

/// Executive: handles dispatch to the various modules.
pub type Executive = frame_executive::Executive<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,6 @@ construct_runtime!(
XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 30,
PolkadotXcm: pallet_xcm::{Pallet, Call, Storage, Event<T>, Origin, Config<T>} = 31,
CumulusXcm: cumulus_pallet_xcm::{Pallet, Event<T>, Origin} = 32,
DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 33,
MessageQueue: pallet_message_queue::{Pallet, Call, Storage, Event<T>} = 34,

// Smart Contracts.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,3 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime {
parameter_types! {
pub const RelayOrigin: AggregateMessageOrigin = AggregateMessageOrigin::Parent;
}

impl cumulus_pallet_dmp_queue::Config for Runtime {
type WeightInfo = cumulus_pallet_dmp_queue::weights::SubstrateWeight<Runtime>;
type RuntimeEvent = crate::RuntimeEvent;
type DmpSink = frame_support::traits::EnqueueWithOrigin<crate::MessageQueue, RelayOrigin>;
}