-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
183 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,48 @@ | ||
[package] | ||
name = "pallet-motion" | ||
version = "4.0.0-dev" | ||
description = "A pallet for dispatching as sudo from collective origins" | ||
authors = ["Substrate DevHub <https://github.com/substrate-developer-hub>"] | ||
homepage = "https://substrate.io" | ||
description = "A pallet for dispatching as sudo from collective origins" | ||
edition = "2021" | ||
homepage = "https://substrate.io" | ||
license = "Unlicense" | ||
name = "pallet-motion" | ||
publish = false | ||
version = "4.0.0-dev" | ||
|
||
[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", | ||
] } | ||
log = { version = "0.4.17", default-features = false } | ||
scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } | ||
frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" } | ||
frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42" } | ||
frame-system = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42" } | ||
sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42" } | ||
sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42" } | ||
codec = {package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [ | ||
"derive", | ||
]} | ||
frame-benchmarking = {version = "4.0.0-dev", default-features = false, optional = true, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42"} | ||
frame-support = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} | ||
frame-system = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} | ||
log = {version = "0.4.17", default-features = false} | ||
pallet-collective = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} | ||
scale-info = {version = "2.5.0", default-features = false, features = ["derive"]} | ||
sp-runtime = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} | ||
sp-std = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} | ||
|
||
[dev-dependencies] | ||
sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42" } | ||
sp-io = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42" } | ||
pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42" } | ||
pallet-collective = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42" } | ||
pallet-membership = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42" } | ||
pallet-balances = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} | ||
pallet-membership = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} | ||
sp-core = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} | ||
sp-io = {git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.42"} | ||
|
||
[features] | ||
default = ["std"] | ||
runtime-benchmarks = [ | ||
"frame-benchmarking/runtime-benchmarks", | ||
"pallet-collective/runtime-benchmarks", | ||
] | ||
std = [ | ||
"codec/std", | ||
"frame-benchmarking?/std", | ||
"frame-support/std", | ||
"frame-system/std", | ||
"scale-info/std", | ||
"sp-std/std", | ||
"codec/std", | ||
"frame-benchmarking?/std", | ||
"frame-support/std", | ||
"frame-system/std", | ||
"scale-info/std", | ||
"sp-std/std", | ||
"pallet-collective/std", | ||
] | ||
runtime-benchmarks = ["frame-benchmarking/runtime-benchmarks"] | ||
try-runtime = ["frame-support/try-runtime"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#![cfg(feature = "runtime-benchmarks")] | ||
|
||
use super::*; | ||
#[allow(unused)] | ||
use crate::Pallet as Motion; | ||
use frame_benchmarking::v2::*; | ||
use frame_support::traits::EnsureOrigin; | ||
|
||
fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) { | ||
frame_system::Pallet::<T>::assert_last_event(generic_event.into()); | ||
} | ||
|
||
#[benchmarks( | ||
where | ||
<T as Config>::RuntimeCall: From<frame_system::Call<T>>, | ||
)] | ||
mod benchmarks { | ||
use super::*; | ||
|
||
#[benchmark] | ||
fn simple_majority() { | ||
let call: <T as Config>::RuntimeCall = frame_system::Call::remark { remark: vec![] }.into(); | ||
let origin = <T as Config>::SimpleMajorityOrigin::try_successful_origin().unwrap(); | ||
#[extrinsic_call] | ||
_(origin as T::RuntimeOrigin, Box::new(call)); | ||
|
||
assert_last_event::<T>(Event::DispatchSimpleMajority { motion_result: Ok(()) }.into()) | ||
} | ||
|
||
#[benchmark] | ||
fn super_majority() { | ||
let call: <T as Config>::RuntimeCall = frame_system::Call::remark { remark: vec![] }.into(); | ||
let origin = <T as Config>::SuperMajorityOrigin::try_successful_origin().unwrap(); | ||
#[extrinsic_call] | ||
_(origin as T::RuntimeOrigin, Box::new(call)); | ||
|
||
assert_last_event::<T>(Event::DispatchSuperMajority { motion_result: Ok(()) }.into()) | ||
} | ||
|
||
#[benchmark] | ||
fn unanimous() { | ||
let call: <T as Config>::RuntimeCall = frame_system::Call::remark { remark: vec![] }.into(); | ||
let origin = <T as Config>::UnanimousOrigin::try_successful_origin().unwrap(); | ||
#[extrinsic_call] | ||
_(origin as T::RuntimeOrigin, Box::new(call)); | ||
|
||
assert_last_event::<T>(Event::DispatchUnanimous { motion_result: Ok(()) }.into()) | ||
} | ||
impl_benchmark_test_suite!(Motion, crate::mock::new_test_ext(), crate::mock::Test); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
|
||
//! Autogenerated weights for pallet_motion | ||
//! | ||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev | ||
//! DATE: 2023-07-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` | ||
//! WORST CASE MAP SIZE: `1000000` | ||
//! HOSTNAME: `PAR03043`, CPU: `<UNKNOWN>` | ||
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 | ||
// Executed Command: | ||
// target/release/parachain-template-node | ||
// benchmark | ||
// pallet | ||
// --chain=dev | ||
// --execution=wasm | ||
// --wasm-execution=compiled | ||
// --pallet=pallet_motion | ||
// --extrinsic=* | ||
// --steps=50 | ||
// --repeat=20 | ||
// --json | ||
// --template | ||
// scripts/frame-weight-template.hbs | ||
// --output=./pallets/motion/src/weights.rs | ||
|
||
#![cfg_attr(rustfmt, rustfmt_skip)] | ||
#![allow(unused_parens)] | ||
#![allow(unused_imports)] | ||
#![allow(missing_docs)] | ||
|
||
use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; | ||
use core::marker::PhantomData; | ||
|
||
/// Weight functions needed for pallet_motion. | ||
pub trait WeightInfo { | ||
fn simple_majority() -> Weight; | ||
fn super_majority() -> Weight; | ||
fn unanimous() -> Weight; | ||
} | ||
|
||
/// Weights for pallet_motion using the Substrate node and recommended hardware. | ||
pub struct SubstrateWeight<T>(PhantomData<T>); | ||
impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> { | ||
fn simple_majority() -> Weight { | ||
// Proof Size summary in bytes: | ||
// Measured: `0` | ||
// Estimated: `0` | ||
// Minimum execution time: 7_000_000 picoseconds. | ||
Weight::from_parts(8_000_000, 0) | ||
} | ||
fn super_majority() -> Weight { | ||
// Proof Size summary in bytes: | ||
// Measured: `0` | ||
// Estimated: `0` | ||
// Minimum execution time: 7_000_000 picoseconds. | ||
Weight::from_parts(8_000_000, 0) | ||
} | ||
fn unanimous() -> Weight { | ||
// Proof Size summary in bytes: | ||
// Measured: `0` | ||
// Estimated: `0` | ||
// Minimum execution time: 7_000_000 picoseconds. | ||
Weight::from_parts(8_000_000, 0) | ||
} | ||
} | ||
|
||
// For backwards compatibility and tests | ||
impl WeightInfo for () { | ||
fn simple_majority() -> Weight { | ||
// Proof Size summary in bytes: | ||
// Measured: `0` | ||
// Estimated: `0` | ||
// Minimum execution time: 7_000_000 picoseconds. | ||
Weight::from_parts(8_000_000, 0) | ||
} | ||
fn super_majority() -> Weight { | ||
// Proof Size summary in bytes: | ||
// Measured: `0` | ||
// Estimated: `0` | ||
// Minimum execution time: 7_000_000 picoseconds. | ||
Weight::from_parts(8_000_000, 0) | ||
} | ||
fn unanimous() -> Weight { | ||
// Proof Size summary in bytes: | ||
// Measured: `0` | ||
// Estimated: `0` | ||
// Minimum execution time: 7_000_000 picoseconds. | ||
Weight::from_parts(8_000_000, 0) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters