Skip to content

Commit

Permalink
Merge pull request #46 from hicommonwealth/drew.tst
Browse files Browse the repository at this point in the history
Drew.tst: Add testnet options and setup
  • Loading branch information
jnaviask authored Feb 28, 2019
2 parents 1c156f1 + 2752504 commit c9db374
Show file tree
Hide file tree
Showing 10 changed files with 337 additions and 7 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions node/runtime/wasm/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 35 additions & 4 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub enum Alternative {
LocalTestnet,
/// Whatever the current runtime is, with all lock droppers and valid authorities
Edgeware,
EdgewareTestnet,
}

/// Helper function to generate AuthorityID from seed
Expand All @@ -35,6 +36,18 @@ pub fn get_authority_id_from_seed(seed: &str) -> Ed25519AuthorityId {
ed25519::Pair::from_seed(&padded_seed).public().0.into()
}

pub fn get_testnet_pubkeys() -> Vec<Ed25519AuthorityId> {
let pubkeys = vec![
ed25519::Public::from_raw(hex!("df291854c27a22c50322344604076e8b2dc3ffe11dbdcd886adba9e0d6c9f950") as [u8; 32]).into(),
ed25519::Public::from_raw(hex!("3bd15363a31eac0e5ecd067731d8a4561185347fc804c50b507025abc29c2ba1") as [u8; 32]).into(),
ed25519::Public::from_raw(hex!("65b118b4ae7fe642a59316fc5f0ad9b75cdb9f5ab52733165004f7602755bcfd") as [u8; 32]).into(),
ed25519::Public::from_raw(hex!("68128017e34fe40f4ed40f79c24dc7f5a531afc82fc6b71e8092c903627a9133") as [u8; 32]).into(),
ed25519::Public::from_raw(hex!("dc746491a214053440d8b9df6774587da105661cc58ed703dc36965359c666a6") as [u8; 32]).into()
];

return pubkeys;
}

impl Alternative {
/// Get an actual chain config from one of the alternatives.
pub(crate) fn load(self) -> Result<ChainSpec, String> {
Expand Down Expand Up @@ -76,8 +89,24 @@ impl Alternative {
None,
None,
),
Alternative::Edgeware => {
match ChainSpec::from_json_file(std::path::PathBuf::from("edgeware_testnet.json")) {
Alternative::Edgeware => ChainSpec::from_genesis(
"Edgeware",
"edgeware-testnet",
|| {
testnet_genesis(
get_testnet_pubkeys(),
get_testnet_pubkeys()[0].into(),
Some(get_testnet_pubkeys()),
)
},
vec![],
None,
None,
None,
None,
),
Alternative::EdgewareTestnet => {
match ChainSpec::from_json_file(std::path::PathBuf::from("testnets/v0.1.3/edgeware.json")) {
Ok(spec) => spec,
Err(e) => panic!(e),
}
Expand All @@ -89,7 +118,8 @@ impl Alternative {
match s {
"dev" => Some(Alternative::Development),
"local" => Some(Alternative::LocalTestnet),
"edgeware" => Some(Alternative::Edgeware),
"edgewaresetup" => Some(Alternative::Edgeware),
"edgeware" => Some(Alternative::EdgewareTestnet),
_ => None,
}
}
Expand All @@ -110,9 +140,10 @@ fn testnet_genesis(
get_authority_id_from_seed("Ferdie"),
]
});

GenesisConfig {
consensus: Some(ConsensusConfig {
code: include_bytes!("../runtime/wasm/target/wasm32-unknown-unknown/release/edgeware_runtime.compact.wasm").to_vec(),
code: include_bytes!("../runtime/wasm/target/wasm32-unknown-unknown/release/edgeware_runtime.wasm").to_vec(),
authorities: initial_authorities.clone(),
}),
system: None,
Expand Down
2 changes: 1 addition & 1 deletion node/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub fn run<I, T, E>(args: I, exit: E, version: cli::VersionInfo) -> error::Resul
|exit, _custom_args, config| {
info!("{}", version.name);
info!(" version {}", config.full_version());
info!(" by Parity Technologies, 2017-2019");
info!(" by Commonwealth Labs, 2018-2019");
info!("Chain specification: {}", config.chain_spec.name());
info!("Node name: {}", config.name);
info!("Roles: {:?}", config.roles);
Expand Down
2 changes: 2 additions & 0 deletions node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ extern crate edgeware_runtime;
extern crate node_executor;
extern crate substrate_finality_grandpa as grandpa;
extern crate node_primitives;
#[macro_use]
extern crate hex_literal;

use futures::sync::oneshot;
use futures::{future, Future};
Expand Down
4 changes: 2 additions & 2 deletions node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ native_executor_instance!(
pub Executor,
edgeware_runtime::api::dispatch,
edgeware_runtime::native_version,
include_bytes!("../runtime/wasm/target/wasm32-unknown-unknown/release/edgeware_runtime.compact.wasm")
include_bytes!("../runtime/wasm/target/wasm32-unknown-unknown/release/edgeware_runtime.wasm")
);

construct_simple_protocol! {
Expand Down Expand Up @@ -153,4 +153,4 @@ construct_service_factory! {
}
},
}
}
}
File renamed without changes.
File renamed without changes.
196 changes: 196 additions & 0 deletions testnets/v0.1.3/chainspec.json

Large diffs are not rendered by default.

97 changes: 97 additions & 0 deletions testnets/v0.1.3/edgeware.json

Large diffs are not rendered by default.

0 comments on commit c9db374

Please sign in to comment.