mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 12:19:24 +00:00
Integrate session pallet into validator-sets pallet (#440)
* remove pallet-session * Store key shares in InSet * integrate grandpa to vs-pallet * integrate pallet babe * remove pallet-session & authority discovery from runtime * update the grandpa pallet path * cargo update grandpa * cargo update substrate * Misc tweaks Sets validators for BABE/GRANDPA in chain_spec, per Akil's realization that was the missing piece. * fix pr comments * bug fix & tidy up --------- Co-authored-by: Luke Parker <lukeparker5132@gmail.com>
This commit is contained in:
@@ -5,9 +5,8 @@ use sp_core::Pair as PairTrait;
|
||||
use sc_service::ChainType;
|
||||
|
||||
use serai_runtime::{
|
||||
primitives::*, WASM_BINARY, opaque::SessionKeys, BABE_GENESIS_EPOCH_CONFIG, RuntimeGenesisConfig,
|
||||
SystemConfig, CoinsConfig, DexConfig, ValidatorSetsConfig, SessionConfig, BabeConfig,
|
||||
GrandpaConfig, AuthorityDiscoveryConfig,
|
||||
primitives::*, WASM_BINARY, BABE_GENESIS_EPOCH_CONFIG, RuntimeGenesisConfig, SystemConfig,
|
||||
CoinsConfig, DexConfig, ValidatorSetsConfig, BabeConfig, GrandpaConfig,
|
||||
};
|
||||
|
||||
pub type ChainSpec = sc_service::GenericChainSpec<RuntimeGenesisConfig>;
|
||||
@@ -21,16 +20,7 @@ fn testnet_genesis(
|
||||
validators: &[&'static str],
|
||||
endowed_accounts: Vec<PublicKey>,
|
||||
) -> RuntimeGenesisConfig {
|
||||
let session_key = |name| {
|
||||
let key = account_from_name(name);
|
||||
(
|
||||
key,
|
||||
key,
|
||||
// TODO: Properly diversify these?
|
||||
SessionKeys { babe: key.into(), grandpa: key.into(), authority_discovery: key.into() },
|
||||
)
|
||||
};
|
||||
|
||||
let validators = validators.iter().map(|name| account_from_name(name)).collect::<Vec<_>>();
|
||||
RuntimeGenesisConfig {
|
||||
system: SystemConfig { code: wasm_binary.to_vec(), _config: PhantomData },
|
||||
|
||||
@@ -59,17 +49,17 @@ fn testnet_genesis(
|
||||
NetworkId::Monero => (NetworkId::Monero, Amount(100_000 * 10_u64.pow(8))),
|
||||
})
|
||||
.collect(),
|
||||
participants: validators.iter().map(|name| account_from_name(name)).collect(),
|
||||
participants: validators.clone(),
|
||||
},
|
||||
session: SessionConfig { keys: validators.iter().map(|name| session_key(*name)).collect() },
|
||||
babe: BabeConfig {
|
||||
authorities: vec![],
|
||||
authorities: validators.iter().map(|validator| ((*validator).into(), 1)).collect(),
|
||||
epoch_config: Some(BABE_GENESIS_EPOCH_CONFIG),
|
||||
_config: PhantomData,
|
||||
},
|
||||
grandpa: GrandpaConfig { authorities: vec![], _config: PhantomData },
|
||||
|
||||
authority_discovery: AuthorityDiscoveryConfig { keys: vec![], _config: PhantomData },
|
||||
grandpa: GrandpaConfig {
|
||||
authorities: validators.into_iter().map(|validator| (validator.into(), 1)).collect(),
|
||||
_config: PhantomData,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user