Skip to content

Commit

Permalink
Feature/add testchain confucianism (paritytech#921)
Browse files Browse the repository at this point in the history
* support confucianism testnet config

* Update bitcoin genesis for testnet confucianism (paritytech#920)

* Update bitcoin genesis for testnet confucianism

* Apply clippy (paritytech#919)

* Start applying clippy

* Pass clippy on src/main.rs

* Pass cli/src/lib.rs

* Pass clippy on cli/src/service.rs

* Pass clippy on cli/src/genesis_config/mod.rs

* Pass clippy on cli/src/genesis_config/chainx.rs

* Add clippy to CI

* Fix a bunch of clippy warnings

* Pass clippy on xbitcoin

* Pass clippy on xdex spot

* Try passing CI

* Fix more clippy warnings

* Add clippy_check GA

* Use actions-rs/cargo@v1

* Add clippy component

* Use stable toolchain

* .

* Add missing running time

* Suppress non-trivival clippy warnings

* .

* Fix CI

* Update btc genesis to most recent difficulty adjusted block

Co-authored-by: Aten <[email protected]>

Co-authored-by: Liu-Cheng Xu <[email protected]>
  • Loading branch information
atenjin and liuchengxu authored May 28, 2020
1 parent 0c7f5d4 commit db37f5c
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 7 deletions.
30 changes: 30 additions & 0 deletions cli/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,33 @@ pub fn testnet_mohism_config() -> ChainSpec {
),
)
}

fn testnet_confucianism_genesis() -> GenesisConfig {
genesis(GenesisSpec::TestnetConfucianism)
}

pub fn testnet_confucianism_config() -> ChainSpec {
let boot_nodes = vec![];
ChainSpec::from_genesis(
"ChainX Testnet Confucianism",
"chainx_testnet_confucianism",
testnet_confucianism_genesis,
boot_nodes,
Some(TelemetryEndpoints::new(vec![(
CHAINX_TELEMETRY_URL.to_string(),
0,
)])),
Some("ChainX Testnet Confucianism"),
None,
Some(
json!({
"network_type": "testnet",
"address_type": 42,
"bitcoin_type": "mainnet"
})
.as_object()
.unwrap()
.to_owned(),
),
)
}
23 changes: 23 additions & 0 deletions cli/src/genesis_config/bitcoin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,29 @@ pub fn testnet_mohism() -> BitcoinGenesisInfo {
)
}

// bitcoin mainnet for confucianism
pub fn mainnet_confucianism() -> BitcoinGenesisInfo {
(
(
BlockHeader {
version: 0x27ffe000,
previous_header_hash: h256_from_rev_str(
"0000000000000000000e87ecbff47d9ab75e78d92328d5951351f9702597dace",
),
merkle_root_hash: h256_from_rev_str(
"783ffb1dd4004232a041ad7d1cb3d3dbc1583b9f27ad558d63db873e880383f6",
),
time: 1589940416,
bits: Compact::new(0x171297f6),
nonce: 0x0dc797f9,
},
631_008,
),
h256_from_rev_str("0000000000000000000afe86c660a568a750c603f72dba13b32abb1f31125188"),
0,
)
}

// bitcoin mainnet
pub fn mainnet() -> BitcoinGenesisInfo {
(
Expand Down
14 changes: 12 additions & 2 deletions cli/src/genesis_config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pub enum GenesisSpec {
Dev,
Testnet,
TestnetMohism,
TestnetConfucianism,
Mainnet,
}
impl Into<ChainSpec> for GenesisSpec {
Expand All @@ -37,6 +38,7 @@ impl Into<ChainSpec> for GenesisSpec {
GenesisSpec::Dev => ChainSpec::Dev,
GenesisSpec::Testnet => ChainSpec::Testnet,
GenesisSpec::TestnetMohism => ChainSpec::Testnet,
GenesisSpec::TestnetConfucianism => ChainSpec::Testnet,
GenesisSpec::Mainnet => ChainSpec::Mainnet,
}
}
Expand Down Expand Up @@ -65,6 +67,13 @@ pub fn genesis(genesis_spec: GenesisSpec) -> GenesisConfig {
(xsystem::NetworkType::Testnet, 42),
bitcoin::testnet_mohism(),
),
GenesisSpec::TestnetConfucianism => (
include_bytes!("res/wasm/testnet_confucianism_chainx_runtime.compact.wasm").to_vec(), // testnet genesis runtime version is 6
chainx::load_genesis_node(&include_bytes!("res/testnet_genesis_node.csv")[..]).unwrap(),
chainx::load_team_council(&include_bytes!("res/testnet_team_council.csv")[..]).unwrap(),
(xsystem::NetworkType::Testnet, 42),
bitcoin::mainnet_confucianism(),
),
GenesisSpec::Mainnet => (
include_bytes!("res/wasm/mainnet_chainx_runtime.compact.wasm").to_vec(), // mainnet genesis runtime version is 0
chainx::load_genesis_node(&include_bytes!("res/mainnet_genesis_node.csv")[..]).unwrap(),
Expand All @@ -91,8 +100,9 @@ pub fn genesis(genesis_spec: GenesisSpec) -> GenesisConfig {

let initial_authorities_len = match genesis_spec {
GenesisSpec::Dev => 1,
GenesisSpec::Testnet => genesis_node_info.len(),
GenesisSpec::TestnetMohism => genesis_node_info.len(),
GenesisSpec::Testnet | GenesisSpec::TestnetMohism | GenesisSpec::TestnetConfucianism => {
genesis_node_info.len()
}
GenesisSpec::Mainnet => genesis_node_info.len(),
};

Expand Down
6 changes: 3 additions & 3 deletions cli/src/genesis_config/res/testnet_genesis_node.csv
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
account_id,session_key,endowed,name,url,about,hot_entity,cold_entity
9b26794331dcf1c41aa29fd482b2e3bd786e190475d9c2119479fb4c9bec239c,5917d1850e940bcd23254c73dcb936b730dd950ee6b750af02cc8caaedcd83ba,10,Laocius,polkadot.network,,0384306cbc714c3a7f9a1a6cc763525d1f65e4993721fc023fc0954a185aa2fd1d,022f0fe2f0801f5dc95d93254e5e6b36e919c4759f24f38e3998f695e35c967984
faedbba3c52607b2d96cd069148b28a6e7233d2fa9b5643e8fe7604689f75ae3,ada1cb1b5d3f0a09e37a2c510295e27f70f1db630b56ebccf2417e0dc401398b,10,Mencius,polkadot.network,,02166422b1b2da8d3f9986b0df694a9008d535fb36475e858b14cb94ea41a339e7,02183ffa596f67f0445ab945933c1e39c3f4f5dcb346cc8d5dfaae30d5d64e8ac4
a0e430eae4f131ef808a981e61dbe6bcc12264d4f103524d395a5ac6c966f059,720aaf07da947bdf7ac25f73cc70207b1e691f2794ee2044fdd0442bda78ed31,10,Confucius,polkadot.network,,026220f0c305bc8131ba929a55b3a4de504afed8cbf980c05d487e40675ba40383,02b9127e1c4f25e6b15e488006c128ddc55327b38100de7b890cd50b5e2cdb9804
9b26794331dcf1c41aa29fd482b2e3bd786e190475d9c2119479fb4c9bec239c,5917d1850e940bcd23254c73dcb936b730dd950ee6b750af02cc8caaedcd83ba,10,Laocius,polkadot.network,,037bcacb8f770632b43d52bbf52c14c94f766c59b6b2853678f3bfd8c2bbf73119,0315565ca86c26a01eb9f561b27c4202a80d760e049621600b46e21d2614943249
faedbba3c52607b2d96cd069148b28a6e7233d2fa9b5643e8fe7604689f75ae3,ada1cb1b5d3f0a09e37a2c510295e27f70f1db630b56ebccf2417e0dc401398b,10,Mencius,polkadot.network,,0292fc46364843cc9909ba6b33cbdf28e2a36d431b20ea47a188a3913e4aed6181,02d2e2729a2f0110b5705b9bc4aad5f54f7b4e80f495e45e465e140c28d0bc5106
a0e430eae4f131ef808a981e61dbe6bcc12264d4f103524d395a5ac6c966f059,720aaf07da947bdf7ac25f73cc70207b1e691f2794ee2044fdd0442bda78ed31,10,Confucius,polkadot.network,,0202df69fc8cf55ebe4c56487cdcb0066eae346fda47a3212a16bd37e91efc41b6,033a8e0a477752755fb3809858d230e8efb0383fd2c36442d3c62830b05b7950c6
e8e4ea2e27dac9c85b138554f323c19e82d3b77ab59ad1bd944c138c31e32588,dc6731942968ba7a321b22f688fbb94449975b5b078f2a495610df52c0fa2fbf,10,Mocius,polkadot.network,,,
Binary file not shown.
7 changes: 5 additions & 2 deletions cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ pub enum ChainSpec {
Development,
Testnet,
TestnetMohism,
TestnetConfucianism,
Mainnet,
}

Expand All @@ -58,14 +59,16 @@ impl ChainSpec {
ChainSpec::Development => chain_spec::development_config(),
ChainSpec::Testnet => chain_spec::testnet_config(),
ChainSpec::TestnetMohism => chain_spec::testnet_mohism_config(),
ChainSpec::TestnetConfucianism => chain_spec::testnet_confucianism_config(),
ChainSpec::Mainnet => chain_spec::mainnet_config(),
})
}

pub(crate) fn from(s: &str) -> Option<Self> {
match s {
"mainnet" | "" => Some(ChainSpec::Mainnet),
"testnet-mohism" => Some(ChainSpec::TestnetMohism),
// "testnet-mohism" => Some(ChainSpec::TestnetMohism),
"testnet-confucianism" => Some(ChainSpec::TestnetConfucianism),
"dev" => Some(ChainSpec::Development),
_ => None,
}
Expand All @@ -77,7 +80,7 @@ fn load_spec(id: &str) -> Result<Option<chain_spec::ChainSpec>, String> {
Some(spec) => Ok(Some(spec.load()?)),
None => Err(format!(
"we just allow:{:?}",
vec!["mainnet", "testnet-mohism", "dev"]
vec!["mainnet", "testnet-confucianism", "dev"]
)),
}
}
Expand Down

0 comments on commit db37f5c

Please sign in to comment.