Skip to content

Commit 9534650

Browse files
authored
Introduce genesis builder (paritytech#282)
* Initial genesis-builder pallet * Refactor chain_spec a bit * Add force_set_free_balance() for genesis-builder * . * Finish xstaking genesis builder * Finish xbtc genesis * Fix some corner cases when importing 1.0 state * Deal with the details * . * Use deserialize_with * Merge xbtc_miners.json xbtc_info.json * Split out xp-genesis-builder * Split out WellknownAccounts * Split out ValidatorInfo * Split out XStakingParams * Merge wellknown_accounts into balances * Refactor xbtc_assets * . * Merge res.rs * Fix staking test * Merge all builder params into one * Nits * Nits * Avoid the allocation and apply the review * Remove unused deps
1 parent 2b25808 commit 9534650

File tree

15 files changed

+91451
-391
lines changed

15 files changed

+91451
-391
lines changed

Cargo.lock

+418-356
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+8-6
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,30 @@ members = [
2020
"cli",
2121
"executor",
2222
"primitives",
23-
"primitives/runtime",
24-
"primitives/mining/common",
25-
"primitives/mining/staking",
2623
"primitives/assets-registrar",
24+
"primitives/genesis-builder",
2725
"primitives/io",
26+
"primitives/mining/common",
27+
"primitives/mining/staking",
28+
"primitives/runtime",
2829
"rpc",
2930
"runtime",
3031

3132
"xpallets/assets",
3233
"xpallets/assets/rpc",
3334
"xpallets/assets/rpc/runtime-api",
3435
"xpallets/assets-registrar",
36+
"xpallets/dex/spot",
37+
"xpallets/dex/spot/rpc",
38+
"xpallets/dex/spot/rpc/runtime-api",
3539
"xpallets/gateway/bitcoin",
3640
"xpallets/gateway/common",
3741
"xpallets/gateway/common/rpc",
3842
"xpallets/gateway/common/rpc/runtime-api",
3943
"xpallets/gateway/records",
4044
"xpallets/gateway/records/rpc",
4145
"xpallets/gateway/records/rpc/runtime-api",
42-
"xpallets/dex/spot",
43-
"xpallets/dex/spot/rpc",
44-
"xpallets/dex/spot/rpc/runtime-api",
46+
"xpallets/genesis-builder",
4547
"xpallets/mining/asset",
4648
"xpallets/mining/asset/rpc",
4749
"xpallets/mining/asset/rpc/runtime-api",

cli/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ chainx-primitives = { path = "../primitives" }
5151
chainx-rpc = { path = "../rpc" }
5252
chainx-runtime = { path = "../runtime" }
5353
xp-io = { path = "../primitives/io" }
54+
xp-genesis-builder = { path = "../primitives/genesis-builder" }
5455
xpallet-protocol = { path = "../xpallets/protocol" }
5556

5657
[build-dependencies]

cli/src/chain_spec.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ use chainx_runtime::{
2929
AuthorityDiscoveryConfig, BalancesConfig, CouncilConfig, DemocracyConfig, ElectionsConfig,
3030
GenesisConfig, GrandpaConfig, ImOnlineConfig, IndicesConfig, SessionConfig, SocietyConfig,
3131
SudoConfig, SystemConfig, TechnicalCommitteeConfig, XAssetsConfig, XAssetsRegistrarConfig,
32-
XGatewayBitcoinConfig, XGatewayCommonConfig, XMiningAssetConfig, XSpotConfig, XStakingConfig,
33-
XSystemConfig,
32+
XGatewayBitcoinConfig, XGatewayCommonConfig, XGenesisBuilderConfig, XMiningAssetConfig,
33+
XSpotConfig, XStakingConfig, XSystemConfig,
3434
};
3535

3636
use crate::genesis::bitcoin::{BtcGenesisParams, BtcTrusteeParams};
@@ -777,5 +777,8 @@ fn build_genesis(
777777
xpallet_dex_spot: Some(XSpotConfig {
778778
trading_pairs: vec![(PCX, X_BTC, 9, 2, 100000, true)],
779779
}),
780+
xpallet_genesis_builder: Some(XGenesisBuilderConfig {
781+
params: crate::genesis::genesis_builder_params(),
782+
}),
780783
}
781784
}

cli/src/genesis/mod.rs

+10
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
11
// Copyright 2019-2020 ChainX Project Authors. Licensed under GPL-3.0.
22

33
pub mod bitcoin;
4+
5+
use xp_genesis_builder::AllParams;
6+
7+
use chainx_primitives::{AccountId, Balance};
8+
9+
pub fn genesis_builder_params() -> AllParams<AccountId, Balance, Balance, Balance> {
10+
serde_json::from_str(include_str!("../res/genesis_builder_params.json"))
11+
.map_err(|e| log::error!("{:?}", e))
12+
.expect("JSON was not well-formatted")
13+
}

0 commit comments

Comments
 (0)