diff --git a/Cargo.lock b/Cargo.lock index ebdbe57..7516019 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2305,7 +2305,6 @@ dependencies = [ "pallet-collator-selection", "pallet-collective", "pallet-identity", - "pallet-motion", "pallet-multisig", "pallet-nft-fractionalization", "pallet-nfts", @@ -5126,7 +5125,6 @@ dependencies = [ "pallet-collator-selection", "pallet-collective", "pallet-identity", - "pallet-motion", "pallet-multisig", "pallet-nft-fractionalization", "pallet-nfts", @@ -6390,25 +6388,6 @@ dependencies = [ "sp-std", ] -[[package]] -name = "pallet-motion" -version = "4.0.0-dev" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "pallet-balances", - "pallet-collective", - "pallet-membership", - "parity-scale-codec", - "scale-info", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", -] - [[package]] name = "pallet-multisig" version = "4.0.0-dev" diff --git a/Cargo.toml b/Cargo.toml index a14351d..a26b96e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,6 @@ repository = "https://github.com/Metaquity-Network/metaquity-network-node" [workspace] members = [ "node", - "pallets/*", "runtime/mainnet", "runtime/devnet", ] diff --git a/pallets/motion/Cargo.toml b/pallets/motion/Cargo.toml deleted file mode 100644 index 2f6480f..0000000 --- a/pallets/motion/Cargo.toml +++ /dev/null @@ -1,49 +0,0 @@ -[package] -name = "pallet-motion" -version = "4.0.0-dev" -description = "FRAME pallet to wrap council calls providing root origin to the council." -authors = ["Substrate DevHub "] -homepage = "https://substrate.io" -edition.workspace = true -license = "Unlicense" -publish = false - -[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.git", branch = "polkadot-v1.0.0" } -frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" } -frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" } -sp-std = { version = "8.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" } -sp-runtime = { version = "24.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" } -pallet-collective = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0" } - -[dev-dependencies] -sp-core = { version = "21.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" } -sp-io = { version = "23.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v1.0.0" } -pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0" } -pallet-membership = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0" } - -[features] -default = ["std"] -std = [ - "codec/std", - "frame-benchmarking?/std", - "frame-support/std", - "frame-system/std", - "scale-info/std", - "sp-std/std", - "pallet-collective/std", - "pallet-balances/std", -] -runtime-benchmarks = [ - "frame-benchmarking/runtime-benchmarks", - "pallet-collective/runtime-benchmarks", -] -try-runtime = ["frame-support/try-runtime"] diff --git a/pallets/motion/README.md b/pallets/motion/README.md deleted file mode 100644 index fa00788..0000000 --- a/pallets/motion/README.md +++ /dev/null @@ -1,32 +0,0 @@ -# Motion Pallet - -`pallet-motion` enables councils (`pallet-collective`) to make root-origin calls by providing three configurable origins: - - `SimpleMajority` (1/2) - - `SuperMajority` (2/3) - - `Unanimous` (1/1) - -It is composed of three associated extrinsics, one for each origin: -- `simple_majority` - - Dispatches the call if and only if the number of votes is greater than `SimpleMajority`. -- `super_majority` - - Dispatches the call if and only if the number of votes is greater than or equal to `SuperMajority`. -- `unanimous` - - Dispatches the call if and only if all collective members have voted yes. - - -## Configuration - -You can configure `pallet-motion` in combination with `pallet-collective` the following way: - -```rust -type CouncilCollective = pallet_collective::Instance1; -impl pallet_motion::Config for Runtime { - // --- - type SimpleMajorityOrigin = - pallet_collective::EnsureProportionMoreThan; - type SuperMajorityOrigin = - pallet_collective::EnsureProportionAtLeast; - type UnanimousOrigin = - pallet_collective::EnsureProportionAtLeast; -} -``` diff --git a/pallets/motion/src/benchmarking.rs b/pallets/motion/src/benchmarking.rs deleted file mode 100644 index b79a29e..0000000 --- a/pallets/motion/src/benchmarking.rs +++ /dev/null @@ -1,50 +0,0 @@ -#![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(generic_event: ::RuntimeEvent) { - frame_system::Pallet::::assert_last_event(generic_event.into()); -} - -#[benchmarks( -where - ::RuntimeCall: From>, -)] -mod benchmarks { - use super::*; - - #[benchmark] - fn simple_majority() { - let call: ::RuntimeCall = frame_system::Call::remark { remark: vec![] }.into(); - let origin = ::SimpleMajorityOrigin::try_successful_origin().unwrap(); - #[extrinsic_call] - _(origin as T::RuntimeOrigin, Box::new(call)); - - assert_last_event::(Event::DispatchSimpleMajority { motion_result: Ok(()) }.into()) - } - - #[benchmark] - fn super_majority() { - let call: ::RuntimeCall = frame_system::Call::remark { remark: vec![] }.into(); - let origin = ::SuperMajorityOrigin::try_successful_origin().unwrap(); - #[extrinsic_call] - _(origin as T::RuntimeOrigin, Box::new(call)); - - assert_last_event::(Event::DispatchSuperMajority { motion_result: Ok(()) }.into()) - } - - #[benchmark] - fn unanimous() { - let call: ::RuntimeCall = frame_system::Call::remark { remark: vec![] }.into(); - let origin = ::UnanimousOrigin::try_successful_origin().unwrap(); - #[extrinsic_call] - _(origin as T::RuntimeOrigin, Box::new(call)); - - assert_last_event::(Event::DispatchUnanimous { motion_result: Ok(()) }.into()) - } - impl_benchmark_test_suite!(Motion, crate::mock::new_test_ext(), crate::mock::Test); -} diff --git a/pallets/motion/src/lib.rs b/pallets/motion/src/lib.rs deleted file mode 100644 index 5597c12..0000000 --- a/pallets/motion/src/lib.rs +++ /dev/null @@ -1,148 +0,0 @@ -#![cfg_attr(not(feature = "std"), no_std)] - -#[cfg(test)] -mod mock; -#[cfg(test)] -mod tests; - -#[cfg(feature = "runtime-benchmarks")] -mod benchmarking; - -pub mod weights; -pub use weights::WeightInfo; - -use sp_runtime::DispatchResult; -use sp_std::prelude::*; - -pub use pallet::*; - -#[frame_support::pallet] -pub mod pallet { - use super::{DispatchResult, *}; - use frame_support::pallet_prelude::*; - use frame_system::pallet_prelude::*; - - use frame_support::{dispatch::GetDispatchInfo, traits::UnfilteredDispatchable}; - - #[pallet::pallet] - pub struct Pallet(_); - - #[pallet::config] - pub trait Config: frame_system::Config { - type RuntimeEvent: From> + IsType<::RuntimeEvent>; - - type RuntimeCall: Parameter - + UnfilteredDispatchable - + GetDispatchInfo; - - type SimpleMajorityOrigin: EnsureOrigin; - type SuperMajorityOrigin: EnsureOrigin; - type UnanimousOrigin: EnsureOrigin; - /// Type representing the weight of this pallet - type WeightInfo: WeightInfo; - } - - #[pallet::event] - #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event { - /// A SimpleMajority motion was executed. motion_result contains the call result - DispatchSimpleMajority { motion_result: DispatchResult }, - /// A SuperMajority motion was executed. motion_result contains the call result - DispatchSuperMajority { motion_result: DispatchResult }, - /// A Unanimous motion was executed. motion_result contains the call result - DispatchUnanimous { motion_result: DispatchResult }, - } - - #[pallet::error] - pub enum Error {} - - #[pallet::call] - impl Pallet { - /// Ensures the simple majority is met and dispatches a call with `Root` origin. - /// - /// # - /// - O(1). - /// - Limited storage reads. - /// - One DB write (event). - /// - Weight of derivative `call` execution + 10,000. - /// # - #[pallet::weight({ - let dispatch_info = call.get_dispatch_info(); - (T::WeightInfo::simple_majority().saturating_add(dispatch_info.weight), dispatch_info.class) - })] - #[pallet::call_index(1)] - pub fn simple_majority( - origin: OriginFor, - call: Box<::RuntimeCall>, - ) -> DispatchResultWithPostInfo { - T::SimpleMajorityOrigin::ensure_origin(origin)?; - - let motion_result = Self::do_dispatch(*call); - Self::deposit_event(Event::DispatchSimpleMajority { motion_result }); - - Ok(Pays::No.into()) - } - - /// Ensures the super majority is met and dispatches a call with `Root` origin. - /// - /// # - /// - O(1). - /// - Limited storage reads. - /// - One DB write (event). - /// - Weight of derivative `call` execution + 10,000. - /// # - #[pallet::weight({ - let dispatch_info = call.get_dispatch_info(); - (T::WeightInfo::super_majority().saturating_add(dispatch_info.weight), dispatch_info.class) - })] - #[pallet::call_index(2)] - pub fn super_majority( - origin: OriginFor, - call: Box<::RuntimeCall>, - ) -> DispatchResultWithPostInfo { - T::SuperMajorityOrigin::ensure_origin(origin)?; - - let motion_result = Self::do_dispatch(*call); - Self::deposit_event(Event::DispatchSuperMajority { motion_result }); - - Ok(Pays::No.into()) - } - - /// Ensures unanimous voting is met and dispatches a call with `Root` origin. - /// - /// # - /// - O(1). - /// - Limited storage reads. - /// - One DB write (event). - /// - Weight of derivative `call` execution + 10,000. - /// # - #[pallet::weight({ - let dispatch_info = call.get_dispatch_info(); - (T::WeightInfo::unanimous().saturating_add(dispatch_info.weight), dispatch_info.class) - })] - #[pallet::call_index(3)] - pub fn unanimous( - origin: OriginFor, - call: Box<::RuntimeCall>, - ) -> DispatchResultWithPostInfo { - T::UnanimousOrigin::ensure_origin(origin)?; - - let motion_result = Self::do_dispatch(*call); - Self::deposit_event(Event::DispatchUnanimous { motion_result }); - - Ok(Pays::No.into()) - } - } - - impl Pallet { - /// Helper to actually dispatch RuntimeCall. - /// - /// Should only be called after the origin is ensured. - /// - /// Returns the `DispatchResult` from the dispatched call. - fn do_dispatch(call: ::RuntimeCall) -> DispatchResult { - let res = call.dispatch_bypass_filter(frame_system::RawOrigin::Root.into()); - res.map(|_| ()).map_err(|e| e.error) - } - } -} diff --git a/pallets/motion/src/mock.rs b/pallets/motion/src/mock.rs deleted file mode 100644 index ebff802..0000000 --- a/pallets/motion/src/mock.rs +++ /dev/null @@ -1,122 +0,0 @@ -use super::*; -pub(crate) use crate as pallet_motion; -use frame_support::{ - parameter_types, - traits::{ConstU16, ConstU32, ConstU64}, - weights::Weight, -}; -use frame_system::limits::BlockWeights; -use sp_core::H256; -use sp_runtime::{ - traits::{BlakeTwo256, IdentityLookup}, - BuildStorage, Perbill, -}; - -type Block = frame_system::mocking::MockBlock; - -parameter_types! { - pub RuntimeBlockWeights: BlockWeights = BlockWeights::default(); -} - -// Configure a mock runtime to test the pallet. -frame_support::construct_runtime!( - pub struct Test { - System: frame_system::{Pallet, Call, Event}, - - Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, - Council: pallet_collective::::{Pallet, Call, Storage, Origin, Event, Config}, - Motion: pallet_motion, - } -); - -impl frame_system::Config for Test { - type RuntimeEvent = RuntimeEvent; - type BaseCallFilter = frame_support::traits::Everything; - type BlockWeights = (); - type BlockLength = (); - type RuntimeOrigin = RuntimeOrigin; - type RuntimeCall = RuntimeCall; - type Nonce = u64; - type Hash = H256; - type Hashing = BlakeTwo256; - type AccountId = u64; - type Lookup = IdentityLookup; - type Block = Block; - type BlockHashCount = ConstU64<250>; - type DbWeight = (); - type Version = (); - type PalletInfo = PalletInfo; - type AccountData = pallet_balances::AccountData; - type OnNewAccount = (); - type OnKilledAccount = (); - type SystemWeightInfo = (); - type SS58Prefix = ConstU16<42>; - type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; -} - -impl pallet_balances::Config for Test { - type RuntimeEvent = RuntimeEvent; - type WeightInfo = (); - type Balance = u64; - type DustRemoval = (); - type ExistentialDeposit = ConstU64<1>; - type AccountStore = System; - type ReserveIdentifier = [u8; 8]; - type RuntimeHoldReason = (); - type FreezeIdentifier = (); - type MaxLocks = (); - type MaxReserves = (); - type MaxHolds = ConstU32<0>; - type MaxFreezes = ConstU32<0>; -} - -parameter_types! { - pub CouncilMotionDuration: u64 = 7; - pub const CouncilMaxProposals: u32 = 100; - pub const CouncilMaxMembers: u32 = 100; - pub MaxProposalWeight: Weight = Perbill::from_percent(50) * RuntimeBlockWeights::get().max_block; -} - -pub type CouncilCollective = pallet_collective::Instance1; -impl pallet_collective::Config for Test { - type RuntimeOrigin = RuntimeOrigin; - type Proposal = RuntimeCall; - type RuntimeEvent = RuntimeEvent; - type MotionDuration = CouncilMotionDuration; - type MaxProposals = CouncilMaxProposals; - type MaxMembers = CouncilMaxMembers; - type DefaultVote = pallet_collective::PrimeDefaultVote; - type WeightInfo = (); - type SetMembersOrigin = frame_system::EnsureRoot; - type MaxProposalWeight = MaxProposalWeight; -} - -impl pallet_motion::Config for Test { - type RuntimeEvent = RuntimeEvent; - type RuntimeCall = RuntimeCall; - type SimpleMajorityOrigin = - pallet_collective::EnsureProportionAtLeast; - type SuperMajorityOrigin = - pallet_collective::EnsureProportionAtLeast; - type UnanimousOrigin = pallet_collective::EnsureProportionAtLeast; - type WeightInfo = (); -} - -// Build genesis storage according to the mock runtime. -pub fn new_test_ext() -> sp_io::TestExternalities { - let mut ext: sp_io::TestExternalities = RuntimeGenesisConfig { - balances: pallet_balances::GenesisConfig:: { - balances: vec![(1, 10), (2, 20), (3, 30), (4, 40), (5, 50)], - }, - council: pallet_collective::GenesisConfig { - members: vec![1, 2, 3, 4], - phantom: Default::default(), - }, - } - .build_storage() - .unwrap() - .into(); - ext.execute_with(|| System::set_block_number(1)); - ext -} diff --git a/pallets/motion/src/tests.rs b/pallets/motion/src/tests.rs deleted file mode 100644 index b824b3b..0000000 --- a/pallets/motion/src/tests.rs +++ /dev/null @@ -1,436 +0,0 @@ -use super::*; -use crate as pallet_motion; -use crate::{mock::*, Event as MotionEvent}; -use codec::Encode; -use frame_support::{assert_ok, dispatch::GetDispatchInfo, weights::Weight}; -use frame_system::{EventRecord, Phase}; -use mock::{RuntimeCall, RuntimeEvent}; -use pallet_collective::Event as CollectiveEvent; -use sp_core::H256; -use sp_runtime::traits::{BlakeTwo256, Hash}; - -fn record(event: RuntimeEvent) -> EventRecord { - EventRecord { phase: Phase::Initialization, event, topics: vec![] } -} - -struct Proposal { - len: u32, - weight: Weight, - hash: H256, -} - -enum MotionType { - SimpleMajority, - SuperMajority, - Unanimous, -} - -// sets up collective proposal with `threshold` and `motion_type`. -fn setup_proposal(threshold: u32, motion_type: MotionType) -> Proposal { - //Inner call (requires sudo). Will be wrapped by pallet_motion. - let inner_call = - RuntimeCall::Balances(pallet_balances::Call::force_set_balance { who: 5, new_free: 5 }); - - // Setup motion with specified origin type - let motion = match motion_type { - MotionType::SimpleMajority => { - RuntimeCall::Motion(pallet_motion::Call::simple_majority { call: Box::new(inner_call) }) - }, - MotionType::SuperMajority => { - RuntimeCall::Motion(pallet_motion::Call::super_majority { call: Box::new(inner_call) }) - }, - MotionType::Unanimous => { - RuntimeCall::Motion(pallet_motion::Call::unanimous { call: Box::new(inner_call) }) - }, - }; - - let proposal_len: u32 = motion.using_encoded(|p| p.len() as u32); - let proposal_weight = motion.get_dispatch_info().weight; - let hash = BlakeTwo256::hash_of(&motion); - - assert_ok!(Council::propose( - RuntimeOrigin::signed(1), - threshold, - Box::new(motion.clone()), - proposal_len - )); - - Proposal { len: proposal_len, weight: proposal_weight, hash } -} - -#[test] -fn simple_majority_works() { - new_test_ext().execute_with(|| { - let proposal = setup_proposal(2, MotionType::SimpleMajority); - - let hash = proposal.hash; - let proposal_len = proposal.len; - let proposal_weight = proposal.weight; - - assert_ok!(Council::vote(RuntimeOrigin::signed(1), hash, 0, true)); - assert_ok!(Council::vote(RuntimeOrigin::signed(2), hash, 0, true)); - - System::set_block_number(3); - - assert_ok!(Council::close( - RuntimeOrigin::signed(4), - hash, - 0, - proposal_weight, - proposal_len - )); - - assert_eq!( - System::events(), - vec![ - record(RuntimeEvent::Council(CollectiveEvent::Proposed { - account: 1, - proposal_index: 0, - proposal_hash: hash, - threshold: 2 - })), - record(RuntimeEvent::Council(CollectiveEvent::Voted { - account: 1, - proposal_hash: hash, - voted: true, - yes: 1, - no: 0 - })), - record(RuntimeEvent::Council(CollectiveEvent::Voted { - account: 2, - proposal_hash: hash, - voted: true, - yes: 2, - no: 0 - })), - record(RuntimeEvent::Council(CollectiveEvent::Closed { - proposal_hash: hash, - yes: 2, - no: 0 - })), - record(RuntimeEvent::Council(CollectiveEvent::Approved { proposal_hash: hash })), - record(RuntimeEvent::Balances(pallet_balances::Event::BalanceSet { - who: 5, - free: 5, - })), - record(RuntimeEvent::Motion(MotionEvent::DispatchSimpleMajority { - motion_result: Ok(()) - })), - record(RuntimeEvent::Council(CollectiveEvent::Executed { - proposal_hash: hash, - result: Ok(()) - })) - ] - ); - }); -} - -#[test] -fn super_majority_works() { - new_test_ext().execute_with(|| { - let proposal = setup_proposal(3, MotionType::SuperMajority); - - let hash = proposal.hash; - let proposal_len = proposal.len; - let proposal_weight = proposal.weight; - - assert_ok!(Council::vote(RuntimeOrigin::signed(1), hash, 0, true)); - assert_ok!(Council::vote(RuntimeOrigin::signed(2), hash, 0, true)); - assert_ok!(Council::vote(RuntimeOrigin::signed(3), hash, 0, true)); - - System::set_block_number(3); - - assert_ok!(Council::close( - RuntimeOrigin::signed(4), - hash, - 0, - proposal_weight, - proposal_len - )); - - assert_eq!( - System::events(), - vec![ - record(RuntimeEvent::Council(CollectiveEvent::Proposed { - account: 1, - proposal_index: 0, - proposal_hash: hash, - threshold: 3 - })), - record(RuntimeEvent::Council(CollectiveEvent::Voted { - account: 1, - proposal_hash: hash, - voted: true, - yes: 1, - no: 0 - })), - record(RuntimeEvent::Council(CollectiveEvent::Voted { - account: 2, - proposal_hash: hash, - voted: true, - yes: 2, - no: 0 - })), - record(RuntimeEvent::Council(CollectiveEvent::Voted { - account: 3, - proposal_hash: hash, - voted: true, - yes: 3, - no: 0 - })), - record(RuntimeEvent::Council(CollectiveEvent::Closed { - proposal_hash: hash, - yes: 3, - no: 0 - })), - record(RuntimeEvent::Council(CollectiveEvent::Approved { proposal_hash: hash })), - record(RuntimeEvent::Balances(pallet_balances::Event::BalanceSet { - who: 5, - free: 5, - })), - record(RuntimeEvent::Motion(MotionEvent::DispatchSuperMajority { - motion_result: Ok(()) - })), - record(RuntimeEvent::Council(CollectiveEvent::Executed { - proposal_hash: hash, - result: Ok(()) - })) - ] - ); - }); -} - -#[test] -fn unanimous_works() { - new_test_ext().execute_with(|| { - let proposal = setup_proposal(4, MotionType::Unanimous); - - let hash = proposal.hash; - let proposal_len = proposal.len; - let proposal_weight = proposal.weight; - - assert_ok!(Council::vote(RuntimeOrigin::signed(1), hash, 0, true)); - assert_ok!(Council::vote(RuntimeOrigin::signed(2), hash, 0, true)); - assert_ok!(Council::vote(RuntimeOrigin::signed(3), hash, 0, true)); - assert_ok!(Council::vote(RuntimeOrigin::signed(4), hash, 0, true)); - - System::set_block_number(3); - - assert_ok!(Council::close( - RuntimeOrigin::signed(4), - hash, - 0, - proposal_weight, - proposal_len - )); - - assert_eq!( - System::events(), - vec![ - record(RuntimeEvent::Council(CollectiveEvent::Proposed { - account: 1, - proposal_index: 0, - proposal_hash: hash, - threshold: 4 - })), - record(RuntimeEvent::Council(CollectiveEvent::Voted { - account: 1, - proposal_hash: hash, - voted: true, - yes: 1, - no: 0 - })), - record(RuntimeEvent::Council(CollectiveEvent::Voted { - account: 2, - proposal_hash: hash, - voted: true, - yes: 2, - no: 0 - })), - record(RuntimeEvent::Council(CollectiveEvent::Voted { - account: 3, - proposal_hash: hash, - voted: true, - yes: 3, - no: 0 - })), - record(RuntimeEvent::Council(CollectiveEvent::Voted { - account: 4, - proposal_hash: hash, - voted: true, - yes: 4, - no: 0 - })), - record(RuntimeEvent::Council(CollectiveEvent::Closed { - proposal_hash: hash, - yes: 4, - no: 0 - })), - record(RuntimeEvent::Council(CollectiveEvent::Approved { proposal_hash: hash })), - record(RuntimeEvent::Balances(pallet_balances::Event::BalanceSet { - who: 5, - free: 5, - })), - record(RuntimeEvent::Motion(MotionEvent::DispatchUnanimous { - motion_result: Ok(()) - })), - record(RuntimeEvent::Council(CollectiveEvent::Executed { - proposal_hash: hash, - result: Ok(()) - })) - ] - ); - }); -} - -#[test] -fn simple_majority_fails() { - new_test_ext().execute_with(|| { - let threshold = 1; - let proposal = setup_proposal(threshold, MotionType::SimpleMajority); - - let hash = proposal.hash; - - System::set_block_number(3); - - // No votes or closing necessary. A proposal with threshold 1 is automatically executed - - assert_eq!( - System::events(), - vec![record(RuntimeEvent::Council(CollectiveEvent::Executed { - proposal_hash: hash, - result: Err(sp_runtime::DispatchError::BadOrigin) - }))] - ); - }); -} - -#[test] -fn super_majority_fails() { - new_test_ext().execute_with(|| { - let threshold = 2; - let proposal = setup_proposal(threshold, MotionType::SuperMajority); - - let hash = proposal.hash; - let proposal_len = proposal.len; - let proposal_weight = proposal.weight; - - assert_ok!(Council::vote(RuntimeOrigin::signed(1), hash, 0, true)); - assert_ok!(Council::vote(RuntimeOrigin::signed(2), hash, 0, true)); - - System::set_block_number(3); - - assert_ok!(Council::close( - RuntimeOrigin::signed(4), - hash, - 0, - proposal_weight, - proposal_len - )); - - assert_eq!( - System::events(), - vec![ - record(RuntimeEvent::Council(CollectiveEvent::Proposed { - account: 1, - proposal_index: 0, - proposal_hash: hash, - threshold, - })), - record(RuntimeEvent::Council(CollectiveEvent::Voted { - account: 1, - proposal_hash: hash, - voted: true, - yes: 1, - no: 0 - })), - record(RuntimeEvent::Council(CollectiveEvent::Voted { - account: 2, - proposal_hash: hash, - voted: true, - yes: 2, - no: 0 - })), - record(RuntimeEvent::Council(CollectiveEvent::Closed { - proposal_hash: hash, - yes: 2, - no: 0 - })), - record(RuntimeEvent::Council(CollectiveEvent::Approved { proposal_hash: hash })), - record(RuntimeEvent::Council(CollectiveEvent::Executed { - proposal_hash: hash, - result: Err(sp_runtime::DispatchError::BadOrigin) - })) - ] - ); - }); -} - -#[test] -fn unanimous_fails() { - new_test_ext().execute_with(|| { - let threshold = 3; - let proposal = setup_proposal(threshold, MotionType::Unanimous); - - let hash = proposal.hash; - let proposal_len = proposal.len; - let proposal_weight = proposal.weight; - - assert_ok!(Council::vote(RuntimeOrigin::signed(1), hash, 0, true)); - assert_ok!(Council::vote(RuntimeOrigin::signed(2), hash, 0, true)); - assert_ok!(Council::vote(RuntimeOrigin::signed(3), hash, 0, true)); - - System::set_block_number(3); - - assert_ok!(Council::close( - RuntimeOrigin::signed(4), - hash, - 0, - proposal_weight, - proposal_len - )); - - assert_eq!( - System::events(), - vec![ - record(RuntimeEvent::Council(CollectiveEvent::Proposed { - account: 1, - proposal_index: 0, - proposal_hash: hash, - threshold, - })), - record(RuntimeEvent::Council(CollectiveEvent::Voted { - account: 1, - proposal_hash: hash, - voted: true, - yes: 1, - no: 0 - })), - record(RuntimeEvent::Council(CollectiveEvent::Voted { - account: 2, - proposal_hash: hash, - voted: true, - yes: 2, - no: 0 - })), - record(RuntimeEvent::Council(CollectiveEvent::Voted { - account: 3, - proposal_hash: hash, - voted: true, - yes: 3, - no: 0 - })), - record(RuntimeEvent::Council(CollectiveEvent::Closed { - proposal_hash: hash, - yes: 3, - no: 0 - })), - record(RuntimeEvent::Council(CollectiveEvent::Approved { proposal_hash: hash })), - record(RuntimeEvent::Council(CollectiveEvent::Executed { - proposal_hash: hash, - result: Err(sp_runtime::DispatchError::BadOrigin) - })) - ] - ); - }); -} diff --git a/pallets/motion/src/weights.rs b/pallets/motion/src/weights.rs deleted file mode 100755 index 2749568..0000000 --- a/pallets/motion/src/weights.rs +++ /dev/null @@ -1,90 +0,0 @@ - -//! 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: `` -//! 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(PhantomData); -impl WeightInfo for SubstrateWeight { - 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) - } -} diff --git a/runtime/devnet/Cargo.toml b/runtime/devnet/Cargo.toml index 4dd9be6..5911cbb 100644 --- a/runtime/devnet/Cargo.toml +++ b/runtime/devnet/Cargo.toml @@ -26,7 +26,6 @@ scale-info = { version = "2.9.0", default-features = false, features = [ smallvec = "1.11.0" # Local -pallet-motion = { path = "../../pallets/motion", default-features = false } runtime-common = { path = "../common", default-features = false } # Substrate @@ -112,7 +111,6 @@ std = [ "pallet-collective/std", "pallet-collator-selection/std", "pallet-identity/std", - "pallet-motion/std", "pallet-multisig/std", "pallet-nft-fractionalization/std", "pallet-nfts/std", @@ -155,7 +153,6 @@ runtime-benchmarks = [ "pallet-collator-selection/runtime-benchmarks", "pallet-collective/runtime-benchmarks", "pallet-identity/runtime-benchmarks", - "pallet-motion/runtime-benchmarks", "pallet-multisig/runtime-benchmarks", "pallet-nft-fractionalization/runtime-benchmarks", "pallet-nfts/runtime-benchmarks", @@ -184,7 +181,6 @@ try-runtime = [ "pallet-collator-selection/try-runtime", "pallet-collective/try-runtime", "pallet-identity/try-runtime", - "pallet-motion/try-runtime", "pallet-multisig/try-runtime", "pallet-nft-fractionalization/try-runtime", "pallet-nfts/try-runtime", diff --git a/runtime/devnet/src/lib.rs b/runtime/devnet/src/lib.rs index a554652..9ed411f 100644 --- a/runtime/devnet/src/lib.rs +++ b/runtime/devnet/src/lib.rs @@ -520,18 +520,6 @@ impl pallet_collective::Config for Runtime { type MaxProposalWeight = MaxCollectivesProposalWeight; } -impl pallet_motion::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type RuntimeCall = RuntimeCall; - type SimpleMajorityOrigin = - pallet_collective::EnsureProportionMoreThan; - type SuperMajorityOrigin = - pallet_collective::EnsureProportionAtLeast; - type UnanimousOrigin = - pallet_collective::EnsureProportionAtLeast; - type WeightInfo = pallet_motion::weights::SubstrateWeight; -} - parameter_types! { // One storage item; key size is 32; value is size 4+4+16+32 bytes = 56 bytes. pub const DepositBase: Balance = deposit(1, 88); @@ -771,7 +759,6 @@ construct_runtime!( // Governance Sudo: pallet_sudo = 15, Council: pallet_collective:: = 16, - Motion: pallet_motion = 17, // Collator support. The order of these 4 are important and shall not change. Authorship: pallet_authorship = 20, diff --git a/runtime/mainnet/Cargo.toml b/runtime/mainnet/Cargo.toml index aa5092c..6fb8a9d 100644 --- a/runtime/mainnet/Cargo.toml +++ b/runtime/mainnet/Cargo.toml @@ -26,7 +26,6 @@ scale-info = { version = "2.9.0", default-features = false, features = [ smallvec = "1.11.0" # Local -pallet-motion = { path = "../../pallets/motion", default-features = false } runtime-common = { path = "../common", default-features = false } # Substrate @@ -112,7 +111,6 @@ std = [ "pallet-collective/std", "pallet-collator-selection/std", "pallet-identity/std", - "pallet-motion/std", "pallet-multisig/std", "pallet-nft-fractionalization/std", "pallet-nfts/std", @@ -155,7 +153,6 @@ runtime-benchmarks = [ "pallet-collator-selection/runtime-benchmarks", "pallet-collective/runtime-benchmarks", "pallet-identity/runtime-benchmarks", - "pallet-motion/runtime-benchmarks", "pallet-multisig/runtime-benchmarks", "pallet-nft-fractionalization/runtime-benchmarks", "pallet-nfts/runtime-benchmarks", @@ -184,7 +181,6 @@ try-runtime = [ "pallet-collator-selection/try-runtime", "pallet-collective/try-runtime", "pallet-identity/try-runtime", - "pallet-motion/try-runtime", "pallet-multisig/try-runtime", "pallet-nft-fractionalization/try-runtime", "pallet-nfts/try-runtime", diff --git a/runtime/mainnet/src/lib.rs b/runtime/mainnet/src/lib.rs index c2a43d1..9b5f271 100644 --- a/runtime/mainnet/src/lib.rs +++ b/runtime/mainnet/src/lib.rs @@ -520,18 +520,6 @@ impl pallet_collective::Config for Runtime { type MaxProposalWeight = MaxCollectivesProposalWeight; } -impl pallet_motion::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type RuntimeCall = RuntimeCall; - type SimpleMajorityOrigin = - pallet_collective::EnsureProportionMoreThan; - type SuperMajorityOrigin = - pallet_collective::EnsureProportionAtLeast; - type UnanimousOrigin = - pallet_collective::EnsureProportionAtLeast; - type WeightInfo = pallet_motion::weights::SubstrateWeight; -} - parameter_types! { // One storage item; key size is 32; value is size 4+4+16+32 bytes = 56 bytes. pub const DepositBase: Balance = deposit(1, 88); @@ -771,7 +759,6 @@ construct_runtime!( // Governance Sudo: pallet_sudo = 15, Council: pallet_collective:: = 16, - Motion: pallet_motion = 17, // Collator support. The order of these 4 are important and shall not change. Authorship: pallet_authorship = 20, @@ -806,7 +793,6 @@ mod benches { [pallet_collator_selection, CollatorSelection] [pallet_multisig, Multisig] [cumulus_pallet_xcmp_queue, XcmpQueue] - [pallet_motion, Motion] // SBP-M1 review: add missing pallets: benchmarks should be re-run on reference hardware based on how they are configured/used by your runtime ); }