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:
Robert Habermeier
2021-09-23 14:29:26 -05:00
committed by GitHub
parent b60d2eeec1
commit 03934d2af1
9 changed files with 182 additions and 0 deletions
@@ -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! {