Skip to content

Commit

Permalink
Merge pull request #64 from hicommonwealth/drew.upgrade
Browse files Browse the repository at this point in the history
Drew.upgrade: New testnet, organizing the node more efficiently/transparently
  • Loading branch information
jnaviask authored Apr 17, 2019
2 parents 2841f61 + b2aa13c commit 57f2d12
Show file tree
Hide file tree
Showing 18 changed files with 2,183 additions and 640 deletions.
712 changes: 423 additions & 289 deletions Cargo.lock

Large diffs are not rendered by default.

45 changes: 15 additions & 30 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "edgeware"
version = "0.1.9"
version = "0.2.0"
authors = ["Commonwealth Labs <[email protected]>"]
build = "build.rs"

Expand All @@ -10,49 +10,34 @@ path = "node/src/main.rs"

[dependencies]
error-chain = "0.12"
edgeware-cli = { path = "node/cli" }
futures = "0.1"
ctrlc = { version = "3.0", features = ["termination"] }
log = "0.4"
tokio = "0.1.7"
exit-future = "0.1"
parking_lot = "0.4"
hex-literal = "0.1"
slog = "^2"
parity-codec = { version = "3.0" }
trie-root = { git = "https://github.com/paritytech/trie" }
sr-io = { git = "https://github.com/paritytech/substrate" }
sr-primitives = { git = "https://github.com/paritytech/substrate" }
substrate-cli = { git = "https://github.com/paritytech/substrate" }
substrate-primitives = { git = "https://github.com/paritytech/substrate" }
substrate-inherents = { git = "https://github.com/paritytech/substrate" }
substrate-keystore = { git = "https://github.com/paritytech/substrate" }
substrate-executor = { git = "https://github.com/paritytech/substrate" }
substrate-service = { git = "https://github.com/paritytech/substrate" }
substrate-transaction-pool = { git = "https://github.com/paritytech/substrate" }
substrate-network = { git = "https://github.com/paritytech/substrate" }
substrate-consensus-aura = { git = "https://github.com/paritytech/substrate" }
substrate-telemetry = { git = "https://github.com/paritytech/substrate" }
substrate-client = { git = "https://github.com/paritytech/substrate", default-features = false }
substrate-finality-grandpa = { git = "https://github.com/paritytech/substrate" }
substrate-basic-authorship = { git = "https://github.com/paritytech/substrate" }
structopt = "0.2"
node-primitives = { path = "node/primitives" }
edgeware-runtime = { path = "node/runtime" }

[build-dependencies]
vergen = "2"
vergen = "3"

[workspace]
members = [
"node/runtime",
"node/cli",
"node/executor",
"node/primitives",
"node/service",
"modules/edge-delegation",
"modules/edge-governance",
"modules/edge-identity",
"modules/edge-voting",
"subkey"
"subkey",
]
exclude = [ "node/runtime/wasm" ]

[badges]
travis-ci = { repository = "paritytech/substrate", branch = "master" }
maintenance = { status = "actively-developed" }
is-it-maintained-issue-resolution = { repository = "paritytech/substrate" }
is-it-maintained-open-issues = { repository = "paritytech/substrate" }

[profile.release]
# Substrate runtime requires unwinding.
panic = "unwind"
panic = "unwind"
11 changes: 3 additions & 8 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,11 @@

extern crate vergen;

use vergen::{ConstantsFlags, Vergen};
use vergen::{ConstantsFlags, generate_cargo_keys};

const ERROR_MSG: &'static str = "Failed to generate metadata files";

fn main() {
let vergen = Vergen::new(ConstantsFlags::all()).expect(ERROR_MSG);

for (k, v) in vergen.build_info() {
println!("cargo:rustc-env={}={}", k.name(), v);
}

generate_cargo_keys(ConstantsFlags::all()).expect(ERROR_MSG);
println!("cargo:rerun-if-changed=.git/HEAD");
}
}
15 changes: 15 additions & 0 deletions node/cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "edgeware-cli"
version = "0.1.0"
authors = ["Commonwealth Labs <[email protected]>"]
edition = "2018"

[dependencies]
log = "0.4.6"
tokio = "0.1.7"
futures = "0.1.17"
exit-future = "0.1"
substrate-cli = { git = "https://github.com/paritytech/substrate" }
edgeware-service = { path = "../service" }
edgeware-primitives = { path = "../primitives" }
edgeware-runtime = { path = "../runtime" }
63 changes: 63 additions & 0 deletions node/cli/src/chain_spec.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Copyright 2018 Commonwealth Labs, Inc.
// This file is part of Edgeware.

// Edgeware is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Edgeware is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Edgeware. If not, see <http://www.gnu.org/licenses/>

use service;

/// The chain specification option.
#[derive(Clone, Debug)]
pub enum ChainSpec {
/// Whatever the current runtime is, with just Alice as an auth.
Development,
/// Whatever the current runtime is, with simple Alice/Bob auths.
LocalTestnet,
/// Edgeware testnet.
Edgeware,
/// Edgeware testnet configuration (intermediate build process)
EdgewareTestnetConfiguration,
// Commonwealth CI testnet
CWCITestnet,
}

impl Default for ChainSpec {
fn default() -> Self {
ChainSpec::Development
}
}

/// Get a chain config from a spec setting.
impl ChainSpec {
pub(crate) fn load(self) -> Result<service::chain_spec::ChainSpec, String> {
Ok(match self {
ChainSpec::EdgewareTestnetConfiguration => service::chain_spec::edgeware_testnet_config()?,
ChainSpec::Edgeware => service::chain_spec::edgeware_config(),
ChainSpec::Development => service::chain_spec::development_config(),
ChainSpec::LocalTestnet => service::chain_spec::local_testnet_config(),
ChainSpec::CWCITestnet => service::chain_spec::cwci_testnet_config(),
})
}

pub(crate) fn from(s: &str) -> Option<Self> {
match s {
"dev" => Some(ChainSpec::Development),
"local" => Some(ChainSpec::LocalTestnet),
"edge" => Some(ChainSpec::EdgewareTestnetConfiguration),
"edgeware" => Some(ChainSpec::Edgeware),
"cwci" => Some(ChainSpec::CWCITestnet),
"" => Some(ChainSpec::default()),
_ => None,
}
}
}
100 changes: 38 additions & 62 deletions node/src/cli.rs → node/cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,56 +14,32 @@
// You should have received a copy of the GNU General Public License
// along with Edgeware. If not, see <http://www.gnu.org/licenses/>

extern crate substrate_cli as cli;

use service;
use tokio::prelude::Future;
use tokio::runtime::{Builder as RuntimeBuilder, Runtime};
pub use substrate_cli::{VersionInfo, IntoExit, NoCustom};
use substrate_service::{ServiceFactory, Roles as ServiceRoles};
use chain_spec;
#![warn(missing_docs)]
#![warn(unused_extern_crates)]

extern crate edgeware_service as service;

use substrate_cli as cli;
use exit_future;

#[macro_use]
extern crate log;

mod chain_spec;

use std::ops::Deref;
pub use substrate_cli::error;

/// The chain specification option.
#[derive(Clone, Debug)]
pub enum ChainSpec {
/// Whatever the current runtime is, with just Alice as an auth.
Development,
/// Whatever the current runtime is, with simple Alice/Bob auths.
LocalTestnet,
/// Edgeware testnet.
Edgeware,
EdgewareTestnet,
// Commonwealth CI testnet
CWCITestnet,
}
use chain_spec::ChainSpec;
use futures::Future;
use tokio::runtime::Runtime;

/// Get a chain config from a spec setting.
impl ChainSpec {
pub(crate) fn load(self) -> Result<chain_spec::ChainSpec, String> {
Ok(match self {
ChainSpec::Edgeware => chain_spec::edgeware_config()?,
ChainSpec::EdgewareTestnet => chain_spec::edgeware_testnet_config(),
ChainSpec::Development => chain_spec::development_config(),
ChainSpec::LocalTestnet => chain_spec::local_testnet_config(),
ChainSpec::CWCITestnet => chain_spec::cwci_testnet_config(),
})
}

pub(crate) fn from(s: &str) -> Option<Self> {
match s {
"dev" => Some(ChainSpec::Development),
"local" => Some(ChainSpec::LocalTestnet),
"" | "edge" => Some(ChainSpec::Edgeware),
"edgeware" => Some(ChainSpec::EdgewareTestnet),
"cwci" => Some(ChainSpec::CWCITestnet),
_ => None,
}
}
}

fn load_spec(id: &str) -> Result<Option<chain_spec::ChainSpec>, String> {
pub use service::{ServiceFactory, Factory};

pub use cli::{VersionInfo, IntoExit, NoCustom};
pub use cli::error;
pub use tokio::runtime::TaskExecutor;

fn load_spec(id: &str) -> Result<Option<service::ChainSpec>, String> {
Ok(match ChainSpec::from(id) {
Some(spec) => Some(spec.load()?),
None => None,
Expand All @@ -77,28 +53,28 @@ pub fn run<I, T, E>(args: I, exit: E, version: cli::VersionInfo) -> error::Resul
E: IntoExit,
{
cli::parse_and_execute::<service::Factory, NoCustom, NoCustom, _, _, _, _, _>(
load_spec, &version, "substrate-node", args, exit,
load_spec, &version, "edgeware-node", args, exit,
|exit, _custom_args, config| {
info!("{}", version.name);
info!(" version {}", config.full_version());
info!(" by Commonwealth Labs, 2018-2019");
info!(" by {}, 2018-2019", version.author);
info!("Chain specification: {}", config.chain_spec.name());
info!("Node name: {}", config.name);
info!("Roles: {:?}", config.roles);
let runtime = RuntimeBuilder::new().name_prefix("main-tokio-").build()
.map_err(|e| format!("{:?}", e))?;
let runtime = Runtime::new().map_err(|e| format!("{:?}", e))?;
let executor = runtime.executor();
match config.roles {
ServiceRoles::LIGHT => run_until_exit(
runtime,
service::Factory::new_light(config, executor).map_err(|e| format!("{:?}", e))?,
exit
),
service::Roles::LIGHT =>
run_until_exit(
runtime,
Factory::new_light(config, executor).map_err(|e| format!("{:?}", e))?,
exit
),
_ => run_until_exit(
runtime,
service::Factory::new_full(config, executor).map_err(|e| format!("{:?}", e))?,
exit
),
runtime,
Factory::new_full(config, executor).map_err(|e| format!("{:?}", e))?,
exit
),
}.map_err(|e| format!("{:?}", e))
}
).map_err(Into::into).map(|_| ())
Expand All @@ -110,8 +86,8 @@ fn run_until_exit<T, C, E>(
e: E,
) -> error::Result<()>
where
T: Deref<Target=substrate_service::Service<C>>,
C: substrate_service::Components,
T: Deref<Target=service::Service<C>>,
C: service::Components,
E: IntoExit,
{
let (exit_send, exit) = exit_future::signal();
Expand Down
35 changes: 35 additions & 0 deletions node/executor/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[package]
name = "edgeware-executor"
version = "0.1.0"
authors = ["Commonwealth Labs <[email protected]>"]
edition = "2018"

[dependencies]
trie-root = "0.12"
parity-codec = "3.3"
runtime_io = { package = "sr-io", git = "https://github.com/paritytech/substrate" }
state_machine = { package = "substrate-state-machine", git = "https://github.com/paritytech/substrate" }
substrate-executor = { git = "https://github.com/paritytech/substrate" }
primitives = { package = "substrate-primitives", git = "https://github.com/paritytech/substrate" }
trie = { package = "substrate-trie", git = "https://github.com/paritytech/substrate" }
edgeware-primitives = { path = "../primitives" }
edgeware-runtime = { path = "../runtime" }

[dev-dependencies]
keyring = { package = "substrate-keyring", git = "https://github.com/paritytech/substrate" }
runtime_primitives = { package = "sr-primitives", git = "https://github.com/paritytech/substrate" }
runtime_support = { package = "srml-support", git = "https://github.com/paritytech/substrate" }
balances = { package = "srml-balances", git = "https://github.com/paritytech/substrate" }
session = { package = "srml-session", git = "https://github.com/paritytech/substrate" }
staking = { package = "srml-staking", git = "https://github.com/paritytech/substrate" }
system = { package = "srml-system", git = "https://github.com/paritytech/substrate" }
consensus = { package = "srml-consensus", git = "https://github.com/paritytech/substrate" }
timestamp = { package = "srml-timestamp", git = "https://github.com/paritytech/substrate" }
treasury = { package = "srml-treasury", git = "https://github.com/paritytech/substrate" }
contract = { package = "srml-contract", git = "https://github.com/paritytech/substrate" }
grandpa = { package = "srml-grandpa", git = "https://github.com/paritytech/substrate" }
indices = { package = "srml-indices", git = "https://github.com/paritytech/substrate" }
wabt = "~0.7.4"

[features]
benchmarks = []
Loading

0 comments on commit 57f2d12

Please sign in to comment.