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

Commit

Permalink
fix curated-grandpa and rebuild wasm (#162)
Browse files Browse the repository at this point in the history
  • Loading branch information
rphmeier authored Feb 26, 2019
1 parent c03d1cd commit 2dd861f
Show file tree
Hide file tree
Showing 7 changed files with 349 additions and 334 deletions.
7 changes: 5 additions & 2 deletions runtime/src/curated_grandpa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ use codec::Decode;
use sr_primitives::traits::{As, Hash as HashT, BlakeTwo256, Zero};
use rstd::prelude::*;


pub trait Trait: grandpa::Trait {}

decl_storage! {
trait Store for Module<T: Trait> as CuratedGrandpa {
/// How often to shuffle the GRANDPA sets.
pub ShufflePeriod get(shuffle_period) build(|_| T::BlockNumber::sa(1024u64)): T::BlockNumber;
///
/// 0 means never.
pub ShufflePeriod get(shuffle_period) config(shuffle_period): T::BlockNumber;
}
}

Expand All @@ -43,6 +44,8 @@ decl_module! {
fn on_finalise(block_number: T::BlockNumber) {
// every so often shuffle the voters and issue a change.
let shuffle_period: u64 = Self::shuffle_period().as_();
if shuffle_period == 0 { return }

if block_number.as_() % shuffle_period == 0 {
let mut seed = system::Module::<T>::random_seed().as_ref().to_vec();
seed.extend(b"grandpa_shuffling");
Expand Down
2 changes: 1 addition & 1 deletion runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ construct_runtime!(
Staking: staking,
Democracy: democracy,
Grandpa: grandpa::{Module, Call, Storage, Config<T>, Log(), Event<T>},
CuratedGrandpa: curated_grandpa::{Module, Call, Storage},
CuratedGrandpa: curated_grandpa::{Module, Call, Config<T>, Storage},
Council: council::{Module, Call, Storage, Event<T>},
CouncilVoting: council_voting,
CouncilMotions: council_motions::{Module, Call, Storage, Event<T>, Origin},
Expand Down
661 changes: 333 additions & 328 deletions runtime/wasm/Cargo.lock

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions runtime/wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ bitvec = { version = "0.8", default-features = false, features = ["alloc"] }
integer-sqrt = { git = "https://github.com/paritytech/integer-sqrt-rs.git", branch = "master" }
polkadot-primitives = { path = "../../primitives", default-features = false }
safe-mix = { version = "1.0", default-features = false }
parity-codec = { version = "3.0", default-features = false }
parity-codec-derive = { version = "3.0", default-features = false }
parity-codec = { version = "3.0", default-features = false }
parity-codec-derive = { version = "3.0", default-features = false }
substrate-primitives = { git = "https://github.com/paritytech/substrate", branch = "v0.10", default-features = false }
substrate-client = { git = "https://github.com/paritytech/substrate", branch = "v0.10", default-features = false }
substrate-consensus-aura-primitives = { git = "https://github.com/paritytech/substrate", branch = "v0.10", default-features = false }
substrate-inherents = { git = "https://github.com/paritytech/substrate", branch = "v0.10", default-features = false }
sr-std = { git = "https://github.com/paritytech/substrate", branch = "v0.10", default-features = false }
sr-io = { git = "https://github.com/paritytech/substrate", branch = "v0.10", default-features = false }
srml-support = { git = "https://github.com/paritytech/substrate", branch = "v0.10", default-features = false }
Expand Down
Binary file not shown.
Binary file not shown.
8 changes: 7 additions & 1 deletion service/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use polkadot_runtime::{
GenesisConfig, ConsensusConfig, CouncilSeatsConfig, DemocracyConfig, TreasuryConfig,
SessionConfig, StakingConfig, TimestampConfig, BalancesConfig, Perbill,
CouncilVotingConfig, GrandpaConfig, UpgradeKeyConfig, SudoConfig, IndicesConfig,
Permill
CuratedGrandpaConfig, Permill
};

const STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/";
Expand Down Expand Up @@ -131,6 +131,9 @@ fn staging_testnet_config_genesis() -> GenesisConfig {
grandpa: Some(GrandpaConfig {
authorities: initial_authorities.clone().into_iter().map(|k| (k, 1)).collect(),
}),
curated_grandpa: Some(CuratedGrandpaConfig {
shuffle_period: 1024,
}),
}
}

Expand Down Expand Up @@ -232,6 +235,9 @@ fn testnet_genesis(initial_authorities: Vec<AuthorityId>, upgrade_key: H256) ->
sudo: Some(SudoConfig {
key: upgrade_key,
}),
curated_grandpa: Some(CuratedGrandpaConfig {
shuffle_period: 1024,
}),
}
}

Expand Down

0 comments on commit 2dd861f

Please sign in to comment.