mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 04:41:02 +00:00
Alliance pallet: retirement notice call (#11970)
* Alliance pallet: retirement notice * add alliance pallet to benchmark list for dev chain * fix type * ".git/.scripts/bench-bot.sh" pallet dev pallet_alliance * ".git/.scripts/bench-bot.sh" pallet dev pallet_alliance * link weight generated by bench for retirement_notice method * migration to clear UpForKicking storage prefix * rename migration from v1 to v0_to_v1 * Apply suggestions from code review Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> * rename `retirement-notice to give-retirement-notice * Apply suggestions from code review Co-authored-by: Squirrel <gilescope@gmail.com> * review fixes: update doc, saturating add, BlockNumber type alias * add suffix to duratin consts *_IN_BLOCKS * ".git/.scripts/bench-bot.sh" pallet dev pallet_alliance * add negative tests (#11995) * add negative tests * remove tests powerless asserts checking against announcment origin * assert bad origin from announcement origin checks Co-authored-by: muharem <ismailov.m.h@gmail.com> Co-authored-by: command-bot <> Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> Co-authored-by: Squirrel <gilescope@gmail.com>
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) 2022 Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use crate::{Config, Pallet, Weight, LOG_TARGET};
|
||||
use frame_support::{pallet_prelude::*, storage::migration, traits::OnRuntimeUpgrade};
|
||||
use log;
|
||||
|
||||
/// The current storage version.
|
||||
pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(1);
|
||||
|
||||
/// Wrapper for all migrations of this pallet.
|
||||
pub fn migrate<T: Config<I>, I: 'static>() -> Weight {
|
||||
let onchain_version = Pallet::<T, I>::on_chain_storage_version();
|
||||
let mut weight: Weight = 0;
|
||||
|
||||
if onchain_version < 1 {
|
||||
weight = weight.saturating_add(v0_to_v1::migrate::<T, I>());
|
||||
}
|
||||
|
||||
STORAGE_VERSION.put::<Pallet<T, I>>();
|
||||
weight = weight.saturating_add(T::DbWeight::get().writes(1));
|
||||
|
||||
weight
|
||||
}
|
||||
|
||||
/// Implements `OnRuntimeUpgrade` trait.
|
||||
pub struct Migration<T, I = ()>(PhantomData<(T, I)>);
|
||||
|
||||
impl<T: Config<I>, I: 'static> OnRuntimeUpgrade for Migration<T, I> {
|
||||
fn on_runtime_upgrade() -> Weight {
|
||||
migrate::<T, I>()
|
||||
}
|
||||
}
|
||||
|
||||
/// v0_to_v1: `UpForKicking` is replaced by a retirement period.
|
||||
mod v0_to_v1 {
|
||||
use super::*;
|
||||
|
||||
pub fn migrate<T: Config<I>, I: 'static>() -> Weight {
|
||||
if migration::clear_storage_prefix(
|
||||
<Pallet<T, I>>::name().as_bytes(),
|
||||
b"UpForKicking",
|
||||
b"",
|
||||
None,
|
||||
None,
|
||||
)
|
||||
.maybe_cursor
|
||||
.is_some()
|
||||
{
|
||||
log::error!(
|
||||
target: LOG_TARGET,
|
||||
"Storage prefix 'UpForKicking' is not completely cleared."
|
||||
);
|
||||
}
|
||||
|
||||
T::DbWeight::get().writes(1)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user