Update to `3dedd246c62255ba6f9b777ecba318dfc2078d85`
parent
ef3a59b007
commit
1434d54e29
File diff suppressed because it is too large
Load Diff
62
Cargo.toml
62
Cargo.toml
|
@ -1,34 +1,26 @@
|
|||
[build-dependencies]
|
||||
vergen = '3'
|
||||
[profile.release]
|
||||
panic = 'unwind'
|
||||
|
||||
[workspace]
|
||||
members = ['runtime']
|
||||
|
||||
[dependencies]
|
||||
derive_more = '0.14.0'
|
||||
exit-future = '0.1'
|
||||
futures = '0.1'
|
||||
log = '0.4'
|
||||
derive_more = '0.15.0'
|
||||
exit-future = '0.1.4'
|
||||
futures = '0.1.29'
|
||||
log = '0.4.8'
|
||||
parking_lot = '0.9.0'
|
||||
tokio = '0.1'
|
||||
tokio = '0.1.22'
|
||||
trie-root = '0.15.2'
|
||||
|
||||
[dependencies.babe]
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
package = 'substrate-consensus-babe'
|
||||
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
|
||||
[dependencies.babe-primitives]
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
package = 'substrate-consensus-babe-primitives'
|
||||
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
|
||||
[dependencies.basic-authorship]
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
package = 'substrate-basic-authorship'
|
||||
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
|
||||
[dependencies.codec]
|
||||
package = 'parity-scale-codec'
|
||||
|
@ -36,27 +28,27 @@ version = '1.0.0'
|
|||
|
||||
[dependencies.ctrlc]
|
||||
features = ['termination']
|
||||
version = '3.0'
|
||||
version = '3.1.3'
|
||||
|
||||
[dependencies.grandpa]
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
package = 'substrate-finality-grandpa'
|
||||
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
|
||||
[dependencies.grandpa-primitives]
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
package = 'substrate-finality-grandpa-primitives'
|
||||
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
|
||||
[dependencies.inherents]
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
package = 'substrate-inherents'
|
||||
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
|
||||
[dependencies.network]
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
package = 'substrate-network'
|
||||
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
|
||||
[dependencies.node-template-runtime]
|
||||
path = 'runtime'
|
||||
|
@ -64,32 +56,41 @@ path = 'runtime'
|
|||
[dependencies.primitives]
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
package = 'substrate-primitives'
|
||||
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
|
||||
[dependencies.sr-io]
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
|
||||
[dependencies.substrate-cli]
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
|
||||
[dependencies.substrate-client]
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
|
||||
[dependencies.substrate-executor]
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
|
||||
[dependencies.substrate-service]
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
|
||||
[dependencies.transaction-pool]
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
package = 'substrate-transaction-pool'
|
||||
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
[profile.release]
|
||||
panic = 'unwind'
|
||||
|
||||
[[bin]]
|
||||
name = 'node-template'
|
||||
path = 'src/main.rs'
|
||||
|
||||
[workspace]
|
||||
members = ['runtime']
|
||||
|
||||
[package]
|
||||
authors = ['Anonymous']
|
||||
|
@ -98,6 +99,5 @@ edition = '2018'
|
|||
name = 'node-template'
|
||||
version = '2.0.0'
|
||||
|
||||
[[bin]]
|
||||
name = 'node-template'
|
||||
path = 'src/main.rs'
|
||||
[build-dependencies]
|
||||
vergen = '3.0.4'
|
||||
|
|
|
@ -1,31 +1,26 @@
|
|||
[package]
|
||||
authors = ['Anonymous']
|
||||
edition = '2018'
|
||||
name = 'node-template-runtime'
|
||||
version = '2.0.0'
|
||||
[dependencies.babe]
|
||||
default-features = false
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
package = 'srml-babe'
|
||||
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
|
||||
[dependencies.babe-primitives]
|
||||
default-features = false
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
package = 'substrate-consensus-babe-primitives'
|
||||
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
|
||||
[dependencies.balances]
|
||||
default_features = false
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
package = 'srml-balances'
|
||||
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
|
||||
[dependencies.client]
|
||||
default_features = false
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
package = 'substrate-client'
|
||||
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
|
||||
[dependencies.codec]
|
||||
default-features = false
|
||||
|
@ -37,99 +32,104 @@ version = '1.0.0'
|
|||
default_features = false
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
package = 'srml-executive'
|
||||
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
|
||||
[dependencies.grandpa]
|
||||
default-features = false
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
package = 'srml-grandpa'
|
||||
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
|
||||
[dependencies.indices]
|
||||
default_features = false
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
package = 'srml-indices'
|
||||
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
|
||||
[dependencies.offchain-primitives]
|
||||
default-features = false
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
package = 'substrate-offchain-primitives'
|
||||
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
|
||||
[dependencies.primitives]
|
||||
default_features = false
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
package = 'substrate-primitives'
|
||||
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
|
||||
[dependencies.rstd]
|
||||
default_features = false
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
package = 'sr-std'
|
||||
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
|
||||
[dependencies.runtime-io]
|
||||
default_features = false
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
package = 'sr-io'
|
||||
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
|
||||
[dependencies.safe-mix]
|
||||
default-features = false
|
||||
version = '1.0'
|
||||
version = '1.0.0'
|
||||
|
||||
[dependencies.serde]
|
||||
features = ['derive']
|
||||
optional = true
|
||||
version = '1.0'
|
||||
version = '1.0.101'
|
||||
|
||||
[dependencies.sr-primitives]
|
||||
default_features = false
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
|
||||
[dependencies.substrate-session]
|
||||
default-features = false
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
|
||||
[dependencies.sudo]
|
||||
default_features = false
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
package = 'srml-sudo'
|
||||
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
|
||||
[dependencies.support]
|
||||
default_features = false
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
package = 'srml-support'
|
||||
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
|
||||
[dependencies.system]
|
||||
default_features = false
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
package = 'srml-system'
|
||||
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
|
||||
[dependencies.timestamp]
|
||||
default_features = false
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
package = 'srml-timestamp'
|
||||
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
|
||||
[dependencies.version]
|
||||
default_features = false
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
package = 'sr-version'
|
||||
rev = '3ba0f2a2dbd37c31851a0ff1c1c0c47aa940de90'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
[build-dependencies.wasm-builder-runner]
|
||||
package = 'substrate-wasm-builder-runner'
|
||||
version = '1.0.2'
|
||||
|
||||
[package]
|
||||
authors = ['Anonymous']
|
||||
edition = '2018'
|
||||
name = 'node-template-runtime'
|
||||
version = '2.0.0'
|
||||
|
||||
[features]
|
||||
default = ['std']
|
||||
no_std = []
|
||||
std = [
|
||||
'codec/std',
|
||||
'client/std',
|
||||
|
|
|
@ -19,7 +19,7 @@ use wasm_builder_runner::{build_current_project_with_rustflags, WasmBuilderSourc
|
|||
fn main() {
|
||||
build_current_project_with_rustflags(
|
||||
"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
|
||||
// external memory allocator.
|
||||
"-Clink-arg=--export=__heap_base",
|
||||
|
|
|
@ -14,11 +14,11 @@ use sr_primitives::{
|
|||
ApplyResult, transaction_validity::TransactionValidity, generic, create_runtime_str,
|
||||
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 babe::{AuthorityId as BabeId};
|
||||
use grandpa::{AuthorityId as GrandpaId, AuthorityWeight as GrandpaWeight};
|
||||
use grandpa::fg_primitives::{self, ScheduledChange};
|
||||
use grandpa::fg_primitives;
|
||||
use client::{
|
||||
block_builder::api::{CheckInherentsResult, InherentData, self as block_builder_api},
|
||||
runtime_api as client_api, impl_runtime_apis
|
||||
|
@ -189,6 +189,7 @@ parameter_types! {
|
|||
impl babe::Trait for Runtime {
|
||||
type EpochDuration = EpochDuration;
|
||||
type ExpectedBlockTime = ExpectedBlockTime;
|
||||
type EpochChangeTrigger = babe::SameAuthoritiesForever;
|
||||
}
|
||||
|
||||
impl grandpa::Trait for Runtime {
|
||||
|
@ -208,7 +209,7 @@ impl indices::Trait for Runtime {
|
|||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const MinimumPeriod: u64 = 5000;
|
||||
pub const MinimumPeriod: u64 = SLOT_DURATION / 2;
|
||||
}
|
||||
|
||||
impl timestamp::Trait for Runtime {
|
||||
|
@ -235,7 +236,6 @@ impl balances::Trait for Runtime {
|
|||
type OnNewAccount = Indices;
|
||||
/// The ubiquitous event type.
|
||||
type Event = Event;
|
||||
|
||||
type TransactionPayment = ();
|
||||
type DustRemoval = ();
|
||||
type TransferPayment = ();
|
||||
|
@ -268,7 +268,7 @@ construct_runtime!(
|
|||
Babe: babe::{Module, Call, Storage, Config, Inherent(Timestamp)},
|
||||
Grandpa: grandpa::{Module, Call, Storage, Config, Event},
|
||||
Indices: indices::{default, Config<T>},
|
||||
Balances: balances,
|
||||
Balances: balances::{default, Error},
|
||||
Sudo: sudo,
|
||||
// Used for the module template in `./template.rs`
|
||||
TemplateModule: template::{Module, Call, Storage, Event<T>},
|
||||
|
@ -357,45 +357,25 @@ impl_runtime_apis! {
|
|||
}
|
||||
|
||||
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)> {
|
||||
Grandpa::grandpa_authorities()
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
// probability of a slot being empty), is done in accordance to the
|
||||
// slot duration and expected target block time, for safely
|
||||
// resisting network delays of maximum two seconds.
|
||||
// <https://research.web3.foundation/en/latest/polkadot/BABE/Babe/#6-practical-results>
|
||||
babe_primitives::BabeConfiguration {
|
||||
median_required_blocks: 1000,
|
||||
slot_duration: Babe::slot_duration(),
|
||||
epoch_length: EpochDuration::get(),
|
||||
c: PRIMARY_PROBABILITY,
|
||||
}
|
||||
}
|
||||
|
||||
fn epoch() -> babe_primitives::Epoch {
|
||||
babe_primitives::Epoch {
|
||||
start_slot: Babe::epoch_start_slot(),
|
||||
authorities: Babe::authorities(),
|
||||
epoch_index: Babe::epoch_index(),
|
||||
genesis_authorities: Babe::authorities(),
|
||||
randomness: Babe::randomness(),
|
||||
duration: EpochDuration::get(),
|
||||
secondary_slots: Babe::secondary_slots().0,
|
||||
secondary_slots: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
/// For more guidance on Substrate modules, see the example module
|
||||
/// 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;
|
||||
|
||||
/// The module's configuration trait.
|
||||
|
|
13
src/cli.rs
13
src/cli.rs
|
@ -4,7 +4,7 @@ use std::cell::RefCell;
|
|||
use tokio::runtime::Runtime;
|
||||
pub use substrate_cli::{VersionInfo, IntoExit, error};
|
||||
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 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,
|
||||
E: IntoExit,
|
||||
{
|
||||
type Config<T> = Configuration<(), T>;
|
||||
match parse_and_prepare::<NoCustom, NoCustom, _>(&version, "substrate-node", args) {
|
||||
ParseAndPrepare::Run(cmd) => cmd.run::<(), _, _, _, _>(load_spec, exit,
|
||||
|exit, _cli_args, _custom_args, config| {
|
||||
ParseAndPrepare::Run(cmd) => cmd.run(load_spec, exit,
|
||||
|exit, _cli_args, _custom_args, config: Config<_>| {
|
||||
info!("{}", version.name);
|
||||
info!(" version {}", config.full_version());
|
||||
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))
|
||||
}),
|
||||
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),
|
||||
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),
|
||||
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),
|
||||
ParseAndPrepare::CustomCommand(_) => Ok(())
|
||||
}?;
|
||||
|
|
132
src/service.rs
132
src/service.rs
|
@ -3,10 +3,10 @@
|
|||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
use substrate_client::LongestChain;
|
||||
use babe::{import_queue, start_babe, Config};
|
||||
use babe;
|
||||
use grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider};
|
||||
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 transaction_pool::{self, txpool::{Pool as TransactionPool}};
|
||||
use inherents::InherentDataProviders;
|
||||
|
@ -18,7 +18,7 @@ pub use substrate_executor::NativeExecutor;
|
|||
native_executor_instance!(
|
||||
pub Executor,
|
||||
node_template_runtime::api::dispatch,
|
||||
node_template_runtime::native_version
|
||||
node_template_runtime::native_version,
|
||||
);
|
||||
|
||||
construct_simple_protocol! {
|
||||
|
@ -34,45 +34,48 @@ macro_rules! new_full_start {
|
|||
($config:expr) => {{
|
||||
let mut import_setup = None;
|
||||
let inherent_data_providers = inherents::InherentDataProviders::new();
|
||||
let mut tasks_to_spawn = None;
|
||||
|
||||
let builder = substrate_service::ServiceBuilder::new_full::<
|
||||
node_template_runtime::opaque::Block, node_template_runtime::RuntimeApi, crate::service::Executor
|
||||
>($config)?
|
||||
.with_select_chain(|_config, client| {
|
||||
#[allow(deprecated)]
|
||||
Ok(substrate_client::LongestChain::new(client.backend().clone()))
|
||||
.with_select_chain(|_config, backend| {
|
||||
Ok(substrate_client::LongestChain::new(backend.clone()))
|
||||
})?
|
||||
.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()
|
||||
.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, _, _>(
|
||||
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)?,
|
||||
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)),
|
||||
None,
|
||||
client.clone(),
|
||||
client,
|
||||
inherent_data_providers.clone(),
|
||||
Some(transaction_pool)
|
||||
)?;
|
||||
|
||||
import_setup = Some((babe_block_import.clone(), link_half, babe_link));
|
||||
tasks_to_spawn = Some(vec![Box::new(pruning_task)]);
|
||||
import_setup = Some((babe_block_import, grandpa_link, babe_link));
|
||||
|
||||
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>
|
||||
{
|
||||
|
||||
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()))?
|
||||
.with_finality_proof_provider(|client|
|
||||
Ok(Arc::new(GrandpaFinalityProofProvider::new(client.clone(), client)) as _)
|
||||
.with_finality_proof_provider(|client, backend|
|
||||
Ok(Arc::new(GrandpaFinalityProofProvider::new(backend, client)) as _)
|
||||
)?
|
||||
.build()?;
|
||||
|
||||
let (block_import, link_half, babe_link) =
|
||||
let (block_import, grandpa_link, babe_link) =
|
||||
import_setup.take()
|
||||
.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 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() {
|
||||
if is_authority {
|
||||
let proposer = basic_authorship::ProposerFactory {
|
||||
client: service.client(),
|
||||
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)?;
|
||||
|
||||
let babe_config = babe::BabeParams {
|
||||
config: Config::get_or_compute(&*client)?,
|
||||
keystore: service.keystore(),
|
||||
client,
|
||||
select_chain,
|
||||
block_import,
|
||||
env: proposer,
|
||||
block_import,
|
||||
sync_oracle: service.network(),
|
||||
inherent_data_providers: inherent_data_providers.clone(),
|
||||
force_authoring: service.config().force_authoring,
|
||||
time_source: babe_link,
|
||||
force_authoring,
|
||||
babe_link,
|
||||
};
|
||||
|
||||
let babe = start_babe(babe_config)?;
|
||||
let babe = babe::start_babe(babe_config)?;
|
||||
let select = babe.select(service.on_exit()).then(|_| Ok(()));
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
let config = grandpa::Config {
|
||||
let grandpa_config = grandpa::Config {
|
||||
// FIXME #1578 make this available through chainspec
|
||||
gossip_duration: Duration::from_millis(333),
|
||||
justification_period: 4096,
|
||||
name: Some(service.config().name.clone()),
|
||||
justification_period: 512,
|
||||
name: Some(name),
|
||||
keystore: Some(service.keystore()),
|
||||
};
|
||||
|
||||
match (service.config().roles.is_authority(), service.config().disable_grandpa) {
|
||||
match (is_authority, disable_grandpa) {
|
||||
(false, false) => {
|
||||
// start the lightweight GRANDPA observer
|
||||
service.spawn_task(Box::new(grandpa::run_grandpa_observer(
|
||||
config,
|
||||
link_half,
|
||||
grandpa_config,
|
||||
grandpa_link,
|
||||
service.network(),
|
||||
service.on_exit(),
|
||||
)?));
|
||||
},
|
||||
(true, false) => {
|
||||
// start the full GRANDPA voter
|
||||
let grandpa_config = grandpa::GrandpaParams {
|
||||
config: config,
|
||||
link: link_half,
|
||||
let voter_config = grandpa::GrandpaParams {
|
||||
config: grandpa_config,
|
||||
link: grandpa_link,
|
||||
network: service.network(),
|
||||
inherent_data_providers: inherent_data_providers.clone(),
|
||||
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.
|
||||
// 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) => {
|
||||
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();
|
||||
|
||||
ServiceBuilder::new_light::<Block, RuntimeApi, Executor>(config)?
|
||||
.with_select_chain(|_config, client| {
|
||||
#[allow(deprecated)]
|
||||
Ok(LongestChain::new(client.backend().clone()))
|
||||
.with_select_chain(|_config, backend| {
|
||||
Ok(LongestChain::new(backend.clone()))
|
||||
})?
|
||||
.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| {
|
||||
#[allow(deprecated)]
|
||||
let fetch_checker = client.backend().blockchain().fetcher()
|
||||
.upgrade()
|
||||
.with_import_queue_and_fprb(|_config, client, backend, fetcher, _select_chain, _tx_pool| {
|
||||
let fetch_checker = fetcher
|
||||
.map(|fetcher| fetcher.checker().clone())
|
||||
.ok_or_else(|| "Trying to start light import queue without active fetch checker")?;
|
||||
let block_import = grandpa::light_block_import::<_, _, _, RuntimeApi, _>(
|
||||
client.clone(), Arc::new(fetch_checker), client.clone()
|
||||
let grandpa_block_import = grandpa::light_block_import::<_, _, _, RuntimeApi, _>(
|
||||
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 =
|
||||
finality_proof_import.create_finality_proof_request_builder();
|
||||
|
||||
// FIXME: pruning task isn't started since light client doesn't do `AuthoritySetup`.
|
||||
let (import_queue, ..) = import_queue(
|
||||
Config::get_or_compute(&*client)?,
|
||||
block_import,
|
||||
let (babe_block_import, babe_link) = babe::block_import(
|
||||
babe::Config::get_or_compute(&*client)?,
|
||||
grandpa_block_import,
|
||||
client.clone(),
|
||||
client.clone(),
|
||||
)?;
|
||||
|
||||
let import_queue = babe::import_queue(
|
||||
babe_link.clone(),
|
||||
babe_block_import,
|
||||
None,
|
||||
Some(Box::new(finality_proof_import)),
|
||||
client.clone(),
|
||||
client,
|
||||
inherent_data_providers.clone(),
|
||||
Some(transaction_pool)
|
||||
)?;
|
||||
|
||||
Ok((import_queue, finality_proof_request_builder))
|
||||
})?
|
||||
.with_network_protocol(|_| Ok(NodeProtocol::new()))?
|
||||
.with_finality_proof_provider(|client|
|
||||
Ok(Arc::new(GrandpaFinalityProofProvider::new(client.clone(), client)) as _)
|
||||
.with_finality_proof_provider(|client, backend|
|
||||
Ok(Arc::new(GrandpaFinalityProofProvider::new(backend, client)) as _)
|
||||
)?
|
||||
.build()
|
||||
}
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue