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 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
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