From 6476f26815040aad65fc221d23a0e6853f64a945 Mon Sep 17 00:00:00 2001 From: Gav <gavin@parity.io> Date: Sat, 3 Mar 2018 19:30:07 +0100 Subject: [PATCH] Introduce minimum deposit --- substrate/demo/runtime/src/runtime/democracy.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/substrate/demo/runtime/src/runtime/democracy.rs b/substrate/demo/runtime/src/runtime/democracy.rs index 1908051d7a2..1fc05d0ef48 100644 --- a/substrate/demo/runtime/src/runtime/democracy.rs +++ b/substrate/demo/runtime/src/runtime/democracy.rs @@ -74,6 +74,7 @@ const PUBLIC_PROP_COUNT: &[u8] = b"dem:cou"; // PropIndex const PUBLIC_PROPS: &[u8] = b"dem:pub"; // Vec<(PropIndex, Proposal)> const DEPOSIT_OF: &[u8] = b"dem:dep:"; // PropIndex -> (Balance, Vec<AccountId>) const LAUNCH_PERIOD: &[u8] = b"dem:lau"; // BlockNumber +const MINIMUM_DEPOSIT: &[u8] = b"dem:min"; // Balance // referenda const VOTING_PERIOD: &[u8] = b"dem:per"; // BlockNumber @@ -83,6 +84,12 @@ const REFERENDUM_INFO_OF: &[u8] = b"dem:pro:"; // ReferendumIndex -> (BlockNumbe const VOTERS_FOR: &[u8] = b"dem:vtr:"; // ReferendumIndex -> Vec<AccountId> const VOTE_OF: &[u8] = b"dem:vot:"; // (ReferendumIndex, AccountId) -> bool +/// The minimum amount to be used as a deposit for a public referendum proposal. +pub fn minimum_deposit() -> Balance { + storage::get(MINIMUM_DEPOSIT) + .expect("all core parameters of council module must be in place") +} + /// How often (in blocks) to check for new votes. pub fn voting_period() -> BlockNumber { storage::get(VOTING_PERIOD) @@ -159,6 +166,7 @@ pub mod public { /// Propose a sensitive action to be taken. pub fn propose(signed: &AccountId, proposal: &Proposal, value: Balance) { + assert!(value >= minimum_deposit()); let b = staking::balance(signed); assert!(b >= value); @@ -321,7 +329,8 @@ mod tests { twox_128(b"sta:vac").to_vec() => vec![].and(&3u64), twox_128(b"sta:era").to_vec() => vec![].and(&1u64), twox_128(LAUNCH_PERIOD).to_vec() => vec![].and(&1u64), - twox_128(VOTING_PERIOD).to_vec() => vec![].and(&1u64) + twox_128(VOTING_PERIOD).to_vec() => vec![].and(&1u64), + twox_128(MINIMUM_DEPOSIT).to_vec() => vec![].and(&1u64) ] } -- GitLab