Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
a83059a
Completely rework dispatch mechanism into something modular.
gavofyork Mar 13, 2018
82a178d
Council vote tests.
gavofyork Mar 13, 2018
1d28d9a
Fix tests.
gavofyork Mar 13, 2018
69c88c3
whitespace.
gavofyork Mar 13, 2018
b12a708
Fix demo runtime tests.
gavofyork Mar 14, 2018
e48e86d
Merge branch 'gav-demo' into gav-dispatch
gavofyork Mar 14, 2018
8e3cc51
Fix up tests.
gavofyork Mar 14, 2018
53e2fdf
Merge branch 'gav-demo' into gav-dispatch
gavofyork Mar 14, 2018
27ecd6f
Merge branch 'master' into gav-dispatch
gavofyork Mar 14, 2018
5eca74a
Remove dead code.
gavofyork Mar 14, 2018
5d5f194
Initial util code for random beacon
gavofyork Mar 14, 2018
7cece3b
Merge branch 'master' into gav-dispatch
gavofyork Mar 14, 2018
8c2396d
Timestamp uses new storage API.
gavofyork Mar 14, 2018
6b6c240
Move over system module to new API.
gavofyork Mar 14, 2018
a79dab2
Much nicer storage API, moved over staking module.
gavofyork Mar 15, 2018
1fd6b3e
More refactoring.
gavofyork Mar 15, 2018
51b4a8c
Democracy uses new storage API.
gavofyork Mar 15, 2018
8ada9f7
Council uses new RPC.
gavofyork Mar 16, 2018
c4f5f42
Fix more tests.
gavofyork Mar 16, 2018
d11f5ca
Use match for Id
gavofyork Mar 16, 2018
53eb893
Merge branch 'gav-storage-revamp' into gav-random-beacon
gavofyork Mar 16, 2018
d228593
Generic mix.
gavofyork Mar 16, 2018
a90fbe3
Integrate random beacon
gavofyork Mar 16, 2018
d352727
Update binaries.
gavofyork Mar 16, 2018
19f7258
Fixes relating to with_ext removal.
gavofyork Mar 16, 2018
ff2fa3c
Remove dead code.
gavofyork Mar 16, 2018
c674963
Rework mixer into an iterator adaptor.
gavofyork Mar 17, 2018
c49d8a9
Merge branch 'master' into gav-random-beacon
gavofyork Mar 19, 2018
74a59b9
Link to paper.
gavofyork Mar 19, 2018
23ca1b2
Algorithm cleanups
gavofyork Mar 19, 2018
1bb150b
Merge and fix test.
gavofyork Mar 19, 2018
2e9fa09
Docs.
gavofyork Mar 19, 2018
e4c2b27
Fix typo.
gavofyork Mar 19, 2018
90dd1a5
rename
gavofyork Mar 19, 2018
f197714
Fix tests.
gavofyork Mar 19, 2018
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
Prev Previous commit
Next Next commit
Much nicer storage API, moved over staking module.
  • Loading branch information
gavofyork committed Mar 15, 2018
commit a79dab27fd191e16e34d3841f442a8d6cf1266a4
10 changes: 5 additions & 5 deletions demo/runtime/src/genesismap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use codec::{KeyedVec, Joiner};
use std::collections::HashMap;
use runtime_io::twox_128;
use runtime_support::{Hashable, StorageMap};
use runtime_support::{Hashable, StorageMap, StorageList, StorageValue};
use primitives::Block;
use demo_primitives::{BlockNumber, AccountId};
use runtime::staking::Balance;
Expand Down Expand Up @@ -83,9 +83,9 @@ impl GenesisConfig {
(&session::SESSION_LENGTH[..], vec![].and(&self.session_length)),
(&session::VALIDATOR_COUNT[..], vec![].and(&(self.validators.len() as u32))),

(&staking::INTENTION_COUNT[..], vec![].and(&0u32)),
(&staking::SESSIONS_PER_ERA[..], vec![].and(&self.sessions_per_era)),
(&staking::CURRENT_ERA[..], vec![].and(&0u64)),
(&staking::Intention::len_key()[..], vec![].and(&0u32)),
(&staking::SessionsPerEra::key()[..], vec![].and(&self.sessions_per_era)),
(&staking::CurrentEra::key()[..], vec![].and(&0u64)),

(&democracy::LAUNCH_PERIOD[..], vec![].and(&self.launch_period)),
(&democracy::VOTING_PERIOD[..], vec![].and(&self.voting_period)),
Expand Down Expand Up @@ -113,7 +113,7 @@ impl GenesisConfig {
)
.map(|(k, v)| (twox_128(&k[..])[..].to_vec(), v.to_vec()))
.chain(vec![
(b":code".to_vec(), wasm_runtime),
(system::CODE.to_vec(), wasm_runtime),
(consensus::AUTHORITY_COUNT[..].into(), vec![].and(&(self.authorities.len() as u32))),
].into_iter())
.chain(self.authorities.iter()
Expand Down
48 changes: 25 additions & 23 deletions demo/runtime/src/runtime/democracy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ pub mod internal {
// tally up votes for any expiring referenda.
for (index, _, proposal, vote_threshold) in maturing_referendums_at(now) {
let (approve, against) = tally(index);
let total_stake = staking::total_stake();
let total_stake = staking::TotalStake::get();
clear_referendum(index);
if vote_threshold.approved(approve, against, total_stake) {
proposal.dispatch(PrivPass);
Expand Down Expand Up @@ -334,6 +334,7 @@ fn clear_referendum(ref_index: ReferendumIndex) {
pub mod testing {
use super::*;
use runtime_io::{twox_128, TestExternalities};
use runtime_support::{StorageList, StorageValue, StorageMap};
use codec::Joiner;
use keyring::Keyring::*;
use runtime::{session, staking};
Expand All @@ -345,22 +346,22 @@ pub mod testing {
twox_128(&0u32.to_keyed_vec(session::VALIDATOR_AT)).to_vec() => Alice.to_raw_public_vec(),
twox_128(&1u32.to_keyed_vec(session::VALIDATOR_AT)).to_vec() => Bob.to_raw_public_vec(),
twox_128(&2u32.to_keyed_vec(session::VALIDATOR_AT)).to_vec() => Charlie.to_raw_public_vec(),
twox_128(staking::INTENTION_COUNT).to_vec() => vec![].and(&3u32),
twox_128(&0u32.to_keyed_vec(staking::INTENTION_AT)).to_vec() => Alice.to_raw_public_vec(),
twox_128(&1u32.to_keyed_vec(staking::INTENTION_AT)).to_vec() => Bob.to_raw_public_vec(),
twox_128(&2u32.to_keyed_vec(staking::INTENTION_AT)).to_vec() => Charlie.to_raw_public_vec(),
twox_128(&Alice.to_raw_public().to_keyed_vec(staking::BALANCE_OF)).to_vec() => vec![].and(&10u64),
twox_128(&Bob.to_raw_public().to_keyed_vec(staking::BALANCE_OF)).to_vec() => vec![].and(&20u64),
twox_128(&Charlie.to_raw_public().to_keyed_vec(staking::BALANCE_OF)).to_vec() => vec![].and(&30u64),
twox_128(&Dave.to_raw_public().to_keyed_vec(staking::BALANCE_OF)).to_vec() => vec![].and(&40u64),
twox_128(&Eve.to_raw_public().to_keyed_vec(staking::BALANCE_OF)).to_vec() => vec![].and(&50u64),
twox_128(&Ferdie.to_raw_public().to_keyed_vec(staking::BALANCE_OF)).to_vec() => vec![].and(&60u64),
twox_128(&One.to_raw_public().to_keyed_vec(staking::BALANCE_OF)).to_vec() => vec![].and(&1u64),
twox_128(staking::TOTAL_STAKE).to_vec() => vec![].and(&210u64),
twox_128(staking::SESSIONS_PER_ERA).to_vec() => vec![].and(&1u64),
twox_128(staking::VALIDATOR_COUNT).to_vec() => vec![].and(&3u64),
twox_128(staking::CURRENT_ERA).to_vec() => vec![].and(&1u64),
twox_128(staking::TRANSACTION_FEE).to_vec() => vec![].and(&1u64),
twox_128(&staking::Intention::len_key()).to_vec() => vec![].and(&3u32),
twox_128(&staking::Intention::key_for(0)).to_vec() => Alice.to_raw_public_vec(),
twox_128(&staking::Intention::key_for(1)).to_vec() => Bob.to_raw_public_vec(),
twox_128(&staking::Intention::key_for(2)).to_vec() => Charlie.to_raw_public_vec(),
twox_128(&staking::FreeBalanceOf::key_for(&Alice)).to_vec() => vec![].and(&10u64),
twox_128(&staking::FreeBalanceOf::key_for(&Bob)).to_vec() => vec![].and(&20u64),
twox_128(&staking::FreeBalanceOf::key_for(&Charlie)).to_vec() => vec![].and(&30u64),
twox_128(&staking::FreeBalanceOf::key_for(&Dave)).to_vec() => vec![].and(&40u64),
twox_128(&staking::FreeBalanceOf::key_for(&Eve)).to_vec() => vec![].and(&50u64),
twox_128(&staking::FreeBalanceOf::key_for(&Ferdie)).to_vec() => vec![].and(&60u64),
twox_128(&staking::FreeBalanceOf::key_for(&One)).to_vec() => vec![].and(&1u64),
twox_128(staking::TotalStake::key()).to_vec() => vec![].and(&210u64),
twox_128(staking::SessionsPerEra::key()).to_vec() => vec![].and(&1u64),
twox_128(staking::ValidatorCount::key()).to_vec() => vec![].and(&3u64),
twox_128(staking::CurrentEra::key()).to_vec() => vec![].and(&1u64),
twox_128(staking::TransactionFee::key()).to_vec() => vec![].and(&1u64),

twox_128(LAUNCH_PERIOD).to_vec() => vec![].and(&1u64),
twox_128(VOTING_PERIOD).to_vec() => vec![].and(&1u64),
Expand All @@ -373,6 +374,7 @@ pub mod testing {
mod tests {
use super::*;
use runtime_io::{with_externalities, twox_128, TestExternalities};
use runtime_support::{StorageValue, StorageMap};
use codec::{KeyedVec, Joiner};
use keyring::Keyring::*;
use environment::with_env;
Expand All @@ -394,8 +396,8 @@ mod tests {
assert_eq!(voting_period(), 1u64);
assert_eq!(minimum_deposit(), 1u64);
assert_eq!(next_free_ref_index(), 0u32);
assert_eq!(staking::sessions_per_era(), 1u64);
assert_eq!(staking::total_stake(), 210u64);
assert_eq!(staking::SessionsPerEra::get(), 1u64);
assert_eq!(staking::TotalStake::get(), 210u64);
});
}

Expand Down Expand Up @@ -519,19 +521,19 @@ mod tests {
PublicPass::test(&Alice).vote(0, true);
democracy::internal::end_block(system::block_number());
staking::internal::check_new_era();
assert_eq!(staking::bonding_duration(), 4u64);
assert_eq!(staking::BondingDuration::get(), 4u64);

with_env(|e| e.block_number = 2);
PublicPass::test(&Alice).vote(1, true);
democracy::internal::end_block(system::block_number());
staking::internal::check_new_era();
assert_eq!(staking::bonding_duration(), 3u64);
assert_eq!(staking::BondingDuration::get(), 3u64);

with_env(|e| e.block_number = 3);
PublicPass::test(&Alice).vote(2, true);
democracy::internal::end_block(system::block_number());
staking::internal::check_new_era();
assert_eq!(staking::bonding_duration(), 2u64);
assert_eq!(staking::BondingDuration::get(), 2u64);
});
}

Expand Down Expand Up @@ -632,7 +634,7 @@ mod tests {
fn passing_low_turnout_voting_should_work() {
with_externalities(&mut new_test_ext(), || {
assert_eq!(staking::era_length(), 1u64);
assert_eq!(staking::total_stake(), 210u64);
assert_eq!(staking::TotalStake::get(), 210u64);

with_env(|e| e.block_number = 1);
let r = inject_referendum(1, sessions_per_era_propsal(2), VoteThreshold::SuperMajorityApprove);
Expand Down
Loading