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

Multi-block migrator #1322

Merged
merged 9 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
50 changes: 25 additions & 25 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ pallet-contracts = { git = "https://github.com/paritytech/polkadot-sdk", branch
pallet-contracts-uapi = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
pallet-identity = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
pallet-multisig = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
pallet-migrations = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
pallet-insecure-randomness-collective-flip = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
pallet-session = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false, features = ["historical"] }
pallet-sudo = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
Expand Down Expand Up @@ -223,7 +224,6 @@ fc-storage = { git = "https://github.com/AstarNetwork/frontier", branch = "polka
# Cumulus
# (wasm)
cumulus-pallet-aura-ext = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
cumulus-pallet-dmp-queue = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
cumulus-pallet-parachain-system = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
cumulus-pallet-xcmp-queue = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
cumulus-primitives-aura = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
Expand Down
8 changes: 4 additions & 4 deletions runtime/astar/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ pallet-evm-precompile-simple = { workspace = true }
pallet-identity = { workspace = true }
pallet-membership = { workspace = true }
pallet-message-queue = { workspace = true }
pallet-migrations = { workspace = true }
pallet-multisig = { workspace = true }
pallet-proxy = { workspace = true }
pallet-session = { workspace = true, features = ["historical"] }
Expand All @@ -72,7 +73,6 @@ pallet-xcm-benchmarks = { workspace = true, optional = true }

# cumulus dependencies
cumulus-pallet-aura-ext = { workspace = true }
cumulus-pallet-dmp-queue = { workspace = true }
cumulus-pallet-parachain-system = { workspace = true, features = ["parameterized-consensus-hook"] }
cumulus-pallet-xcm = { workspace = true }
cumulus-pallet-xcmp-queue = { workspace = true }
Expand Down Expand Up @@ -192,6 +192,7 @@ std = [
"pallet-evm-precompile-sha3fips/std",
"pallet-identity/std",
"pallet-multisig/std",
"pallet-migrations/std",
"pallet-session/std",
"pallet-utility/std",
"pallet-timestamp/std",
Expand All @@ -212,7 +213,6 @@ std = [
"cumulus-primitives-timestamp/std",
"cumulus-pallet-parachain-system/std",
"cumulus-pallet-aura-ext/std",
"cumulus-pallet-dmp-queue/std",
"cumulus-pallet-xcmp-queue/std",
"pallet-message-queue/std",
"parachains-common/std",
Expand Down Expand Up @@ -278,14 +278,14 @@ runtime-benchmarks = [
"pallet-evm-precompile-xcm/runtime-benchmarks",
"pallet-identity/runtime-benchmarks",
"pallet-multisig/runtime-benchmarks",
"pallet-migrations/runtime-benchmarks",
"pallet-sudo/runtime-benchmarks",
"pallet-utility/runtime-benchmarks",
"pallet-vesting/runtime-benchmarks",
"polkadot-parachain/runtime-benchmarks",
"polkadot-primitives/runtime-benchmarks",
"polkadot-runtime-common/runtime-benchmarks",
"xcm-executor/runtime-benchmarks",
"cumulus-pallet-dmp-queue/runtime-benchmarks",
"cumulus-primitives-core/runtime-benchmarks",
"parachains-common/runtime-benchmarks",
"orml-oracle/runtime-benchmarks",
Expand Down Expand Up @@ -320,8 +320,8 @@ try-runtime = [
"pallet-xcm/try-runtime",
"pallet-identity/try-runtime",
"pallet-multisig/try-runtime",
"pallet-migrations/try-runtime",
"cumulus-pallet-aura-ext/try-runtime",
"cumulus-pallet-dmp-queue/try-runtime",
"cumulus-pallet-parachain-system/try-runtime",
"cumulus-pallet-xcm/try-runtime",
"cumulus-pallet-xcmp-queue/try-runtime",
Expand Down
74 changes: 53 additions & 21 deletions runtime/astar/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ impl frame_system::Config for Runtime {
type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;
type MaxConsumers = frame_support::traits::ConstU32<16>;
type SingleBlockMigrations = ();
type MultiBlockMigrator = ();
type MultiBlockMigrator = MultiBlockMigrations;
type PreInherents = ();
type PostInherents = ();
type PostTransactions = ();
Expand Down Expand Up @@ -1189,6 +1189,25 @@ impl frame_support::traits::SortedMembers<AccountId> for OracleMembershipWrapper
}
}

parameter_types! {
pub MbmServiceWeight: Weight = Perbill::from_percent(80) * RuntimeBlockWeights::get().max_block;
}
Dinonard marked this conversation as resolved.
Show resolved Hide resolved

impl pallet_migrations::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
#[cfg(not(feature = "runtime-benchmarks"))]
type Migrations = ();
// Benchmarks need mocked migrations to guarantee that they succeed.
#[cfg(feature = "runtime-benchmarks")]
type Migrations = pallet_migrations::mock_helpers::MockedMigrations;
type CursorMaxLen = ConstU32<65_536>;
ermalkaleci marked this conversation as resolved.
Show resolved Hide resolved
type IdentifierMaxLen = ConstU32<256>;
type MigrationStatusHandler = ();
type FailedMigrationHandler = frame_support::migrations::FreezeChainOnFailedMigration;
ermalkaleci marked this conversation as resolved.
Show resolved Hide resolved
type MaxServiceWeight = MbmServiceWeight;
type WeightInfo = pallet_migrations::weights::SubstrateWeight<Runtime>;
}

construct_runtime!(
pub struct Runtime
{
Expand Down Expand Up @@ -1225,6 +1244,7 @@ construct_runtime!(
XcmpQueue: cumulus_pallet_xcmp_queue = 50,
PolkadotXcm: pallet_xcm = 51,
CumulusXcm: cumulus_pallet_xcm = 52,
// skip 53 - cumulus_pallet_dmp_queue previously
XcAssetConfig: pallet_xc_asset_config = 54,
XTokens: orml_xtokens = 55,
MessageQueue: pallet_message_queue = 56,
Expand All @@ -1236,6 +1256,8 @@ construct_runtime!(
Contracts: pallet_contracts = 70,

Sudo: pallet_sudo = 99,

MultiBlockMigrations: pallet_migrations = 120,
}
);

Expand Down Expand Up @@ -1271,13 +1293,13 @@ pub type Executive = frame_executive::Executive<
frame_system::ChainContext<Runtime>,
Runtime,
AllPalletsWithSystem,
Migrations,
migrations::OnRuntimeUpgrade,
ermalkaleci marked this conversation as resolved.
Show resolved Hide resolved
>;

parameter_types! {
// Threshold amount variation allowed for this migration - 10%
pub const ThresholdVariationPercentage: u32 = 10;
// percentages below are calulated based on total issuance at the time when dApp staking v3 was launched (8.4B)
// percentages below are calculated based on total issuance at the time when dApp staking v3 was launched (8.4B)
pub const TierThresholds: [TierThreshold; 4] = [
TierThreshold::DynamicPercentage {
percentage: Perbill::from_parts(35_700_000), // 3.57%
Expand All @@ -1301,24 +1323,33 @@ parameter_types! {
pub const DmpQueuePalletName: &'static str = "DmpQueue";
}

/// All migrations that will run on the next runtime upgrade.
///
/// Once done, migrations should be removed from the tuple.
pub type Migrations = (
// permanent migration, do not remove
pallet_xcm::migration::MigrateToLatestXcmVersion<Runtime>,
// dapp-staking dyn tier threshold migrations
pallet_dapp_staking_v3::migration::versioned_migrations::V7ToV8<
Runtime,
TierThresholds,
ThresholdVariationPercentage,
>,
frame_support::migrations::RemovePallet<
DmpQueuePalletName,
<Runtime as frame_system::Config>::DbWeight,
>,
pallet_contracts::Migration<Runtime>,
);
/// The runtime migrations per release.
mod migrations {
use super::*;

/// All migrations that will run on the next runtime upgrade.
///
/// __NOTE:__ THE ORDER IS IMPORTANT.
pub type OnRuntimeUpgrade = (Unreleased, Permanent);

/// Unreleased migrations. Add new ones here:
pub type Unreleased = (
// dApp-staking dyn tier threshold migrations
pallet_dapp_staking_v3::migration::versioned_migrations::V7ToV8<
Runtime,
TierThresholds,
ThresholdVariationPercentage,
>,
frame_support::migrations::RemovePallet<
DmpQueuePalletName,
<Runtime as frame_system::Config>::DbWeight,
>,
pallet_contracts::Migration<Runtime>,
);

/// Migrations/checks that do not need to be versioned and can run on every upgrade.
pub type Permanent = (pallet_xcm::migration::MigrateToLatestXcmVersion<Runtime>,);
}

type EventRecord = frame_system::EventRecord<
<Runtime as frame_system::Config>::RuntimeEvent,
Expand Down Expand Up @@ -1397,6 +1428,7 @@ mod benches {
[pallet_timestamp, Timestamp]
[pallet_dapp_staking_v3, DappStaking]
[pallet_inflation, Inflation]
[pallet_migrations, MultiBlockMigrations]
[pallet_xc_asset_config, XcAssetConfig]
[pallet_collator_selection, CollatorSelection]
[pallet_xcm, PalletXcmExtrinsicsBenchmark::<Runtime>]
Expand Down
8 changes: 4 additions & 4 deletions runtime/shibuya/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ pallet-identity = { workspace = true }
pallet-insecure-randomness-collective-flip = { workspace = true }
pallet-membership = { workspace = true }
pallet-message-queue = { workspace = true }
pallet-migrations = { workspace = true }
pallet-multisig = { workspace = true }
pallet-preimage = { workspace = true }
pallet-proxy = { workspace = true }
Expand All @@ -78,7 +79,6 @@ pallet-vesting = { workspace = true }

# cumulus dependencies
cumulus-pallet-aura-ext = { workspace = true }
cumulus-pallet-dmp-queue = { workspace = true }
cumulus-pallet-parachain-system = { workspace = true, features = ["parameterized-consensus-hook"] }
cumulus-pallet-xcm = { workspace = true }
cumulus-pallet-xcmp-queue = { workspace = true }
Expand Down Expand Up @@ -210,6 +210,7 @@ std = [
"pallet-price-aggregator/std",
"pallet-identity/std",
"pallet-multisig/std",
"pallet-migrations/std",
"pallet-insecure-randomness-collective-flip/std",
"pallet-session/std",
"pallet-utility/std",
Expand All @@ -236,7 +237,6 @@ std = [
"cumulus-primitives-timestamp/std",
"cumulus-pallet-parachain-system/std",
"cumulus-pallet-aura-ext/std",
"cumulus-pallet-dmp-queue/std",
"cumulus-pallet-xcmp-queue/std",
"cumulus-pallet-xcm/std",
"pallet-collator-selection/std",
Expand Down Expand Up @@ -306,6 +306,7 @@ runtime-benchmarks = [
"pallet-evm-precompile-xcm/runtime-benchmarks",
"pallet-identity/runtime-benchmarks",
"pallet-multisig/runtime-benchmarks",
"pallet-migrations/runtime-benchmarks",
"pallet-proxy/runtime-benchmarks",
"pallet-scheduler/runtime-benchmarks",
"pallet-sudo/runtime-benchmarks",
Expand All @@ -315,7 +316,6 @@ runtime-benchmarks = [
"polkadot-primitives/runtime-benchmarks",
"polkadot-runtime-common/runtime-benchmarks",
"xcm-executor/runtime-benchmarks",
"cumulus-pallet-dmp-queue/runtime-benchmarks",
"cumulus-primitives-core/runtime-benchmarks",
"parachains-common/runtime-benchmarks",
"orml-oracle/runtime-benchmarks",
Expand Down Expand Up @@ -352,13 +352,13 @@ try-runtime = [
"pallet-xcm/try-runtime",
"pallet-identity/try-runtime",
"pallet-multisig/try-runtime",
"pallet-migrations/try-runtime",
"pallet-insecure-randomness-collective-flip/try-runtime",
"pallet-scheduler/try-runtime",
"pallet-proxy/try-runtime",
"pallet-contracts/try-runtime",
"pallet-evm-chain-id/try-runtime",
"cumulus-pallet-aura-ext/try-runtime",
"cumulus-pallet-dmp-queue/try-runtime",
"cumulus-pallet-parachain-system/try-runtime",
"cumulus-pallet-xcm/try-runtime",
"cumulus-pallet-xcmp-queue/try-runtime",
Expand Down
Loading
Loading