mirror of
https://github.com/serai-dex/serai.git
synced 2025-01-08 03:49:41 +00:00
b427f4b8ab
This reverts commit 1096ddb7ea
.
This commit was intended for the testnet branch alone.
141 lines
3.7 KiB
Rust
141 lines
3.7 KiB
Rust
use core::marker::PhantomData;
|
|
|
|
use sp_core::Pair as PairTrait;
|
|
|
|
use sc_service::ChainType;
|
|
|
|
use serai_runtime::{
|
|
primitives::*, WASM_BINARY, BABE_GENESIS_EPOCH_CONFIG, RuntimeGenesisConfig, SystemConfig,
|
|
CoinsConfig, DexConfig, ValidatorSetsConfig, SignalsConfig, BabeConfig, GrandpaConfig,
|
|
};
|
|
|
|
pub type ChainSpec = sc_service::GenericChainSpec<RuntimeGenesisConfig>;
|
|
|
|
fn account_from_name(name: &'static str) -> PublicKey {
|
|
insecure_pair_from_name(name).public()
|
|
}
|
|
|
|
fn testnet_genesis(
|
|
wasm_binary: &[u8],
|
|
validators: &[&'static str],
|
|
endowed_accounts: Vec<PublicKey>,
|
|
) -> RuntimeGenesisConfig {
|
|
let validators = validators.iter().map(|name| account_from_name(name)).collect::<Vec<_>>();
|
|
RuntimeGenesisConfig {
|
|
system: SystemConfig { code: wasm_binary.to_vec(), _config: PhantomData },
|
|
|
|
transaction_payment: Default::default(),
|
|
|
|
coins: CoinsConfig {
|
|
accounts: endowed_accounts
|
|
.into_iter()
|
|
.map(|a| (a, Balance { coin: Coin::Serai, amount: Amount(1 << 60) }))
|
|
.collect(),
|
|
_ignore: Default::default(),
|
|
},
|
|
|
|
dex: DexConfig {
|
|
pools: vec![Coin::Bitcoin, Coin::Ether, Coin::Dai, Coin::Monero],
|
|
_ignore: Default::default(),
|
|
},
|
|
|
|
validator_sets: ValidatorSetsConfig {
|
|
networks: serai_runtime::primitives::NETWORKS
|
|
.iter()
|
|
.map(|network| match network {
|
|
NetworkId::Serai => (NetworkId::Serai, Amount(50_000 * 10_u64.pow(8))),
|
|
NetworkId::Bitcoin => (NetworkId::Bitcoin, Amount(1_000_000 * 10_u64.pow(8))),
|
|
NetworkId::Ethereum => (NetworkId::Ethereum, Amount(1_000_000 * 10_u64.pow(8))),
|
|
NetworkId::Monero => (NetworkId::Monero, Amount(100_000 * 10_u64.pow(8))),
|
|
})
|
|
.collect(),
|
|
participants: validators.clone(),
|
|
},
|
|
signals: SignalsConfig::default(),
|
|
babe: BabeConfig {
|
|
authorities: validators.iter().map(|validator| ((*validator).into(), 1)).collect(),
|
|
epoch_config: Some(BABE_GENESIS_EPOCH_CONFIG),
|
|
_config: PhantomData,
|
|
},
|
|
grandpa: GrandpaConfig {
|
|
authorities: validators.into_iter().map(|validator| (validator.into(), 1)).collect(),
|
|
_config: PhantomData,
|
|
},
|
|
}
|
|
}
|
|
|
|
pub fn development_config() -> Result<ChainSpec, &'static str> {
|
|
let wasm_binary = WASM_BINARY.ok_or("Development wasm not available")?;
|
|
|
|
Ok(ChainSpec::from_genesis(
|
|
// Name
|
|
"Development Network",
|
|
// ID
|
|
"devnet",
|
|
ChainType::Development,
|
|
|| {
|
|
testnet_genesis(
|
|
wasm_binary,
|
|
&["Alice"],
|
|
vec![
|
|
account_from_name("Alice"),
|
|
account_from_name("Bob"),
|
|
account_from_name("Charlie"),
|
|
account_from_name("Dave"),
|
|
account_from_name("Eve"),
|
|
account_from_name("Ferdie"),
|
|
],
|
|
)
|
|
},
|
|
// Bootnodes
|
|
vec![],
|
|
// Telemetry
|
|
None,
|
|
// Protocol ID
|
|
Some("serai"),
|
|
// Fork ID
|
|
None,
|
|
// Properties
|
|
None,
|
|
// Extensions
|
|
None,
|
|
))
|
|
}
|
|
|
|
pub fn testnet_config() -> Result<ChainSpec, &'static str> {
|
|
let wasm_binary = WASM_BINARY.ok_or("Testnet wasm not available")?;
|
|
|
|
Ok(ChainSpec::from_genesis(
|
|
// Name
|
|
"Local Test Network",
|
|
// ID
|
|
"local",
|
|
ChainType::Local,
|
|
|| {
|
|
testnet_genesis(
|
|
wasm_binary,
|
|
&["Alice", "Bob", "Charlie", "Dave"],
|
|
vec![
|
|
account_from_name("Alice"),
|
|
account_from_name("Bob"),
|
|
account_from_name("Charlie"),
|
|
account_from_name("Dave"),
|
|
account_from_name("Eve"),
|
|
account_from_name("Ferdie"),
|
|
],
|
|
)
|
|
},
|
|
// Bootnodes
|
|
vec![],
|
|
// Telemetry
|
|
None,
|
|
// Protocol ID
|
|
Some("serai"),
|
|
// Fork ID
|
|
None,
|
|
// Properties
|
|
None,
|
|
// Extensions
|
|
None,
|
|
))
|
|
}
|