Update to `3dedd246c62255ba6f9b777ecba318dfc2078d85`

main
Shawn Tabrizi 2019-10-04 15:32:53 +02:00
parent ef3a59b007
commit 1434d54e29
9 changed files with 1395 additions and 1210 deletions

2304
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,34 +1,26 @@
[build-dependencies]
vergen = '3'
[profile.release]
panic = 'unwind'
[workspace]
members = ['runtime']
[dependencies] [dependencies]
derive_more = '0.14.0' derive_more = '0.15.0'
exit-future = '0.1' exit-future = '0.1.4'
futures = '0.1' futures = '0.1.29'
log = '0.4' log = '0.4.8'
parking_lot = '0.9.0' parking_lot = '0.9.0'
tokio = '0.1' tokio = '0.1.22'
trie-root = '0.15.2' trie-root = '0.15.2'
[dependencies.babe] [dependencies.babe]
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/paritytech/substrate.git'
package = 'substrate-consensus-babe' package = 'substrate-consensus-babe'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90' rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
[dependencies.babe-primitives] [dependencies.babe-primitives]
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/paritytech/substrate.git'
package = 'substrate-consensus-babe-primitives' package = 'substrate-consensus-babe-primitives'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90' rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
[dependencies.basic-authorship] [dependencies.basic-authorship]
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/paritytech/substrate.git'
package = 'substrate-basic-authorship' package = 'substrate-basic-authorship'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90' rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
[dependencies.codec] [dependencies.codec]
package = 'parity-scale-codec' package = 'parity-scale-codec'
@ -36,27 +28,27 @@ version = '1.0.0'
[dependencies.ctrlc] [dependencies.ctrlc]
features = ['termination'] features = ['termination']
version = '3.0' version = '3.1.3'
[dependencies.grandpa] [dependencies.grandpa]
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/paritytech/substrate.git'
package = 'substrate-finality-grandpa' package = 'substrate-finality-grandpa'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90' rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
[dependencies.grandpa-primitives] [dependencies.grandpa-primitives]
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/paritytech/substrate.git'
package = 'substrate-finality-grandpa-primitives' package = 'substrate-finality-grandpa-primitives'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90' rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
[dependencies.inherents] [dependencies.inherents]
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/paritytech/substrate.git'
package = 'substrate-inherents' package = 'substrate-inherents'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90' rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
[dependencies.network] [dependencies.network]
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/paritytech/substrate.git'
package = 'substrate-network' package = 'substrate-network'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90' rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
[dependencies.node-template-runtime] [dependencies.node-template-runtime]
path = 'runtime' path = 'runtime'
@ -64,32 +56,41 @@ path = 'runtime'
[dependencies.primitives] [dependencies.primitives]
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/paritytech/substrate.git'
package = 'substrate-primitives' package = 'substrate-primitives'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90' rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
[dependencies.sr-io] [dependencies.sr-io]
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/paritytech/substrate.git'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90' rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
[dependencies.substrate-cli] [dependencies.substrate-cli]
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/paritytech/substrate.git'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90' rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
[dependencies.substrate-client] [dependencies.substrate-client]
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/paritytech/substrate.git'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90' rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
[dependencies.substrate-executor] [dependencies.substrate-executor]
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/paritytech/substrate.git'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90' rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
[dependencies.substrate-service] [dependencies.substrate-service]
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/paritytech/substrate.git'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90' rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
[dependencies.transaction-pool] [dependencies.transaction-pool]
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/paritytech/substrate.git'
package = 'substrate-transaction-pool' package = 'substrate-transaction-pool'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90' rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
[profile.release]
panic = 'unwind'
[[bin]]
name = 'node-template'
path = 'src/main.rs'
[workspace]
members = ['runtime']
[package] [package]
authors = ['Anonymous'] authors = ['Anonymous']
@ -98,6 +99,5 @@ edition = '2018'
name = 'node-template' name = 'node-template'
version = '2.0.0' version = '2.0.0'
[[bin]] [build-dependencies]
name = 'node-template' vergen = '3.0.4'
path = 'src/main.rs'

View File

@ -1,31 +1,26 @@
[package]
authors = ['Anonymous']
edition = '2018'
name = 'node-template-runtime'
version = '2.0.0'
[dependencies.babe] [dependencies.babe]
default-features = false default-features = false
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/paritytech/substrate.git'
package = 'srml-babe' package = 'srml-babe'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90' rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
[dependencies.babe-primitives] [dependencies.babe-primitives]
default-features = false default-features = false
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/paritytech/substrate.git'
package = 'substrate-consensus-babe-primitives' package = 'substrate-consensus-babe-primitives'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90' rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
[dependencies.balances] [dependencies.balances]
default_features = false default_features = false
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/paritytech/substrate.git'
package = 'srml-balances' package = 'srml-balances'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90' rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
[dependencies.client] [dependencies.client]
default_features = false default_features = false
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/paritytech/substrate.git'
package = 'substrate-client' package = 'substrate-client'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90' rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
[dependencies.codec] [dependencies.codec]
default-features = false default-features = false
@ -37,99 +32,104 @@ version = '1.0.0'
default_features = false default_features = false
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/paritytech/substrate.git'
package = 'srml-executive' package = 'srml-executive'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90' rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
[dependencies.grandpa] [dependencies.grandpa]
default-features = false default-features = false
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/paritytech/substrate.git'
package = 'srml-grandpa' package = 'srml-grandpa'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90' rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
[dependencies.indices] [dependencies.indices]
default_features = false default_features = false
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/paritytech/substrate.git'
package = 'srml-indices' package = 'srml-indices'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90' rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
[dependencies.offchain-primitives] [dependencies.offchain-primitives]
default-features = false default-features = false
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/paritytech/substrate.git'
package = 'substrate-offchain-primitives' package = 'substrate-offchain-primitives'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90' rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
[dependencies.primitives] [dependencies.primitives]
default_features = false default_features = false
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/paritytech/substrate.git'
package = 'substrate-primitives' package = 'substrate-primitives'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90' rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
[dependencies.rstd] [dependencies.rstd]
default_features = false default_features = false
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/paritytech/substrate.git'
package = 'sr-std' package = 'sr-std'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90' rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
[dependencies.runtime-io] [dependencies.runtime-io]
default_features = false default_features = false
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/paritytech/substrate.git'
package = 'sr-io' package = 'sr-io'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90' rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
[dependencies.safe-mix] [dependencies.safe-mix]
default-features = false default-features = false
version = '1.0' version = '1.0.0'
[dependencies.serde] [dependencies.serde]
features = ['derive'] features = ['derive']
optional = true optional = true
version = '1.0' version = '1.0.101'
[dependencies.sr-primitives] [dependencies.sr-primitives]
default_features = false default_features = false
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/paritytech/substrate.git'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90' rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
[dependencies.substrate-session] [dependencies.substrate-session]
default-features = false default-features = false
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/paritytech/substrate.git'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90' rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
[dependencies.sudo] [dependencies.sudo]
default_features = false default_features = false
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/paritytech/substrate.git'
package = 'srml-sudo' package = 'srml-sudo'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90' rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
[dependencies.support] [dependencies.support]
default_features = false default_features = false
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/paritytech/substrate.git'
package = 'srml-support' package = 'srml-support'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90' rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
[dependencies.system] [dependencies.system]
default_features = false default_features = false
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/paritytech/substrate.git'
package = 'srml-system' package = 'srml-system'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90' rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
[dependencies.timestamp] [dependencies.timestamp]
default_features = false default_features = false
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/paritytech/substrate.git'
package = 'srml-timestamp' package = 'srml-timestamp'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90' rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
[dependencies.version] [dependencies.version]
default_features = false default_features = false
git = 'https://github.com/paritytech/substrate.git' git = 'https://github.com/paritytech/substrate.git'
package = 'sr-version' package = 'sr-version'
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90' rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
[build-dependencies.wasm-builder-runner] [build-dependencies.wasm-builder-runner]
package = 'substrate-wasm-builder-runner' package = 'substrate-wasm-builder-runner'
version = '1.0.2' version = '1.0.2'
[package]
authors = ['Anonymous']
edition = '2018'
name = 'node-template-runtime'
version = '2.0.0'
[features] [features]
default = ['std'] default = ['std']
no_std = []
std = [ std = [
'codec/std', 'codec/std',
'client/std', 'client/std',

View File

@ -19,7 +19,7 @@ use wasm_builder_runner::{build_current_project_with_rustflags, WasmBuilderSourc
fn main() { fn main() {
build_current_project_with_rustflags( build_current_project_with_rustflags(
"wasm_binary.rs", "wasm_binary.rs",
WasmBuilderSource::Crates("1.0.5"), WasmBuilderSource::Crates("1.0.7"),
// This instructs LLD to export __heap_base as a global variable, which is used by the // This instructs LLD to export __heap_base as a global variable, which is used by the
// external memory allocator. // external memory allocator.
"-Clink-arg=--export=__heap_base", "-Clink-arg=--export=__heap_base",

View File

@ -14,11 +14,11 @@ use sr_primitives::{
ApplyResult, transaction_validity::TransactionValidity, generic, create_runtime_str, ApplyResult, transaction_validity::TransactionValidity, generic, create_runtime_str,
impl_opaque_keys, AnySignature impl_opaque_keys, AnySignature
}; };
use sr_primitives::traits::{NumberFor, BlakeTwo256, Block as BlockT, DigestFor, StaticLookup, Verify, ConvertInto}; use sr_primitives::traits::{NumberFor, BlakeTwo256, Block as BlockT, StaticLookup, Verify, ConvertInto};
use sr_primitives::weights::Weight; use sr_primitives::weights::Weight;
use babe::{AuthorityId as BabeId}; use babe::{AuthorityId as BabeId};
use grandpa::{AuthorityId as GrandpaId, AuthorityWeight as GrandpaWeight}; use grandpa::{AuthorityId as GrandpaId, AuthorityWeight as GrandpaWeight};
use grandpa::fg_primitives::{self, ScheduledChange}; use grandpa::fg_primitives;
use client::{ use client::{
block_builder::api::{CheckInherentsResult, InherentData, self as block_builder_api}, block_builder::api::{CheckInherentsResult, InherentData, self as block_builder_api},
runtime_api as client_api, impl_runtime_apis runtime_api as client_api, impl_runtime_apis
@ -189,6 +189,7 @@ parameter_types! {
impl babe::Trait for Runtime { impl babe::Trait for Runtime {
type EpochDuration = EpochDuration; type EpochDuration = EpochDuration;
type ExpectedBlockTime = ExpectedBlockTime; type ExpectedBlockTime = ExpectedBlockTime;
type EpochChangeTrigger = babe::SameAuthoritiesForever;
} }
impl grandpa::Trait for Runtime { impl grandpa::Trait for Runtime {
@ -208,7 +209,7 @@ impl indices::Trait for Runtime {
} }
parameter_types! { parameter_types! {
pub const MinimumPeriod: u64 = 5000; pub const MinimumPeriod: u64 = SLOT_DURATION / 2;
} }
impl timestamp::Trait for Runtime { impl timestamp::Trait for Runtime {
@ -235,7 +236,6 @@ impl balances::Trait for Runtime {
type OnNewAccount = Indices; type OnNewAccount = Indices;
/// The ubiquitous event type. /// The ubiquitous event type.
type Event = Event; type Event = Event;
type TransactionPayment = (); type TransactionPayment = ();
type DustRemoval = (); type DustRemoval = ();
type TransferPayment = (); type TransferPayment = ();
@ -268,7 +268,7 @@ construct_runtime!(
Babe: babe::{Module, Call, Storage, Config, Inherent(Timestamp)}, Babe: babe::{Module, Call, Storage, Config, Inherent(Timestamp)},
Grandpa: grandpa::{Module, Call, Storage, Config, Event}, Grandpa: grandpa::{Module, Call, Storage, Config, Event},
Indices: indices::{default, Config<T>}, Indices: indices::{default, Config<T>},
Balances: balances, Balances: balances::{default, Error},
Sudo: sudo, Sudo: sudo,
// Used for the module template in `./template.rs` // Used for the module template in `./template.rs`
TemplateModule: template::{Module, Call, Storage, Event<T>}, TemplateModule: template::{Module, Call, Storage, Event<T>},
@ -357,45 +357,25 @@ impl_runtime_apis! {
} }
impl fg_primitives::GrandpaApi<Block> for Runtime { impl fg_primitives::GrandpaApi<Block> for Runtime {
fn grandpa_pending_change(digest: &DigestFor<Block>)
-> Option<ScheduledChange<NumberFor<Block>>>
{
Grandpa::pending_change(digest)
}
fn grandpa_forced_change(digest: &DigestFor<Block>)
-> Option<(NumberFor<Block>, ScheduledChange<NumberFor<Block>>)>
{
Grandpa::forced_change(digest)
}
fn grandpa_authorities() -> Vec<(GrandpaId, GrandpaWeight)> { fn grandpa_authorities() -> Vec<(GrandpaId, GrandpaWeight)> {
Grandpa::grandpa_authorities() Grandpa::grandpa_authorities()
} }
} }
impl babe_primitives::BabeApi<Block> for Runtime { impl babe_primitives::BabeApi<Block> for Runtime {
fn startup_data() -> babe_primitives::BabeConfiguration { fn configuration() -> babe_primitives::BabeConfiguration {
// The choice of `c` parameter (where `1 - c` represents the // The choice of `c` parameter (where `1 - c` represents the
// probability of a slot being empty), is done in accordance to the // probability of a slot being empty), is done in accordance to the
// slot duration and expected target block time, for safely // slot duration and expected target block time, for safely
// resisting network delays of maximum two seconds. // resisting network delays of maximum two seconds.
// <https://research.web3.foundation/en/latest/polkadot/BABE/Babe/#6-practical-results> // <https://research.web3.foundation/en/latest/polkadot/BABE/Babe/#6-practical-results>
babe_primitives::BabeConfiguration { babe_primitives::BabeConfiguration {
median_required_blocks: 1000,
slot_duration: Babe::slot_duration(), slot_duration: Babe::slot_duration(),
epoch_length: EpochDuration::get(),
c: PRIMARY_PROBABILITY, c: PRIMARY_PROBABILITY,
} genesis_authorities: Babe::authorities(),
}
fn epoch() -> babe_primitives::Epoch {
babe_primitives::Epoch {
start_slot: Babe::epoch_start_slot(),
authorities: Babe::authorities(),
epoch_index: Babe::epoch_index(),
randomness: Babe::randomness(), randomness: Babe::randomness(),
duration: EpochDuration::get(), secondary_slots: true,
secondary_slots: Babe::secondary_slots().0,
} }
} }
} }

View File

@ -8,7 +8,7 @@
/// For more guidance on Substrate modules, see the example module /// For more guidance on Substrate modules, see the example module
/// https://github.com/paritytech/substrate/blob/master/srml/example/src/lib.rs /// https://github.com/paritytech/substrate/blob/master/srml/example/src/lib.rs
use support::{decl_module, decl_storage, decl_event, StorageValue, dispatch::Result}; use support::{decl_module, decl_storage, decl_event, dispatch::Result};
use system::ensure_signed; use system::ensure_signed;
/// The module's configuration trait. /// The module's configuration trait.

View File

@ -4,7 +4,7 @@ use std::cell::RefCell;
use tokio::runtime::Runtime; use tokio::runtime::Runtime;
pub use substrate_cli::{VersionInfo, IntoExit, error}; pub use substrate_cli::{VersionInfo, IntoExit, error};
use substrate_cli::{informant, parse_and_prepare, ParseAndPrepare, NoCustom}; use substrate_cli::{informant, parse_and_prepare, ParseAndPrepare, NoCustom};
use substrate_service::{AbstractService, Roles as ServiceRoles}; use substrate_service::{AbstractService, Roles as ServiceRoles, Configuration};
use crate::chain_spec; use crate::chain_spec;
use log::info; use log::info;
@ -14,9 +14,10 @@ pub fn run<I, T, E>(args: I, exit: E, version: VersionInfo) -> error::Result<()>
T: Into<std::ffi::OsString> + Clone, T: Into<std::ffi::OsString> + Clone,
E: IntoExit, E: IntoExit,
{ {
type Config<T> = Configuration<(), T>;
match parse_and_prepare::<NoCustom, NoCustom, _>(&version, "substrate-node", args) { match parse_and_prepare::<NoCustom, NoCustom, _>(&version, "substrate-node", args) {
ParseAndPrepare::Run(cmd) => cmd.run::<(), _, _, _, _>(load_spec, exit, ParseAndPrepare::Run(cmd) => cmd.run(load_spec, exit,
|exit, _cli_args, _custom_args, config| { |exit, _cli_args, _custom_args, config: Config<_>| {
info!("{}", version.name); info!("{}", version.name);
info!(" version {}", config.full_version()); info!(" version {}", config.full_version());
info!(" by {}, 2017, 2018", version.author); info!(" by {}, 2017, 2018", version.author);
@ -38,12 +39,12 @@ pub fn run<I, T, E>(args: I, exit: E, version: VersionInfo) -> error::Result<()>
}.map_err(|e| format!("{:?}", e)) }.map_err(|e| format!("{:?}", e))
}), }),
ParseAndPrepare::BuildSpec(cmd) => cmd.run(load_spec), ParseAndPrepare::BuildSpec(cmd) => cmd.run(load_spec),
ParseAndPrepare::ExportBlocks(cmd) => cmd.run_with_builder::<(), _, _, _, _, _>(|config| ParseAndPrepare::ExportBlocks(cmd) => cmd.run_with_builder(|config: Config<_>|
Ok(new_full_start!(config).0), load_spec, exit), Ok(new_full_start!(config).0), load_spec, exit),
ParseAndPrepare::ImportBlocks(cmd) => cmd.run_with_builder::<(), _, _, _, _, _>(|config| ParseAndPrepare::ImportBlocks(cmd) => cmd.run_with_builder(|config: Config<_>|
Ok(new_full_start!(config).0), load_spec, exit), Ok(new_full_start!(config).0), load_spec, exit),
ParseAndPrepare::PurgeChain(cmd) => cmd.run(load_spec), ParseAndPrepare::PurgeChain(cmd) => cmd.run(load_spec),
ParseAndPrepare::RevertChain(cmd) => cmd.run_with_builder::<(), _, _, _, _>(|config| ParseAndPrepare::RevertChain(cmd) => cmd.run_with_builder(|config: Config<_>|
Ok(new_full_start!(config).0), load_spec), Ok(new_full_start!(config).0), load_spec),
ParseAndPrepare::CustomCommand(_) => Ok(()) ParseAndPrepare::CustomCommand(_) => Ok(())
}?; }?;

View File

@ -3,10 +3,10 @@
use std::sync::Arc; use std::sync::Arc;
use std::time::Duration; use std::time::Duration;
use substrate_client::LongestChain; use substrate_client::LongestChain;
use babe::{import_queue, start_babe, Config}; use babe;
use grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider}; use grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider};
use futures::prelude::*; use futures::prelude::*;
use node_template_runtime::{self, GenesisConfig, opaque::Block, RuntimeApi, WASM_BINARY}; use node_template_runtime::{self, GenesisConfig, opaque::Block, RuntimeApi};
use substrate_service::{error::{Error as ServiceError}, AbstractService, Configuration, ServiceBuilder}; use substrate_service::{error::{Error as ServiceError}, AbstractService, Configuration, ServiceBuilder};
use transaction_pool::{self, txpool::{Pool as TransactionPool}}; use transaction_pool::{self, txpool::{Pool as TransactionPool}};
use inherents::InherentDataProviders; use inherents::InherentDataProviders;
@ -18,7 +18,7 @@ pub use substrate_executor::NativeExecutor;
native_executor_instance!( native_executor_instance!(
pub Executor, pub Executor,
node_template_runtime::api::dispatch, node_template_runtime::api::dispatch,
node_template_runtime::native_version node_template_runtime::native_version,
); );
construct_simple_protocol! { construct_simple_protocol! {
@ -34,45 +34,48 @@ macro_rules! new_full_start {
($config:expr) => {{ ($config:expr) => {{
let mut import_setup = None; let mut import_setup = None;
let inherent_data_providers = inherents::InherentDataProviders::new(); let inherent_data_providers = inherents::InherentDataProviders::new();
let mut tasks_to_spawn = None;
let builder = substrate_service::ServiceBuilder::new_full::< let builder = substrate_service::ServiceBuilder::new_full::<
node_template_runtime::opaque::Block, node_template_runtime::RuntimeApi, crate::service::Executor node_template_runtime::opaque::Block, node_template_runtime::RuntimeApi, crate::service::Executor
>($config)? >($config)?
.with_select_chain(|_config, client| { .with_select_chain(|_config, backend| {
#[allow(deprecated)] Ok(substrate_client::LongestChain::new(backend.clone()))
Ok(substrate_client::LongestChain::new(client.backend().clone()))
})? })?
.with_transaction_pool(|config, client| .with_transaction_pool(|config, client|
Ok(transaction_pool::txpool::Pool::new(config, transaction_pool::ChainApi::new(client))) Ok(transaction_pool::txpool::Pool::new(config, transaction_pool::FullChainApi::new(client)))
)? )?
.with_import_queue(|_config, client, mut select_chain, transaction_pool| { .with_import_queue(|_config, client, mut select_chain, _transaction_pool| {
let select_chain = select_chain.take() let select_chain = select_chain.take()
.ok_or_else(|| substrate_service::Error::SelectChainRequired)?; .ok_or_else(|| substrate_service::Error::SelectChainRequired)?;
let (block_import, link_half) = let (grandpa_block_import, grandpa_link) =
grandpa::block_import::<_, _, _, node_template_runtime::RuntimeApi, _, _>( grandpa::block_import::<_, _, _, node_template_runtime::RuntimeApi, _, _>(
client.clone(), client.clone(), select_chain client.clone(), &*client, select_chain
)?; )?;
let justification_import = block_import.clone(); let justification_import = grandpa_block_import.clone();
let (import_queue, babe_link, babe_block_import, pruning_task) = babe::import_queue( let (babe_block_import, babe_link) = babe::block_import(
babe::Config::get_or_compute(&*client)?, babe::Config::get_or_compute(&*client)?,
block_import, grandpa_block_import,
client.clone(),
client.clone(),
)?;
let import_queue = babe::import_queue(
babe_link.clone(),
babe_block_import.clone(),
Some(Box::new(justification_import)), Some(Box::new(justification_import)),
None, None,
client.clone(), client.clone(),
client, client,
inherent_data_providers.clone(), inherent_data_providers.clone(),
Some(transaction_pool)
)?; )?;
import_setup = Some((babe_block_import.clone(), link_half, babe_link)); import_setup = Some((babe_block_import, grandpa_link, babe_link));
tasks_to_spawn = Some(vec![Box::new(pruning_task)]);
Ok(import_queue) Ok(import_queue)
})?; })?;
(builder, import_setup, inherent_data_providers, tasks_to_spawn) (builder, import_setup, inherent_data_providers)
}} }}
} }
@ -81,30 +84,24 @@ pub fn new_full<C: Send + Default + 'static>(config: Configuration<C, GenesisCon
-> Result<impl AbstractService, ServiceError> -> Result<impl AbstractService, ServiceError>
{ {
let (builder, mut import_setup, inherent_data_providers, mut tasks_to_spawn) = new_full_start!(config); let is_authority = config.roles.is_authority();
let name = config.name.clone();
let disable_grandpa = config.disable_grandpa;
let force_authoring = config.force_authoring;
let (builder, mut import_setup, inherent_data_providers) = new_full_start!(config);
let service = builder.with_network_protocol(|_| Ok(NodeProtocol::new()))? let service = builder.with_network_protocol(|_| Ok(NodeProtocol::new()))?
.with_finality_proof_provider(|client| .with_finality_proof_provider(|client, backend|
Ok(Arc::new(GrandpaFinalityProofProvider::new(client.clone(), client)) as _) Ok(Arc::new(GrandpaFinalityProofProvider::new(backend, client)) as _)
)? )?
.build()?; .build()?;
let (block_import, link_half, babe_link) = let (block_import, grandpa_link, babe_link) =
import_setup.take() import_setup.take()
.expect("Link Half and Block Import are present for Full Services or setup failed before. qed"); .expect("Link Half and Block Import are present for Full Services or setup failed before. qed");
// spawn any futures that were created in the previous setup steps if is_authority {
if let Some(tasks) = tasks_to_spawn.take() {
for task in tasks {
service.spawn_task(
task.select(service.on_exit())
.map(|_| ())
.map_err(|_| ())
);
}
}
if service.config().roles.is_authority() {
let proposer = basic_authorship::ProposerFactory { let proposer = basic_authorship::ProposerFactory {
client: service.client(), client: service.client(),
transaction_pool: service.transaction_pool(), transaction_pool: service.transaction_pool(),
@ -115,19 +112,18 @@ pub fn new_full<C: Send + Default + 'static>(config: Configuration<C, GenesisCon
.ok_or(ServiceError::SelectChainRequired)?; .ok_or(ServiceError::SelectChainRequired)?;
let babe_config = babe::BabeParams { let babe_config = babe::BabeParams {
config: Config::get_or_compute(&*client)?,
keystore: service.keystore(), keystore: service.keystore(),
client, client,
select_chain, select_chain,
block_import,
env: proposer, env: proposer,
block_import,
sync_oracle: service.network(), sync_oracle: service.network(),
inherent_data_providers: inherent_data_providers.clone(), inherent_data_providers: inherent_data_providers.clone(),
force_authoring: service.config().force_authoring, force_authoring,
time_source: babe_link, babe_link,
}; };
let babe = start_babe(babe_config)?; let babe = babe::start_babe(babe_config)?;
let select = babe.select(service.on_exit()).then(|_| Ok(())); let select = babe.select(service.on_exit()).then(|_| Ok(()));
// the BABE authoring task is considered infallible, i.e. if it // the BABE authoring task is considered infallible, i.e. if it
@ -135,29 +131,29 @@ pub fn new_full<C: Send + Default + 'static>(config: Configuration<C, GenesisCon
service.spawn_essential_task(select); service.spawn_essential_task(select);
} }
let config = grandpa::Config { let grandpa_config = grandpa::Config {
// FIXME #1578 make this available through chainspec // FIXME #1578 make this available through chainspec
gossip_duration: Duration::from_millis(333), gossip_duration: Duration::from_millis(333),
justification_period: 4096, justification_period: 512,
name: Some(service.config().name.clone()), name: Some(name),
keystore: Some(service.keystore()), keystore: Some(service.keystore()),
}; };
match (service.config().roles.is_authority(), service.config().disable_grandpa) { match (is_authority, disable_grandpa) {
(false, false) => { (false, false) => {
// start the lightweight GRANDPA observer // start the lightweight GRANDPA observer
service.spawn_task(Box::new(grandpa::run_grandpa_observer( service.spawn_task(Box::new(grandpa::run_grandpa_observer(
config, grandpa_config,
link_half, grandpa_link,
service.network(), service.network(),
service.on_exit(), service.on_exit(),
)?)); )?));
}, },
(true, false) => { (true, false) => {
// start the full GRANDPA voter // start the full GRANDPA voter
let grandpa_config = grandpa::GrandpaParams { let voter_config = grandpa::GrandpaParams {
config: config, config: grandpa_config,
link: link_half, link: grandpa_link,
network: service.network(), network: service.network(),
inherent_data_providers: inherent_data_providers.clone(), inherent_data_providers: inherent_data_providers.clone(),
on_exit: service.on_exit(), on_exit: service.on_exit(),
@ -166,7 +162,7 @@ pub fn new_full<C: Send + Default + 'static>(config: Configuration<C, GenesisCon
// the GRANDPA voter task is considered infallible, i.e. // the GRANDPA voter task is considered infallible, i.e.
// if it fails we take down the service with it. // if it fails we take down the service with it.
service.spawn_essential_task(grandpa::run_grandpa_voter(grandpa_config)?); service.spawn_essential_task(grandpa::run_grandpa_voter(voter_config)?);
}, },
(_, true) => { (_, true) => {
grandpa::setup_disabled_grandpa( grandpa::setup_disabled_grandpa(
@ -187,44 +183,46 @@ pub fn new_light<C: Send + Default + 'static>(config: Configuration<C, GenesisCo
let inherent_data_providers = InherentDataProviders::new(); let inherent_data_providers = InherentDataProviders::new();
ServiceBuilder::new_light::<Block, RuntimeApi, Executor>(config)? ServiceBuilder::new_light::<Block, RuntimeApi, Executor>(config)?
.with_select_chain(|_config, client| { .with_select_chain(|_config, backend| {
#[allow(deprecated)] Ok(LongestChain::new(backend.clone()))
Ok(LongestChain::new(client.backend().clone()))
})? })?
.with_transaction_pool(|config, client| .with_transaction_pool(|config, client|
Ok(TransactionPool::new(config, transaction_pool::ChainApi::new(client))) Ok(TransactionPool::new(config, transaction_pool::FullChainApi::new(client)))
)? )?
.with_import_queue_and_fprb(|_config, client, _select_chain, transaction_pool| { .with_import_queue_and_fprb(|_config, client, backend, fetcher, _select_chain, _tx_pool| {
#[allow(deprecated)] let fetch_checker = fetcher
let fetch_checker = client.backend().blockchain().fetcher()
.upgrade()
.map(|fetcher| fetcher.checker().clone()) .map(|fetcher| fetcher.checker().clone())
.ok_or_else(|| "Trying to start light import queue without active fetch checker")?; .ok_or_else(|| "Trying to start light import queue without active fetch checker")?;
let block_import = grandpa::light_block_import::<_, _, _, RuntimeApi, _>( let grandpa_block_import = grandpa::light_block_import::<_, _, _, RuntimeApi, _>(
client.clone(), Arc::new(fetch_checker), client.clone() client.clone(), backend, Arc::new(fetch_checker), client.clone()
)?; )?;
let finality_proof_import = block_import.clone(); let finality_proof_import = grandpa_block_import.clone();
let finality_proof_request_builder = let finality_proof_request_builder =
finality_proof_import.create_finality_proof_request_builder(); finality_proof_import.create_finality_proof_request_builder();
// FIXME: pruning task isn't started since light client doesn't do `AuthoritySetup`. let (babe_block_import, babe_link) = babe::block_import(
let (import_queue, ..) = import_queue( babe::Config::get_or_compute(&*client)?,
Config::get_or_compute(&*client)?, grandpa_block_import,
block_import, client.clone(),
client.clone(),
)?;
let import_queue = babe::import_queue(
babe_link.clone(),
babe_block_import,
None, None,
Some(Box::new(finality_proof_import)), Some(Box::new(finality_proof_import)),
client.clone(), client.clone(),
client, client,
inherent_data_providers.clone(), inherent_data_providers.clone(),
Some(transaction_pool)
)?; )?;
Ok((import_queue, finality_proof_request_builder)) Ok((import_queue, finality_proof_request_builder))
})? })?
.with_network_protocol(|_| Ok(NodeProtocol::new()))? .with_network_protocol(|_| Ok(NodeProtocol::new()))?
.with_finality_proof_provider(|client| .with_finality_proof_provider(|client, backend|
Ok(Arc::new(GrandpaFinalityProofProvider::new(client.clone(), client)) as _) Ok(Arc::new(GrandpaFinalityProofProvider::new(backend, client)) as _)
)? )?
.build() .build()
} }

Binary file not shown.