Skip to content

Commit

Permalink
remove migrations (#498)
Browse files Browse the repository at this point in the history
* remove migrations

* #498 (comment)
  • Loading branch information
b-yap authored Oct 23, 2024
1 parent fd8995c commit f9ca9df
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 119 deletions.
43 changes: 2 additions & 41 deletions runtime/amplitude/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,46 +158,13 @@ parameter_types! {
pub const InactiveAccounts: Vec<AccountId> = Vec::new();
}

// TODO remove contract migrations after update
use pallet_contracts::migration::{v11, v12, v13, v14, v15};

// Custom storage version bump
use frame_support::{
pallet_prelude::StorageVersion,
traits::{GetStorageVersion, OnRuntimeUpgrade},
};

pub struct CustomOnRuntimeUpgrade;
impl OnRuntimeUpgrade for CustomOnRuntimeUpgrade {
fn on_runtime_upgrade() -> frame_support::weights::Weight {
log::info!("Custom on-runtime-upgrade function");

let mut writes = 0;
// WARNING: manually setting the storage version
if ParachainStaking::on_chain_storage_version() == 0 {
log::info!("Upgrading parachain staking storage version to 7");
StorageVersion::new(7).put::<ParachainStaking>();
writes += 1;
}

if Bounties::on_chain_storage_version() == 0 {
log::info!("Upgrading bounties storage version to 4");
StorageVersion::new(4).put::<Bounties>();
writes += 1;
}
// not really a heavy operation
<Runtime as frame_system::Config>::DbWeight::get().reads_writes(2, writes)
}
}

/// Executive: handles dispatch to the various modules.
pub type Executive = frame_executive::Executive<
Runtime,
Block,
frame_system::ChainContext<Runtime>,
Runtime,
AllPalletsWithSystem,
(CustomOnRuntimeUpgrade, pallet_contracts::migration::Migration<Runtime>),
AllPalletsWithSystem
>;

pub struct ConvertPrice;
Expand Down Expand Up @@ -1024,13 +991,7 @@ impl pallet_contracts::Config for Runtime {
type CodeHashLockupDepositPercent = CodeHashLockupDepositPercent;
type MaxDelegateDependencies = MaxDelegateDependencies;
type RuntimeHoldReason = RuntimeHoldReason;
type Migrations = (
v11::Migration<Self>,
v12::Migration<Runtime, Balances>,
v13::Migration<Self>,
v14::Migration<Self, Balances>,
v15::Migration<Self>,
);
type Migrations = ();
type Debug = ();
type Environment = ();
}
Expand Down
39 changes: 1 addition & 38 deletions runtime/foucoco/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,44 +158,13 @@ pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, RuntimeCall, Si

pub type SignedPayload = generic::SignedPayload<RuntimeCall, SignedExtra>;

// To be removed after contracts migrations executes.
use pallet_contracts::migration::{v11, v12, v13, v14, v15};
// Custom storage version bump
use frame_support::{
pallet_prelude::StorageVersion,
traits::{GetStorageVersion, OnRuntimeUpgrade},
};

pub struct CustomOnRuntimeUpgrade;
impl OnRuntimeUpgrade for CustomOnRuntimeUpgrade {
fn on_runtime_upgrade() -> frame_support::weights::Weight {
log::info!("Custom on-runtime-upgrade function");

let mut writes = 0;
// WARNING: manually setting the storage version
if ParachainStaking::on_chain_storage_version() == 0 {
log::info!("Upgrading parachain staking storage version to 7");
StorageVersion::new(7).put::<ParachainStaking>();
writes += 1;
}

if Bounties::on_chain_storage_version() == 0 {
log::info!("Upgrading bounties storage version to 4");
StorageVersion::new(4).put::<Bounties>();
writes += 1;
}
// not really a heavy operation
<Runtime as frame_system::Config>::DbWeight::get().reads_writes(2, writes)
}
}
/// Executive: handles dispatch to the various modules.
pub type Executive = frame_executive::Executive<
Runtime,
Block,
frame_system::ChainContext<Runtime>,
Runtime,
AllPalletsWithSystem,
(CustomOnRuntimeUpgrade, pallet_contracts::migration::Migration<Runtime>),
>;

pub struct ConvertPrice;
Expand Down Expand Up @@ -1072,13 +1041,7 @@ impl pallet_contracts::Config for Runtime {
type CodeHashLockupDepositPercent = CodeHashLockupDepositPercent;
type MaxDelegateDependencies = MaxDelegateDependencies;
type RuntimeHoldReason = RuntimeHoldReason;
type Migrations = (
v11::Migration<Self>,
v12::Migration<Runtime, Balances>,
v13::Migration<Self>,
v14::Migration<Self, Balances>,
v15::Migration<Self>,
);
type Migrations = ();
type Debug = ();
type Environment = ();
}
Expand Down
41 changes: 1 addition & 40 deletions runtime/pendulum/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,46 +158,13 @@ parameter_types! {
pub const InactiveAccounts: Vec<AccountId> = Vec::new();
}

// To be removed after contracts migrations executes.
use pallet_contracts::migration::{v11, v12, v13, v14, v15};

// Custom storage version bump
use frame_support::{
pallet_prelude::StorageVersion,
traits::{GetStorageVersion, OnRuntimeUpgrade},
};

pub struct CustomOnRuntimeUpgrade;
impl OnRuntimeUpgrade for CustomOnRuntimeUpgrade {
fn on_runtime_upgrade() -> frame_support::weights::Weight {
log::info!("Custom on-runtime-upgrade function");

let mut writes = 0;
// WARNING: manually setting the storage version
if ParachainStaking::on_chain_storage_version() == 0 {
log::info!("Upgrading parachain staking storage version to 7");
StorageVersion::new(7).put::<ParachainStaking>();
writes += 1;
}

if Bounties::on_chain_storage_version() == 0 {
log::info!("Upgrading bounties storage version to 4");
StorageVersion::new(4).put::<Bounties>();
writes += 1;
}
// not really a heavy operation
<Runtime as frame_system::Config>::DbWeight::get().reads_writes(2, writes)
}
}

/// Executive: handles dispatch to the various modules.
pub type Executive = frame_executive::Executive<
Runtime,
Block,
frame_system::ChainContext<Runtime>,
Runtime,
AllPalletsWithSystem,
(CustomOnRuntimeUpgrade, pallet_contracts::migration::Migration<Runtime>),
>;

pub struct ConvertPrice;
Expand Down Expand Up @@ -1024,13 +991,7 @@ impl pallet_contracts::Config for Runtime {
type CodeHashLockupDepositPercent = CodeHashLockupDepositPercent;
type MaxDelegateDependencies = MaxDelegateDependencies;
type RuntimeHoldReason = RuntimeHoldReason;
type Migrations = (
v11::Migration<Self>,
v12::Migration<Runtime, Balances>,
v13::Migration<Self>,
v14::Migration<Self, Balances>,
v15::Migration<Self>,
);
type Migrations = ();
type Debug = ();
type Environment = ();
}
Expand Down

0 comments on commit f9ca9df

Please sign in to comment.