Companion to Substrate #11490 (#1305)

* Fix warnings

* Bump

* Fix build

* Fix the build

* Fixes

* Formatting

Co-authored-by: Bastian Köcher <info@kchr.de>
This commit is contained in:
Gavin Wood
2022-05-30 18:47:28 +01:00
committed by GitHub
parent 9349f0ffaa
commit 02d9eb0883
4 changed files with 372 additions and 406 deletions
+366 -385
View File
File diff suppressed because it is too large Load Diff
@@ -41,9 +41,11 @@ pub fn on_runtime_upgrade<T: Config>() -> Weight {
/// mechanism now uses signals instead of block offsets. /// mechanism now uses signals instead of block offsets.
mod v1 { mod v1 {
use crate::{Config, Pallet}; use crate::{Config, Pallet};
#[allow(deprecated)]
use frame_support::{migration::remove_storage_prefix, pallet_prelude::*}; use frame_support::{migration::remove_storage_prefix, pallet_prelude::*};
pub fn migrate<T: Config>() -> Weight { pub fn migrate<T: Config>() -> Weight {
#[allow(deprecated)]
remove_storage_prefix(<Pallet<T>>::name().as_bytes(), b"LastUpgrade", b""); remove_storage_prefix(<Pallet<T>>::name().as_bytes(), b"LastUpgrade", b"");
T::DbWeight::get().writes(1) T::DbWeight::get().writes(1)
} }
@@ -222,13 +222,7 @@ fn host_storage_root(version: StateVersion) -> Vec<u8> {
} }
fn host_storage_clear_prefix(prefix: &[u8], limit: Option<u32>) -> KillStorageResult { fn host_storage_clear_prefix(prefix: &[u8], limit: Option<u32>) -> KillStorageResult {
with_externalities(|ext| { with_externalities(|ext| ext.clear_prefix(prefix, limit, None).into())
let (all_removed, num_removed) = ext.clear_prefix(prefix, limit);
match all_removed {
true => KillStorageResult::AllRemoved(num_removed),
false => KillStorageResult::SomeRemaining(num_removed),
}
})
} }
fn host_storage_append(key: &[u8], value: Vec<u8>) { fn host_storage_append(key: &[u8], value: Vec<u8>) {
@@ -294,13 +288,7 @@ fn host_default_child_storage_storage_kill(
limit: Option<u32>, limit: Option<u32>,
) -> KillStorageResult { ) -> KillStorageResult {
let child_info = ChildInfo::new_default(storage_key); let child_info = ChildInfo::new_default(storage_key);
with_externalities(|ext| { with_externalities(|ext| ext.kill_child_storage(&child_info, limit, None).into())
let (all_removed, num_removed) = ext.kill_child_storage(&child_info, limit);
match all_removed {
true => KillStorageResult::AllRemoved(num_removed),
false => KillStorageResult::SomeRemaining(num_removed),
}
})
} }
fn host_default_child_storage_exists(storage_key: &[u8], key: &[u8]) -> bool { fn host_default_child_storage_exists(storage_key: &[u8], key: &[u8]) -> bool {
@@ -314,13 +302,7 @@ fn host_default_child_storage_clear_prefix(
limit: Option<u32>, limit: Option<u32>,
) -> KillStorageResult { ) -> KillStorageResult {
let child_info = ChildInfo::new_default(storage_key); let child_info = ChildInfo::new_default(storage_key);
with_externalities(|ext| { with_externalities(|ext| ext.clear_child_prefix(&child_info, prefix, limit, None).into())
let (all_removed, num_removed) = ext.clear_child_prefix(&child_info, prefix, limit);
match all_removed {
true => KillStorageResult::AllRemoved(num_removed),
false => KillStorageResult::SomeRemaining(num_removed),
}
})
} }
fn host_default_child_storage_root(storage_key: &[u8], version: StateVersion) -> Vec<u8> { fn host_default_child_storage_root(storage_key: &[u8], version: StateVersion) -> Vec<u8> {
@@ -592,6 +592,7 @@ impl frame_support::traits::OnRuntimeUpgrade for RemoveCollectiveFlip {
fn on_runtime_upgrade() -> Weight { fn on_runtime_upgrade() -> Weight {
use frame_support::storage::migration; use frame_support::storage::migration;
// Remove the storage value `RandomMaterial` from removed pallet `RandomnessCollectiveFlip` // Remove the storage value `RandomMaterial` from removed pallet `RandomnessCollectiveFlip`
#[allow(deprecated)]
migration::remove_storage_prefix(b"RandomnessCollectiveFlip", b"RandomMaterial", b""); migration::remove_storage_prefix(b"RandomnessCollectiveFlip", b"RandomMaterial", b"");
<Runtime as frame_system::Config>::DbWeight::get().writes(1) <Runtime as frame_system::Config>::DbWeight::get().writes(1)
} }