Skip to content
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
3 changes: 3 additions & 0 deletions Cargo.lock

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

11 changes: 11 additions & 0 deletions runtimes/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ sp-io = {git = "https://github.com/paritytech/substrate", default-features = fal

[dependencies]
codec = {package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"]}
hex-literal = "0.3.4"
log = "0.4.16"
scale-info = {version = "2.0.1", default-features = false, features = ["derive"]}
serde = {version = "1.0.132", optional = true, features = ["derive"]}
smallvec = "1.8.0"
Expand All @@ -24,9 +26,13 @@ pallet-membership = {git = "https://github.com/paritytech/substrate", default-fe
pallet-transaction-payment = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.19"}
sp-consensus-aura = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.19"}
sp-core = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.19"}
sp-io = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.19"}
sp-runtime = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.19"}
sp-std = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.19"}

# Runtime tests
frame-try-runtime = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.19", optional = true}

[features]
default = ["std"]
fast-gov = []
Expand All @@ -50,6 +56,11 @@ std = [
"serde",
"sp-consensus-aura/std",
"sp-core/std",
"sp-io/std",
"sp-runtime/std",
"sp-std/std",
]
try-runtime = [
"frame-support/try-runtime",
"frame-try-runtime",
]
1 change: 1 addition & 0 deletions runtimes/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ use sp_std::marker::PhantomData;
pub mod authorization;
pub mod constants;
pub mod fees;
pub mod migrations;
pub mod pallet_id;

#[cfg(feature = "runtime-benchmarks")]
Expand Down
75 changes: 75 additions & 0 deletions runtimes/common/src/migrations.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// KILT Blockchain – https://botlabs.org
// Copyright (C) 2019-2022 BOTLabs GmbH

// The KILT Blockchain is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// The KILT Blockchain is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

// If you feel like getting in touch with us, you can do so at [email protected]

use core::marker::PhantomData;
use frame_support::traits::Get;
use hex_literal::hex;

pub struct RemoveKiltLaunch<R>(PhantomData<R>);
impl<R: frame_system::Config> frame_support::traits::OnRuntimeUpgrade for RemoveKiltLaunch<R> {
fn on_runtime_upgrade() -> frame_support::weights::Weight {
let items = match frame_support::storage::unhashed::kill_prefix(&hex!("37be294ab4b5aa76f1df3f80e7c180ef"), None)
{
sp_io::KillStorageResult::AllRemoved(n) => {
log::info!("🚀 Successfully removed all {} storage items of the launch pallet", n);
n
}
sp_io::KillStorageResult::SomeRemaining(n) => {
log::warn!(
"🚀 Failed to remove all storage items of the launch pallet, {} are remaining",
n
);
n
}
};
<R as frame_system::Config>::DbWeight::get().writes(items.into())
}

#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<(), &'static str> {
// FIXME: Why does this fail?
log::info!(
"🚀 Pre check: Launch pallet storage exists {}?",
frame_support::storage::migration::have_storage_value(
&hex!("37be294ab4b5aa76f1df3f80e7c180ef"),
// b"KiltLaunch"
b"TransferAccount",
&[]
)
);

assert!(frame_support::storage::migration::have_storage_value(
&hex!("37be294ab4b5aa76f1df3f80e7c180ef"),
// b"KiltLaunch",
b"TransferAccount",
&[]
));
Ok(())
}

#[cfg(feature = "try-runtime")]
fn post_upgrade() -> Result<(), &'static str> {
match frame_support::storage::unhashed::kill_prefix(&hex!("37be294ab4b5aa76f1df3f80e7c180ef"), Some(1)) {
sp_io::KillStorageResult::AllRemoved(0) => {
log::info!("🚀 Post check: Launch pallet storage successfully removed");
Ok(())
}
_ => Err("🚀 Post check: Launch pallet storage still exists!"),
}
}
}
2 changes: 1 addition & 1 deletion runtimes/peregrine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,7 @@ pub type Executive = frame_executive::Executive<
// Executes pallet hooks in reverse order of definition in construct_runtime
// If we want to switch to AllPalletsWithSystem, we need to reorder the staking pallets
AllPalletsReversedWithSystemFirst,
pallet_did_lookup::migrations::LookupReverseIndexMigration<Runtime>,
runtime_common::migrations::RemoveKiltLaunch<Runtime>,
>;

impl_runtime_apis! {
Expand Down
1 change: 1 addition & 0 deletions runtimes/spiritnet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -230,4 +230,5 @@ try-runtime = [
"pallet-utility/try-runtime",
"pallet-vesting/try-runtime",
"parachain-staking/try-runtime",
"runtime-common/try-runtime",
]
2 changes: 1 addition & 1 deletion runtimes/spiritnet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,7 @@ pub type Executive = frame_executive::Executive<
// Executes pallet hooks in reverse order of definition in construct_runtime
// If we want to switch to AllPalletsWithSystem, we need to reorder the staking pallets
AllPalletsReversedWithSystemFirst,
pallet_did_lookup::migrations::LookupReverseIndexMigration<Runtime>,
runtime_common::migrations::RemoveKiltLaunch<Runtime>,
>;

impl_runtime_apis! {
Expand Down