Skip to content

Added pallet migration #589

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

Merged
merged 1 commit into from
May 26, 2025
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
1 change: 1 addition & 0 deletions Cargo.lock

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

4 changes: 4 additions & 0 deletions runtime/cere-dev/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ pallet-im-online = { workspace = true }
pallet-indices = { workspace = true }
pallet-insecure-randomness-collective-flip = { workspace = true }
pallet-membership = { workspace = true }
pallet-migrations = { workspace = true }
pallet-multisig = { workspace = true }
pallet-nomination-pools = { workspace = true }
pallet-nomination-pools-benchmarking = { workspace = true }
Expand Down Expand Up @@ -213,6 +214,7 @@ std = [
"anyhow/std",
"frame-metadata-hash-extension/std",
"pallet-token-gateway/std",
"pallet-migrations/std",
]
runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
Expand Down Expand Up @@ -267,6 +269,7 @@ runtime-benchmarks = [
"pallet-origins/runtime-benchmarks",
"pallet-ddc-verification/runtime-benchmarks",
"pallet-token-gateway/runtime-benchmarks",
"pallet-migrations/runtime-benchmarks",
]
try-runtime = [
"frame-executive/try-runtime",
Expand Down Expand Up @@ -326,6 +329,7 @@ try-runtime = [
"pallet-hyperbridge/try-runtime",
"ismp-grandpa/try-runtime",
"pallet-token-gateway/try-runtime",
"pallet-migrations/try-runtime",
]

# Enable the metadata hash generation in the wasm builder.
Expand Down
30 changes: 27 additions & 3 deletions runtime/cere-dev/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
// and set impl_version to 0. If only runtime
// implementation changes and behavior does not, then leave spec_version as
// is and increment impl_version.
spec_version: 73039,
spec_version: 73040,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 24,
Expand Down Expand Up @@ -261,6 +261,7 @@ impl frame_system::Config for Runtime {
type AccountData = pallet_balances::AccountData<Balance>;
type SS58Prefix = ConstU16<54>;
type MaxConsumers = ConstU32<16>;
type MultiBlockMigrator = MultiBlockMigrations;
}

impl pallet_insecure_randomness_collective_flip::Config for Runtime {}
Expand Down Expand Up @@ -1391,6 +1392,25 @@ impl pallet_ddc_verification::Config for Runtime {
const OCW_INTERVAL: u16 = 1; // every block
}

parameter_types! {
pub MbmServiceWeight: Weight = Perbill::from_percent(80) * RuntimeBlockWeights::get().max_block;
}

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>;
type IdentifierMaxLen = ConstU32<256>;
type MigrationStatusHandler = ();
type FailedMigrationHandler = frame_support::migrations::FreezeChainOnFailedMigration;
type MaxServiceWeight = MbmServiceWeight;
type WeightInfo = pallet_migrations::weights::SubstrateWeight<Runtime>;
}

#[frame_support::runtime]
mod runtime {
#[runtime::runtime]
Expand Down Expand Up @@ -1564,6 +1584,10 @@ mod runtime {

#[runtime::pallet_index(50)]
pub type TokenGateway = pallet_token_gateway::Pallet<Runtime>;

// Migrations pallet
#[runtime::pallet_index(51)]
pub type MultiBlockMigrations = pallet_migrations;
}

/// The address format for describing accounts.
Expand Down Expand Up @@ -1604,8 +1628,7 @@ pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, RuntimeCall, Tx
parameter_types! {
pub BalanceTransferAllowDeath: Weight = weights::pallet_balances_balances::WeightInfo::<Runtime>::transfer_allow_death();
}
type Migrations =
(pallet_child_bounties::migration::MigrateV0ToV1<Runtime, BalanceTransferAllowDeath>,);
type Migrations = ();

/// Executive: handles dispatch to the various modules.
pub type Executive = frame_executive::Executive<
Expand Down Expand Up @@ -1663,6 +1686,7 @@ mod benches {
[pallet_ddc_clusters_gov, DdcClustersGov]
[pallet_ddc_payouts, DdcPayouts]
[pallet_token_gateway, TokenGateway]
[pallet_migrations, MultiBlockMigrations]
);
}

Expand Down
Loading