Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

More standard staking miner deposits #3621

Merged
merged 2 commits into from
Aug 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 22 additions & 9 deletions runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -1044,14 +1041,16 @@ impl InstanceFilter<Call> for ProxyType {
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 {
Expand Down Expand Up @@ -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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why use assert_eq_error_rate! and not just assert_eq! ? Seems like the values should be constant relative to each other

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just to help with human readability

}
}
29 changes: 19 additions & 10 deletions runtime/polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -994,14 +993,16 @@ impl InstanceFilter<Call> for ProxyType {
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 {
Expand Down Expand Up @@ -1547,7 +1548,7 @@ mod test_fees {
use pallet_transaction_payment::Multiplier;
use parity_scale_codec::Encode;
use separator::Separatable;
use sp_runtime::FixedPointNumber;
use sp_runtime::{assert_eq_error_rate, FixedPointNumber};

#[test]
fn payout_weight_portion() {
Expand Down Expand Up @@ -1672,6 +1673,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)]
Expand Down
22 changes: 11 additions & 11 deletions runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -708,20 +705,23 @@ impl InstanceFilter<Call> 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,
},
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 {
Expand Down