mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 19:51:02 +00:00
Add a force_unfreeze extrinsic to the disputes module (#3906)
* add a 'force_unfreeze' to the Disputes module * fmt * Benchmark Disputes `force_unfreeze` extrinsic (#3908) * Companion for Generate storage info for pallet babe #9760 (#3831) * Adding MaxSegmentLength and MaxAuthorities to pallet babe * Missed a few to_vec * Removing `MaxSegmentLength` as not needed anymore * Adding `MaxAuthorities` to couple of missing place * Adding missing definition of `MaxAuthorities` * Adding a missing to_vec * update Substrate Co-authored-by: thiolliere <gui.thiolliere@gmail.com> Co-authored-by: parity-processbot <> * Benchmark Disputes `force_unfreeze` extrinsic target pr: #3906 target branch: rh-unfreeze * Add benchmark to rococo runtime; run benchmark locally * Revert unintentionally added diff * Some spacing and comments * Bump proc-macro-crate from 1.0.0 to 1.1.0 (#3863) Bumps [proc-macro-crate](https://github.com/bkchr/proc-macro-crate) from 1.0.0 to 1.1.0. - [Release notes](https://github.com/bkchr/proc-macro-crate/releases) - [Commits](https://github.com/bkchr/proc-macro-crate/commits) --- updated-dependencies: - dependency-name: proc-macro-crate dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump parity-scale-codec from 2.2.0 to 2.3.0 (#3833) Bumps [parity-scale-codec](https://github.com/paritytech/parity-scale-codec) from 2.2.0 to 2.3.0. - [Release notes](https://github.com/paritytech/parity-scale-codec/releases) - [Changelog](https://github.com/paritytech/parity-scale-codec/blob/master/CHANGELOG.md) - [Commits](https://github.com/paritytech/parity-scale-codec/compare/v2.2...parity-scale-codec-v2.3.0) --- updated-dependencies: - dependency-name: parity-scale-codec dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Use super::WeightInfo to try and get CI to compile * cargo run --quiet --release --features runtime-benchmarks -- benchmark --chain=rococo-dev --steps=50 --repeat=20 --pallet=runtime_parachains::disputes --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./runtime/parachains/src/disputes/weights.rs --header=./file_header.txt * impl TestWeightInfo; remove weights from runtime_parachains dir * fmt * Update test-runtime Co-authored-by: Georges <georges.dib@gmail.com> Co-authored-by: thiolliere <gui.thiolliere@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Parity Bot <admin@parity.io> Co-authored-by: Zeke Mostov <32168567+emostov@users.noreply.github.com> Co-authored-by: Georges <georges.dib@gmail.com> Co-authored-by: thiolliere <gui.thiolliere@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Parity Bot <admin@parity.io>
This commit is contained in:
committed by
GitHub
parent
b60d2eeec1
commit
03934d2af1
@@ -23,6 +23,7 @@ use crate::{
|
||||
};
|
||||
use bitvec::{bitvec, order::Lsb0 as BitOrderLsb0};
|
||||
use frame_support::{ensure, traits::Get, weights::Weight};
|
||||
use frame_system::pallet_prelude::*;
|
||||
use parity_scale_codec::{Decode, Encode};
|
||||
use primitives::v1::{
|
||||
byzantine_threshold, supermajority_threshold, ApprovalVote, CandidateHash, CompactStatement,
|
||||
@@ -37,6 +38,11 @@ use sp_runtime::{
|
||||
};
|
||||
use sp_std::{collections::btree_set::BTreeSet, prelude::*};
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
mod benchmarking;
|
||||
|
||||
pub use crate::Origin as ParachainOrigin;
|
||||
|
||||
/// Whether the dispute is local or remote.
|
||||
#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo)]
|
||||
pub enum DisputeLocation {
|
||||
@@ -212,6 +218,17 @@ impl<T: Config> DisputesHandler<T::BlockNumber> for pallet::Pallet<T> {
|
||||
}
|
||||
}
|
||||
|
||||
pub trait WeightInfo {
|
||||
fn force_unfreeze() -> Weight;
|
||||
}
|
||||
|
||||
pub struct TestWeightInfo;
|
||||
impl WeightInfo for TestWeightInfo {
|
||||
fn force_unfreeze() -> Weight {
|
||||
0
|
||||
}
|
||||
}
|
||||
|
||||
pub use pallet::*;
|
||||
#[frame_support::pallet]
|
||||
pub mod pallet {
|
||||
@@ -223,6 +240,9 @@ pub mod pallet {
|
||||
type Event: From<Event<Self>> + IsType<<Self as frame_system::Config>::Event>;
|
||||
type RewardValidators: RewardValidators;
|
||||
type PunishValidators: PunishValidators;
|
||||
|
||||
/// Weight information for extrinsics in this pallet.
|
||||
type WeightInfo: WeightInfo;
|
||||
}
|
||||
|
||||
#[pallet::pallet]
|
||||
@@ -305,6 +325,19 @@ pub mod pallet {
|
||||
/// Too many spam slots used by some specific validator.
|
||||
PotentialSpam,
|
||||
}
|
||||
|
||||
#[pallet::origin]
|
||||
pub type Origin = ParachainOrigin;
|
||||
|
||||
#[pallet::call]
|
||||
impl<T: Config> Pallet<T> {
|
||||
#[pallet::weight(<T as Config>::WeightInfo::force_unfreeze())]
|
||||
pub fn force_unfreeze(origin: OriginFor<T>) -> DispatchResult {
|
||||
ensure_root(origin)?;
|
||||
Frozen::<T>::set(None);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bitflags::bitflags! {
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
// Copyright 2021 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Polkadot.
|
||||
|
||||
// Polkadot 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.
|
||||
|
||||
// Polkadot 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 Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use super::*;
|
||||
|
||||
use frame_benchmarking::{benchmarks, impl_benchmark_test_suite};
|
||||
use frame_system::RawOrigin;
|
||||
use sp_runtime::traits::One;
|
||||
|
||||
benchmarks! {
|
||||
force_unfreeze {
|
||||
Frozen::<T>::set(Some(One::one()));
|
||||
}: _(RawOrigin::Root)
|
||||
verify {
|
||||
assert!(Frozen::<T>::get().is_none())
|
||||
}
|
||||
}
|
||||
|
||||
impl_benchmark_test_suite!(
|
||||
Pallet,
|
||||
crate::mock::new_test_ext(Default::default()),
|
||||
crate::mock::Test
|
||||
);
|
||||
@@ -149,6 +149,7 @@ impl crate::disputes::Config for Test {
|
||||
type Event = Event;
|
||||
type RewardValidators = Self;
|
||||
type PunishValidators = Self;
|
||||
type WeightInfo = crate::disputes::TestWeightInfo;
|
||||
}
|
||||
|
||||
thread_local! {
|
||||
|
||||
Reference in New Issue
Block a user