Unverified Commit 36b831a1 authored by Arkadiy Paronyan's avatar Arkadiy Paronyan
Browse files

Merge branch 'master' of github.com:paritytech/polkadot into a-wasm-authoring

parents 0357d231 bb5919da
This diff is collapsed.
......@@ -17,7 +17,6 @@ substrate-client = { git = "https://github.com/paritytech/substrate" }
substrate-primitives = { git = "https://github.com/paritytech/substrate" }
substrate-executor = { git = "https://github.com/paritytech/substrate" }
substrate-state-machine = { git = "https://github.com/paritytech/substrate" }
log = "0.3"
[dev-dependencies]
substrate-keyring = { git = "https://github.com/paritytech/substrate" }
......@@ -205,10 +205,10 @@ mod tests {
authorities: session_keys(),
}),
system: None,
balances: Some(Default::default()),
session: Some(SessionConfig {
validators: validators(),
session_length: 100,
broken_percent_late: 100,
}),
council: Some(Default::default()),
democracy: Some(Default::default()),
......
......@@ -7,8 +7,8 @@ description = "Collator node implementation"
[dependencies]
futures = "0.1.17"
substrate-client = { git = "https://github.com/paritytech/substrate" }
substrate-codec = { git = "https://github.com/paritytech/substrate", version = "0.1" }
substrate-primitives = { git = "https://github.com/paritytech/substrate", version = "0.1" }
substrate-codec = { git = "https://github.com/paritytech/substrate" }
substrate-primitives = { git = "https://github.com/paritytech/substrate" }
polkadot-api = { path = "../api" }
polkadot-runtime = { path = "../runtime", version = "0.1" }
polkadot-primitives = { path = "../primitives", version = "0.1" }
......
......@@ -64,7 +64,7 @@ extern crate substrate_keyring;
use std::collections::{HashMap, HashSet};
use std::sync::Arc;
use std::time::{Duration, Instant};
use std::time::{self, Duration, Instant};
use codec::{Decode, Encode};
use extrinsic_store::Store as ExtrinsicStore;
......@@ -274,6 +274,9 @@ impl<C, N, P> bft::Environment<Block> for ProposerFactory<C, N, P>
) -> Result<(Self::Proposer, Self::Input, Self::Output), Error> {
use runtime_primitives::traits::{Hash as HashT, BlakeTwo256};
// force delay in evaluation this long.
const FORCE_DELAY: Timestamp = 5;
let parent_hash = parent_header.hash().into();
let id = BlockId::hash(parent_hash);
......@@ -343,6 +346,7 @@ impl<C, N, P> bft::Environment<Block> for ProposerFactory<C, N, P>
transaction_pool: self.transaction_pool.clone(),
offline: self.offline.clone(),
validators,
minimum_timestamp: current_timestamp() + FORCE_DELAY,
_drop_signal: drop_signal,
};
......@@ -422,6 +426,7 @@ pub struct Proposer<C: PolkadotApi + Send + Sync> {
transaction_pool: Arc<TransactionPool<C>>,
offline: SharedOfflineTracker,
validators: Vec<AccountId>,
minimum_timestamp: u64,
_drop_signal: exit_future::Signal,
}
......@@ -473,6 +478,7 @@ impl<C> bft::Proposer<Block> for Proposer<C>
table: self.table.clone(),
offline: self.offline.clone(),
validators: self.validators.clone(),
minimum_timestamp: self.minimum_timestamp,
timing,
})
}
......@@ -525,9 +531,11 @@ impl<C> bft::Proposer<Block> for Proposer<C>
);
// the duration until the given timestamp is current
let proposed_timestamp = proposal.timestamp();
let proposed_timestamp = ::std::cmp::max(self.minimum_timestamp, proposal.timestamp());
let timestamp_delay = if proposed_timestamp > current_timestamp {
Some(now + Duration::from_secs(proposed_timestamp - current_timestamp))
let delay_s = proposed_timestamp - current_timestamp;
debug!(target: "bft", "Delaying evaluation of proposal for {} seconds", delay_s);
Some(now + Duration::from_secs(delay_s))
} else {
None
};
......@@ -677,8 +685,6 @@ impl<C> bft::Proposer<Block> for Proposer<C>
}
fn current_timestamp() -> Timestamp {
use std::time;
time::SystemTime::now().duration_since(time::UNIX_EPOCH)
.expect("now always later than unix epoch; qed")
.as_secs()
......@@ -732,6 +738,7 @@ pub struct CreateProposal<C: PolkadotApi + Send + Sync> {
timing: ProposalTiming,
validators: Vec<AccountId>,
offline: SharedOfflineTracker,
minimum_timestamp: Timestamp,
}
impl<C> CreateProposal<C> where C: PolkadotApi + Send + Sync {
......@@ -743,7 +750,7 @@ impl<C> CreateProposal<C> where C: PolkadotApi + Send + Sync {
const MAX_VOTE_OFFLINE_SECONDS: Duration = Duration::from_secs(60);
// TODO: handle case when current timestamp behind that in state.
let timestamp = current_timestamp();
let timestamp = ::std::cmp::max(self.minimum_timestamp, current_timestamp());
let elapsed_since_start = self.timing.dynamic_inclusion.started_at().elapsed();
let offline_indices = if elapsed_since_start > MAX_VOTE_OFFLINE_SECONDS {
......
......@@ -39,7 +39,7 @@ use extrinsic_store::Store as ExtrinsicStore;
use tokio::executor::current_thread::TaskExecutor as LocalThreadHandle;
use tokio::runtime::TaskExecutor as ThreadPoolHandle;
use tokio::runtime::current_thread::Runtime as LocalRuntime;
use tokio::timer::{Delay, Interval};
use tokio::timer::Interval;
use super::{Network, Collators, ProposerFactory};
use error;
......@@ -59,25 +59,10 @@ fn start_bft<F, C>(
<F::Proposer as bft::Proposer<Block>>::Error: ::std::fmt::Display + Into<error::Error>,
<F as bft::Environment<Block>>::Error: ::std::fmt::Display
{
const DELAY_UNTIL: Duration = Duration::from_millis(5000);
let mut handle = LocalThreadHandle::current();
match bft_service.build_upon(&header) {
Ok(Some(bft_work)) => {
// do not poll work for some amount of time.
let work = Delay::new(Instant::now() + DELAY_UNTIL).then(move |res| {
if let Err(e) = res {
warn!(target: "bft", "Failed to force delay of consensus: {:?}", e);
}
debug!(target: "bft", "Starting agreement. After forced delay for {:?}",
DELAY_UNTIL);
bft_work
});
if let Err(e) = handle.spawn_local(Box::new(work)) {
warn!(target: "bft", "Couldn't initialize BFT agreement: {:?}", e);
}
Ok(Some(bft_work)) => if let Err(e) = handle.spawn_local(Box::new(bft_work)) {
warn!(target: "bft", "Couldn't initialize BFT agreement: {:?}", e);
}
Ok(None) => trace!(target: "bft", "Could not start agreement on top of {}", header.hash()),
Err(e) => warn!(target: "bft", "BFT agreement error: {}", e),
......@@ -207,7 +192,7 @@ impl Service {
let mut prev_best = match client.best_block_header() {
Ok(header) => header.hash(),
Err(e) => {
warn!("Cant's start consensus service. Error reading best block header: {:?}", e);
warn!("Can't start consensus service. Error reading best block header: {:?}", e);
return;
}
};
......
......@@ -11,12 +11,14 @@ serde_derive = { version = "1.0", optional = true }
safe-mix = { version = "1.0", default_features = false}
polkadot-primitives = { path = "../primitives", default_features = false }
substrate-codec = { git = "https://github.com/paritytech/substrate" }
substrate-codec-derive = { git = "https://github.com/paritytech/substrate" }
substrate-serializer = { git = "https://github.com/paritytech/substrate" }
substrate-runtime-std = { git = "https://github.com/paritytech/substrate" }
substrate-runtime-io = { git = "https://github.com/paritytech/substrate" }
substrate-runtime-support = { git = "https://github.com/paritytech/substrate" }
substrate-primitives = { git = "https://github.com/paritytech/substrate" }
substrate-keyring = { git = "https://github.com/paritytech/substrate" }
substrate-runtime-balances = { git = "https://github.com/paritytech/substrate" }
substrate-runtime-consensus = { git = "https://github.com/paritytech/substrate" }
substrate-runtime-council = { git = "https://github.com/paritytech/substrate" }
substrate-runtime-democracy = { git = "https://github.com/paritytech/substrate" }
......@@ -36,10 +38,12 @@ default = ["std"]
std = [
"polkadot-primitives/std",
"substrate-codec/std",
"substrate-codec-derive/std",
"substrate-primitives/std",
"substrate-runtime-std/std",
"substrate-runtime-io/std",
"substrate-runtime-support/std",
"substrate-runtime-balances/std",
"substrate-runtime-consensus/std",
"substrate-runtime-council/std",
"substrate-runtime-democracy/std",
......
......@@ -19,7 +19,7 @@
use super::{Call, Block, TIMESTAMP_SET_POSITION, PARACHAINS_SET_POSITION, NOTE_OFFLINE_POSITION};
use timestamp::Call as TimestampCall;
use parachains::Call as ParachainsCall;
use session::Call as SessionCall;
use consensus::Call as ConsensusCall;
use primitives::parachain::CandidateReceipt;
/// Provides a type-safe wrapper around a structurally valid block.
......@@ -90,10 +90,10 @@ impl CheckedBlock {
}
}
/// Extract the noted offline validator indices (if any) from the block.
/// Extract the noted missed proposal validator indices (if any) from the block.
pub fn noted_offline(&self) -> &[u32] {
self.inner.extrinsics.get(NOTE_OFFLINE_POSITION as usize).and_then(|xt| match xt.extrinsic.function {
Call::Session(SessionCall::note_offline(ref x)) => Some(&x[..]),
Call::Consensus(ConsensusCall::note_offline(ref x)) => Some(&x[..]),
_ => None,
}).unwrap_or(&[])
}
......
......@@ -45,9 +45,12 @@ extern crate substrate_primitives;
#[macro_use]
extern crate substrate_runtime_std as rstd;
#[macro_use]
extern crate substrate_codec_derive;
extern crate polkadot_primitives as primitives;
extern crate substrate_codec as codec;
extern crate substrate_runtime_balances as balances;
extern crate substrate_runtime_consensus as consensus;
extern crate substrate_runtime_council as council;
extern crate substrate_runtime_democracy as democracy;
......@@ -67,7 +70,7 @@ mod utils;
#[cfg(feature = "std")]
pub use checked_block::CheckedBlock;
pub use utils::{inherent_extrinsics, check_extrinsic};
pub use staking::address::Address as RawAddress;
pub use balances::address::Address as RawAddress;
use primitives::{AccountId, AccountIndex, Balance, BlockNumber, Hash, Index, Log, SessionKey, Signature};
use runtime_primitives::{generic, traits::{HasPublicAux, BlakeTwo256, Convert}};
......@@ -85,11 +88,11 @@ pub use primitives::Header;
pub const TIMESTAMP_SET_POSITION: u32 = 0;
/// The position of the parachains set extrinsic.
pub const PARACHAINS_SET_POSITION: u32 = 1;
/// The position of the offline nodes noting extrinsic.
/// The position of the note_offline in the block, if it exists.
pub const NOTE_OFFLINE_POSITION: u32 = 2;
/// The address format for describing accounts.
pub type Address = staking::Address<Concrete>;
pub type Address = balances::Address<Concrete>;
/// Block Id type for this block.
pub type BlockId = generic::BlockId<Block>;
/// Unchecked extrinsic type as expected by this runtime.
......@@ -128,6 +131,7 @@ impl HasPublicAux for Concrete {
}
impl system::Trait for Concrete {
type PublicAux = <Concrete as HasPublicAux>::PublicAux;
type Index = Index;
type BlockNumber = BlockNumber;
type Hash = Hash;
......@@ -135,13 +139,25 @@ impl system::Trait for Concrete {
type Digest = generic::Digest<Log>;
type AccountId = AccountId;
type Header = Header;
type Event = Event;
}
/// System module for this concrete runtime.
pub type System = system::Module<Concrete>;
impl balances::Trait for Concrete {
type Balance = Balance;
type AccountIndex = AccountIndex;
type OnFreeBalanceZero = Staking;
type EnsureAccountLiquid = Staking;
type Event = Event;
}
/// Staking module for this concrete runtime.
pub type Balances = balances::Module<Concrete>;
impl consensus::Trait for Concrete {
type PublicAux = <Concrete as HasPublicAux>::PublicAux;
const NOTE_OFFLINE_POSITION: u32 = NOTE_OFFLINE_POSITION;
type SessionKey = SessionKey;
type OnOfflineValidator = Staking;
}
/// Consensus module for this concrete runtime.
pub type Consensus = consensus::Module<Concrete>;
......@@ -162,17 +178,15 @@ impl Convert<AccountId, SessionKey> for SessionKeyConversion {
}
impl session::Trait for Concrete {
const NOTE_OFFLINE_POSITION: u32 = NOTE_OFFLINE_POSITION;
type ConvertAccountIdToSessionKey = SessionKeyConversion;
type OnSessionChange = Staking;
type Event = Event;
}
/// Session module for this concrete runtime.
pub type Session = session::Module<Concrete>;
impl staking::Trait for Concrete {
type Balance = Balance;
type AccountIndex = AccountIndex;
type OnAccountKill = ();
type Event = Event;
}
/// Staking module for this concrete runtime.
pub type Staking = staking::Module<Concrete>;
......@@ -196,15 +210,22 @@ impl parachains::Trait for Concrete {
}
pub type Parachains = parachains::Module<Concrete>;
impl_outer_event! {
pub enum Event for Concrete {
balances, session, staking
}
}
impl_outer_dispatch! {
/// Call type for polkadot transactions.
#[derive(Clone, PartialEq, Eq)]
#[cfg_attr(feature = "std", derive(Debug, Serialize, Deserialize))]
pub enum Call where aux: <Concrete as HasPublicAux>::PublicAux {
Consensus = 0,
Session = 1,
Staking = 2,
Timestamp = 3,
Balances = 1,
Session = 2,
Staking = 3,
Timestamp = 4,
Democracy = 5,
Council = 6,
CouncilVoting = 7,
......@@ -216,8 +237,9 @@ impl_outer_dispatch! {
#[cfg_attr(feature = "std", derive(Debug, Serialize, Deserialize))]
pub enum PrivCall {
Consensus = 0,
Session = 1,
Staking = 2,
Balances = 1,
Session = 2,
Staking = 3,
Democracy = 5,
Council = 6,
CouncilVoting = 7,
......@@ -226,13 +248,14 @@ impl_outer_dispatch! {
}
/// Executive: handles dispatch to the various modules.
pub type Executive = executive::Executive<Concrete, Block, Staking, Staking,
pub type Executive = executive::Executive<Concrete, Block, Balances, Balances,
(((((((), Parachains), Council), Democracy), Staking), Session), Timestamp)>;
impl_outer_config! {
pub struct GenesisConfig for Concrete {
ConsensusConfig => consensus,
SystemConfig => system,
BalancesConfig => balances,
SessionConfig => session,
StakingConfig => staking,
DemocracyConfig => democracy,
......@@ -250,7 +273,7 @@ pub mod api {
apply_extrinsic => |extrinsic| super::Executive::apply_extrinsic(extrinsic),
execute_block => |block| super::Executive::execute_block(block),
finalise_block => |()| super::Executive::finalise_block(),
inherent_extrinsics => |(inherent, version)| super::inherent_extrinsics(inherent, version),
inherent_extrinsics => |(inherent, spec_version)| super::inherent_extrinsics(inherent, spec_version),
validator_count => |()| super::Session::validator_count(),
validators => |()| super::Session::validators(),
duty_roster => |()| super::Parachains::calculate_duty_roster(),
......@@ -260,7 +283,7 @@ pub mod api {
timestamp => |()| super::Timestamp::get(),
random_seed => |()| super::System::random_seed(),
account_nonce => |account| super::System::account_nonce(&account),
lookup_address => |address| super::Staking::lookup_address(address)
lookup_address => |address| super::Balances::lookup_address(address)
);
}
......@@ -388,7 +411,7 @@ mod tests {
// 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
let v = Encode::encode(&tx);
assert_eq!(&v[..], &hex!["6f000000ff0101010101010101010101010101010101010101010101010101010101010101e70300000300df0f02000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"][..]);
assert_eq!(&v[..], &hex!["6f000000ff0101010101010101010101010101010101010101010101010101010101010101e70300000400df0f02000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"][..]);
println!("{}", HexDisplay::from(&v));
assert_eq!(UncheckedExtrinsic::decode(&mut &v[..]).unwrap(), tx);
}
......
......@@ -61,16 +61,17 @@ decl_module! {
}
decl_storage! {
trait Store for Module<T: Trait>;
// Vector of all parachain IDs.
pub Parachains get(active_parachains): b"para:chains" => default Vec<Id>;
// The parachains registered at present.
pub Code get(parachain_code): b"para:code" => map [ Id => Vec<u8> ];
// The heads of the parachains registered at present. these are kept sorted.
pub Heads get(parachain_head): b"para:head" => map [ Id => Vec<u8> ];
// Did the parachain heads get updated in this block?
DidUpdate: b"para:did" => default bool;
trait Store for Module<T: Trait> as Parachains {
// Vector of all parachain IDs.
pub Parachains get(active_parachains): default Vec<Id>;
// The parachains registered at present.
pub Code get(parachain_code): map [ Id => Vec<u8> ];
// The heads of the parachains registered at present. these are kept sorted.
pub Heads get(parachain_head): map [ Id => Vec<u8> ];
// Did the parachain heads get updated in this block?
DidUpdate: default bool;
}
}
impl<T: Trait> Module<T> {
......@@ -157,7 +158,7 @@ impl<T: Trait> Module<T> {
ensure!(aux.is_empty(), "set_heads must not be signed");
ensure!(!<DidUpdate<T>>::exists(), "Parachain heads must be updated only once in the block");
ensure!(
<system::Module<T>>::extrinsic_index() == T::SET_POSITION,
<system::Module<T>>::extrinsic_index() == Some(T::SET_POSITION),
"Parachain heads update extrinsic must be at position {} in the block"
// , T::SET_POSITION
);
......@@ -257,10 +258,12 @@ mod tests {
type PublicAux = u64;
}
impl consensus::Trait for Test {
type PublicAux = <Self as HasPublicAux>::PublicAux;
const NOTE_OFFLINE_POSITION: u32 = 1;
type SessionKey = u64;
type OnOfflineValidator = ();
}
impl system::Trait for Test {
type PublicAux = <Self as HasPublicAux>::PublicAux;
type Index = u64;
type BlockNumber = u64;
type Hash = H256;
......@@ -268,11 +271,12 @@ mod tests {
type Digest = Digest;
type AccountId = u64;
type Header = Header;
type Event = ();
}
impl session::Trait for Test {
const NOTE_OFFLINE_POSITION: u32 = 1;
type ConvertAccountIdToSessionKey = Identity;
type OnSessionChange = ();
type Event = ();
}
impl timestamp::Trait for Test {
const TIMESTAMP_SET_POSITION: u32 = 0;
......@@ -295,7 +299,6 @@ mod tests {
t.extend(session::GenesisConfig::<Test>{
session_length: 1000,
validators: vec![1, 2, 3, 4, 5, 6, 7, 8],
broken_percent_late: 100,
}.build_storage().unwrap());
t.extend(GenesisConfig::<Test>{
parachains: parachains,
......
......@@ -17,16 +17,15 @@
//! Utils for block interaction.
use rstd::prelude::*;
use super::{Call, UncheckedExtrinsic, Extrinsic, Staking};
use super::{Call, UncheckedExtrinsic, Extrinsic, Balances};
use runtime_primitives::traits::{Checkable, AuxLookup};
use timestamp::Call as TimestampCall;
use parachains::Call as ParachainsCall;
use session::Call as SessionCall;
use version::RuntimeVersion;
use consensus::Call as ConsensusCall;
/// Produces the list of inherent extrinsics.
pub fn inherent_extrinsics(data: ::primitives::InherentData, runtime_version: RuntimeVersion) -> Vec<UncheckedExtrinsic> {
let make_inherent = |function| UncheckedExtrinsic::new(
pub fn inherent_extrinsics(data: ::primitives::InherentData, spec_version: u32) -> Vec<UncheckedExtrinsic> {
let make_inherent = |function| UncheckedExtrinsic::new(
Extrinsic {
signed: Default::default(),
function,
......@@ -40,9 +39,9 @@ pub fn inherent_extrinsics(data: ::primitives::InherentData, runtime_version: Ru
make_inherent(Call::Parachains(ParachainsCall::set_heads(data.parachain_heads))),
];
if !data.offline_indices.is_empty() && runtime_version.spec_version == 4 {
if !data.offline_indices.is_empty() && spec_version == 4 {
inherent.push(make_inherent(
Call::Session(SessionCall::note_offline(data.offline_indices))
Call::Consensus(ConsensusCall::note_offline(data.offline_indices))
));
}
......@@ -51,5 +50,5 @@ pub fn inherent_extrinsics(data: ::primitives::InherentData, runtime_version: Ru
/// Checks an unchecked extrinsic for validity.
pub fn check_extrinsic(xt: UncheckedExtrinsic) -> bool {
xt.check_with(Staking::lookup).is_ok()
xt.check_with(Balances::lookup).is_ok()
}
This diff is collapsed.
......@@ -11,10 +11,12 @@ integer-sqrt = { git = "https://github.com/paritytech/integer-sqrt-rs.git", bran
polkadot-primitives = { path = "../../primitives", default-features = false }
safe-mix = { version = "1.0", default-features = false }
substrate-codec = { git = "https://github.com/paritytech/substrate", default-features = false }
substrate-codec-derive = { git = "https://github.com/paritytech/substrate", default-features = false }
substrate-primitives = { git = "https://github.com/paritytech/substrate", default-features = false }
substrate-runtime-std = { git = "https://github.com/paritytech/substrate", default-features = false }
substrate-runtime-io = { git = "https://github.com/paritytech/substrate", default-features = false }
substrate-runtime-support = { git = "https://github.com/paritytech/substrate", default-features = false }
substrate-runtime-balances = { git = "https://github.com/paritytech/substrate", default-features = false }
substrate-runtime-consensus = { git = "https://github.com/paritytech/substrate", default-features = false }
substrate-runtime-council = { git = "https://github.com/paritytech/substrate", default-features = false }
substrate-runtime-democracy = { git = "https://github.com/paritytech/substrate", default-features = false }
......@@ -32,10 +34,12 @@ std = [
"polkadot-primitives/std",
"safe-mix/std",
"substrate-codec/std",
"substrate-codec-derive/std",
"substrate-primitives/std",
"substrate-runtime-std/std",
"substrate-runtime-io/std",
"substrate-runtime-support/std",
"substrate-runtime-balances/std",
"substrate-runtime-consensus/std",
"substrate-runtime-council/std",
"substrate-runtime-democracy/std",
......
......@@ -6,6 +6,10 @@ echo "*** Initialising WASM build environment"
rustup update nightly
rustup target add wasm32-unknown-unknown --toolchain nightly
# Temporarily install llvm-tools.
# See https://github.com/rust-lang/rust/issues/53813
# TODO: Remove this when fixed.
rustup component add llvm-tools-preview --toolchain nightly
rustup update stable
# Install wasm-gc. It's useful for stripping slimming down wasm binaries.
......
......@@ -19,7 +19,7 @@
use ed25519;
use primitives::AuthorityId;
use polkadot_runtime::{GenesisConfig, ConsensusConfig, CouncilConfig, DemocracyConfig,
SessionConfig, StakingConfig, TimestampConfig};
SessionConfig, StakingConfig, TimestampConfig, BalancesConfig};
use service::ChainSpec;
const STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/";
......@@ -44,26 +44,29 @@ fn staging_testnet_config_genesis() -> GenesisConfig {
authorities: initial_authorities.clone(),
}),
system: None,
balances: Some(BalancesConfig {
transaction_base_fee: 100,
transaction_byte_fee: 1,
existential_deposit: 500,
transfer_fee: 0,
creation_fee: 0,
reclaim_rebate: 0,
balances: endowed_accounts.iter().map(|&k|(k, 1u128 << 60)).collect(),
}),
session: Some(SessionConfig {
validators: initial_authorities.iter().cloned().map(Into::into).collect(),
session_length: 60, // that's 5 minutes per session.
broken_percent_late: 50,
}),
staking: Some(StakingConfig {
current_era: 0,
intentions: initial_authorities.iter().cloned().map(Into::into).collect(),
transaction_base_fee: 100,
transaction_byte_fee: 1,
existential_deposit: 500,
transfer_fee: 0,
creation_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: 12, // 1 hour per era
bonding_duration: 24, // 1 day per bond.
bonding_duration: 24 * 60 * 12, // 1 day per bond.
offline_slash_grace: 4,
minimum_validator_count: 4,
}),
democracy: Some(DemocracyConfig {
launch_period: 12 * 60 * 24, // 1 day per public referendum
......@@ -119,14 +122,7 @@ fn testnet_genesis(initial_authorities: Vec<AuthorityId>) -> GenesisConfig {
authorities: initial_authorities.clone(),
}),
system: None,
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,
intentions: initial_authorities.iter().cloned().map(Into::into).collect(),
balances: Some(BalancesConfig {
transaction_base_fee: 1,
transaction_byte_fee: 0,
existential_deposit: 500,
......@@ -134,11 +130,21 @@ fn testnet_genesis(initial_authorities: Vec<AuthorityId>) -> GenesisConfig {
creation_fee: 0,
reclaim_rebate: 0,
balances: endowed_accounts.iter().map(|&k|(k, (1u128 << 60))).collect(),
}),
session: Some(SessionConfig {
validators: initial_authorities.iter().cloned().map(Into::into).collect(),
session_length: 10,
}),
staking: Some(StakingConfig {
current_era: 0,
intentions: initial_authorities.iter().cloned().map(Into::into).collect(),
minimum_validator_count: 1,
validator_count: 2,