diff --git a/Cargo.lock b/Cargo.lock index 1ee6f950e9..d69caf4c6c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6731,7 +6731,6 @@ dependencies = [ "sp-io", "sp-runtime", "sp-std 8.0.0 (git+https://github.com/chainflip-io/substrate.git?tag=chainflip-monthly-2023-08+1)", - "sp-version", ] [[package]] diff --git a/api/lib/src/lib.rs b/api/lib/src/lib.rs index 2de42bed7e..f0f2f49bdb 100644 --- a/api/lib/src/lib.rs +++ b/api/lib/src/lib.rs @@ -10,6 +10,7 @@ use cf_chains::{ }; use cf_primitives::{AccountRole, Asset, BasisPoints, ChannelId}; use futures::FutureExt; +use pallet_cf_governance::ExecutionMode; use pallet_cf_validator::MAX_LENGTH_FOR_VANITY_NAME; use serde::Serialize; use sp_consensus_aura::sr25519::AuthorityId as AuraId; @@ -265,6 +266,7 @@ pub trait GovernanceApi: SignedExtrinsicApi { println!("Submitting governance proposal for rotation."); self.submit_signed_extrinsic(pallet_cf_governance::Call::propose_governance_extrinsic { call: Box::new(pallet_cf_validator::Call::force_rotation {}.into()), + execution: ExecutionMode::Automatic, }) .await .until_finalized() diff --git a/bouncer/shared/cf_governance.ts b/bouncer/shared/cf_governance.ts index d0cd26ea50..ddb1c951b8 100644 --- a/bouncer/shared/cf_governance.ts +++ b/bouncer/shared/cf_governance.ts @@ -15,10 +15,13 @@ const keyring = new Keyring({ type: 'sr25519' }); export const snowWhite = keyring.createFromUri(snowWhiteUri); -export async function submitGovernanceExtrinsic(extrinsic: SubmittableExtrinsic<'promise'>) { +export async function submitGovernanceExtrinsic( + extrinsic: SubmittableExtrinsic<'promise'>, + preAuthorise = 0, +) { return snowWhiteMutex.runExclusive(async () => chainflip.tx.governance - .proposeGovernanceExtrinsic(extrinsic) + .proposeGovernanceExtrinsic(extrinsic, preAuthorise) .signAndSend(snowWhite, { nonce: -1 }, handleSubstrateError(chainflip)), ); } diff --git a/state-chain/pallets/cf-governance/Cargo.toml b/state-chain/pallets/cf-governance/Cargo.toml index eb01e585c0..eebd356fc1 100644 --- a/state-chain/pallets/cf-governance/Cargo.toml +++ b/state-chain/pallets/cf-governance/Cargo.toml @@ -28,7 +28,6 @@ frame-benchmarking = { git = "https://github.com/chainflip-io/substrate.git", ta frame-support = { git = "https://github.com/chainflip-io/substrate.git", tag = "chainflip-monthly-2023-08+1", default-features = false } frame-system = { git = "https://github.com/chainflip-io/substrate.git", tag = "chainflip-monthly-2023-08+1", default-features = false } sp-std = { git = "https://github.com/chainflip-io/substrate.git", tag = "chainflip-monthly-2023-08+1", default-features = false } -sp-version = { git = "https://github.com/chainflip-io/substrate.git", tag = "chainflip-monthly-2023-08+1", default-features = false } cf-runtime-upgrade-utilities = { path = '../../runtime-upgrade-utilities', default-features = false } @@ -50,7 +49,6 @@ std = [ 'frame-system/std', 'scale-info/std', 'sp-std/std', - 'sp-version/std', ] runtime-benchmarks = [ 'cf-primitives/runtime-benchmarks', diff --git a/state-chain/pallets/cf-governance/src/benchmarking.rs b/state-chain/pallets/cf-governance/src/benchmarking.rs index aebefde5f5..625dbf9337 100644 --- a/state-chain/pallets/cf-governance/src/benchmarking.rs +++ b/state-chain/pallets/cf-governance/src/benchmarking.rs @@ -16,7 +16,7 @@ benchmarks! { let caller: T::AccountId = whitelisted_caller(); let call = Box::new(frame_system::Call::remark{remark: vec![]}.into()); >::put(BTreeSet::from([caller.clone()])); - }: _(RawOrigin::Signed(caller.clone()), call) + }: _(RawOrigin::Signed(caller.clone()), call, ExecutionMode::Automatic) verify { assert_eq!(ProposalIdCounter::::get(), 1); } @@ -24,7 +24,7 @@ benchmarks! { let call: ::RuntimeCall = frame_system::Call::remark{remark: vec![]}.into(); let caller: T::AccountId = whitelisted_caller(); >::put(BTreeSet::from([caller.clone()])); - Pallet::::push_proposal(Box::new(call)); + Pallet::::push_proposal(Box::new(call), ExecutionMode::Automatic); }: _(RawOrigin::Signed(caller.clone()), 1) verify { assert_eq!(ProposalIdCounter::::get(), 1); @@ -48,7 +48,7 @@ benchmarks! { let b in 1 .. 100u32; for _n in 1 .. b { let call = Box::new(frame_system::Call::remark{remark: vec![]}.into()); - Pallet::::push_proposal(call); + Pallet::::push_proposal(call, ExecutionMode::Automatic); } }: { Pallet::::on_initialize(2u32.into()); @@ -61,7 +61,7 @@ benchmarks! { let b in 1 .. 100u32; for _n in 1 .. b { let call = Box::new(frame_system::Call::remark{remark: vec![]}.into()); - Pallet::::push_proposal(call); + Pallet::::push_proposal(call, ExecutionMode::Automatic); } } : { Pallet::::expire_proposals(>::get()); @@ -106,5 +106,15 @@ benchmarks! { assert!(GovKeyWhitelistedCallHash::::get().is_none()); } + dispatch_whitelisted_call { + let caller: T::AccountId = whitelisted_caller(); + >::put(BTreeSet::from([caller.clone()])); + let call: ::RuntimeCall = Call::::new_membership_set { + accounts: vec![] + }.into(); + Pallet::::push_proposal(Box::new(call.clone()), ExecutionMode::Manual); + PreAuthorisedGovCalls::::insert(1, call.encode()); + }: _(RawOrigin::Signed(caller.clone()), 1) + impl_benchmark_test_suite!(Pallet, crate::mock::new_test_ext(), crate::mock::Test,); } diff --git a/state-chain/pallets/cf-governance/src/lib.rs b/state-chain/pallets/cf-governance/src/lib.rs index 1396ccc152..d5c6c5fbef 100644 --- a/state-chain/pallets/cf-governance/src/lib.rs +++ b/state-chain/pallets/cf-governance/src/lib.rs @@ -52,6 +52,13 @@ pub mod pallet { use super::{GovCallHash, WeightInfo}; + #[derive(Default, Encode, Decode, TypeInfo, Clone, RuntimeDebug, PartialEq, Eq)] + pub enum ExecutionMode { + #[default] + Automatic, + Manual, + } + #[derive(Encode, Decode, TypeInfo, Clone, Copy, RuntimeDebug, PartialEq, Eq)] pub struct ActiveProposal { pub proposal_id: ProposalId, @@ -65,12 +72,8 @@ pub mod pallet { pub call: OpaqueCall, /// Accounts who have already approved the proposal. pub approved: BTreeSet, - } - - impl Default for Proposal { - fn default() -> Self { - Self { call: Default::default(), approved: Default::default() } - } + /// Proposal is pre authorised. + pub execution: ExecutionMode, } type AccountId = ::AccountId; @@ -115,7 +118,7 @@ pub mod pallet { #[pallet::storage] #[pallet::getter(fn proposals)] pub(super) type Proposals = - StorageMap<_, Blake2_128Concat, ProposalId, Proposal, ValueQuery>; + StorageMap<_, Blake2_128Concat, ProposalId, Proposal>; /// Active proposals. #[pallet::storage] @@ -127,6 +130,11 @@ pub mod pallet { #[pallet::getter(fn gov_key_whitelisted_call_hash)] pub(super) type GovKeyWhitelistedCallHash = StorageValue<_, GovCallHash, OptionQuery>; + /// Pre authorised governance calls. + #[pallet::storage] + pub(super) type PreAuthorisedGovCalls = + StorageMap<_, Twox64Concat, u32, OpaqueCall, OptionQuery>; + /// Any nonces before this have been consumed. #[pallet::storage] #[pallet::getter(fn next_gov_key_call_hash_nonce)] @@ -242,11 +250,12 @@ pub mod pallet { pub fn propose_governance_extrinsic( origin: OriginFor, call: Box<::RuntimeCall>, + execution: ExecutionMode, ) -> DispatchResultWithPostInfo { let who = ensure_signed(origin)?; ensure!(Members::::get().contains(&who), Error::::NotMember); - let id = Self::push_proposal(call); + let id = Self::push_proposal(call, execution); Self::deposit_event(Event::Proposed(id)); Self::inner_approve(who, id)?; @@ -425,6 +434,29 @@ pub mod pallet { _ => Err(Error::::CallHashNotWhitelisted.into()), } } + + #[pallet::call_index(7)] + #[pallet::weight(T::WeightInfo::dispatch_whitelisted_call())] + pub fn dispatch_whitelisted_call( + origin: OriginFor, + approved_id: ProposalId, + ) -> DispatchResult { + let who = ensure_signed(origin)?; + ensure!(Members::::get().contains(&who), Error::::NotMember); + if let Some(call) = PreAuthorisedGovCalls::::take(approved_id) { + if let Ok(call) = ::RuntimeCall::decode(&mut &(*call)) { + Self::deposit_event(match Self::dispatch_governance_call(call) { + Ok(_) => Event::Executed(approved_id), + Err(err) => Event::FailedExecution(err.error), + }); + Ok(()) + } else { + Err(Error::::DecodeOfCallFailed.into()) + } + } else { + Err(Error::::ProposalNotFound.into()) + } + } } /// Genesis definition @@ -491,7 +523,9 @@ impl Pallet { ensure!(Proposals::::contains_key(approved_id), Error::::ProposalNotFound); // Try to approve the proposal - let proposal = Proposals::::mutate(approved_id, |proposal| { + let proposal = Proposals::::try_mutate(approved_id, |proposal| { + let proposal = proposal.as_mut().ok_or(Error::::ProposalNotFound)?; + if !proposal.approved.insert(who) { return Err(Error::::AlreadyApproved) } @@ -502,7 +536,11 @@ impl Pallet { if proposal.approved.len() > (Members::::decode_len().ok_or(Error::::DecodeMembersLenFailed)? / 2) { - ExecutionPipeline::::append((proposal.call, approved_id)); + if proposal.execution == ExecutionMode::Manual { + PreAuthorisedGovCalls::::insert(approved_id, proposal.call); + } else { + ExecutionPipeline::::append((proposal.call, approved_id)); + } Proposals::::remove(approved_id); ActiveProposals::::mutate(|proposals| { proposals.retain(|ActiveProposal { proposal_id, .. }| *proposal_id != approved_id) @@ -560,11 +598,11 @@ impl Pallet { T::WeightInfo::expire_proposals(expired.len() as u32) } - fn push_proposal(call: Box<::RuntimeCall>) -> u32 { + fn push_proposal(call: Box<::RuntimeCall>, execution: ExecutionMode) -> u32 { let proposal_id = ProposalIdCounter::::get().add(1); Proposals::::insert( proposal_id, - Proposal { call: call.encode(), approved: Default::default() }, + Proposal { call: call.encode(), approved: Default::default(), execution }, ); ProposalIdCounter::::put(proposal_id); ActiveProposals::::append(ActiveProposal { diff --git a/state-chain/pallets/cf-governance/src/tests.rs b/state-chain/pallets/cf-governance/src/tests.rs index 4872a3b4cc..2b17f0d0e0 100644 --- a/state-chain/pallets/cf-governance/src/tests.rs +++ b/state-chain/pallets/cf-governance/src/tests.rs @@ -1,5 +1,6 @@ use crate::{ - mock::*, ActiveProposals, Error, ExecutionPipeline, ExpiryTime, Members, ProposalIdCounter, + mock::*, ActiveProposals, Error, ExecutionMode, ExecutionPipeline, ExpiryTime, Members, + PreAuthorisedGovCalls, ProposalIdCounter, }; use cf_test_utilities::last_event; use cf_traits::mocks::time_source; @@ -33,7 +34,11 @@ fn genesis_config() { fn not_a_member() { new_test_ext().execute_with(|| { assert_noop!( - Governance::propose_governance_extrinsic(RuntimeOrigin::signed(EVE), mock_extrinsic()), + Governance::propose_governance_extrinsic( + RuntimeOrigin::signed(EVE), + mock_extrinsic(), + ExecutionMode::Automatic, + ), >::NotMember ); }); @@ -46,7 +51,8 @@ fn propose_a_governance_extrinsic_and_expect_execution() { // Propose a governance extrinsic assert_ok!(Governance::propose_governance_extrinsic( RuntimeOrigin::signed(ALICE), - mock_extrinsic() + mock_extrinsic(), + ExecutionMode::Automatic, )); assert_eq!( last_event::(), @@ -77,7 +83,8 @@ fn already_executed() { // Propose a governance extrinsic assert_ok!(Governance::propose_governance_extrinsic( RuntimeOrigin::signed(ALICE), - mock_extrinsic() + mock_extrinsic(), + ExecutionMode::Automatic, )); // Assert the proposed event was fired assert_eq!( @@ -119,7 +126,8 @@ fn propose_a_governance_extrinsic_and_expect_it_to_expire() { // Propose governance extrinsic assert_ok!(Governance::propose_governance_extrinsic( RuntimeOrigin::signed(ALICE), - mock_extrinsic() + mock_extrinsic(), + ExecutionMode::Automatic, )); }) .then_execute_at_next_block(|_| { @@ -142,7 +150,8 @@ fn can_not_vote_twice() { // Propose a governance extrinsic assert_ok!(Governance::propose_governance_extrinsic( RuntimeOrigin::signed(ALICE), - mock_extrinsic() + mock_extrinsic(), + ExecutionMode::Automatic, )); // Try to approve it again. Proposing implies approving. assert_noop!( @@ -157,7 +166,8 @@ fn several_open_proposals() { new_test_ext().execute_with(|| { assert_ok!(Governance::propose_governance_extrinsic( RuntimeOrigin::signed(ALICE), - mock_extrinsic() + mock_extrinsic(), + ExecutionMode::Automatic, )); assert_eq!( last_event::(), @@ -165,7 +175,8 @@ fn several_open_proposals() { ); assert_ok!(Governance::propose_governance_extrinsic( RuntimeOrigin::signed(BOB), - mock_extrinsic() + mock_extrinsic(), + ExecutionMode::Automatic, )); assert_eq!( last_event::(), @@ -190,7 +201,8 @@ fn sudo_extrinsic() { // Propose the governance extrinsic assert_ok!(Governance::propose_governance_extrinsic( RuntimeOrigin::signed(ALICE), - governance_extrinsic + governance_extrinsic, + ExecutionMode::Automatic, )); assert_eq!( last_event::(), @@ -309,3 +321,18 @@ fn runtime_upgrade_can_have_no_cfes_version_requirement() { )); }); } + +#[test] +fn whitelisted_gov_call() { + new_test_ext().execute_with(|| { + assert_ok!(Governance::propose_governance_extrinsic( + RuntimeOrigin::signed(ALICE), + mock_extrinsic(), + ExecutionMode::Manual, + )); + assert_ok!(Governance::approve(RuntimeOrigin::signed(BOB), 1)); + assert!(PreAuthorisedGovCalls::::contains_key(1)); + assert_ok!(Governance::dispatch_whitelisted_call(RuntimeOrigin::signed(CHARLES), 1)); + assert!(!PreAuthorisedGovCalls::::contains_key(1)); + }); +} diff --git a/state-chain/pallets/cf-governance/src/weights.rs b/state-chain/pallets/cf-governance/src/weights.rs index 298ee8db39..29515f0b2f 100644 --- a/state-chain/pallets/cf-governance/src/weights.rs +++ b/state-chain/pallets/cf-governance/src/weights.rs @@ -1,32 +1,34 @@ //! Autogenerated weights for pallet_cf_governance //! -//! THIS FILE WAS AUTO-GENERATED USING THE CHAINFLIP BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-01-20, STEPS: `20`, REPEAT: 10, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `wagmi.local`, CPU: `` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024 +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-09-07, STEPS: `20`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `janislav030.local`, CPU: `` +//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024 // Executed Command: -// ./target/production/chainflip-node +// ./target/release/chainflip-node // benchmark // pallet -// --pallet -// pallet_cf_governance // --extrinsic // * +// --pallet +// pallet_cf_governance // --output // state-chain/pallets/cf-governance/src/weights.rs // --execution=wasm // --steps=20 -// --repeat=10 +// --repeat=20 // --template=state-chain/chainflip-weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; /// Weight functions needed for pallet_cf_governance. pub trait WeightInfo { @@ -39,177 +41,312 @@ pub trait WeightInfo { fn expire_proposals(b: u32, ) -> Weight; fn set_whitelisted_call_hash() -> Weight; fn submit_govkey_call() -> Weight; + fn dispatch_whitelisted_call() -> Weight; } /// Weights for pallet_cf_governance using the Substrate node and recommended hardware. pub struct PalletWeight(PhantomData); impl WeightInfo for PalletWeight { - // Storage: Governance Members (r:1 w:0) - // Storage: Governance ProposalIdCounter (r:1 w:1) - // Storage: Timestamp Now (r:1 w:0) - // Storage: Governance ExpiryTime (r:1 w:0) - // Storage: Governance ActiveProposals (r:1 w:1) - // Storage: Governance ExecutionPipeline (r:1 w:1) - // Storage: Governance Proposals (r:0 w:1) + /// Storage: `Governance::Members` (r:1 w:0) + /// Proof: `Governance::Members` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Governance::ProposalIdCounter` (r:1 w:1) + /// Proof: `Governance::ProposalIdCounter` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// Storage: `Governance::ExpiryTime` (r:1 w:0) + /// Proof: `Governance::ExpiryTime` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Governance::ActiveProposals` (r:1 w:1) + /// Proof: `Governance::ActiveProposals` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Governance::ExecutionPipeline` (r:1 w:1) + /// Proof: `Governance::ExecutionPipeline` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Governance::Proposals` (r:0 w:1) + /// Proof: `Governance::Proposals` (`max_values`: None, `max_size`: None, mode: `Measured`) fn propose_governance_extrinsic() -> Weight { - // Minimum execution time: 29_000 nanoseconds. - Weight::from_parts(30_000_000, 0) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(4)) - } - // Storage: Governance Members (r:1 w:0) - // Storage: Governance Proposals (r:1 w:1) - // Storage: Governance ExecutionPipeline (r:1 w:1) - // Storage: Governance ActiveProposals (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `134` + // Estimated: `1619` + // Minimum execution time: 55_000_000 picoseconds. + Weight::from_parts(56_000_000, 1619) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + } + /// Storage: `Governance::Members` (r:1 w:0) + /// Proof: `Governance::Members` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Governance::Proposals` (r:1 w:1) + /// Proof: `Governance::Proposals` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Governance::ExecutionPipeline` (r:1 w:1) + /// Proof: `Governance::ExecutionPipeline` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Governance::ActiveProposals` (r:1 w:1) + /// Proof: `Governance::ActiveProposals` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn approve() -> Weight { - // Minimum execution time: 23_000 nanoseconds. - Weight::from_parts(24_000_000, 0) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(3)) + // Proof Size summary in bytes: + // Measured: `197` + // Estimated: `3662` + // Minimum execution time: 38_000_000 picoseconds. + Weight::from_parts(39_000_000, 3662) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) } - // Storage: Governance Members (r:0 w:1) + /// Storage: `Governance::Members` (r:0 w:1) + /// Proof: `Governance::Members` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn new_membership_set() -> Weight { - // Minimum execution time: 4_000 nanoseconds. - Weight::from_parts(4_000_000, 0) - .saturating_add(T::DbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 6_000_000 picoseconds. + Weight::from_parts(6_000_000, 0) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: System Digest (r:1 w:1) - // Storage: unknown [0x3a636f6465] (r:0 w:1) + /// Storage: `System::Digest` (r:1 w:1) + /// Proof: `System::Digest` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: UNKNOWN KEY `0x3a636f6465` (r:0 w:1) + /// Proof: UNKNOWN KEY `0x3a636f6465` (r:0 w:1) fn call_as_sudo() -> Weight { - // Minimum execution time: 14_000 nanoseconds. - Weight::from_parts(16_000_000, 0) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(2)) - } - // Storage: Governance ActiveProposals (r:1 w:0) - // Storage: Governance ExecutionPipeline (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `1485` + // Minimum execution time: 31_000_000 picoseconds. + Weight::from_parts(33_000_000, 1485) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: `Governance::ActiveProposals` (r:1 w:1) + /// Proof: `Governance::ActiveProposals` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// Storage: `Governance::ExecutionPipeline` (r:1 w:0) + /// Proof: `Governance::ExecutionPipeline` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) /// The range of component `b` is `[1, 100]`. fn on_initialize(b: u32, ) -> Weight { - // Minimum execution time: 3_000 nanoseconds. - Weight::from_parts(6_951_927, 0) - // Standard Error: 4_941 - .saturating_add(Weight::from_parts(394_899, 0).saturating_mul(b.into())) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(1)) - } - // Storage: Governance ActiveProposals (r:1 w:0) - // Storage: Governance ExecutionPipeline (r:1 w:0) + // Proof Size summary in bytes: + // Measured: `182 + b * (12 ±0)` + // Estimated: `1644 + b * (12 ±0)` + // Minimum execution time: 5_000_000 picoseconds. + Weight::from_parts(12_452_612, 1644) + // Standard Error: 5_162 + .saturating_add(Weight::from_parts(1_193_154, 0).saturating_mul(b.into())) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + .saturating_add(Weight::from_parts(0, 12).saturating_mul(b.into())) + } + /// Storage: `Governance::ActiveProposals` (r:1 w:0) + /// Proof: `Governance::ActiveProposals` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Governance::ExecutionPipeline` (r:1 w:0) + /// Proof: `Governance::ExecutionPipeline` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn on_initialize_best_case() -> Weight { - // Minimum execution time: 2_000 nanoseconds. - Weight::from_parts(3_000_000, 0) - .saturating_add(T::DbWeight::get().reads(2)) + // Proof Size summary in bytes: + // Measured: `70` + // Estimated: `1555` + // Minimum execution time: 5_000_000 picoseconds. + Weight::from_parts(6_000_000, 1555) + .saturating_add(T::DbWeight::get().reads(2_u64)) } - // Storage: Governance ActiveProposals (r:1 w:0) - // Storage: Governance Proposals (r:0 w:5) + /// Storage: `Governance::ActiveProposals` (r:1 w:0) + /// Proof: `Governance::ActiveProposals` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Governance::Proposals` (r:0 w:99) + /// Proof: `Governance::Proposals` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `b` is `[1, 100]`. fn expire_proposals(b: u32, ) -> Weight { - // Minimum execution time: 2_000 nanoseconds. - Weight::from_parts(8_763_542, 0) - // Standard Error: 13_275 - .saturating_add(Weight::from_parts(2_998_230, 0).saturating_mul(b.into())) - .saturating_add(T::DbWeight::get().reads(1)) + // Proof Size summary in bytes: + // Measured: `140 + b * (12 ±0)` + // Estimated: `1610 + b * (12 ±0)` + // Minimum execution time: 4_000_000 picoseconds. + Weight::from_parts(4_000_000, 1610) + // Standard Error: 3_830 + .saturating_add(Weight::from_parts(8_538_132, 0).saturating_mul(b.into())) + .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(b.into()))) + .saturating_add(Weight::from_parts(0, 12).saturating_mul(b.into())) } - // Storage: Governance GovKeyWhitelistedCallHash (r:0 w:1) + /// Storage: `Governance::GovKeyWhitelistedCallHash` (r:0 w:1) + /// Proof: `Governance::GovKeyWhitelistedCallHash` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn set_whitelisted_call_hash() -> Weight { - // Minimum execution time: 11_000 nanoseconds. - Weight::from_parts(11_000_000, 0) - .saturating_add(T::DbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 13_000_000 picoseconds. + Weight::from_parts(13_000_000, 0) + .saturating_add(T::DbWeight::get().writes(1_u64)) } - // Storage: Governance NextGovKeyCallHashNonce (r:1 w:1) - // Storage: Governance GovKeyWhitelistedCallHash (r:1 w:1) - // Storage: Governance Members (r:0 w:1) + /// Storage: `Governance::NextGovKeyCallHashNonce` (r:1 w:1) + /// Proof: `Governance::NextGovKeyCallHashNonce` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Governance::GovKeyWhitelistedCallHash` (r:1 w:1) + /// Proof: `Governance::GovKeyWhitelistedCallHash` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Governance::Members` (r:0 w:1) + /// Proof: `Governance::Members` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn submit_govkey_call() -> Weight { - // Minimum execution time: 21_000 nanoseconds. - Weight::from_parts(21_000_000, 0) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(3)) + // Proof Size summary in bytes: + // Measured: `148` + // Estimated: `1633` + // Minimum execution time: 33_000_000 picoseconds. + Weight::from_parts(33_000_000, 1633) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: `Governance::Members` (r:1 w:1) + /// Proof: `Governance::Members` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Governance::PreAuthorisedGovCalls` (r:1 w:1) + /// Proof: `Governance::PreAuthorisedGovCalls` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn dispatch_whitelisted_call() -> Weight { + // Proof Size summary in bytes: + // Measured: `190` + // Estimated: `3655` + // Minimum execution time: 30_000_000 picoseconds. + Weight::from_parts(31_000_000, 3655) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) } } // For backwards compatibility and tests impl WeightInfo for () { - // Storage: Governance Members (r:1 w:0) - // Storage: Governance ProposalIdCounter (r:1 w:1) - // Storage: Timestamp Now (r:1 w:0) - // Storage: Governance ExpiryTime (r:1 w:0) - // Storage: Governance ActiveProposals (r:1 w:1) - // Storage: Governance ExecutionPipeline (r:1 w:1) - // Storage: Governance Proposals (r:0 w:1) + /// Storage: `Governance::Members` (r:1 w:0) + /// Proof: `Governance::Members` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Governance::ProposalIdCounter` (r:1 w:1) + /// Proof: `Governance::ProposalIdCounter` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// Storage: `Governance::ExpiryTime` (r:1 w:0) + /// Proof: `Governance::ExpiryTime` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Governance::ActiveProposals` (r:1 w:1) + /// Proof: `Governance::ActiveProposals` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Governance::ExecutionPipeline` (r:1 w:1) + /// Proof: `Governance::ExecutionPipeline` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Governance::Proposals` (r:0 w:1) + /// Proof: `Governance::Proposals` (`max_values`: None, `max_size`: None, mode: `Measured`) fn propose_governance_extrinsic() -> Weight { - // Minimum execution time: 29_000 nanoseconds. - Weight::from_parts(30_000_000, 0) - .saturating_add(RocksDbWeight::get().reads(6)) - .saturating_add(RocksDbWeight::get().writes(4)) - } - // Storage: Governance Members (r:1 w:0) - // Storage: Governance Proposals (r:1 w:1) - // Storage: Governance ExecutionPipeline (r:1 w:1) - // Storage: Governance ActiveProposals (r:1 w:1) + // Proof Size summary in bytes: + // Measured: `134` + // Estimated: `1619` + // Minimum execution time: 55_000_000 picoseconds. + Weight::from_parts(56_000_000, 1619) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + } + /// Storage: `Governance::Members` (r:1 w:0) + /// Proof: `Governance::Members` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Governance::Proposals` (r:1 w:1) + /// Proof: `Governance::Proposals` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Governance::ExecutionPipeline` (r:1 w:1) + /// Proof: `Governance::ExecutionPipeline` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Governance::ActiveProposals` (r:1 w:1) + /// Proof: `Governance::ActiveProposals` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn approve() -> Weight { - // Minimum execution time: 23_000 nanoseconds. - Weight::from_parts(24_000_000, 0) - .saturating_add(RocksDbWeight::get().reads(4)) - .saturating_add(RocksDbWeight::get().writes(3)) + // Proof Size summary in bytes: + // Measured: `197` + // Estimated: `3662` + // Minimum execution time: 38_000_000 picoseconds. + Weight::from_parts(39_000_000, 3662) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) } - // Storage: Governance Members (r:0 w:1) + /// Storage: `Governance::Members` (r:0 w:1) + /// Proof: `Governance::Members` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn new_membership_set() -> Weight { - // Minimum execution time: 4_000 nanoseconds. - Weight::from_parts(4_000_000, 0) - .saturating_add(RocksDbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 6_000_000 picoseconds. + Weight::from_parts(6_000_000, 0) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: System Digest (r:1 w:1) - // Storage: unknown [0x3a636f6465] (r:0 w:1) + /// Storage: `System::Digest` (r:1 w:1) + /// Proof: `System::Digest` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: UNKNOWN KEY `0x3a636f6465` (r:0 w:1) + /// Proof: UNKNOWN KEY `0x3a636f6465` (r:0 w:1) fn call_as_sudo() -> Weight { - // Minimum execution time: 14_000 nanoseconds. - Weight::from_parts(16_000_000, 0) - .saturating_add(RocksDbWeight::get().reads(1)) - .saturating_add(RocksDbWeight::get().writes(2)) - } - // Storage: Governance ActiveProposals (r:1 w:0) - // Storage: Governance ExecutionPipeline (r:1 w:0) - // Storage: Timestamp Now (r:1 w:0) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `1485` + // Minimum execution time: 31_000_000 picoseconds. + Weight::from_parts(33_000_000, 1485) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: `Governance::ActiveProposals` (r:1 w:1) + /// Proof: `Governance::ActiveProposals` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// Storage: `Governance::ExecutionPipeline` (r:1 w:0) + /// Proof: `Governance::ExecutionPipeline` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) /// The range of component `b` is `[1, 100]`. fn on_initialize(b: u32, ) -> Weight { - // Minimum execution time: 3_000 nanoseconds. - Weight::from_parts(6_951_927, 0) - // Standard Error: 4_941 - .saturating_add(Weight::from_parts(394_899, 0).saturating_mul(b.into())) - .saturating_add(RocksDbWeight::get().reads(3)) - .saturating_add(RocksDbWeight::get().writes(1)) - } - // Storage: Governance ActiveProposals (r:1 w:0) - // Storage: Governance ExecutionPipeline (r:1 w:0) + // Proof Size summary in bytes: + // Measured: `182 + b * (12 ±0)` + // Estimated: `1644 + b * (12 ±0)` + // Minimum execution time: 5_000_000 picoseconds. + Weight::from_parts(12_452_612, 1644) + // Standard Error: 5_162 + .saturating_add(Weight::from_parts(1_193_154, 0).saturating_mul(b.into())) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + .saturating_add(Weight::from_parts(0, 12).saturating_mul(b.into())) + } + /// Storage: `Governance::ActiveProposals` (r:1 w:0) + /// Proof: `Governance::ActiveProposals` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Governance::ExecutionPipeline` (r:1 w:0) + /// Proof: `Governance::ExecutionPipeline` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn on_initialize_best_case() -> Weight { - // Minimum execution time: 2_000 nanoseconds. - Weight::from_parts(3_000_000, 0) - .saturating_add(RocksDbWeight::get().reads(2)) + // Proof Size summary in bytes: + // Measured: `70` + // Estimated: `1555` + // Minimum execution time: 5_000_000 picoseconds. + Weight::from_parts(6_000_000, 1555) + .saturating_add(RocksDbWeight::get().reads(2_u64)) } - // Storage: Governance ActiveProposals (r:1 w:0) - // Storage: Governance Proposals (r:0 w:5) + /// Storage: `Governance::ActiveProposals` (r:1 w:0) + /// Proof: `Governance::ActiveProposals` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Governance::Proposals` (r:0 w:99) + /// Proof: `Governance::Proposals` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `b` is `[1, 100]`. fn expire_proposals(b: u32, ) -> Weight { - // Minimum execution time: 2_000 nanoseconds. - Weight::from_parts(8_763_542, 0) - // Standard Error: 13_275 - .saturating_add(Weight::from_parts(2_998_230, 0).saturating_mul(b.into())) - .saturating_add(RocksDbWeight::get().reads(1)) + // Proof Size summary in bytes: + // Measured: `140 + b * (12 ±0)` + // Estimated: `1610 + b * (12 ±0)` + // Minimum execution time: 4_000_000 picoseconds. + Weight::from_parts(4_000_000, 1610) + // Standard Error: 3_830 + .saturating_add(Weight::from_parts(8_538_132, 0).saturating_mul(b.into())) + .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(b.into()))) + .saturating_add(Weight::from_parts(0, 12).saturating_mul(b.into())) } - // Storage: Governance GovKeyWhitelistedCallHash (r:0 w:1) + /// Storage: `Governance::GovKeyWhitelistedCallHash` (r:0 w:1) + /// Proof: `Governance::GovKeyWhitelistedCallHash` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn set_whitelisted_call_hash() -> Weight { - // Minimum execution time: 11_000 nanoseconds. - Weight::from_parts(11_000_000, 0) - .saturating_add(RocksDbWeight::get().writes(1)) + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 13_000_000 picoseconds. + Weight::from_parts(13_000_000, 0) + .saturating_add(RocksDbWeight::get().writes(1_u64)) } - // Storage: Governance NextGovKeyCallHashNonce (r:1 w:1) - // Storage: Governance GovKeyWhitelistedCallHash (r:1 w:1) - // Storage: Governance Members (r:0 w:1) + /// Storage: `Governance::NextGovKeyCallHashNonce` (r:1 w:1) + /// Proof: `Governance::NextGovKeyCallHashNonce` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Governance::GovKeyWhitelistedCallHash` (r:1 w:1) + /// Proof: `Governance::GovKeyWhitelistedCallHash` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Governance::Members` (r:0 w:1) + /// Proof: `Governance::Members` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) fn submit_govkey_call() -> Weight { - // Minimum execution time: 21_000 nanoseconds. - Weight::from_parts(21_000_000, 0) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(3)) + // Proof Size summary in bytes: + // Measured: `148` + // Estimated: `1633` + // Minimum execution time: 33_000_000 picoseconds. + Weight::from_parts(33_000_000, 1633) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: `Governance::Members` (r:1 w:1) + /// Proof: `Governance::Members` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Governance::PreAuthorisedGovCalls` (r:1 w:1) + /// Proof: `Governance::PreAuthorisedGovCalls` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn dispatch_whitelisted_call() -> Weight { + // Proof Size summary in bytes: + // Measured: `190` + // Estimated: `3655` + // Minimum execution time: 30_000_000 picoseconds. + Weight::from_parts(31_000_000, 3655) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) } }