Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
pgherveou committed May 12, 2023
1 parent b3da625 commit 481c29d
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 20 deletions.
4 changes: 0 additions & 4 deletions pallets/dmp-queue/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,6 @@ pub mod pallet {

#[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
fn on_runtime_upgrade() -> Weight {
migration::migrate_to_latest::<T>()
}

fn on_idle(_now: T::BlockNumber, max_weight: Weight) -> Weight {
// on_idle processes additional messages with any remaining block weight.
Self::service_queue(max_weight)
Expand Down
11 changes: 9 additions & 2 deletions pallets/dmp-queue/src/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use crate::{Config, Configuration, Overweight, Pallet, DEFAULT_POV_SIZE};
use frame_support::{
pallet_prelude::*,
traits::StorageVersion,
traits::{OnRuntimeUpgrade, StorageVersion},
weights::{constants::WEIGHT_REF_TIME_PER_MILLIS, Weight},
};

Expand All @@ -28,7 +28,7 @@ pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(1);

/// Migrates the pallet storage to the most recent version, checking and setting the
/// `StorageVersion`.
pub fn migrate_to_latest<T: Config>() -> Weight {
fn migrate_to_latest<T: Config>() -> Weight {
let mut weight = T::DbWeight::get().reads(1);

if StorageVersion::get::<Pallet<T>>() == 0 {
Expand All @@ -46,6 +46,13 @@ pub fn migrate_to_latest<T: Config>() -> Weight {
weight
}

pub struct Migration<T: Config>(PhantomData<T>);
impl<T: Config> OnRuntimeUpgrade for Migration<T> {
fn on_runtime_upgrade() -> Weight {
migrate_to_latest::<T>()
}
}

mod v0 {
use super::*;
use codec::{Decode, Encode};
Expand Down
6 changes: 1 addition & 5 deletions pallets/parachain-system/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ use sp_runtime::{
use sp_std::{cmp, collections::btree_map::BTreeMap, prelude::*};
use xcm::latest::XcmHash;

mod migration;
pub mod migration;
mod relay_state_snapshot;
#[macro_use]
pub mod validate_block;
Expand Down Expand Up @@ -197,10 +197,6 @@ pub mod pallet {

#[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
fn on_runtime_upgrade() -> Weight {
migration::on_runtime_upgrade::<T>()
}

fn on_finalize(_: T::BlockNumber) {
<DidSetValidationCode<T>>::kill();
<UpgradeRestrictionSignal<T>>::kill();
Expand Down
12 changes: 10 additions & 2 deletions pallets/parachain-system/src/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@

use crate::{Config, Pallet, ReservedDmpWeightOverride, ReservedXcmpWeightOverride};
use frame_support::{
traits::{Get, StorageVersion},
pallet_prelude::*,
traits::{Get, OnRuntimeUpgrade, StorageVersion},
weights::Weight,
};

/// The current storage version.
pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(2);

/// Call this during the next runtime upgrade for this module.
pub fn on_runtime_upgrade<T: Config>() -> Weight {
fn on_runtime_upgrade<T: Config>() -> Weight {
let mut weight: Weight = T::DbWeight::get().reads(2);

if StorageVersion::get::<Pallet<T>>() == 0 {
Expand All @@ -44,6 +45,13 @@ pub fn on_runtime_upgrade<T: Config>() -> Weight {
weight
}

pub struct Migration<T: Config>(PhantomData<T>);
impl<T: Config> OnRuntimeUpgrade for Migration<T> {
fn on_runtime_upgrade() -> Weight {
on_runtime_upgrade::<T>()
}
}

/// V2: Migrate to 2D weights for ReservedXcmpWeightOverride and ReservedDmpWeightOverride.
mod v2 {
use super::*;
Expand Down
4 changes: 0 additions & 4 deletions pallets/xcmp-queue/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,6 @@ pub mod pallet {

#[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
fn on_runtime_upgrade() -> Weight {
migration::migrate_to_latest::<T>()
}

fn on_idle(_now: T::BlockNumber, max_weight: Weight) -> Weight {
// on_idle processes additional messages with any remaining block weight.
Self::service_xcmp_queue(max_weight)
Expand Down
11 changes: 9 additions & 2 deletions pallets/xcmp-queue/src/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use crate::{Config, Overweight, Pallet, QueueConfig, DEFAULT_POV_SIZE};
use frame_support::{
pallet_prelude::*,
traits::StorageVersion,
traits::{OnRuntimeUpgrade, StorageVersion},
weights::{constants::WEIGHT_REF_TIME_PER_MILLIS, Weight},
};

Expand All @@ -28,7 +28,7 @@ pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(2);

/// Migrates the pallet storage to the most recent version, checking and setting the
/// `StorageVersion`.
pub fn migrate_to_latest<T: Config>() -> Weight {
fn migrate_to_latest<T: Config>() -> Weight {
let mut weight = T::DbWeight::get().reads(1);

if StorageVersion::get::<Pallet<T>>() == 1 {
Expand All @@ -46,6 +46,13 @@ pub fn migrate_to_latest<T: Config>() -> Weight {
weight
}

pub struct Migration<T: Config>(PhantomData<T>);
impl<T: Config> OnRuntimeUpgrade for Migration<T> {
fn on_runtime_upgrade() -> Weight {
migrate_to_latest::<T>()
}
}

mod v1 {
use super::*;
use codec::{Decode, Encode};
Expand Down
1 change: 1 addition & 0 deletions parachains/runtimes/contracts/contracts-rococo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ std = [
"frame-support/std",
"frame-system-rpc-runtime-api/std",
"frame-system/std",
"frame-try-runtime/std",
"kusama-runtime-constants/std",
"pallet-aura/std",
"pallet-authorship/std",
Expand Down
10 changes: 9 additions & 1 deletion parachains/runtimes/contracts/contracts-rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,15 @@ pub type UncheckedExtrinsic =
/// Extrinsic type that has already been checked.
pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, RuntimeCall, SignedExtra>;

pub type Migrations = (pallet_contracts::Migration<Runtime>,);
pub type Migrations = (
cumulus_pallet_parachain_system::migration::Migration<Runtime>,
cumulus_pallet_xcmp_queue::migration::Migration<Runtime>,
pallet_balances::migration::MigrateToTrackInactive<Runtime, xcm_config::CheckingAccount>,
pallet_multisig::migrations::v1::MigrateToV1<Runtime>,
pallet_contracts::Migration<Runtime>,
pallet_xcm::migration::v1::MigrateToV1<Runtime>,
cumulus_pallet_dmp_queue::migration::Migration<Runtime>,
);

type EventRecord = frame_system::EventRecord<
<Runtime as frame_system::Config>::RuntimeEvent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ parameter_types! {
pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
pub UniversalLocation: InteriorMultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();
pub const ExecutiveBody: BodyId = BodyId::Executive;
pub CheckingAccount: AccountId = PolkadotXcm::check_account();
}

/// We allow root and the Relay Chain council to execute privileged collator selection operations.
Expand Down

0 comments on commit 481c29d

Please sign in to comment.