From 6cc3dd1e3321194d2934f2f3ed879571b01df21e Mon Sep 17 00:00:00 2001 From: kianenigma Date: Wed, 11 Aug 2021 15:28:22 +0200 Subject: [PATCH 1/2] More standard staking miner deposits --- runtime/kusama/src/lib.rs | 41 +++++++++++------ runtime/polkadot/src/lib.rs | 90 ++++++++++++++++++++----------------- runtime/westend/src/lib.rs | 22 ++++----- 3 files changed, 88 insertions(+), 65 deletions(-) diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index 2cc4b8892227..64f6515d559c 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -345,11 +345,8 @@ parameter_types! { // signed config pub const SignedMaxSubmissions: u32 = 16; - pub const SignedDepositBase: Balance = deposit(1, 0); - // A typical solution occupies within an order of magnitude of 50kb. - // This formula is currently adjusted such that a typical solution will spend an amount equal - // to the base deposit for every 50 kb. - pub const SignedDepositByte: Balance = deposit(1, 0) / (50 * 1024); + pub const SignedDepositBase: Balance = deposit(2, 0); + pub const SignedDepositByte: Balance = deposit(0, 10) / 1024; // Each good submission will get 1/10 KSM as reward pub SignedRewardBase: Balance = UNITS / 10; // fallback: emergency phase. @@ -1038,20 +1035,22 @@ impl InstanceFilter for ProxyType { ), ProxyType::Governance => matches!( c, - Call::Democracy(..) | - Call::Council(..) | Call::TechnicalCommittee(..) | - Call::PhragmenElection(..) | - Call::Treasury(..) | Call::Bounties(..) | - Call::Tips(..) | Call::Utility(..) + Call::Democracy(..) + | Call::Council(..) | Call::TechnicalCommittee(..) + | Call::PhragmenElection(..) + | Call::Treasury(..) | Call::Bounties(..) + | Call::Tips(..) | Call::Utility(..) ), - ProxyType::Staking => - matches!(c, Call::Staking(..) | Call::Session(..) | Call::Utility(..)), + ProxyType::Staking => { + matches!(c, Call::Staking(..) | Call::Session(..) | Call::Utility(..)) + } ProxyType::IdentityJudgement => matches!( c, Call::Identity(pallet_identity::Call::provide_judgement(..)) | Call::Utility(..) ), - ProxyType::CancelProxy => - matches!(c, Call::Proxy(pallet_proxy::Call::reject_announcement(..))), + ProxyType::CancelProxy => { + matches!(c, Call::Proxy(pallet_proxy::Call::reject_announcement(..))) + } } } fn is_superset(&self, o: &Self) -> bool { @@ -1919,3 +1918,17 @@ sp_api::impl_runtime_apis! { } } } + +#[cfg(test)] +mod tests_fess { + use super::*; + use sp_runtime::assert_eq_error_rate; + + #[test] + fn signed_deposit_is_sensible() { + // ensure this number does not change, or that it is checked after each change. + // a 1 MB solution should need around 0.16 KSM deposit + let deposit = SignedDepositBase::get() + (SignedDepositByte::get() * 1024 * 1024); + assert_eq_error_rate!(deposit, UNITS * 16 / 100, UNITS / 100); + } +} diff --git a/runtime/polkadot/src/lib.rs b/runtime/polkadot/src/lib.rs index 9eaf21440cf3..c5e59e2b6264 100644 --- a/runtime/polkadot/src/lib.rs +++ b/runtime/polkadot/src/lib.rs @@ -123,32 +123,32 @@ impl Contains for BaseFilter { fn contains(call: &Call) -> bool { match call { // These modules are all allowed to be called by transactions: - Call::Democracy(_) | - Call::Council(_) | - Call::TechnicalCommittee(_) | - Call::TechnicalMembership(_) | - Call::Treasury(_) | - Call::PhragmenElection(_) | - Call::System(_) | - Call::Scheduler(_) | - Call::Indices(_) | - Call::Babe(_) | - Call::Timestamp(_) | - Call::Balances(_) | - Call::Authorship(_) | - Call::Staking(_) | - Call::Session(_) | - Call::Grandpa(_) | - Call::ImOnline(_) | - Call::Utility(_) | - Call::Claims(_) | - Call::Vesting(_) | - Call::Identity(_) | - Call::Proxy(_) | - Call::Multisig(_) | - Call::Bounties(_) | - Call::Tips(_) | - Call::ElectionProviderMultiPhase(_) => true, + Call::Democracy(_) + | Call::Council(_) + | Call::TechnicalCommittee(_) + | Call::TechnicalMembership(_) + | Call::Treasury(_) + | Call::PhragmenElection(_) + | Call::System(_) + | Call::Scheduler(_) + | Call::Indices(_) + | Call::Babe(_) + | Call::Timestamp(_) + | Call::Balances(_) + | Call::Authorship(_) + | Call::Staking(_) + | Call::Session(_) + | Call::Grandpa(_) + | Call::ImOnline(_) + | Call::Utility(_) + | Call::Claims(_) + | Call::Vesting(_) + | Call::Identity(_) + | Call::Proxy(_) + | Call::Multisig(_) + | Call::Bounties(_) + | Call::Tips(_) + | Call::ElectionProviderMultiPhase(_) => true, } } } @@ -350,11 +350,10 @@ parameter_types! { // signed config pub const SignedMaxSubmissions: u32 = 16; - pub const SignedDepositBase: Balance = deposit(1, 0); - // A typical solution occupies within an order of magnitude of 50kb. - // This formula is currently adjusted such that a typical solution will spend an amount equal - // to the base deposit for every 50 kb. - pub const SignedDepositByte: Balance = deposit(1, 0) / (50 * 1024); + // 40 DOTs fixed deposit.. + pub const SignedDepositBase: Balance = deposit(2, 0); + // 0.01 DOT per KB of solution data. + pub const SignedDepositByte: Balance = deposit(0, 10) / 1024; // Each good submission will get 1 DOT as reward pub SignedRewardBase: Balance = 1 * UNITS; // fallback: emergency phase. @@ -988,20 +987,22 @@ impl InstanceFilter for ProxyType { ), ProxyType::Governance => matches!( c, - Call::Democracy(..) | - Call::Council(..) | Call::TechnicalCommittee(..) | - Call::PhragmenElection(..) | - Call::Treasury(..) | Call::Bounties(..) | - Call::Tips(..) | Call::Utility(..) + Call::Democracy(..) + | Call::Council(..) | Call::TechnicalCommittee(..) + | Call::PhragmenElection(..) + | Call::Treasury(..) | Call::Bounties(..) + | Call::Tips(..) | Call::Utility(..) ), - ProxyType::Staking => - matches!(c, Call::Staking(..) | Call::Session(..) | Call::Utility(..)), + ProxyType::Staking => { + matches!(c, Call::Staking(..) | Call::Session(..) | Call::Utility(..)) + } ProxyType::IdentityJudgement => matches!( c, Call::Identity(pallet_identity::Call::provide_judgement(..)) | Call::Utility(..) ), - ProxyType::CancelProxy => - matches!(c, Call::Proxy(pallet_proxy::Call::reject_announcement(..))), + ProxyType::CancelProxy => { + matches!(c, Call::Proxy(pallet_proxy::Call::reject_announcement(..))) + } } } fn is_superset(&self, o: &Self) -> bool { @@ -1547,6 +1548,7 @@ mod test_fees { use pallet_transaction_payment::Multiplier; use parity_scale_codec::Encode; use separator::Separatable; + use sp_runtime::assert_eq_error_rate; use sp_runtime::FixedPointNumber; #[test] @@ -1672,6 +1674,14 @@ mod test_fees { println!("can support {} nominators to yield a weight of {}", active, weight_with(active)); assert!(active > target_voters, "we need to reevaluate the weight of the election system"); } + + #[test] + fn signed_deposit_is_sensible() { + // ensure this number does not change, or that it is checked after each change. + // a 1 MB solution should take (40 + 10) DOTs of deposit. + let deposit = SignedDepositBase::get() + (SignedDepositByte::get() * 1024 * 1024); + assert_eq_error_rate!(deposit, 50 * DOLLARS, DOLLARS); + } } #[cfg(test)] diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index 54cdeed90131..e33cb9240714 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -331,11 +331,8 @@ parameter_types! { // signed config pub const SignedMaxSubmissions: u32 = 128; - pub const SignedDepositBase: Balance = deposit(1, 0); - // A typical solution occupies within an order of magnitude of 50kb. - // This formula is currently adjusted such that a typical solution will spend an amount equal - // to the base deposit for every 50 kb. - pub const SignedDepositByte: Balance = deposit(1, 0) / (50 * 1024); + pub const SignedDepositBase: Balance = deposit(2, 0); + pub const SignedDepositByte: Balance = deposit(0, 10) / 1024; // Each good submission will get 1 WND as reward pub SignedRewardBase: Balance = 1 * UNITS; // fallback: emergency phase. @@ -708,11 +705,13 @@ impl InstanceFilter for ProxyType { Call::Slots(..) | Call::Auctions(..) // Specifically omitting the entire XCM Pallet ), - ProxyType::Staking => - matches!(c, Call::Staking(..) | Call::Session(..) | Call::Utility(..)), + ProxyType::Staking => { + matches!(c, Call::Staking(..) | Call::Session(..) | Call::Utility(..)) + } ProxyType::SudoBalances => match c { - Call::Sudo(pallet_sudo::Call::sudo(ref x)) => - matches!(x.as_ref(), &Call::Balances(..)), + Call::Sudo(pallet_sudo::Call::sudo(ref x)) => { + matches!(x.as_ref(), &Call::Balances(..)) + } Call::Utility(..) => true, _ => false, }, @@ -720,8 +719,9 @@ impl InstanceFilter for ProxyType { c, Call::Identity(pallet_identity::Call::provide_judgement(..)) | Call::Utility(..) ), - ProxyType::CancelProxy => - matches!(c, Call::Proxy(pallet_proxy::Call::reject_announcement(..))), + ProxyType::CancelProxy => { + matches!(c, Call::Proxy(pallet_proxy::Call::reject_announcement(..))) + } } } fn is_superset(&self, o: &Self) -> bool { From f0562633239cf0fd65b78242d175fb94ee8c521b Mon Sep 17 00:00:00 2001 From: kianenigma Date: Wed, 11 Aug 2021 18:04:59 +0200 Subject: [PATCH 2/2] undo fmt --- runtime/kusama/src/lib.rs | 14 ++++---- runtime/polkadot/src/lib.rs | 69 ++++++++++++++++++------------------- runtime/westend/src/lib.rs | 6 ++-- 3 files changed, 44 insertions(+), 45 deletions(-) diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index 64f6515d559c..bc47e20cf127 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -1035,22 +1035,22 @@ impl InstanceFilter for ProxyType { ), ProxyType::Governance => matches!( c, - Call::Democracy(..) - | Call::Council(..) | Call::TechnicalCommittee(..) - | Call::PhragmenElection(..) - | Call::Treasury(..) | Call::Bounties(..) - | Call::Tips(..) | Call::Utility(..) + Call::Democracy(..) | + Call::Council(..) | Call::TechnicalCommittee(..) | + Call::PhragmenElection(..) | + Call::Treasury(..) | Call::Bounties(..) | + Call::Tips(..) | Call::Utility(..) ), ProxyType::Staking => { matches!(c, Call::Staking(..) | Call::Session(..) | Call::Utility(..)) - } + }, ProxyType::IdentityJudgement => matches!( c, Call::Identity(pallet_identity::Call::provide_judgement(..)) | Call::Utility(..) ), ProxyType::CancelProxy => { matches!(c, Call::Proxy(pallet_proxy::Call::reject_announcement(..))) - } + }, } } fn is_superset(&self, o: &Self) -> bool { diff --git a/runtime/polkadot/src/lib.rs b/runtime/polkadot/src/lib.rs index c5e59e2b6264..c7ac04989dbb 100644 --- a/runtime/polkadot/src/lib.rs +++ b/runtime/polkadot/src/lib.rs @@ -123,32 +123,32 @@ impl Contains for BaseFilter { fn contains(call: &Call) -> bool { match call { // These modules are all allowed to be called by transactions: - Call::Democracy(_) - | Call::Council(_) - | Call::TechnicalCommittee(_) - | Call::TechnicalMembership(_) - | Call::Treasury(_) - | Call::PhragmenElection(_) - | Call::System(_) - | Call::Scheduler(_) - | Call::Indices(_) - | Call::Babe(_) - | Call::Timestamp(_) - | Call::Balances(_) - | Call::Authorship(_) - | Call::Staking(_) - | Call::Session(_) - | Call::Grandpa(_) - | Call::ImOnline(_) - | Call::Utility(_) - | Call::Claims(_) - | Call::Vesting(_) - | Call::Identity(_) - | Call::Proxy(_) - | Call::Multisig(_) - | Call::Bounties(_) - | Call::Tips(_) - | Call::ElectionProviderMultiPhase(_) => true, + Call::Democracy(_) | + Call::Council(_) | + Call::TechnicalCommittee(_) | + Call::TechnicalMembership(_) | + Call::Treasury(_) | + Call::PhragmenElection(_) | + Call::System(_) | + Call::Scheduler(_) | + Call::Indices(_) | + Call::Babe(_) | + Call::Timestamp(_) | + Call::Balances(_) | + Call::Authorship(_) | + Call::Staking(_) | + Call::Session(_) | + Call::Grandpa(_) | + Call::ImOnline(_) | + Call::Utility(_) | + Call::Claims(_) | + Call::Vesting(_) | + Call::Identity(_) | + Call::Proxy(_) | + Call::Multisig(_) | + Call::Bounties(_) | + Call::Tips(_) | + Call::ElectionProviderMultiPhase(_) => true, } } } @@ -987,22 +987,22 @@ impl InstanceFilter for ProxyType { ), ProxyType::Governance => matches!( c, - Call::Democracy(..) - | Call::Council(..) | Call::TechnicalCommittee(..) - | Call::PhragmenElection(..) - | Call::Treasury(..) | Call::Bounties(..) - | Call::Tips(..) | Call::Utility(..) + Call::Democracy(..) | + Call::Council(..) | Call::TechnicalCommittee(..) | + Call::PhragmenElection(..) | + Call::Treasury(..) | Call::Bounties(..) | + Call::Tips(..) | Call::Utility(..) ), ProxyType::Staking => { matches!(c, Call::Staking(..) | Call::Session(..) | Call::Utility(..)) - } + }, ProxyType::IdentityJudgement => matches!( c, Call::Identity(pallet_identity::Call::provide_judgement(..)) | Call::Utility(..) ), ProxyType::CancelProxy => { matches!(c, Call::Proxy(pallet_proxy::Call::reject_announcement(..))) - } + }, } } fn is_superset(&self, o: &Self) -> bool { @@ -1548,8 +1548,7 @@ mod test_fees { use pallet_transaction_payment::Multiplier; use parity_scale_codec::Encode; use separator::Separatable; - use sp_runtime::assert_eq_error_rate; - use sp_runtime::FixedPointNumber; + use sp_runtime::{assert_eq_error_rate, FixedPointNumber}; #[test] fn payout_weight_portion() { diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index e33cb9240714..983337efb4f1 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -707,11 +707,11 @@ impl InstanceFilter for ProxyType { ), ProxyType::Staking => { matches!(c, Call::Staking(..) | Call::Session(..) | Call::Utility(..)) - } + }, ProxyType::SudoBalances => match c { Call::Sudo(pallet_sudo::Call::sudo(ref x)) => { matches!(x.as_ref(), &Call::Balances(..)) - } + }, Call::Utility(..) => true, _ => false, }, @@ -721,7 +721,7 @@ impl InstanceFilter for ProxyType { ), ProxyType::CancelProxy => { matches!(c, Call::Proxy(pallet_proxy::Call::reject_announcement(..))) - } + }, } } fn is_superset(&self, o: &Self) -> bool {