diff --git a/polkadot/api/src/full.rs b/polkadot/api/src/full.rs index 46931653e0..66f6ceedcd 100644 --- a/polkadot/api/src/full.rs +++ b/polkadot/api/src/full.rs @@ -112,7 +112,7 @@ impl> PolkadotApi for Client Result { - with_runtime!(self, at, ::runtime::Timestamp::now) + with_runtime!(self, at, ::runtime::Timestamp::get) } fn evaluate_block(&self, at: &CheckedId, block: Block) -> Result { @@ -216,11 +216,13 @@ mod tests { session: Some(SessionConfig { validators: validators(), session_length: 100, + broken_percent_late: 100, }), council: Some(Default::default()), democracy: Some(Default::default()), parachains: Some(Default::default()), staking: Some(Default::default()), + timestamp: Some(Default::default()), }; ::client::new_in_mem(LocalDispatch::new(), genesis_config.build_storage()).unwrap() diff --git a/polkadot/cli/src/preset_config.rs b/polkadot/cli/src/preset_config.rs index e1a914073e..5bf44648d9 100644 --- a/polkadot/cli/src/preset_config.rs +++ b/polkadot/cli/src/preset_config.rs @@ -22,7 +22,7 @@ use serde_json; use substrate_primitives::{AuthorityId, storage::{StorageKey, StorageData}}; use runtime_primitives::{MakeStorage, BuildStorage, StorageMap}; use polkadot_runtime::{GenesisConfig, ConsensusConfig, CouncilConfig, DemocracyConfig, - SessionConfig, StakingConfig}; + SessionConfig, StakingConfig, TimestampConfig}; use chain_spec::ChainSpec; enum Config { @@ -98,7 +98,8 @@ impl PresetConfig { system: None, session: Some(SessionConfig { validators: initial_authorities.iter().cloned().map(Into::into).collect(), - session_length: 720, // that's 1 hour per session. + session_length: 60, // that's 5 minutes per session. + broken_percent_late: 50, }), staking: Some(StakingConfig { current_era: 0, @@ -110,32 +111,37 @@ impl PresetConfig { creation_fee: 0, contract_fee: 0, reclaim_rebate: 0, + early_era_slash: 10000, + session_reward: 100, balances: endowed_accounts.iter().map(|&k|(k, 1u128 << 60)).collect(), validator_count: 12, - sessions_per_era: 24, // 24 hours per era. - bonding_duration: 90, // 90 days per bond. + sessions_per_era: 12, // 1 hour per era + bonding_duration: 24, // 1 day per bond. }), democracy: Some(DemocracyConfig { - launch_period: 120 * 24 * 14, // 2 weeks per public referendum - voting_period: 120 * 24 * 28, // 4 weeks to discuss & vote on an active referendum - minimum_deposit: 1000, // 1000 as the minimum deposit for a referendum + launch_period: 12 * 60 * 24, // 1 day per public referendum + voting_period: 12 * 60 * 24 * 3, // 3 days to discuss & vote on an active referendum + minimum_deposit: 5000, // 12000 as the minimum deposit for a referendum }), council: Some(CouncilConfig { active_council: vec![], - candidacy_bond: 1000, // 1000 to become a council candidate - voter_bond: 100, // 100 down to vote for a candidate + candidacy_bond: 5000, // 5000 to become a council candidate + voter_bond: 1000, // 1000 down to vote for a candidate present_slash_per_voter: 1, // slash by 1 per voter for an invalid presentation. - carry_count: 24, // carry over the 24 runners-up to the next council election - presentation_duration: 120 * 24, // one day for presenting winners. - approval_voting_period: 7 * 120 * 24, // one week period between possible council elections. - term_duration: 180 * 120 * 24, // 180 day term duration for the council. + carry_count: 6, // carry over the 6 runners-up to the next council election + presentation_duration: 12 * 60 * 24, // one day for presenting winners. + approval_voting_period: 12 * 60 * 24 * 2, // two days period between possible council elections. + term_duration: 12 * 60 * 24 * 24, // 24 day term duration for the council. desired_seats: 0, // start with no council: we'll raise this once the stake has been dispersed a bit. inactive_grace_period: 1, // one addition vote should go by before an inactive voter can be reaped. - cooloff_period: 90 * 120 * 24, // 90 day cooling off period if council member vetoes a proposal. - voting_period: 7 * 120 * 24, // 7 day voting period for council members. + cooloff_period: 12 * 60 * 24 * 4, // 4 day cooling off period if council member vetoes a proposal. + voting_period: 12 * 60 * 24, // 1 day voting period for council members. }), parachains: Some(Default::default()), + timestamp: Some(TimestampConfig { + period: 5, // 5 second block time. + }), }); let boot_nodes = vec![ "enode://a93a29fa68d965452bf0ff8c1910f5992fe2273a72a1ee8d3a3482f68512a61974211ba32bb33f051ceb1530b8ba3527fc36224ba6b9910329025e6d9153cf50@104.211.54.233:30333".into(), @@ -163,6 +169,7 @@ impl PresetConfig { session: Some(SessionConfig { validators: initial_authorities.iter().cloned().map(Into::into).collect(), session_length: 10, + broken_percent_late: 30, }), staking: Some(StakingConfig { current_era: 0, @@ -178,6 +185,8 @@ impl PresetConfig { validator_count: 2, sessions_per_era: 5, bonding_duration: 2, + early_era_slash: 0, + session_reward: 0, }), democracy: Some(DemocracyConfig { launch_period: 9, @@ -200,6 +209,9 @@ impl PresetConfig { voting_period: 20, }), parachains: Some(Default::default()), + timestamp: Some(TimestampConfig { + period: 5, // 5 second block time. + }), }); let boot_nodes = Vec::new(); PresetConfig { genesis_config, boot_nodes } diff --git a/polkadot/runtime/src/lib.rs b/polkadot/runtime/src/lib.rs index e0a678993e..8aca5da767 100644 --- a/polkadot/runtime/src/lib.rs +++ b/polkadot/runtime/src/lib.rs @@ -126,8 +126,8 @@ impl consensus::Trait for Concrete { pub type Consensus = consensus::Module; impl timestamp::Trait for Concrete { - const SET_POSITION: u32 = TIMESTAMP_SET_POSITION; - type Value = u64; + const TIMESTAMP_SET_POSITION: u32 = TIMESTAMP_SET_POSITION; + type Moment = u64; } /// Timestamp module for this concrete runtime. pub type Timestamp = timestamp::Module; @@ -142,6 +142,7 @@ impl Convert for SessionKeyConversion { impl session::Trait for Concrete { type ConvertAccountIdToSessionKey = SessionKeyConversion; + type OnSessionChange = Staking; } /// Session module for this concrete runtime. pub type Session = session::Module; @@ -213,6 +214,7 @@ impl_outer_config! { StakingConfig => staking, DemocracyConfig => democracy, CouncilConfig => council, + TimestampConfig => timestamp, ParachainsConfig => parachains, } } diff --git a/polkadot/runtime/src/parachains.rs b/polkadot/runtime/src/parachains.rs index c200648112..b12eaa0765 100644 --- a/polkadot/runtime/src/parachains.rs +++ b/polkadot/runtime/src/parachains.rs @@ -33,7 +33,7 @@ use rstd::marker::PhantomData; #[cfg(any(feature = "std", test))] use {runtime_io, runtime_primitives}; -pub trait Trait: system::Trait + session::Trait { +pub trait Trait: session::Trait { /// The position of the set_heads call in the block. const SET_POSITION: u32; @@ -232,7 +232,7 @@ mod tests { use runtime_primitives::BuildStorage; use runtime_primitives::traits::{HasPublicAux, Identity, BlakeTwo256}; use runtime_primitives::testing::{Digest, Header}; - use consensus; + use {consensus, timestamp}; #[derive(Clone, Eq, PartialEq)] pub struct Test; @@ -254,6 +254,11 @@ mod tests { } impl session::Trait for Test { type ConvertAccountIdToSessionKey = Identity; + type OnSessionChange = (); + } + impl timestamp::Trait for Test { + const TIMESTAMP_SET_POSITION: u32 = 0; + type Moment = u64; } impl Trait for Test { const SET_POSITION: u32 = 0; @@ -272,6 +277,7 @@ mod tests { t.extend(session::GenesisConfig::{ session_length: 1000, validators: vec![1, 2, 3, 4, 5, 6, 7, 8], + broken_percent_late: 100, }.build_storage()); t.extend(GenesisConfig::{ parachains: parachains, diff --git a/polkadot/runtime/wasm/Cargo.lock b/polkadot/runtime/wasm/Cargo.lock index 73fab465f6..74829d6520 100644 --- a/polkadot/runtime/wasm/Cargo.lock +++ b/polkadot/runtime/wasm/Cargo.lock @@ -905,6 +905,7 @@ dependencies = [ "substrate-runtime-std 0.1.0", "substrate-runtime-support 0.1.0", "substrate-runtime-system 0.1.0", + "substrate-runtime-timestamp 0.1.0", ] [[package]] @@ -927,6 +928,7 @@ dependencies = [ "substrate-runtime-std 0.1.0", "substrate-runtime-support 0.1.0", "substrate-runtime-system 0.1.0", + "substrate-runtime-timestamp 0.1.0", ] [[package]] @@ -977,6 +979,7 @@ dependencies = [ "serde_derive 1.0.64 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-codec 0.1.0", "substrate-primitives 0.1.0", + "substrate-runtime-consensus 0.1.0", "substrate-runtime-io 0.1.0", "substrate-runtime-primitives 0.1.0", "substrate-runtime-std 0.1.0", diff --git a/polkadot/runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.compact.wasm b/polkadot/runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.compact.wasm index 9fa902edcb..1014b8781b 100644 Binary files a/polkadot/runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.compact.wasm and b/polkadot/runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.compact.wasm differ diff --git a/polkadot/runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.wasm b/polkadot/runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.wasm index a98f50b4ca..1925b939a7 100755 Binary files a/polkadot/runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.wasm and b/polkadot/runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.wasm differ