Minimal switch of substrate-node to GRANDPA /Aura (#1128)

* add beginnings of SRML grandpa library

* get srml-grandpa compiling

* tests for srml-grandpa

* add optional session integration to grandpa SRML

* start integration into node runtime

* Allow extracting pending change from header digest

* Make it compile on wasm

* make tests compile again

* Move Authority Key fetching into service, simplify service factory construction

* Generalize Authority Consensus Setup system

* Add Authority Setup Docs

* Allow CLI params to be extensible

 - move params to structopts
 - split parsing and default command execution
 - add custom config to node
 - extended parsing of custom config
 - extending params via structop's flatten

* Minor fixes on cli extension params:
 - added docs
 - re-add actual app name, rather than node-name
 - make strategy and subcommand optional

* better cli params

* synchronize GRANDPA and normal node authorities

* Implement grandpa::network for gossip consensus

* run_grandpa in Node

* Fix missed merge error

* Integrate grandpa import queue

* more specific type def

* link up linkhalf and import block

* make grandpa future send

* get compiling

* Fix new params convention and license header

* get it running

* rebuild node runtime WASM

* change logging level

* Update node/cli/src/params.rs

Co-Authored-By: rphmeier <rphmeier@gmail.com>

* Update node/cli/src/params.rs

Co-Authored-By: rphmeier <rphmeier@gmail.com>

* Update node/cli/src/lib.rs

Co-Authored-By: rphmeier <rphmeier@gmail.com>

* Update node/runtime/src/lib.rs

Co-Authored-By: rphmeier <rphmeier@gmail.com>

* Update node/cli/src/lib.rs

Co-Authored-By: rphmeier <rphmeier@gmail.com>

* Clean up and Fixme for mutable config

* Move GrandpaService Integration into grandpa, feature gated but on per default

* Fixing grandpa runtime module test

* Update wasm runtime hashes for tests

* GRANDPA: use post-header hash when logging scheduled changes

* add an extra bit of logging to authorities

* fixing missing constrain

* remove old code

* move `NewAuthorities` to an event in srml-grandpa

* fix node-executor tests to use grandpa log

* Remove GossipConsensus from tests, use newly provided sync-feature, fixes tests

* Update to latest wasm runtimes

* address grumbles

* address grumbles

* only derive deserialize when using std

* Clean up use of Deserialize
This commit is contained in:
Robert Habermeier
2018-11-21 18:42:50 +01:00
committed by GitHub
parent 84da9d4a02
commit 11fe84a742
59 changed files with 1694 additions and 696 deletions
+216
View File
@@ -0,0 +1,216 @@
// Copyright 2018 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
// Substrate 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.
// Substrate 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 Substrate. If not, see <http://www.gnu.org/licenses/>.
use std::path::PathBuf;
use structopt::StructOpt;
#[derive(Debug, StructOpt)]
#[structopt(name = "Substrate")]
pub struct CoreParams {
#[structopt(short = "l", long = "log", value_name = "LOG_PATTERN", help = "Sets a custom logging filter")]
log: Option<String>,
#[structopt(long = "base-path", short = "d", value_name = "PATH", help = "Specify custom base path", parse(from_os_str))]
base_path: Option<PathBuf>,
#[structopt(long = "keystore-path", value_name = "PATH", help = "Specify custom keystore path", parse(from_os_str))]
keystore_path: Option<PathBuf>,
#[structopt(long = "key", value_name = "STRING", help = "Specify additional key seed")]
key: Option<String>,
#[structopt(long = "node-key", value_name = "KEY", help = "Specify node secret key (64-character hex string)")]
node_key: Option<String>,
#[structopt(long = "validator",help = "Enable validator mode")]
validator: bool,
#[structopt(long = "light", help = "Run in light client mode")]
light: bool,
#[structopt(long = "dev", help = "Run in development mode; implies --chain=dev --validator --key Alice")]
dev: bool,
#[structopt(long = "listen-addr", value_name = "LISTEN_ADDR", help = "Listen on this multiaddress")]
listen_addr: Vec<String>,
#[structopt(long = "port", value_name = "PORT", help = "Specify p2p protocol TCP port. Only used if --listen-addr is not specified.")]
port: Option<u32>,
#[structopt(long = "rpc-external", help = "Listen to all RPC interfaces (default is local)")]
rpc_external: bool,
#[structopt(long = "ws-external", help = "Listen to all Websocket interfaces (default is local)")]
ws_external: bool,
#[structopt(long = "rpc-port", value_name = "PORT", help = "Specify HTTP RPC server TCP port")]
rpc_port: Option<u32>,
#[structopt(long = "ws-port", value_name = "PORT", help = "Specify WebSockets RPC server TCP port")]
ws_port: Option<u32>,
#[structopt(long = "bootnodes", value_name = "URL", help = "Specify a list of bootnodes")]
bootnodes: Vec<String>,
#[structopt(long = "reserved-nodes", value_name = "URL", help = "Specify a list of reserved node addresses")]
reserved_nodes: Vec<String>,
#[structopt(long = "out-peers", value_name = "OUT_PEERS", help = "Specify the number of outgoing connections we're trying to maintain")]
out_peers: Option<u8>,
#[structopt(long = "in-peers", value_name = "IN_PEERS", help = "Specify the maximum number of incoming connections we're accepting")]
in_peers: Option<u8>,
#[structopt(long = "chain", value_name = "CHAIN_SPEC", help = "Specify the chain specification (one of dev, local or staging)")]
chain: Option<String>,
#[structopt(long = "pruning", value_name = "PRUNING_MODE", help = "Specify the pruning mode, a number of blocks to keep or 'archive'. Default is 256.")]
pruning: Option<u32>,
#[structopt(long = "name", value_name = "NAME", help = "The human-readable name for this node, as reported to the telemetry server, if enabled")]
name: Option<String>,
#[structopt(short = "t", long = "telemetry", help = "Should connect to the Substrate telemetry server (telemetry is off by default on local chains)")]
telemetry: bool,
#[structopt(long = "no-telemetry", help = "Should not connect to the Substrate telemetry server (telemetry is on by default on global chains)")]
no_telemetry: bool,
#[structopt(long = "telemetry-url", value_name = "TELEMETRY_URL", help = "The URL of the telemetry server. Implies --telemetry")]
telemetry_url: Option<String>,
#[structopt(long = "execution", value_name = "STRATEGY", help = "The means of execution used when calling into the runtime. Can be either wasm, native or both.")]
execution: Option<ExecutionStrategy>,
#[structopt(subcommand)]
cmds: Option<CoreCommands>,
}
#[derive(Debug, StructOpt)]
pub enum ExecutionStrategy {
Native,
Wasm,
Both,
}
impl Default for ExecutionStrategy {
fn default() -> Self {
ExecutionStrategy::Both
}
}
impl std::str::FromStr for ExecutionStrategy {
type Err = String;
fn from_str(input: &str) -> Result<Self, Self::Err> {
match input {
"native" => Ok(ExecutionStrategy::Native),
"wasm" | "webassembly" => Ok(ExecutionStrategy::Wasm),
"both" => Ok(ExecutionStrategy::Both),
_ => Err("Please specify either 'native', 'wasm' or 'both".to_owned())
}
}
}
#[derive(Debug, StructOpt)]
pub enum CoreCommands {
#[structopt(name = "build-spec", about = "Build a spec.json file, outputing to stdout")]
BuildSpec {
#[structopt(long = "raw", help = "Force raw genesis storage output.")]
raw: bool,
#[structopt(long = "chain", value_name = "CHAIN_SPEC", help = "Specify the chain specification (one of dev, local or staging)")]
chain: Option<String>,
#[structopt(long = "dev", help = "Specify the development chain")]
dev: bool,
},
#[structopt(name = "export-blocks", about = "Export blocks to a file")]
ExportBlocks {
#[structopt(help = "Output file name or stdout if unspecified.", parse(from_os_str))]
OUTPUT: Option<PathBuf>,
#[structopt(long = "chain", value_name = "CHAIN_SPEC", help = "Specify the chain specification.")]
chain: Option<String>,
#[structopt(long = "dev", help = "Specify the development chain")]
dev: bool,
#[structopt(long = "base-path", short = "d", value_name = "PATH", help = "Specify custom base path.")]
base_path: Option<String>,
#[structopt(long = "from", value_name = "BLOCK", help = "Specify starting block number. 1 by default.")]
from: Option<u128>,
#[structopt(long = "to", value_name = "BLOCK", help = "Specify last block number. Best block by default.")]
to: Option<u128>,
#[structopt(long = "json", help = "Use JSON output rather than binary.")]
json: bool,
},
#[structopt(name = "import-blocks", about = "Import blocks from file.")]
ImportBlocks {
#[structopt(help = "Input file or stdin if unspecified.", parse(from_os_str))]
INPUT: Option<PathBuf>,
#[structopt(long = "chain", value_name = "CHAIN_SPEC", help = "Specify the chain specification.")]
chain: Option<String>,
#[structopt(long = "dev", help = "Specify the development chain")]
dev: bool,
#[structopt(long = "base-path", short = "d", value_name = "PATH", help = "Specify custom base path.", parse(from_os_str))]
base_path: Option<PathBuf>,
#[structopt(long = "execution", value_name = "STRATEGY", help = "The means of execution used when executing blocks. Can be either wasm, native or both.")]
execution: ExecutionStrategy,
#[structopt(long = "api-execution", value_name = "STRATEGY", help = "The means of execution used when calling into the runtime. Can be either wasm, native or both.")]
api_execution: ExecutionStrategy,
#[structopt(long = "max-heap-pages", value_name = "COUNT", help = "The maximum number of 64KB pages to ever allocate for Wasm execution. Don't alter this unless you know what you're doing.")]
max_heap_pages: Option<u32>,
},
#[structopt(name = "revert", about = "Revert chain to the previous state")]
Revert {
#[structopt(help = "Number of blocks to revert. Default is 256.")]
NUM: Option<u32>,
#[structopt(long = "chain", value_name = "CHAIN_SPEC", help = "Specify the chain specification.")]
chain: Option<String>,
#[structopt(long = "dev", help = "Specify the development chain")]
dev: bool,
#[structopt(long = "base-path", short = "d", value_name = "PATH", help = "Specify custom base path.", parse(from_os_str))]
base_path: Option<PathBuf>,
},
#[structopt(name = "purge-chain", about = "Remove the whole chain data.")]
PurgeChain {
#[structopt(long = "chain", value_name = "CHAIN_SPEC", help = "Specify the chain specification.")]
chain: Option<String>,
#[structopt(long = "dev", help = "Specify the development chain")]
dev: bool,
#[structopt(long = "base-path", short = "d", value_name = "PATH", help = "Specify custom base path.", parse(from_os_str))]
base_path: Option<PathBuf>
}
}