From aae3ad42946bd047b9bd8d9822f288902009f695 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Sat, 8 Oct 2022 17:39:35 +0200 Subject: [PATCH 01/20] Move fill_block to RootOffences --- Cargo.lock | 5 +++-- bin/node/executor/Cargo.toml | 1 + bin/node/executor/tests/fees.rs | 4 ++-- bin/node/runtime/Cargo.toml | 4 ++++ bin/node/runtime/src/lib.rs | 6 ++++++ frame/root-offences/Cargo.toml | 5 ++--- frame/root-offences/src/lib.rs | 20 ++++++++++++++++++++ frame/system/src/lib.rs | 20 +------------------- 8 files changed, 39 insertions(+), 26 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 49b3dd3cf957b..8306135f67df4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3387,6 +3387,7 @@ dependencies = [ "pallet-recovery", "pallet-referenda", "pallet-remark", + "pallet-root-offences", "pallet-scheduler", "pallet-session", "pallet-session-benchmarking", @@ -4747,6 +4748,7 @@ dependencies = [ "pallet-balances", "pallet-contracts", "pallet-im-online", + "pallet-root-offences", "pallet-sudo", "pallet-timestamp", "pallet-transaction-payment", @@ -6147,13 +6149,12 @@ dependencies = [ [[package]] name = "pallet-root-offences" -version = "1.0.0" +version = "1.0.0-dev" dependencies = [ "frame-election-provider-support", "frame-support", "frame-system", "pallet-balances", - "pallet-offences", "pallet-session", "pallet-staking", "pallet-staking-reward-curve", diff --git a/bin/node/executor/Cargo.toml b/bin/node/executor/Cargo.toml index 651e4657dde32..1ec25c94b37ea 100644 --- a/bin/node/executor/Cargo.toml +++ b/bin/node/executor/Cargo.toml @@ -38,6 +38,7 @@ pallet-sudo = { version = "4.0.0-dev", path = "../../../frame/sudo" } pallet-timestamp = { version = "4.0.0-dev", path = "../../../frame/timestamp" } pallet-treasury = { version = "4.0.0-dev", path = "../../../frame/treasury" } pallet-transaction-payment = { version = "4.0.0-dev", path = "../../../frame/transaction-payment" } +pallet-root-offences = { version = "1.0.0-dev", path = "../../../frame/root-offences" } sp-application-crypto = { version = "6.0.0", path = "../../../primitives/application-crypto" } sp-consensus-babe = { version = "0.10.0-dev", path = "../../../primitives/consensus/babe" } sp-externalities = { version = "0.12.0", path = "../../../primitives/externalities" } diff --git a/bin/node/executor/tests/fees.rs b/bin/node/executor/tests/fees.rs index 6932cb2cea867..29b141faa4aa0 100644 --- a/bin/node/executor/tests/fees.rs +++ b/bin/node/executor/tests/fees.rs @@ -60,9 +60,9 @@ fn fee_multiplier_increases_and_decreases_on_big_weight() { CheckedExtrinsic { signed: Some((charlie(), signed_extra(0, 0))), function: RuntimeCall::Sudo(pallet_sudo::Call::sudo { - call: Box::new(RuntimeCall::System(frame_system::Call::fill_block { + call: RuntimeCall::RootOffences(pallet_root_offences::Call::fill_block { ratio: Perbill::from_percent(60), - })), + }), }), }, ], diff --git a/bin/node/runtime/Cargo.toml b/bin/node/runtime/Cargo.toml index 6940e968e28e7..12c5251e3211d 100644 --- a/bin/node/runtime/Cargo.toml +++ b/bin/node/runtime/Cargo.toml @@ -89,6 +89,7 @@ pallet-ranked-collective = { version = "4.0.0-dev", default-features = false, pa pallet-recovery = { version = "4.0.0-dev", default-features = false, path = "../../../frame/recovery" } pallet-referenda = { version = "4.0.0-dev", default-features = false, path = "../../../frame/referenda" } pallet-remark = { version = "4.0.0-dev", default-features = false, path = "../../../frame/remark" } +pallet-root-offences = { version = "1.0.0-dev", default-features = false, path = "../../../frame/root-offences" } pallet-session = { version = "4.0.0-dev", features = [ "historical" ], path = "../../../frame/session", default-features = false } pallet-session-benchmarking = { version = "4.0.0-dev", path = "../../../frame/session/benchmarking", default-features = false, optional = true } pallet-staking = { version = "4.0.0-dev", default-features = false, path = "../../../frame/staking" } @@ -192,6 +193,7 @@ std = [ "pallet-ranked-collective/std", "pallet-referenda/std", "pallet-remark/std", + "pallet-root-offences/std", "pallet-recovery/std", "pallet-uniques/std", "pallet-vesting/std", @@ -239,6 +241,7 @@ runtime-benchmarks = [ "pallet-referenda/runtime-benchmarks", "pallet-recovery/runtime-benchmarks", "pallet-remark/runtime-benchmarks", + "pallet-root-offences/runtime-benchmarks", "pallet-session-benchmarking/runtime-benchmarks", "pallet-society/runtime-benchmarks", "pallet-staking/runtime-benchmarks", @@ -292,6 +295,7 @@ try-runtime = [ "pallet-recovery/try-runtime", "pallet-referenda/try-runtime", "pallet-remark/try-runtime", + "pallet-root-offences/try-runtime", "pallet-session/try-runtime", "pallet-staking/try-runtime", "pallet-state-trie-migration/try-runtime", diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 34f6988c31643..6834504420cbf 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -902,6 +902,10 @@ impl pallet_remark::Config for Runtime { type RuntimeEvent = RuntimeEvent; } +impl pallet_root_offences::Config for Runtime { + type RuntimeEvent = RuntimeEvent; +} + parameter_types! { pub const LaunchPeriod: BlockNumber = 28 * 24 * 60 * MINUTES; pub const VotingPeriod: BlockNumber = 28 * 24 * 60 * MINUTES; @@ -1659,6 +1663,7 @@ construct_runtime!( ChildBounties: pallet_child_bounties, Referenda: pallet_referenda, Remark: pallet_remark, + RootOffences: pallet_root_offences, ConvictionVoting: pallet_conviction_voting, Whitelist: pallet_whitelist, AllianceMotion: pallet_collective::, @@ -1771,6 +1776,7 @@ mod benches { [pallet_referenda, Referenda] [pallet_recovery, Recovery] [pallet_remark, Remark] + [pallet_root_offences, RootOffences] [pallet_scheduler, Scheduler] [pallet_session, SessionBench::] [pallet_staking, Staking] diff --git a/frame/root-offences/Cargo.toml b/frame/root-offences/Cargo.toml index ea6a6527848aa..01dc82589379d 100644 --- a/frame/root-offences/Cargo.toml +++ b/frame/root-offences/Cargo.toml @@ -1,12 +1,13 @@ [package] name = "pallet-root-offences" -version = "1.0.0" +version = "1.0.0-dev" authors = ["Parity Technologies "] edition = "2021" license = "Apache-2.0" homepage = "https://substrate.io" repository = "https://github.com/paritytech/substrate/" description = "FRAME root offences pallet" +readme = "README.md" [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] @@ -17,7 +18,6 @@ scale-info = { version = "2.1.1", default-features = false, features = ["derive" pallet-session = { version = "4.0.0-dev", features = [ "historical" ], path = "../../frame/session", default-features = false } pallet-staking = { version = "4.0.0-dev", default-features = false, path = "../../frame/staking" } -pallet-offences = { version = "4.0.0-dev", default-features = false, path = "../../frame/offences" } frame-support = { version = "4.0.0-dev", default-features = false, path = "../support" } frame-system = { version = "4.0.0-dev", default-features = false, path = "../system" } @@ -45,7 +45,6 @@ std = [ "frame-system/std", "pallet-session/std", "pallet-staking/std", - "pallet-offences/std", "scale-info/std", "sp-runtime/std", ] diff --git a/frame/root-offences/src/lib.rs b/frame/root-offences/src/lib.rs index b4b549627f3fa..91be232674418 100644 --- a/frame/root-offences/src/lib.rs +++ b/frame/root-offences/src/lib.rs @@ -27,6 +27,8 @@ mod mock; #[cfg(test)] mod tests; +use frame_support::dispatch::DispatchErrorWithPostInfo; +use frame_system::WeightInfo; use pallet_session::historical::IdentificationTuple; use pallet_staking::{BalanceOf, Exposure, ExposureOf, Pallet as Staking}; use sp_runtime::Perbill; @@ -96,6 +98,24 @@ pub mod pallet { Self::deposit_event(Event::OffenceCreated { offenders }); Ok(()) } + + /// A dispatch that will fill the block weight up to the given ratio. + #[pallet::weight(*_ratio * T::BlockWeights::get().max_block)] + pub fn fill_block(origin: OriginFor, _ratio: Perbill) -> DispatchResultWithPostInfo { + match ensure_root(origin) { + Ok(_) => Ok(().into()), + Err(_) => { + // roughly same as a 4 byte remark since perbill is u32. + Err(DispatchErrorWithPostInfo { + post_info: Some(::SystemWeightInfo::remark( + 4u32, + )) + .into(), + error: DispatchError::BadOrigin, + }) + }, + } + } } impl Pallet { diff --git a/frame/system/src/lib.rs b/frame/system/src/lib.rs index 7577d0dc6b158..477ebb97fbd95 100644 --- a/frame/system/src/lib.rs +++ b/frame/system/src/lib.rs @@ -75,7 +75,7 @@ use sp_runtime::{ CheckEqual, Dispatchable, Hash, Lookup, LookupError, MaybeDisplay, MaybeMallocSizeOf, MaybeSerializeDeserialize, Member, One, Saturating, SimpleBitOps, StaticLookup, Zero, }, - DispatchError, Perbill, RuntimeDebug, + DispatchError, RuntimeDebug, }; #[cfg(any(feature = "std", test))] use sp_std::map; @@ -197,7 +197,6 @@ impl, MaxOverflow: Get> ConsumerLimits for (MaxNormal, pub mod pallet { use crate::{self as frame_system, pallet_prelude::*, *}; use frame_support::pallet_prelude::*; - use sp_runtime::DispatchErrorWithPostInfo; /// System configuration trait. Implemented by runtime. #[pallet::config] @@ -370,23 +369,6 @@ pub mod pallet { #[pallet::call] impl Pallet { - /// A dispatch that will fill the block weight up to the given ratio. - // TODO: This should only be available for testing, rather than in general usage, but - // that's not possible at present (since it's within the pallet macro). - #[pallet::weight(*_ratio * T::BlockWeights::get().max_block)] - pub fn fill_block(origin: OriginFor, _ratio: Perbill) -> DispatchResultWithPostInfo { - match ensure_root(origin) { - Ok(_) => Ok(().into()), - Err(_) => { - // roughly same as a 4 byte remark since perbill is u32. - Err(DispatchErrorWithPostInfo { - post_info: Some(T::SystemWeightInfo::remark(4u32)).into(), - error: DispatchError::BadOrigin, - }) - }, - } - } - /// Make some on-chain remark. /// /// # From fae1f2ffff9b906ef802f032588d509683fe031b Mon Sep 17 00:00:00 2001 From: Szegoo Date: Sat, 8 Oct 2022 17:43:25 +0200 Subject: [PATCH 02/20] docs --- frame/root-offences/README.md | 2 +- frame/root-offences/src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frame/root-offences/README.md b/frame/root-offences/README.md index a2c5261b6985a..c582158721816 100644 --- a/frame/root-offences/README.md +++ b/frame/root-offences/README.md @@ -1,4 +1,4 @@ -# Sudo Offences Pallet +# Root Offences Pallet Pallet that allows the root to create an offence. diff --git a/frame/root-offences/src/lib.rs b/frame/root-offences/src/lib.rs index 91be232674418..1614f4f6e3d7a 100644 --- a/frame/root-offences/src/lib.rs +++ b/frame/root-offences/src/lib.rs @@ -15,7 +15,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -//! # Sudo Offences Pallet +//! # Root Offences Pallet //! Pallet that allows the root to create an offence. //! //! NOTE: This pallet should be used for testing purposes. From 450b02f64ac022e570ba96369d80380d4ee0dda2 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Mon, 24 Oct 2022 19:06:50 +0200 Subject: [PATCH 03/20] new pallet --- Cargo.lock | 16 +++++++- Cargo.toml | 1 + bin/node/executor/Cargo.toml | 2 +- bin/node/executor/tests/fees.rs | 2 +- bin/node/runtime/Cargo.toml | 8 ++-- bin/node/runtime/src/lib.rs | 6 +-- frame/root-offences/src/lib.rs | 20 --------- frame/root-testing/Cargo.toml | 35 ++++++++++++++++ frame/root-testing/src/lib.rs | 72 +++++++++++++++++++++++++++++++++ frame/utility/Cargo.toml | 1 + frame/utility/src/tests.rs | 12 +++++- 11 files changed, 142 insertions(+), 33 deletions(-) create mode 100644 frame/root-testing/Cargo.toml create mode 100644 frame/root-testing/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 8306135f67df4..5571aa558aed9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3387,7 +3387,7 @@ dependencies = [ "pallet-recovery", "pallet-referenda", "pallet-remark", - "pallet-root-offences", + "pallet-root-testing", "pallet-scheduler", "pallet-session", "pallet-session-benchmarking", @@ -4748,7 +4748,7 @@ dependencies = [ "pallet-balances", "pallet-contracts", "pallet-im-online", - "pallet-root-offences", + "pallet-root-testing", "pallet-sudo", "pallet-timestamp", "pallet-transaction-payment", @@ -6168,6 +6168,17 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-root-testing" +version = "1.0.0-dev" +dependencies = [ + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "sp-runtime", +] + [[package]] name = "pallet-scheduler" version = "4.0.0-dev" @@ -6506,6 +6517,7 @@ dependencies = [ "frame-support", "frame-system", "pallet-balances", + "pallet-root-testing", "parity-scale-codec", "scale-info", "sp-core", diff --git a/Cargo.toml b/Cargo.toml index e203cbbee7e0d..e05bff47aeeb0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -135,6 +135,7 @@ members = [ "frame/state-trie-migration", "frame/sudo", "frame/root-offences", + "frame/root-testing", "frame/support", "frame/support/procedural", "frame/support/procedural/tools", diff --git a/bin/node/executor/Cargo.toml b/bin/node/executor/Cargo.toml index 1ec25c94b37ea..681eb79f0d224 100644 --- a/bin/node/executor/Cargo.toml +++ b/bin/node/executor/Cargo.toml @@ -38,7 +38,7 @@ pallet-sudo = { version = "4.0.0-dev", path = "../../../frame/sudo" } pallet-timestamp = { version = "4.0.0-dev", path = "../../../frame/timestamp" } pallet-treasury = { version = "4.0.0-dev", path = "../../../frame/treasury" } pallet-transaction-payment = { version = "4.0.0-dev", path = "../../../frame/transaction-payment" } -pallet-root-offences = { version = "1.0.0-dev", path = "../../../frame/root-offences" } +pallet-root-testing = { version = "1.0.0-dev", path = "../../../frame/root-testing" } sp-application-crypto = { version = "6.0.0", path = "../../../primitives/application-crypto" } sp-consensus-babe = { version = "0.10.0-dev", path = "../../../primitives/consensus/babe" } sp-externalities = { version = "0.12.0", path = "../../../primitives/externalities" } diff --git a/bin/node/executor/tests/fees.rs b/bin/node/executor/tests/fees.rs index 29b141faa4aa0..6186b84263738 100644 --- a/bin/node/executor/tests/fees.rs +++ b/bin/node/executor/tests/fees.rs @@ -60,7 +60,7 @@ fn fee_multiplier_increases_and_decreases_on_big_weight() { CheckedExtrinsic { signed: Some((charlie(), signed_extra(0, 0))), function: RuntimeCall::Sudo(pallet_sudo::Call::sudo { - call: RuntimeCall::RootOffences(pallet_root_offences::Call::fill_block { + call: RuntimeCall::RootOffences(pallet_root_testing::Call::fill_block { ratio: Perbill::from_percent(60), }), }), diff --git a/bin/node/runtime/Cargo.toml b/bin/node/runtime/Cargo.toml index 12c5251e3211d..bd56f32b0883d 100644 --- a/bin/node/runtime/Cargo.toml +++ b/bin/node/runtime/Cargo.toml @@ -89,7 +89,7 @@ pallet-ranked-collective = { version = "4.0.0-dev", default-features = false, pa pallet-recovery = { version = "4.0.0-dev", default-features = false, path = "../../../frame/recovery" } pallet-referenda = { version = "4.0.0-dev", default-features = false, path = "../../../frame/referenda" } pallet-remark = { version = "4.0.0-dev", default-features = false, path = "../../../frame/remark" } -pallet-root-offences = { version = "1.0.0-dev", default-features = false, path = "../../../frame/root-offences" } +pallet-root-testing = { version = "1.0.0-dev", default-features = false, path = "../../../frame/root-testing" } pallet-session = { version = "4.0.0-dev", features = [ "historical" ], path = "../../../frame/session", default-features = false } pallet-session-benchmarking = { version = "4.0.0-dev", path = "../../../frame/session/benchmarking", default-features = false, optional = true } pallet-staking = { version = "4.0.0-dev", default-features = false, path = "../../../frame/staking" } @@ -193,7 +193,7 @@ std = [ "pallet-ranked-collective/std", "pallet-referenda/std", "pallet-remark/std", - "pallet-root-offences/std", + "pallet-root-testing/std", "pallet-recovery/std", "pallet-uniques/std", "pallet-vesting/std", @@ -241,7 +241,7 @@ runtime-benchmarks = [ "pallet-referenda/runtime-benchmarks", "pallet-recovery/runtime-benchmarks", "pallet-remark/runtime-benchmarks", - "pallet-root-offences/runtime-benchmarks", + "pallet-root-testing/runtime-benchmarks", "pallet-session-benchmarking/runtime-benchmarks", "pallet-society/runtime-benchmarks", "pallet-staking/runtime-benchmarks", @@ -295,7 +295,7 @@ try-runtime = [ "pallet-recovery/try-runtime", "pallet-referenda/try-runtime", "pallet-remark/try-runtime", - "pallet-root-offences/try-runtime", + "pallet-root-testing/try-runtime", "pallet-session/try-runtime", "pallet-staking/try-runtime", "pallet-state-trie-migration/try-runtime", diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 6834504420cbf..8b051bb8015aa 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -902,7 +902,7 @@ impl pallet_remark::Config for Runtime { type RuntimeEvent = RuntimeEvent; } -impl pallet_root_offences::Config for Runtime { +impl pallet_root_testing::Config for Runtime { type RuntimeEvent = RuntimeEvent; } @@ -1663,7 +1663,7 @@ construct_runtime!( ChildBounties: pallet_child_bounties, Referenda: pallet_referenda, Remark: pallet_remark, - RootOffences: pallet_root_offences, + RootTesting: pallet_root_testing, ConvictionVoting: pallet_conviction_voting, Whitelist: pallet_whitelist, AllianceMotion: pallet_collective::, @@ -1776,7 +1776,7 @@ mod benches { [pallet_referenda, Referenda] [pallet_recovery, Recovery] [pallet_remark, Remark] - [pallet_root_offences, RootOffences] + [pallet_root_testing, RootTesting] [pallet_scheduler, Scheduler] [pallet_session, SessionBench::] [pallet_staking, Staking] diff --git a/frame/root-offences/src/lib.rs b/frame/root-offences/src/lib.rs index 1614f4f6e3d7a..298fe0078a6a6 100644 --- a/frame/root-offences/src/lib.rs +++ b/frame/root-offences/src/lib.rs @@ -27,8 +27,6 @@ mod mock; #[cfg(test)] mod tests; -use frame_support::dispatch::DispatchErrorWithPostInfo; -use frame_system::WeightInfo; use pallet_session::historical::IdentificationTuple; use pallet_staking::{BalanceOf, Exposure, ExposureOf, Pallet as Staking}; use sp_runtime::Perbill; @@ -98,24 +96,6 @@ pub mod pallet { Self::deposit_event(Event::OffenceCreated { offenders }); Ok(()) } - - /// A dispatch that will fill the block weight up to the given ratio. - #[pallet::weight(*_ratio * T::BlockWeights::get().max_block)] - pub fn fill_block(origin: OriginFor, _ratio: Perbill) -> DispatchResultWithPostInfo { - match ensure_root(origin) { - Ok(_) => Ok(().into()), - Err(_) => { - // roughly same as a 4 byte remark since perbill is u32. - Err(DispatchErrorWithPostInfo { - post_info: Some(::SystemWeightInfo::remark( - 4u32, - )) - .into(), - error: DispatchError::BadOrigin, - }) - }, - } - } } impl Pallet { diff --git a/frame/root-testing/Cargo.toml b/frame/root-testing/Cargo.toml new file mode 100644 index 0000000000000..06f3f32aef9e3 --- /dev/null +++ b/frame/root-testing/Cargo.toml @@ -0,0 +1,35 @@ +[package] +name = "pallet-root-testing" +version = "1.0.0-dev" +authors = ["Parity Technologies "] +edition = "2021" +license = "Apache-2.0" +homepage = "https://substrate.io" +repository = "https://github.com/paritytech/substrate/" +description = "FRAME root testing pallet" +readme = "README.md" + +[package.metadata.docs.rs] +targets = ["x86_64-unknown-linux-gnu"] + +[dependencies] +codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } + +frame-support = { version = "4.0.0-dev", default-features = false, path = "../support" } +frame-system = { version = "4.0.0-dev", default-features = false, path = "../system" } +sp-runtime = { version = "6.0.0", path = "../../primitives/runtime" } + +[dev-dependencies] + +[features] +runtime-benchmarks = [] +try-runtime = ["frame-support/try-runtime"] +default = ["std"] +std = [ + "codec/std", + "frame-support/std", + "frame-system/std", + "scale-info/std", + "sp-runtime/std", +] \ No newline at end of file diff --git a/frame/root-testing/src/lib.rs b/frame/root-testing/src/lib.rs new file mode 100644 index 0000000000000..95a9d5c2c19fe --- /dev/null +++ b/frame/root-testing/src/lib.rs @@ -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. + +//! # Root Testing Pallet +//! Pallet that contains extrinsics that can be usefull in testing. +//! +//! NOTE: This pallet should only be used for testing purposes. + +#![cfg_attr(not(feature = "std"), no_std)] + +use frame_support::dispatch::DispatchErrorWithPostInfo; +use frame_system::WeightInfo; +use sp_runtime::Perbill; + +pub use pallet::*; + +#[frame_support::pallet] +pub mod pallet { + use super::*; + use frame_support::pallet_prelude::*; + use frame_system::pallet_prelude::*; + + #[pallet::config] + pub trait Config: frame_system::Config { + type RuntimeEvent: From> + IsType<::RuntimeEvent>; + } + + #[pallet::pallet] + #[pallet::generate_store(pub(super) trait Store)] + pub struct Pallet(_); + + #[pallet::event] + pub enum Event {} + + #[pallet::error] + pub enum Error {} + + #[pallet::call] + impl Pallet { + /// A dispatch that will fill the block weight up to the given ratio. + #[pallet::weight(*_ratio * T::BlockWeights::get().max_block)] + pub fn fill_block(origin: OriginFor, _ratio: Perbill) -> DispatchResultWithPostInfo { + match ensure_root(origin) { + Ok(_) => Ok(().into()), + Err(_) => { + // roughly same as a 4 byte remark since perbill is u32. + Err(DispatchErrorWithPostInfo { + post_info: Some(::SystemWeightInfo::remark( + 4u32, + )) + .into(), + error: DispatchError::BadOrigin, + }) + }, + } + } + } +} diff --git a/frame/utility/Cargo.toml b/frame/utility/Cargo.toml index cbe2892d72dc7..4afb316132415 100644 --- a/frame/utility/Cargo.toml +++ b/frame/utility/Cargo.toml @@ -25,6 +25,7 @@ sp-std = { version = "4.0.0", default-features = false, path = "../../primitives [dev-dependencies] pallet-balances = { version = "4.0.0-dev", path = "../balances" } +pallet-root-testing = { version = "1.0.0-dev", path = "../root-testing" } sp-core = { version = "6.0.0", path = "../../primitives/core" } [features] diff --git a/frame/utility/src/tests.rs b/frame/utility/src/tests.rs index ebd8dda81adbc..c4320aa70334a 100644 --- a/frame/utility/src/tests.rs +++ b/frame/utility/src/tests.rs @@ -93,6 +93,7 @@ frame_support::construct_runtime!( { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, + RootTesting: pallet_root_testing::{Pallet, Call, Storage, Event}, Utility: utility::{Pallet, Call, Event}, Example: example::{Pallet, Call}, } @@ -140,6 +141,11 @@ impl pallet_balances::Config for Test { type AccountStore = System; type WeightInfo = (); } + +impl pallet_root_testing::Config for Test { + type RuntimeEvent = RuntimeEvent; +} + parameter_types! { pub const MultisigDepositBase: u64 = 1; pub const MultisigDepositFactor: u64 = 1; @@ -175,6 +181,7 @@ type UtilityCall = crate::Call; use frame_system::Call as SystemCall; use pallet_balances::{Call as BalancesCall, Error as BalancesError}; +use pallet_root_testing::Call as RootTestingCall; pub fn new_test_ext() -> sp_io::TestExternalities { let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); @@ -388,8 +395,9 @@ fn batch_early_exit_works() { fn batch_weight_calculation_doesnt_overflow() { use sp_runtime::Perbill; new_test_ext().execute_with(|| { - let big_call = - RuntimeCall::System(SystemCall::fill_block { ratio: Perbill::from_percent(50) }); + let big_call = RuntimeCall::RootTesting(RootTestingCall::fill_block { + ratio: Perbill::from_percent(50), + }); assert_eq!(big_call.get_dispatch_info().weight, Weight::MAX / 2); // 3 * 50% saturates to 100% From dd5be153e60ebf6db57bd5171305f8dc140a2a98 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Mon, 24 Oct 2022 19:08:19 +0200 Subject: [PATCH 04/20] new line --- frame/root-testing/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/root-testing/Cargo.toml b/frame/root-testing/Cargo.toml index 06f3f32aef9e3..66116a22509d1 100644 --- a/frame/root-testing/Cargo.toml +++ b/frame/root-testing/Cargo.toml @@ -32,4 +32,4 @@ std = [ "frame-system/std", "scale-info/std", "sp-runtime/std", -] \ No newline at end of file +] From 85de51fa25b76bff43410fd70b5a87a6dc0c0c70 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Mon, 24 Oct 2022 19:24:22 +0200 Subject: [PATCH 05/20] fix --- frame/system/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/system/src/lib.rs b/frame/system/src/lib.rs index 477ebb97fbd95..308c14a3d4ffb 100644 --- a/frame/system/src/lib.rs +++ b/frame/system/src/lib.rs @@ -75,7 +75,7 @@ use sp_runtime::{ CheckEqual, Dispatchable, Hash, Lookup, LookupError, MaybeDisplay, MaybeMallocSizeOf, MaybeSerializeDeserialize, Member, One, Saturating, SimpleBitOps, StaticLookup, Zero, }, - DispatchError, RuntimeDebug, + DispatchError, Perbill, RuntimeDebug, }; #[cfg(any(feature = "std", test))] use sp_std::map; From 796b0213401953fecbf860d5dffb0000adcc348b Mon Sep 17 00:00:00 2001 From: Sergej Sakac <73715684+Szegoo@users.noreply.github.com> Date: Tue, 25 Oct 2022 15:50:06 +0200 Subject: [PATCH 06/20] Update frame/root-testing/src/lib.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bastian Köcher --- frame/root-testing/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/frame/root-testing/src/lib.rs b/frame/root-testing/src/lib.rs index 95a9d5c2c19fe..aed4a43c1436e 100644 --- a/frame/root-testing/src/lib.rs +++ b/frame/root-testing/src/lib.rs @@ -16,6 +16,7 @@ // limitations under the License. //! # Root Testing Pallet +//! //! Pallet that contains extrinsics that can be usefull in testing. //! //! NOTE: This pallet should only be used for testing purposes. From 6dc43719cdc14c4cd35872313b0f9b7ac497c6d3 Mon Sep 17 00:00:00 2001 From: Sergej Sakac <73715684+Szegoo@users.noreply.github.com> Date: Tue, 25 Oct 2022 15:50:21 +0200 Subject: [PATCH 07/20] Update frame/root-testing/src/lib.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bastian Köcher --- frame/root-testing/src/lib.rs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/frame/root-testing/src/lib.rs b/frame/root-testing/src/lib.rs index aed4a43c1436e..cd41b3468a238 100644 --- a/frame/root-testing/src/lib.rs +++ b/frame/root-testing/src/lib.rs @@ -44,12 +44,6 @@ pub mod pallet { #[pallet::generate_store(pub(super) trait Store)] pub struct Pallet(_); - #[pallet::event] - pub enum Event {} - - #[pallet::error] - pub enum Error {} - #[pallet::call] impl Pallet { /// A dispatch that will fill the block weight up to the given ratio. From 10654bc82ba81922c1697db50c93e72cf9c55050 Mon Sep 17 00:00:00 2001 From: Sergej Sakac <73715684+Szegoo@users.noreply.github.com> Date: Tue, 25 Oct 2022 15:50:55 +0200 Subject: [PATCH 08/20] Update bin/node/runtime/src/lib.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bastian Köcher --- bin/node/runtime/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 4745e47ac3a6b..ea33ea4d4e093 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -1779,7 +1779,6 @@ mod benches { [pallet_referenda, Referenda] [pallet_recovery, Recovery] [pallet_remark, Remark] - [pallet_root_testing, RootTesting] [pallet_scheduler, Scheduler] [pallet_session, SessionBench::] [pallet_staking, Staking] From afb0518ba3b8b942676327e6b684a94630b701ef Mon Sep 17 00:00:00 2001 From: Sergej Sakac <73715684+Szegoo@users.noreply.github.com> Date: Tue, 25 Oct 2022 15:51:25 +0200 Subject: [PATCH 09/20] Update frame/root-testing/src/lib.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bastian Köcher --- frame/root-testing/src/lib.rs | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/frame/root-testing/src/lib.rs b/frame/root-testing/src/lib.rs index cd41b3468a238..cad941e90440f 100644 --- a/frame/root-testing/src/lib.rs +++ b/frame/root-testing/src/lib.rs @@ -49,19 +49,7 @@ pub mod pallet { /// A dispatch that will fill the block weight up to the given ratio. #[pallet::weight(*_ratio * T::BlockWeights::get().max_block)] pub fn fill_block(origin: OriginFor, _ratio: Perbill) -> DispatchResultWithPostInfo { - match ensure_root(origin) { - Ok(_) => Ok(().into()), - Err(_) => { - // roughly same as a 4 byte remark since perbill is u32. - Err(DispatchErrorWithPostInfo { - post_info: Some(::SystemWeightInfo::remark( - 4u32, - )) - .into(), - error: DispatchError::BadOrigin, - }) - }, - } + ensure_root(origin) } } } From b8e7c21ba8e81b31ef6b59f65383998a030eb1df Mon Sep 17 00:00:00 2001 From: Sergej Sakac <73715684+Szegoo@users.noreply.github.com> Date: Tue, 25 Oct 2022 15:51:39 +0200 Subject: [PATCH 10/20] Update frame/root-testing/src/lib.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bastian Köcher --- frame/root-testing/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/root-testing/src/lib.rs b/frame/root-testing/src/lib.rs index cad941e90440f..be7163f69b6bc 100644 --- a/frame/root-testing/src/lib.rs +++ b/frame/root-testing/src/lib.rs @@ -19,7 +19,7 @@ //! //! Pallet that contains extrinsics that can be usefull in testing. //! -//! NOTE: This pallet should only be used for testing purposes. +//! NOTE: This pallet should only be used for testing purposes and should not be used in production runtimes! #![cfg_attr(not(feature = "std"), no_std)] From 346070b3d07239ca658e2cc7293be49a8871da34 Mon Sep 17 00:00:00 2001 From: Sergej Sakac <73715684+Szegoo@users.noreply.github.com> Date: Tue, 25 Oct 2022 15:51:54 +0200 Subject: [PATCH 11/20] Update frame/root-testing/src/lib.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bastian Köcher --- frame/root-testing/src/lib.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/frame/root-testing/src/lib.rs b/frame/root-testing/src/lib.rs index be7163f69b6bc..2a5cd7ef7bcea 100644 --- a/frame/root-testing/src/lib.rs +++ b/frame/root-testing/src/lib.rs @@ -36,9 +36,7 @@ pub mod pallet { use frame_system::pallet_prelude::*; #[pallet::config] - pub trait Config: frame_system::Config { - type RuntimeEvent: From> + IsType<::RuntimeEvent>; - } + pub trait Config: frame_system::Config {} #[pallet::pallet] #[pallet::generate_store(pub(super) trait Store)] From f7ca099dd170f182a82a76dbbc13c4c03d6ad18f Mon Sep 17 00:00:00 2001 From: Szegoo Date: Tue, 25 Oct 2022 16:22:02 +0200 Subject: [PATCH 12/20] fixes --- Cargo.lock | 1 - bin/node/runtime/Cargo.toml | 1 - frame/root-testing/Cargo.toml | 1 - frame/root-testing/src/lib.rs | 11 ++++++----- frame/system/src/lib.rs | 2 +- 5 files changed, 7 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 149d34643a3e9..61a75f008e8d6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5996,7 +5996,6 @@ version = "1.0.0-dev" dependencies = [ "frame-support", "frame-system", - "parity-scale-codec", "scale-info", "sp-runtime", ] diff --git a/bin/node/runtime/Cargo.toml b/bin/node/runtime/Cargo.toml index 143fed616a078..c45d468c59616 100644 --- a/bin/node/runtime/Cargo.toml +++ b/bin/node/runtime/Cargo.toml @@ -241,7 +241,6 @@ runtime-benchmarks = [ "pallet-referenda/runtime-benchmarks", "pallet-recovery/runtime-benchmarks", "pallet-remark/runtime-benchmarks", - "pallet-root-testing/runtime-benchmarks", "pallet-session-benchmarking/runtime-benchmarks", "pallet-society/runtime-benchmarks", "pallet-staking/runtime-benchmarks", diff --git a/frame/root-testing/Cargo.toml b/frame/root-testing/Cargo.toml index 66116a22509d1..2d8f8071b6b1e 100644 --- a/frame/root-testing/Cargo.toml +++ b/frame/root-testing/Cargo.toml @@ -23,7 +23,6 @@ sp-runtime = { version = "6.0.0", path = "../../primitives/runtime" } [dev-dependencies] [features] -runtime-benchmarks = [] try-runtime = ["frame-support/try-runtime"] default = ["std"] std = [ diff --git a/frame/root-testing/src/lib.rs b/frame/root-testing/src/lib.rs index 2a5cd7ef7bcea..25d66cfac202d 100644 --- a/frame/root-testing/src/lib.rs +++ b/frame/root-testing/src/lib.rs @@ -19,12 +19,12 @@ //! //! Pallet that contains extrinsics that can be usefull in testing. //! -//! NOTE: This pallet should only be used for testing purposes and should not be used in production runtimes! +//! NOTE: This pallet should only be used for testing purposes and should not be used in production +//! runtimes! #![cfg_attr(not(feature = "std"), no_std)] -use frame_support::dispatch::DispatchErrorWithPostInfo; -use frame_system::WeightInfo; +use frame_support::dispatch::DispatchResult; use sp_runtime::Perbill; pub use pallet::*; @@ -46,8 +46,9 @@ pub mod pallet { impl Pallet { /// A dispatch that will fill the block weight up to the given ratio. #[pallet::weight(*_ratio * T::BlockWeights::get().max_block)] - pub fn fill_block(origin: OriginFor, _ratio: Perbill) -> DispatchResultWithPostInfo { - ensure_root(origin) + pub fn fill_block(origin: OriginFor, _ratio: Perbill) -> DispatchResult { + ensure_root(origin)?; + Ok(()) } } } diff --git a/frame/system/src/lib.rs b/frame/system/src/lib.rs index 308c14a3d4ffb..477ebb97fbd95 100644 --- a/frame/system/src/lib.rs +++ b/frame/system/src/lib.rs @@ -75,7 +75,7 @@ use sp_runtime::{ CheckEqual, Dispatchable, Hash, Lookup, LookupError, MaybeDisplay, MaybeMallocSizeOf, MaybeSerializeDeserialize, Member, One, Saturating, SimpleBitOps, StaticLookup, Zero, }, - DispatchError, Perbill, RuntimeDebug, + DispatchError, RuntimeDebug, }; #[cfg(any(feature = "std", test))] use sp_std::map; From 76c01ec79dc76f0ce6a08797a8872bc06fc904c6 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Tue, 25 Oct 2022 21:53:48 +0200 Subject: [PATCH 13/20] problem solved --- Cargo.lock | 1 + bin/node/runtime/Cargo.toml | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index f633f13fb0075..3f1c999b30f8e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5996,6 +5996,7 @@ version = "1.0.0-dev" dependencies = [ "frame-support", "frame-system", + "parity-scale-codec", "scale-info", "sp-runtime", ] diff --git a/bin/node/runtime/Cargo.toml b/bin/node/runtime/Cargo.toml index c45d468c59616..fcef7efc8a41c 100644 --- a/bin/node/runtime/Cargo.toml +++ b/bin/node/runtime/Cargo.toml @@ -89,7 +89,6 @@ pallet-ranked-collective = { version = "4.0.0-dev", default-features = false, pa pallet-recovery = { version = "4.0.0-dev", default-features = false, path = "../../../frame/recovery" } pallet-referenda = { version = "4.0.0-dev", default-features = false, path = "../../../frame/referenda" } pallet-remark = { version = "4.0.0-dev", default-features = false, path = "../../../frame/remark" } -pallet-root-testing = { version = "1.0.0-dev", default-features = false, path = "../../../frame/root-testing" } pallet-session = { version = "4.0.0-dev", features = [ "historical" ], path = "../../../frame/session", default-features = false } pallet-session-benchmarking = { version = "4.0.0-dev", path = "../../../frame/session/benchmarking", default-features = false, optional = true } pallet-staking = { version = "4.0.0-dev", default-features = false, path = "../../../frame/staking" } @@ -113,6 +112,9 @@ pallet-whitelist = { version = "4.0.0-dev", default-features = false, path = ".. [build-dependencies] substrate-wasm-builder = { version = "5.0.0-dev", path = "../../../utils/wasm-builder" } +[dev-dependencies] +pallet-root-testing = { version = "1.0.0-dev", default-features = false, path = "../../../frame/root-testing" } + [features] default = ["std"] with-tracing = ["frame-executive/with-tracing"] From 97cd12c3c73a3637635c4353caf52928f9bce877 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Tue, 25 Oct 2022 21:59:10 +0200 Subject: [PATCH 14/20] revert --- bin/node/runtime/Cargo.toml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/bin/node/runtime/Cargo.toml b/bin/node/runtime/Cargo.toml index fcef7efc8a41c..c45d468c59616 100644 --- a/bin/node/runtime/Cargo.toml +++ b/bin/node/runtime/Cargo.toml @@ -89,6 +89,7 @@ pallet-ranked-collective = { version = "4.0.0-dev", default-features = false, pa pallet-recovery = { version = "4.0.0-dev", default-features = false, path = "../../../frame/recovery" } pallet-referenda = { version = "4.0.0-dev", default-features = false, path = "../../../frame/referenda" } pallet-remark = { version = "4.0.0-dev", default-features = false, path = "../../../frame/remark" } +pallet-root-testing = { version = "1.0.0-dev", default-features = false, path = "../../../frame/root-testing" } pallet-session = { version = "4.0.0-dev", features = [ "historical" ], path = "../../../frame/session", default-features = false } pallet-session-benchmarking = { version = "4.0.0-dev", path = "../../../frame/session/benchmarking", default-features = false, optional = true } pallet-staking = { version = "4.0.0-dev", default-features = false, path = "../../../frame/staking" } @@ -112,9 +113,6 @@ pallet-whitelist = { version = "4.0.0-dev", default-features = false, path = ".. [build-dependencies] substrate-wasm-builder = { version = "5.0.0-dev", path = "../../../utils/wasm-builder" } -[dev-dependencies] -pallet-root-testing = { version = "1.0.0-dev", default-features = false, path = "../../../frame/root-testing" } - [features] default = ["std"] with-tracing = ["frame-executive/with-tracing"] From 667b5dac319856f15e5b61200c8d2e5b5b05d4f4 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Wed, 26 Oct 2022 14:22:19 +0200 Subject: [PATCH 15/20] fix dependency --- bin/node/runtime/src/lib.rs | 4 +--- frame/root-offences/Cargo.toml | 2 +- frame/root-testing/Cargo.toml | 2 +- frame/root-testing/README.md | 5 +++++ frame/utility/src/tests.rs | 4 +--- 5 files changed, 9 insertions(+), 8 deletions(-) create mode 100644 frame/root-testing/README.md diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index fff8a66297708..182c5c2e408ac 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -902,9 +902,7 @@ impl pallet_remark::Config for Runtime { type RuntimeEvent = RuntimeEvent; } -impl pallet_root_testing::Config for Runtime { - type RuntimeEvent = RuntimeEvent; -} +impl pallet_root_testing::Config for Runtime {} parameter_types! { pub const LaunchPeriod: BlockNumber = 28 * 24 * 60 * MINUTES; diff --git a/frame/root-offences/Cargo.toml b/frame/root-offences/Cargo.toml index 01dc82589379d..a205fc4aa6ca7 100644 --- a/frame/root-offences/Cargo.toml +++ b/frame/root-offences/Cargo.toml @@ -21,7 +21,7 @@ pallet-staking = { version = "4.0.0-dev", default-features = false, path = "../. frame-support = { version = "4.0.0-dev", default-features = false, path = "../support" } frame-system = { version = "4.0.0-dev", default-features = false, path = "../system" } -sp-runtime = { version = "6.0.0", path = "../../primitives/runtime" } +sp-runtime = { version = "6.0.0", default-features = false, path = "../../primitives/runtime" } sp-staking = { version = "4.0.0-dev", default-features = false, path = "../../primitives/staking" } [dev-dependencies] diff --git a/frame/root-testing/Cargo.toml b/frame/root-testing/Cargo.toml index 2d8f8071b6b1e..c625d640bc289 100644 --- a/frame/root-testing/Cargo.toml +++ b/frame/root-testing/Cargo.toml @@ -18,7 +18,7 @@ scale-info = { version = "2.1.1", default-features = false, features = ["derive" frame-support = { version = "4.0.0-dev", default-features = false, path = "../support" } frame-system = { version = "4.0.0-dev", default-features = false, path = "../system" } -sp-runtime = { version = "6.0.0", path = "../../primitives/runtime" } +sp-runtime = { version = "6.0.0", default-features = false, path = "../../primitives/runtime" } [dev-dependencies] diff --git a/frame/root-testing/README.md b/frame/root-testing/README.md new file mode 100644 index 0000000000000..637430445a22f --- /dev/null +++ b/frame/root-testing/README.md @@ -0,0 +1,5 @@ +# Root Testing Pallet + +Pallet that contains extrinsics that can be usefull in testing. + +NOTE: This pallet should only be used for testing purposes and should not be used in production runtimes! \ No newline at end of file diff --git a/frame/utility/src/tests.rs b/frame/utility/src/tests.rs index e0c060d8201f9..f65c0094a32d5 100644 --- a/frame/utility/src/tests.rs +++ b/frame/utility/src/tests.rs @@ -142,9 +142,7 @@ impl pallet_balances::Config for Test { type WeightInfo = (); } -impl pallet_root_testing::Config for Test { - type RuntimeEvent = RuntimeEvent; -} +impl pallet_root_testing::Config for Test {} parameter_types! { pub const MultisigDepositBase: u64 = 1; From 5c46effc27fb509f984d272cafeedf437e3947df Mon Sep 17 00:00:00 2001 From: Szegoo Date: Wed, 26 Oct 2022 15:03:28 +0200 Subject: [PATCH 16/20] hopefully making the CI happy --- bin/node/executor/tests/fees.rs | 6 +++--- frame/utility/src/tests.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/node/executor/tests/fees.rs b/bin/node/executor/tests/fees.rs index 6186b84263738..3c696d595040b 100644 --- a/bin/node/executor/tests/fees.rs +++ b/bin/node/executor/tests/fees.rs @@ -60,9 +60,9 @@ fn fee_multiplier_increases_and_decreases_on_big_weight() { CheckedExtrinsic { signed: Some((charlie(), signed_extra(0, 0))), function: RuntimeCall::Sudo(pallet_sudo::Call::sudo { - call: RuntimeCall::RootOffences(pallet_root_testing::Call::fill_block { - ratio: Perbill::from_percent(60), - }), + call: Box::new(RuntimeCall::RootTesting( + pallet_root_testing::Call::fill_block { ratio: Perbill::from_percent(60) }, + )), }), }, ], diff --git a/frame/utility/src/tests.rs b/frame/utility/src/tests.rs index f65c0094a32d5..3355880384c3d 100644 --- a/frame/utility/src/tests.rs +++ b/frame/utility/src/tests.rs @@ -93,7 +93,7 @@ frame_support::construct_runtime!( { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, - RootTesting: pallet_root_testing::{Pallet, Call, Storage, Event}, + RootTesting: pallet_root_testing::{Pallet, Call, Storage}, Utility: utility::{Pallet, Call, Event}, Example: example::{Pallet, Call}, } From 6356478d577c272dcb4c19737de3c21e045f4f6f Mon Sep 17 00:00:00 2001 From: Szegoo Date: Wed, 26 Oct 2022 15:10:35 +0200 Subject: [PATCH 17/20] ... --- frame/system/src/mock.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/system/src/mock.rs b/frame/system/src/mock.rs index d31a1b08667e5..fb230f66a94f7 100644 --- a/frame/system/src/mock.rs +++ b/frame/system/src/mock.rs @@ -24,7 +24,7 @@ use sp_core::H256; use sp_runtime::{ testing::Header, traits::{BlakeTwo256, IdentityLookup}, - BuildStorage, + BuildStorage, Perbill, }; type UncheckedExtrinsic = mocking::MockUncheckedExtrinsic; From a52b05eddf7f4b6743f278f9e306985b1f300a8a Mon Sep 17 00:00:00 2001 From: Szegoo Date: Tue, 8 Nov 2022 12:22:41 +0100 Subject: [PATCH 18/20] dummy call --- frame/system/src/lib.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/frame/system/src/lib.rs b/frame/system/src/lib.rs index 477ebb97fbd95..3dde4b6b4d218 100644 --- a/frame/system/src/lib.rs +++ b/frame/system/src/lib.rs @@ -75,7 +75,7 @@ use sp_runtime::{ CheckEqual, Dispatchable, Hash, Lookup, LookupError, MaybeDisplay, MaybeMallocSizeOf, MaybeSerializeDeserialize, Member, One, Saturating, SimpleBitOps, StaticLookup, Zero, }, - DispatchError, RuntimeDebug, + DispatchError, Perbill, RuntimeDebug, }; #[cfg(any(feature = "std", test))] use sp_std::map; @@ -369,6 +369,13 @@ pub mod pallet { #[pallet::call] impl Pallet { + /// Do not use. + #[pallet::weight(T::BlockWeights::get().max_block)] + pub fn removed_call_do_not_use(origin: OriginFor, _ratio: Perbill) -> DispatchResult { + ensure_signed_or_root(origin)?; + Ok(()) + } + /// Make some on-chain remark. /// /// # From 62e4f83dc9a580ef012a3cc7e03d3a8c90e724f2 Mon Sep 17 00:00:00 2001 From: Sergej Sakac Date: Sat, 12 Nov 2022 14:43:23 +0100 Subject: [PATCH 19/20] remove dummy --- frame/system/src/lib.rs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/frame/system/src/lib.rs b/frame/system/src/lib.rs index 3dde4b6b4d218..308c14a3d4ffb 100644 --- a/frame/system/src/lib.rs +++ b/frame/system/src/lib.rs @@ -369,13 +369,6 @@ pub mod pallet { #[pallet::call] impl Pallet { - /// Do not use. - #[pallet::weight(T::BlockWeights::get().max_block)] - pub fn removed_call_do_not_use(origin: OriginFor, _ratio: Perbill) -> DispatchResult { - ensure_signed_or_root(origin)?; - Ok(()) - } - /// Make some on-chain remark. /// /// # From 370f46ef852c80585a6f1268b89ed91caebeea09 Mon Sep 17 00:00:00 2001 From: Sergej Sakac Date: Sat, 12 Nov 2022 15:22:02 +0100 Subject: [PATCH 20/20] fix warning --- frame/system/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/system/src/lib.rs b/frame/system/src/lib.rs index 308c14a3d4ffb..477ebb97fbd95 100644 --- a/frame/system/src/lib.rs +++ b/frame/system/src/lib.rs @@ -75,7 +75,7 @@ use sp_runtime::{ CheckEqual, Dispatchable, Hash, Lookup, LookupError, MaybeDisplay, MaybeMallocSizeOf, MaybeSerializeDeserialize, Member, One, Saturating, SimpleBitOps, StaticLookup, Zero, }, - DispatchError, Perbill, RuntimeDebug, + DispatchError, RuntimeDebug, }; #[cfg(any(feature = "std", test))] use sp_std::map;