Skip to content
This repository was archived by the owner on Mar 13, 2023. It is now read-only.
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
49 changes: 47 additions & 2 deletions node/runtime/pangolin/src/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,55 @@ fn migrate() -> Weight {
),
(b"TransactionPause", &[b"PausedTransactions"]),
];
let hash = &[];

removed_items.iter().for_each(|(module, items)| {
items.iter().for_each(|item| migration::remove_storage_prefix(module, item, hash));
items.iter().for_each(|item| migration::remove_storage_prefix(module, item, &[]));
});

let grandpas: &[&[u8]] =
&[b"BridgePangoroGrandpa", b"BridgeRococoGrandpa", b"BridgeMoonbaseRelayGrandpa"];

grandpas
.iter()
.for_each(|grandpa| bridge_runtime_common::migrate_pallet_operation_mode(grandpa));

macro_rules! migrate_best_finalized {
($c:ty, $i:ty, $n:expr) => {
if let Some(hash) = migration::take_storage_value::<<$c as bp_runtime::Chain>::Hash>(
$n,
b"BestFinalized",
&[],
) {
if let Some(header) =
<pallet_bridge_grandpa::ImportedHeaders<Runtime, $i>>::get(hash)
{
<pallet_bridge_grandpa::BestFinalized<Runtime, $i>>::put((header.number, hash));
}
}
};
}

migrate_best_finalized!(Pangoro, WithPangoroGrandpa, b"BridgePangoroGrandpa");
migrate_best_finalized!(Rococo, WithRococoGrandpa, b"BridgeRococoGrandpa");
migrate_best_finalized!(MoonbaseRelay, WithMoonbaseRelayGrandpa, b"BridgeMoonbaseRelayGrandpa");

let messages: &[&[u8]] = &[
b"BridgePangoroMessages",
b"BridgePangolinParachainMessages",
b"BridgePangolinParachainAlphaMessages",
];

messages
.iter()
.for_each(|message| bridge_runtime_common::migrate_message_pallet_operation_mode(message));

let parachains_modules: &[&[u8]] = &[b"BridgeRococoParachain", b"BridgeMoonbaseRelayParachain"];

parachains_modules.iter().for_each(|module| {
bridge_runtime_common::put_pallet_operation_mode(
module,
bp_runtime::BasicOperatingMode::Normal,
);
});

// 0
Expand Down
21 changes: 21 additions & 0 deletions node/runtime/pangoro/src/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,27 @@ impl OnRuntimeUpgrade for CustomOnRuntimeUpgrade {
fn migrate() -> Weight {
migration::remove_storage_prefix(b"TransactionPause", b"PausedTransactions", &[]);

let grandpa = b"BridgePangolinGrandpa";

bridge_runtime_common::migrate_pallet_operation_mode(grandpa);

if let Some(hash) = migration::take_storage_value::<<Pangolin as bp_runtime::Chain>::Hash>(
grandpa,
b"BestFinalized",
&[],
) {
if let Some(header) =
<pallet_bridge_grandpa::ImportedHeaders<Runtime, WithPangolinGrandpa>>::get(hash)
{
<pallet_bridge_grandpa::BestFinalized<Runtime, WithPangolinGrandpa>>::put((
header.number,
hash,
));
}
}

bridge_runtime_common::migrate_message_pallet_operation_mode(b"BridgePangolinMessages");

// 0
RuntimeBlockWeights::get().max_block
}