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

Self-Vote for Staking (among others.) #2078

Merged
merged 65 commits into from
Mar 22, 2019
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
aa83f22
initial doc for the staking module
kianenigma Mar 9, 2019
b9d09bb
Remove md style links.
kianenigma Mar 9, 2019
7df2b19
Remove todos.
kianenigma Mar 9, 2019
28b959b
Add rust code types
kianenigma Mar 9, 2019
91be68b
Rename and fix review notes.
kianenigma Mar 11, 2019
5912ff5
Add new md file
kianenigma Mar 11, 2019
64ca546
Final touches.
kianenigma Mar 11, 2019
a8ba78e
Migrate compleatly to rustdoc
kianenigma Mar 11, 2019
982d7e8
Update link
kianenigma Mar 11, 2019
4a572a2
Fix heading
kianenigma Mar 11, 2019
ea5ae00
Merge branch 'master' into kiz-document-staking
kianenigma Mar 12, 2019
89682a6
Final touches wrt the new template.
kianenigma Mar 12, 2019
956ec96
Remove empty prereq.
kianenigma Mar 12, 2019
2879e1d
Fix more reviews
kianenigma Mar 12, 2019
105723b
Some final nits.
kianenigma Mar 12, 2019
531ae73
Merge branch 'master' of github.com:paritytech/substrate into kiz-doc…
kianenigma Mar 14, 2019
5567859
Fix some side issues.
kianenigma Mar 14, 2019
e739361
Fix another set of reviews
kianenigma Mar 15, 2019
4eb568c
Fix + stabilize leftover reivews.
kianenigma Mar 15, 2019
9b026cc
Remove unused test parameters
kianenigma Mar 15, 2019
a8075c7
Fix typo.
kianenigma Mar 15, 2019
a33205b
Merge redundant loops
kianenigma Mar 15, 2019
07f9710
Merge branch 'kiz-document-staking' into kiz-staking-enhance
kianenigma Mar 15, 2019
cfb39b9
Adds phantom self-vote
kianenigma Mar 16, 2019
a4c298c
Fix broken tests.
kianenigma Mar 17, 2019
5eb6f24
Refactor some names to match the reference.
kianenigma Mar 17, 2019
c4bdb81
Remove redundant inner loops from election round.
kianenigma Mar 18, 2019
03d7583
Introduce phragmen post-processing.
kianenigma Mar 19, 2019
bf8212f
Some fixes and todos.
kianenigma Mar 19, 2019
85f1294
Fix some tests with new phragmen params
kianenigma Mar 21, 2019
eb6d9b5
master.into()
kianenigma Mar 21, 2019
54c1417
Fix test
gavofyork Mar 21, 2019
abc1685
Bump spec
gavofyork Mar 21, 2019
0cdc3c1
Fix wasm build
gavofyork Mar 21, 2019
0d429d8
Fix tests and phragmen fallback. Avoid double-controlling
gavofyork Mar 22, 2019
ae0f53e
Fix and rebuild wasm
gavofyork Mar 22, 2019
7b301ad
Whitespaces, whitespaces everywhere.
kianenigma Mar 22, 2019
1488960
Merge remote-tracking branch 'origin/master' into kiz-staking-enhance
gavofyork Mar 22, 2019
f6b9fbc
Rebuild
gavofyork Mar 22, 2019
c26f890
Disable post-processing.
kianenigma Mar 22, 2019
f40f671
Merge test conflicts.
kianenigma Mar 22, 2019
b399c8a
Identify by stash, not controller account.
gavofyork Mar 22, 2019
d3e5539
Couple of fixes
gavofyork Mar 22, 2019
fcce528
Fix first test
gavofyork Mar 22, 2019
202f67b
Merge branch 'kiz-staking-enhance' of github.com:paritytech/substrate…
gavofyork Mar 22, 2019
6c64125
Fix invulnerability_should_work
gavofyork Mar 22, 2019
badd121
Fix a couple more tests
gavofyork Mar 22, 2019
7b83e30
Fix more tests
gavofyork Mar 22, 2019
a9a3a92
Fix more tests
gavofyork Mar 22, 2019
f14977d
Fix more tests
gavofyork Mar 22, 2019
a41aeec
Fix some tests
kianenigma Mar 22, 2019
f584fd1
Merge branch 'kiz-staking-enhance' of github.com:paritytech/substrate…
kianenigma Mar 22, 2019
817d538
Fix update-ledger.
gavofyork Mar 22, 2019
1257dfe
Merge remote-tracking branch 'origin/kiz-staking-enhance' into kiz-st…
gavofyork Mar 22, 2019
a879983
Fix update-ledger.
gavofyork Mar 22, 2019
0d6136d
Fix another test
gavofyork Mar 22, 2019
0dbff72
Fix another test
gavofyork Mar 22, 2019
184cb5c
Fix rest of staking tests
gavofyork Mar 22, 2019
1b4b05f
Remove printlns
gavofyork Mar 22, 2019
1be69c2
Rebuild wasm
gavofyork Mar 22, 2019
d380360
Merge remote-tracking branch 'origin/master' into kiz-staking-enhance
gavofyork Mar 22, 2019
f255ef5
Fix & tests for auth/val syncing
gavofyork Mar 22, 2019
fd5b2cd
Merge remote-tracking branch 'origin/master' into kiz-staking-enhance
gavofyork Mar 22, 2019
e20b766
Fix up threading for tests
gavofyork Mar 22, 2019
4d8a2fd
Remove superfluous asserts
gavofyork Mar 22, 2019
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
1 change: 1 addition & 0 deletions core/sr-std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ pub mod prelude {
pub use crate::boxed::Box;
pub use crate::cmp::{Eq, PartialEq};
pub use crate::clone::Clone;
pub use crate::alloc::prelude::*;

// Re-export `vec!` macro here, but not in `std` mode, since
// std's prelude already brings `vec!` into the scope.
Expand Down
16 changes: 1 addition & 15 deletions node/executor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,13 +443,7 @@ mod tests {
]
);

// let mut digest = generic::Digest::<Log>::default();
// digest.push(Log::from(::grandpa::RawLog::AuthoritiesChangeSignal(0, vec![
// (Keyring::Charlie.to_raw_public().into(), 1),
// (Keyring::Bob.to_raw_public().into(), 1),
// (Keyring::Alice.to_raw_public().into(), 1),
// ])));
let digest = generic::Digest::<Log>::default(); // TODO test this
let digest = generic::Digest::<Log>::default();
assert_eq!(Header::decode(&mut &block2.0[..]).unwrap().digest, digest);

(block1, block2)
Expand Down Expand Up @@ -578,14 +572,6 @@ mod tests {
phase: Phase::Finalization,
event: Event::session(session::RawEvent::NewSession(1))
},
// EventRecord { // TODO: this might be wrong.
// phase: Phase::Finalization,
// event: Event::grandpa(::grandpa::RawEvent::NewAuthorities(vec![
// (Keyring::Charlie.to_raw_public().into(), 1),
// (Keyring::Bob.to_raw_public().into(), 1),
// (Keyring::Alice.to_raw_public().into(), 1),
// ])),
// },
EventRecord {
phase: Phase::Finalization,
event: Event::treasury(treasury::RawEvent::Spending(0))
Expand Down
2 changes: 1 addition & 1 deletion node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("node"),
impl_name: create_runtime_str!("substrate-node"),
authoring_version: 10,
spec_version: 38,
spec_version: 39,
impl_version: 39,
apis: RUNTIME_API_VERSIONS,
};
Expand Down
Binary file not shown.
266 changes: 239 additions & 27 deletions srml/staking/src/lib.rs

Large diffs are not rendered by default.

71 changes: 27 additions & 44 deletions srml/staking/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ pub struct ExtBuilder {
session_length: u64,
sessions_per_era: u64,
current_era: u64,
monied: bool,
reward: u64,
validator_pool: bool,
nominate: bool,
validator_count: u32,
minimum_validator_count: u32,
fare: bool,
}

impl Default for ExtBuilder {
Expand All @@ -99,12 +99,12 @@ impl Default for ExtBuilder {
session_length: 1,
sessions_per_era: 1,
current_era: 0,
monied: true,
reward: 10,
validator_pool: false,
nominate: true,
validator_count: 2,
minimum_validator_count: 0,
fare: true
}
}
}
Expand All @@ -126,16 +126,7 @@ impl ExtBuilder {
self.current_era = current_era;
self
}
pub fn _monied(mut self, monied: bool) -> Self {
self.monied = monied;
self
}
pub fn reward(mut self, reward: u64) -> Self {
self.reward = reward;
self
}
pub fn validator_pool(mut self, validator_pool: bool) -> Self {
// NOTE: this should only be set to true with monied = false.
self.validator_pool = validator_pool;
self
}
Expand All @@ -152,6 +143,10 @@ impl ExtBuilder {
self.minimum_validator_count = count;
self
}
pub fn fare(mut self, is_fare: bool) -> Self {
self.fare = is_fare;
self
}
pub fn build(self) -> runtime_io::TestExternalities<Blake2Hasher> {
let (mut t, mut c) = system::GenesisConfig::<Test>::default().build_storage().unwrap();
let balance_factor = if self.existential_deposit > 0 {
Expand All @@ -170,34 +165,22 @@ impl ExtBuilder {
keys: vec![],
}.assimilate_storage(&mut t, &mut c);
let _ = balances::GenesisConfig::<Test>{
balances: if self.monied {
if self.reward > 0 {
vec![
(1, 10 * balance_factor),
(2, 20 * balance_factor),
(3, 300 * balance_factor),
(4, 400 * balance_factor),
(10, balance_factor),
(11, balance_factor * 1000),
(20, balance_factor),
(21, balance_factor * 2000),
(100, 2000 * balance_factor),
(101, 2000 * balance_factor),
]
} else {
vec![
(1, 10 * balance_factor), (2, 20 * balance_factor),
(3, 300 * balance_factor), (4, 400 * balance_factor)
]
}
} else {
vec![
(10, balance_factor), (11, balance_factor * 10),
(20, balance_factor), (21, balance_factor * 20),
(30, balance_factor), (31, balance_factor * 30),
(40, balance_factor), (41, balance_factor * 40)
]
},
balances: vec![
(1, 10 * balance_factor),
(2, 20 * balance_factor),
(3, 300 * balance_factor),
(4, 400 * balance_factor),
(10, balance_factor),
(11, balance_factor * 1000),
(20, balance_factor),
(21, balance_factor * 2000),
(30, balance_factor),
(31, balance_factor * 2000),
(40, balance_factor),
(41, balance_factor * 2000),
(100, 2000 * balance_factor),
(101, 2000 * balance_factor),
],
transaction_base_fee: 0,
transaction_byte_fee: 0,
existential_deposit: self.existential_deposit,
Expand All @@ -211,16 +194,16 @@ impl ExtBuilder {
stakers: if self.validator_pool {
vec![
(11, 10, balance_factor * 1000, StakerStatus::<AccountIdType>::Validator),
(21, 20, balance_factor * 2000, StakerStatus::<AccountIdType>::Validator),
(31, 30, balance_factor * 3000, if self.validator_pool { StakerStatus::<AccountIdType>::Validator } else { StakerStatus::<AccountIdType>::Idle }),
(41, 40, balance_factor * 4000, if self.validator_pool { StakerStatus::<AccountIdType>::Validator } else { StakerStatus::<AccountIdType>::Idle }),
(21, 20, balance_factor * if self.fare { 1000 } else { 2000 }, StakerStatus::<AccountIdType>::Validator),
(31, 30, balance_factor * 1000, if self.validator_pool { StakerStatus::<AccountIdType>::Validator } else { StakerStatus::<AccountIdType>::Idle }),
(41, 40, balance_factor * 1000, if self.validator_pool { StakerStatus::<AccountIdType>::Validator } else { StakerStatus::<AccountIdType>::Idle }),
// nominator
(101, 100, balance_factor * 500, if self.nominate { StakerStatus::<AccountIdType>::Nominator(vec![10, 20]) } else { StakerStatus::<AccountIdType>::Nominator(vec![]) })
]
} else {
vec![
(11, 10, balance_factor * 1000, StakerStatus::<AccountIdType>::Validator),
(21, 20, balance_factor * 2000, StakerStatus::<AccountIdType>::Validator),
(21, 20, balance_factor * if self.fare { 1000 } else { 2000 }, StakerStatus::<AccountIdType>::Validator),
// nominator
(101, 100, balance_factor * 500, if self.nominate { StakerStatus::<AccountIdType>::Nominator(vec![10, 20]) } else { StakerStatus::<AccountIdType>::Nominator(vec![]) })
]
Expand All @@ -229,7 +212,7 @@ impl ExtBuilder {
minimum_validator_count: self.minimum_validator_count,
bonding_duration: self.sessions_per_era * self.session_length * 3,
session_reward: Perbill::from_millionths((1000000 * self.reward / balance_factor) as u32),
offline_slash: if self.monied { Perbill::from_percent(40) } else { Perbill::zero() },
offline_slash: Perbill::from_percent(40),
current_session_reward: self.reward,
current_offline_slash: 20,
offline_slash_grace: 0,
Expand Down
Loading