Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mb-session pallet #1

Merged
merged 10 commits into from
Mar 19, 2020
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
37 changes: 19 additions & 18 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use sp_core::{Pair, Public, sr25519};
use sp_consensus_babe::{AuthorityId as BabeId};
use grandpa_primitives::{AuthorityId as GrandpaId};
use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
use sp_runtime::{Perbill, traits::{Verify, IdentifyAccount}};
use sp_runtime::{traits::{Verify, IdentifyAccount}};
use sc_telemetry::TelemetryEndpoints;

use pallet_im_online::sr25519::{AuthorityId as ImOnlineId};
Expand All @@ -16,8 +16,8 @@ pub use node_primitives::{AccountId, Balance, Signature, Block};

use moonbeam_runtime::{
GenesisConfig, AuthorityDiscoveryConfig, BabeConfig, BalancesConfig, ContractsConfig,
GrandpaConfig, ImOnlineConfig, SessionConfig, SessionKeys, StakerStatus, StakingConfig,
IndicesConfig, SudoConfig, SystemConfig, WASM_BINARY, MoonbeamCoreConfig
GrandpaConfig, ImOnlineConfig, SessionConfig, SessionKeys,
IndicesConfig, SudoConfig, SystemConfig, WASM_BINARY, MoonbeamCoreConfig, MoonbeamSessionConfig
};

use moonbeam_runtime::constants::mb_genesis::*;
Expand Down Expand Up @@ -111,18 +111,6 @@ fn testnet_genesis(
pallet_session: Some(SessionConfig {
keys: keys,
}),
// https://crates.parity.io/pallet_staking/struct.GenesisConfig.html
pallet_staking: Some(StakingConfig {
current_era: 0,
validator_count: initial_authorities.len() as u32 * 2,
minimum_validator_count: initial_authorities.len() as u32,
stakers: initial_authorities.iter().map(|x| {
(x.0.clone(), x.1.clone(), STASH, StakerStatus::Validator)
}).collect(),
invulnerables: initial_authorities.iter().map(|x| x.0.clone()).collect(),
slash_reward_fraction: Perbill::from_percent(10),
.. Default::default()
}),
pallet_indices: Some(IndicesConfig {
indices: vec![],
}),
Expand Down Expand Up @@ -150,8 +138,14 @@ fn testnet_genesis(
}),
pallet_vesting: Some(Default::default()),
mb_core: Some(MoonbeamCoreConfig {
treasury: TREASURY_ENDOWMENT,
genesis_accounts: endowed_accounts,
treasury: TREASURY_FUND,
genesis_accounts: endowed_accounts.clone(),
}),
mb_session: Some(MoonbeamSessionConfig {
treasury: TREASURY_FUND,
session_validators: initial_authorities.iter().map(|x| {
x.0.clone()
}).collect(),
}),
}
}
Expand All @@ -161,8 +155,10 @@ fn development_config_genesis() -> GenesisConfig {
let seeds = vec![
"Armstrong",
"Aldrin",
"Collins",
"Armstrong//stash",
"Aldrin//stash"
"Aldrin//stash",
"Collins//stash"
];
let mut accounts: Vec<AccountId> = vec![];
let mut initial_authorities: Vec<(
Expand All @@ -180,6 +176,11 @@ fn development_config_genesis() -> GenesisConfig {
initial_authorities.push( get_authority_keys_from_seed(&s) );
}
}

// default accounts with some endorsement
accounts.push( get_account_id_from_seed::<sr25519::Public>("Alice") );
accounts.push( get_account_id_from_seed::<sr25519::Public>("Bob") );
accounts.push( get_account_id_from_seed::<sr25519::Public>("Ferdie") );

testnet_genesis(
initial_authorities,
Expand Down
40 changes: 40 additions & 0 deletions pallets/mb-session/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[package]
authors = ['PureStake']
edition = '2018'
name = 'mb-session'
version = '0.1.0'

[dependencies]
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
safe-mix = { default-features = false, version = '1.0.0' }
serde = { version = "1.0.102", features = ["derive"] }

# primitives
sp-core = { git = 'https://github.com/paritytech/substrate.git', rev = '992aea815a753da256a9c0bff053df408532df02', default-features = false }
sp-io = { git = 'https://github.com/paritytech/substrate.git', rev = '992aea815a753da256a9c0bff053df408532df02', default-features = false }
sp-runtime = { git = 'https://github.com/paritytech/substrate.git', rev = '992aea815a753da256a9c0bff053df408532df02', default-features = false }
sp-std = { git = 'https://github.com/paritytech/substrate.git', rev = '992aea815a753da256a9c0bff053df408532df02', default-features = false }
sp-session = { git = 'https://github.com/paritytech/substrate.git', rev = '992aea815a753da256a9c0bff053df408532df02', default-features = false }
sp-staking = { git = 'https://github.com/paritytech/substrate.git', rev = '992aea815a753da256a9c0bff053df408532df02', default-features = false }
node-primitives = { git = 'https://github.com/paritytech/substrate.git', rev = '992aea815a753da256a9c0bff053df408532df02', default-features = false }

# frame dependencies
frame-support = { git = 'https://github.com/paritytech/substrate.git', rev = '992aea815a753da256a9c0bff053df408532df02', default-features = false }
system = { package = 'frame-system', git = 'https://github.com/paritytech/substrate.git', rev = '992aea815a753da256a9c0bff053df408532df02', default-features = false }
pallet-balances = { git = 'https://github.com/paritytech/substrate.git', rev = '992aea815a753da256a9c0bff053df408532df02', default-features = false }
pallet-session = { features = ["historical"], git = 'https://github.com/paritytech/substrate.git', rev = '992aea815a753da256a9c0bff053df408532df02', default-features = false }
pallet-authorship = { git = 'https://github.com/paritytech/substrate.git', rev = '992aea815a753da256a9c0bff053df408532df02', default-features = false }

[features]
default = ['std']
std = [
"sp-std/std",
"sp-staking/std",
'codec/std',
'frame-support/std',
'safe-mix/std',
"sp-session/std",
'system/std',
"pallet-session/std",
"pallet-authorship/std",
]
Loading