mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 05: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
Generated
+2
@@ -7811,10 +7811,12 @@ dependencies = [
|
||||
"bp-runtime",
|
||||
"bp-wococo",
|
||||
"bridge-runtime-common",
|
||||
"frame-benchmarking",
|
||||
"frame-executive",
|
||||
"frame-support",
|
||||
"frame-system",
|
||||
"frame-system-rpc-runtime-api",
|
||||
"hex-literal",
|
||||
"log",
|
||||
"pallet-authority-discovery",
|
||||
"pallet-authorship",
|
||||
|
||||
@@ -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! {
|
||||
|
||||
@@ -78,6 +78,10 @@ pallet-bridge-dispatch = { path = "../../bridges/modules/dispatch", default-feat
|
||||
pallet-bridge-grandpa = { path = "../../bridges/modules/grandpa", default-features = false }
|
||||
pallet-bridge-messages = { path = "../../bridges/modules/messages", default-features = false }
|
||||
|
||||
# Benchmarking Dependencies
|
||||
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }
|
||||
hex-literal = { version = "0.3.3", optional = true }
|
||||
|
||||
[build-dependencies]
|
||||
substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
|
||||
@@ -169,6 +173,8 @@ runtime-benchmarks = [
|
||||
"pallet-timestamp/runtime-benchmarks",
|
||||
"pallet-xcm/runtime-benchmarks",
|
||||
"xcm-builder/runtime-benchmarks",
|
||||
"frame-benchmarking",
|
||||
"hex-literal"
|
||||
]
|
||||
try-runtime = [
|
||||
"frame-executive/try-runtime",
|
||||
|
||||
@@ -94,6 +94,7 @@ use xcm_executor::XcmExecutor;
|
||||
/// Constant values used within the runtime.
|
||||
pub mod constants;
|
||||
mod validator_manager;
|
||||
mod weights;
|
||||
|
||||
// Make the WASM binary available.
|
||||
#[cfg(feature = "std")]
|
||||
@@ -369,6 +370,7 @@ impl parachains_disputes::Config for Runtime {
|
||||
type Event = Event;
|
||||
type RewardValidators = ();
|
||||
type PunishValidators = ();
|
||||
type WeightInfo = weights::runtime_parachains_disputes::WeightInfo<Runtime>;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
@@ -1559,4 +1561,52 @@ sp_api::impl_runtime_apis! {
|
||||
TransactionPayment::query_fee_details(uxt, len)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
impl frame_benchmarking::Benchmark<Block> for Runtime {
|
||||
fn benchmark_metadata(extra: bool) -> (
|
||||
Vec<frame_benchmarking::BenchmarkList>,
|
||||
Vec<frame_support::traits::StorageInfo>,
|
||||
) {
|
||||
use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList};
|
||||
use frame_support::traits::StorageInfoTrait;
|
||||
|
||||
let mut list = Vec::<BenchmarkList>::new();
|
||||
|
||||
list_benchmark!(list, extra, runtime_parachains::disputes, ParasDisputes);
|
||||
|
||||
let storage_info = AllPalletsWithSystem::storage_info();
|
||||
|
||||
return (list, storage_info)
|
||||
}
|
||||
|
||||
fn dispatch_benchmark(
|
||||
config: frame_benchmarking::BenchmarkConfig,
|
||||
) -> Result<
|
||||
Vec<frame_benchmarking::BenchmarkBatch>,
|
||||
sp_runtime::RuntimeString,
|
||||
> {
|
||||
use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};
|
||||
|
||||
let mut batches = Vec::<BenchmarkBatch>::new();
|
||||
let whitelist: Vec<TrackedStorageKey> = vec![
|
||||
// Block Number
|
||||
hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(),
|
||||
// Total Issuance
|
||||
hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(),
|
||||
// Execution Phase
|
||||
hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),
|
||||
// Event Count
|
||||
hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),
|
||||
// System Events
|
||||
hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),
|
||||
];
|
||||
let params = (&config, &whitelist);
|
||||
|
||||
add_benchmark!(params, batches, runtime_parachains::disputes, ParasDisputes);
|
||||
|
||||
if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }
|
||||
Ok(batches)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
pub mod runtime_parachains_disputes;
|
||||
@@ -0,0 +1,52 @@
|
||||
// Copyright 2017-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/>.
|
||||
//! Autogenerated weights for `runtime_parachains::disputes`
|
||||
//!
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
|
||||
//! DATE: 2021-09-23, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 128
|
||||
|
||||
// Executed Command:
|
||||
// target/release/polkadot
|
||||
// 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
|
||||
|
||||
|
||||
#![cfg_attr(rustfmt, rustfmt_skip)]
|
||||
#![allow(unused_parens)]
|
||||
#![allow(unused_imports)]
|
||||
|
||||
use frame_support::{traits::Get, weights::Weight};
|
||||
use sp_std::marker::PhantomData;
|
||||
|
||||
/// Weight functions for `runtime_parachains::disputes`.
|
||||
pub struct WeightInfo<T>(PhantomData<T>);
|
||||
impl<T: frame_system::Config> runtime_parachains::disputes::WeightInfo for WeightInfo<T> {
|
||||
// Storage: ParasDisputes Frozen (r:0 w:1)
|
||||
fn force_unfreeze() -> Weight {
|
||||
(2_022_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
}
|
||||
@@ -472,6 +472,7 @@ impl parachains_disputes::Config for Runtime {
|
||||
type Event = Event;
|
||||
type RewardValidators = ();
|
||||
type PunishValidators = ();
|
||||
type WeightInfo = parachains_disputes::TestWeightInfo;
|
||||
}
|
||||
|
||||
impl parachains_paras_inherent::Config for Runtime {}
|
||||
|
||||
Reference in New Issue
Block a user