From f03a05377056a79102287e0d2059698c9283f208 Mon Sep 17 00:00:00 2001 From: David Craven Date: Sun, 23 Aug 2020 13:21:50 +0200 Subject: [PATCH 1/2] Update to rc6. --- Cargo.toml | 30 ++--- client/Cargo.toml | 12 +- client/src/lib.rs | 7 +- proc-macro/Cargo.toml | 10 +- test-node/Cargo.toml | 42 +++--- test-node/runtime/Cargo.toml | 66 +++++----- test-node/runtime/build.rs | 2 +- test-node/runtime/src/lib.rs | 56 ++++---- test-node/src/chain_spec.rs | 10 +- test-node/src/command.rs | 20 ++- test-node/src/service.rs | 249 ++++++++++++++++++----------------- 11 files changed, 255 insertions(+), 249 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ea222904f8..f86ab4e8ac 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,30 +25,30 @@ thiserror = "1.0.20" futures = "0.3.5" jsonrpsee = { version = "0.1.0", features = ["ws"] } num-traits = { version = "0.2.12", default-features = false } -serde = { version = "1.0.114", features = ["derive"] } -serde_json = "1.0.56" +serde = { version = "1.0.115", features = ["derive"] } +serde_json = "1.0.57" url = "2.1.1" codec = { package = "parity-scale-codec", version = "1.3.4", default-features = false, features = ["derive", "full"] } -frame-metadata = { version = "11.0.0-rc5", package = "frame-metadata" } -frame-support = { version = "2.0.0-rc5", package = "frame-support" } -sp-runtime = { version = "2.0.0-rc5", package = "sp-runtime" } -sp-version = { version = "2.0.0-rc5", package = "sp-version" } -pallet-indices = { version = "2.0.0-rc5", package = "pallet-indices" } +frame-metadata = { version = "11.0.0-rc6", package = "frame-metadata" } +frame-support = { version = "2.0.0-rc6", package = "frame-support" } +sp-runtime = { version = "2.0.0-rc6", package = "sp-runtime" } +sp-version = { version = "2.0.0-rc6", package = "sp-version" } +pallet-indices = { version = "2.0.0-rc6", package = "pallet-indices" } hex = "0.4.2" -sp-rpc = { version = "2.0.0-rc5", package = "sp-rpc" } -sp-core = { version = "2.0.0-rc5", package = "sp-core" } -sc-rpc-api = { version = "0.8.0-rc5", package = "sc-rpc-api" } -sp-transaction-pool = { version = "2.0.0-rc5", package = "sp-transaction-pool" } +sp-rpc = { version = "2.0.0-rc6", package = "sp-rpc" } +sp-core = { version = "2.0.0-rc6", package = "sp-core" } +sc-rpc-api = { version = "0.8.0-rc6", package = "sc-rpc-api" } +sp-transaction-pool = { version = "2.0.0-rc6", package = "sp-transaction-pool" } substrate-subxt-client = { version = "0.3.0", path = "client", optional = true } substrate-subxt-proc-macro = { version = "0.11.0", path = "proc-macro" } [dev-dependencies] -async-std = { version = "1.6.2", features = ["attributes"] } +async-std = { version = "1.6.3", features = ["attributes"] } env_logger = "0.7.1" -frame-system = { version = "2.0.0-rc5", package = "frame-system" } -pallet-balances = { version = "2.0.0-rc5", package = "pallet-balances" } -sp-keyring = { version = "2.0.0-rc5", package = "sp-keyring" } +frame-system = { version = "2.0.0-rc6", package = "frame-system" } +pallet-balances = { version = "2.0.0-rc6", package = "pallet-balances" } +sp-keyring = { version = "2.0.0-rc6", package = "sp-keyring" } substrate-subxt-client = { version = "0.3.0", path = "client" } tempdir = "0.3.7" test-node = { path = "test-node" } diff --git a/client/Cargo.toml b/client/Cargo.toml index a9a31bab3d..8bd0a919f5 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -12,19 +12,19 @@ description = "Embed a substrate node into your subxt application." keywords = ["parity", "substrate", "blockchain"] [dependencies] -async-std = "1.6.2" +async-std = "1.6.3" futures = { version = "0.3.5", features = ["compat"] } futures01 = { package = "futures", version = "0.1.29" } jsonrpsee = "0.1.0" log = "0.4.11" -sc-network = { version = "0.8.0-rc5", default-features = false } -sc-service = { version = "0.8.0-rc5", default-features = false } -serde_json = "1.0.56" -sp-keyring = "2.0.0-rc5" +sc-network = { version = "0.8.0-rc6", default-features = false } +sc-service = { version = "0.8.0-rc6", default-features = false } +serde_json = "1.0.57" +sp-keyring = "2.0.0-rc6" thiserror = "1.0.20" [dev-dependencies] -async-std = { version = "1.6.2", features = ["attributes"] } +async-std = { version = "1.6.3", features = ["attributes"] } env_logger = "0.7.1" substrate-subxt = { path = ".." } tempdir = "0.3.7" diff --git a/client/src/lib.rs b/client/src/lib.rs index 2dabb6aee2..6420086f52 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -64,7 +64,6 @@ use sc_service::{ use std::{ future::Future, pin::Pin, - sync::Arc, }; use thiserror::Error; @@ -87,7 +86,7 @@ pub struct SubxtClient { impl SubxtClient { /// Create a new client. - pub fn new(mut task_manager: TaskManager, rpc: Arc) -> Self { + pub fn new(mut task_manager: TaskManager, rpc: RpcHandlers) -> Self { let (to_back, from_front) = mpsc::channel(4); let (to_front, from_back) = mpsc01::channel(4); @@ -122,9 +121,7 @@ impl SubxtClient { /// Creates a new client from a config. pub fn from_config( config: SubxtClientConfig, - builder: impl Fn( - Configuration, - ) -> Result<(TaskManager, Arc), ServiceError>, + builder: impl Fn(Configuration) -> Result<(TaskManager, RpcHandlers), ServiceError>, ) -> Result { let config = config.to_service_config(); let (task_manager, rpc_handlers) = (builder)(config)?; diff --git a/proc-macro/Cargo.toml b/proc-macro/Cargo.toml index 844920f0cf..0a112230f2 100644 --- a/proc-macro/Cargo.toml +++ b/proc-macro/Cargo.toml @@ -18,19 +18,19 @@ proc-macro = true heck = "0.3.1" proc-macro2 = "1.0.19" proc-macro-crate = "0.1.5" -proc-macro-error = "1.0.3" +proc-macro-error = "1.0.4" quote = "1.0.7" -syn = "1.0.35" +syn = "1.0.38" synstructure = "0.12.4" [dev-dependencies] -async-std = { version = "1.6.2", features = ["attributes"] } +async-std = { version = "1.6.3", features = ["attributes"] } codec = { package = "parity-scale-codec", version = "1.3.4", features = ["derive"] } env_logger = "0.7.1" pretty_assertions = "0.6.1" -sp-keyring = "2.0.0-rc5" +sp-keyring = "2.0.0-rc6" substrate-subxt = { path = ".." } -trybuild = "1.0.30" +trybuild = "1.0.32" [[test]] name = "balances" diff --git a/test-node/Cargo.toml b/test-node/Cargo.toml index 82a9c9a20f..5b25fd25a4 100644 --- a/test-node/Cargo.toml +++ b/test-node/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "test-node" -version = "2.0.0-rc5" +version = "2.0.0" authors = ["Anonymous"] description = "Substrate Node template" edition = "2018" @@ -15,28 +15,28 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] futures = "0.3.5" log = "0.4.11" -structopt = "0.3.15" +structopt = "0.3.16" parking_lot = "0.11.0" -sc-cli = { version = "0.8.0-rc5", features = ["wasmtime"] } -sp-core = "2.0.0-rc5" -sc-executor = { version = "0.8.0-rc5", features = ["wasmtime"] } -sc-service = { version = "0.8.0-rc5", features = ["wasmtime"] } -sp-inherents = "2.0.0-rc5" -sc-transaction-pool = "2.0.0-rc5" -sp-transaction-pool = "2.0.0-rc5" -sc-network = "0.8.0-rc5" -sc-consensus-aura = "0.8.0-rc5" -sp-consensus-aura = "0.8.0-rc5" -sp-consensus = "0.8.0-rc5" -sc-consensus = "0.8.0-rc5" -sc-finality-grandpa = "0.8.0-rc5" -sp-finality-grandpa = "2.0.0-rc5" -sc-client-api = "2.0.0-rc5" -sp-runtime = "2.0.0-rc5" -sc-basic-authorship = "0.8.0-rc5" +sc-cli = { version = "0.8.0-rc6", features = ["wasmtime"] } +sp-core = "2.0.0-rc6" +sc-executor = { version = "0.8.0-rc6", features = ["wasmtime"] } +sc-service = { version = "0.8.0-rc6", features = ["wasmtime"] } +sp-inherents = "2.0.0-rc6" +sc-transaction-pool = "2.0.0-rc6" +sp-transaction-pool = "2.0.0-rc6" +sc-network = "0.8.0-rc6" +sc-consensus-aura = "0.8.0-rc6" +sp-consensus-aura = "0.8.0-rc6" +sp-consensus = "0.8.0-rc6" +sc-consensus = "0.8.0-rc6" +sc-finality-grandpa = "0.8.0-rc6" +sp-finality-grandpa = "2.0.0-rc6" +sc-client-api = "2.0.0-rc6" +sp-runtime = "2.0.0-rc6" +sc-basic-authorship = "0.8.0-rc6" -test-node-runtime = { version = "2.0.0-rc5", path = "runtime" } +test-node-runtime = { path = "runtime" } [build-dependencies] -substrate-build-script-utils = "2.0.0-rc5" +substrate-build-script-utils = "2.0.0-rc6" diff --git a/test-node/runtime/Cargo.toml b/test-node/runtime/Cargo.toml index 2a27d3ea3a..85463292cc 100644 --- a/test-node/runtime/Cargo.toml +++ b/test-node/runtime/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "test-node-runtime" -version = "2.0.0-rc5" +version = "2.0.0" authors = ["Anonymous"] edition = "2018" license = "Unlicense" @@ -13,43 +13,47 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { package = "parity-scale-codec", version = "1.3.4", default-features = false, features = ["derive"] } -aura = { version = "2.0.0-rc5", default-features = false, package = "pallet-aura" } -balances = { version = "2.0.0-rc5", default-features = false, package = "pallet-balances" } -frame-support = { version = "2.0.0-rc5", default-features = false } -grandpa = { version = "2.0.0-rc5", default-features = false, package = "pallet-grandpa" } -randomness-collective-flip = { version = "2.0.0-rc5", default-features = false, package = "pallet-randomness-collective-flip" } -sudo = { version = "2.0.0-rc5", default-features = false, package = "pallet-sudo" } -system = { version = "2.0.0-rc5", default-features = false, package = "frame-system" } -timestamp = { version = "2.0.0-rc5", default-features = false, package = "pallet-timestamp" } -transaction-payment = { version = "2.0.0-rc5", default-features = false, package = "pallet-transaction-payment" } -frame-executive = { version = "2.0.0-rc5", default-features = false } -serde = { version = "1.0.114", optional = true, features = ["derive"] } -sp-api = { version = "2.0.0-rc5", default-features = false } -sp-block-builder = { version = "2.0.0-rc5", default-features = false } -sp-consensus-aura = { version = "0.8.0-rc5", default-features = false } -sp-core = { version = "2.0.0-rc5", default-features = false } -sp-inherents = { version = "2.0.0-rc5", default-features = false } -sp-io = { version = "2.0.0-rc5", default-features = false } -sp-offchain = { version = "2.0.0-rc5", default-features = false } -sp-runtime = { version = "2.0.0-rc5", default-features = false } -sp-session = { version = "2.0.0-rc5", default-features = false } -sp-std = { version = "2.0.0-rc5", default-features = false } -sp-transaction-pool = { version = "2.0.0-rc5", default-features = false } -sp-version = { version = "2.0.0-rc5", default-features = false } +frame-executive = { version = "2.0.0-rc6", default-features = false } +frame-support = { version = "2.0.0-rc6", default-features = false } +frame-system = { version = "2.0.0-rc6", default-features = false } +pallet-aura = { version = "2.0.0-rc6", default-features = false } +pallet-balances = { version = "2.0.0-rc6", default-features = false } +pallet-grandpa = { version = "2.0.0-rc6", default-features = false } +pallet-randomness-collective-flip = { version = "2.0.0-rc6", default-features = false } +pallet-sudo = { version = "2.0.0-rc6", default-features = false } +pallet-timestamp = { version = "2.0.0-rc6", default-features = false } +pallet-transaction-payment = { version = "2.0.0-rc6", default-features = false } +serde = { version = "1.0.115", optional = true, features = ["derive"] } +sp-api = { version = "2.0.0-rc6", default-features = false } +sp-block-builder = { version = "2.0.0-rc6", default-features = false } +sp-consensus-aura = { version = "0.8.0-rc6", default-features = false } +sp-core = { version = "2.0.0-rc6", default-features = false } +sp-inherents = { version = "2.0.0-rc6", default-features = false } +sp-io = { version = "2.0.0-rc6", default-features = false } +sp-offchain = { version = "2.0.0-rc6", default-features = false } +sp-runtime = { version = "2.0.0-rc6", default-features = false } +sp-session = { version = "2.0.0-rc6", default-features = false } +sp-std = { version = "2.0.0-rc6", default-features = false } +sp-transaction-pool = { version = "2.0.0-rc6", default-features = false } +sp-version = { version = "2.0.0-rc6", default-features = false } [build-dependencies] -wasm-builder-runner = { version = "1.0.5", package = "substrate-wasm-builder-runner" } +substrate-wasm-builder-runner = "1.0.6" [features] default = ["std"] std = [ - "aura/std", - "balances/std", "codec/std", "frame-executive/std", "frame-support/std", - "grandpa/std", - "randomness-collective-flip/std", + "frame-system/std", + "pallet-aura/std", + "pallet-balances/std", + "pallet-grandpa/std", + "pallet-randomness-collective-flip/std", + "pallet-sudo/std", + "pallet-timestamp/std", + "pallet-transaction-payment/std", "serde", "sp-api/std", "sp-block-builder/std", @@ -63,8 +67,4 @@ std = [ "sp-std/std", "sp-transaction-pool/std", "sp-version/std", - "sudo/std", - "system/std", - "timestamp/std", - "transaction-payment/std", ] diff --git a/test-node/runtime/build.rs b/test-node/runtime/build.rs index 8dfb883c04..2ab31cf6cd 100644 --- a/test-node/runtime/build.rs +++ b/test-node/runtime/build.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with substrate-subxt. If not, see . -use wasm_builder_runner::WasmBuilder; +use substrate_wasm_builder_runner::WasmBuilder; fn main() { WasmBuilder::new() diff --git a/test-node/runtime/src/lib.rs b/test-node/runtime/src/lib.rs index 66f9c1bd52..146b0ebcca 100644 --- a/test-node/runtime/src/lib.rs +++ b/test-node/runtime/src/lib.rs @@ -24,7 +24,7 @@ #[cfg(feature = "std")] include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); -use grandpa::{ +use pallet_grandpa::{ fg_primitives, AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList, @@ -61,7 +61,6 @@ use sp_version::NativeVersion; use sp_version::RuntimeVersion; // A few exports that help ease life for downstream crates. -pub use balances::Call as BalancesCall; pub use frame_support::{ construct_runtime, parameter_types, @@ -81,13 +80,14 @@ pub use frame_support::{ }, StorageValue, }; +pub use pallet_balances::Call as BalancesCall; +pub use pallet_timestamp::Call as TimestampCall; #[cfg(any(feature = "std", test))] pub use sp_runtime::BuildStorage; pub use sp_runtime::{ Perbill, Permill, }; -pub use timestamp::Call as TimestampCall; /// An index to a block. pub type BlockNumber = u32; @@ -180,7 +180,7 @@ parameter_types! { pub const Version: RuntimeVersion = VERSION; } -impl system::Trait for Runtime { +impl frame_system::Trait for Runtime { /// The basic call filter to use in dispatchable. type BaseCallFilter = (); /// The identifier used to distinguish between accounts. @@ -234,16 +234,16 @@ impl system::Trait for Runtime { /// What to do if an account is fully reaped from the system. type OnKilledAccount = (); /// The data to be stored in an account. - type AccountData = balances::AccountData; + type AccountData = pallet_balances::AccountData; /// Weight information for the extrinsics of this pallet. type SystemWeightInfo = (); } -impl aura::Trait for Runtime { +impl pallet_aura::Trait for Runtime { type AuthorityId = AuraId; } -impl grandpa::Trait for Runtime { +impl pallet_grandpa::Trait for Runtime { type Event = Event; type Call = Call; @@ -264,7 +264,7 @@ parameter_types! { pub const MinimumPeriod: u64 = SLOT_DURATION / 2; } -impl timestamp::Trait for Runtime { +impl pallet_timestamp::Trait for Runtime { /// A timestamp: milliseconds since the unix epoch. type Moment = u64; type OnTimestampSet = Aura; @@ -276,7 +276,7 @@ parameter_types! { pub const ExistentialDeposit: u128 = 500; } -impl balances::Trait for Runtime { +impl pallet_balances::Trait for Runtime { /// The type for recording an account's balance. type Balance = Balance; /// The ubiquitous event type. @@ -291,15 +291,15 @@ parameter_types! { pub const TransactionByteFee: Balance = 1; } -impl transaction_payment::Trait for Runtime { - type Currency = balances::Module; +impl pallet_transaction_payment::Trait for Runtime { + type Currency = pallet_balances::Module; type OnTransactionPayment = (); type TransactionByteFee = TransactionByteFee; type WeightToFee = IdentityFee; type FeeMultiplierUpdate = (); } -impl sudo::Trait for Runtime { +impl pallet_sudo::Trait for Runtime { type Event = Event; type Call = Call; } @@ -310,14 +310,14 @@ construct_runtime!( NodeBlock = opaque::Block, UncheckedExtrinsic = UncheckedExtrinsic { - System: system::{Module, Call, Config, Storage, Event}, - RandomnessCollectiveFlip: randomness_collective_flip::{Module, Call, Storage}, - Timestamp: timestamp::{Module, Call, Storage, Inherent}, - Aura: aura::{Module, Config, Inherent}, - Grandpa: grandpa::{Module, Call, Storage, Config, Event}, - Balances: balances::{Module, Call, Storage, Config, Event}, - TransactionPayment: transaction_payment::{Module, Storage}, - Sudo: sudo::{Module, Call, Config, Storage, Event}, + System: frame_system::{Module, Call, Config, Storage, Event}, + RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage}, + Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent}, + Aura: pallet_aura::{Module, Config, Inherent}, + Grandpa: pallet_grandpa::{Module, Call, Storage, Config, Event}, + Balances: pallet_balances::{Module, Call, Storage, Config, Event}, + TransactionPayment: pallet_transaction_payment::{Module, Storage}, + Sudo: pallet_sudo::{Module, Call, Config, Storage, Event}, } ); @@ -333,13 +333,13 @@ pub type SignedBlock = generic::SignedBlock; pub type BlockId = generic::BlockId; /// The SignedExtension to the basic transaction logic. pub type SignedExtra = ( - system::CheckSpecVersion, - system::CheckTxVersion, - system::CheckGenesis, - system::CheckEra, - system::CheckNonce, - system::CheckWeight, - transaction_payment::ChargeTransactionPayment, + frame_system::CheckSpecVersion, + frame_system::CheckTxVersion, + frame_system::CheckGenesis, + frame_system::CheckEra, + frame_system::CheckNonce, + frame_system::CheckWeight, + pallet_transaction_payment::ChargeTransactionPayment, ); /// Unchecked extrinsic type as expected by this runtime. pub type UncheckedExtrinsic = @@ -350,7 +350,7 @@ pub type CheckedExtrinsic = generic::CheckedExtrinsic, + frame_system::ChainContext, Runtime, AllModules, >; diff --git a/test-node/src/chain_spec.rs b/test-node/src/chain_spec.rs index c1e028f39b..a9cc64e42d 100644 --- a/test-node/src/chain_spec.rs +++ b/test-node/src/chain_spec.rs @@ -164,12 +164,12 @@ fn testnet_genesis( _enable_println: bool, ) -> GenesisConfig { GenesisConfig { - system: Some(SystemConfig { + frame_system: Some(SystemConfig { // Add Wasm runtime to storage. code: wasm_binary.to_vec(), changes_trie_config: Default::default(), }), - balances: Some(BalancesConfig { + pallet_balances: Some(BalancesConfig { // Configure endowed accounts with initial balance of 1 << 60. balances: endowed_accounts .iter() @@ -177,16 +177,16 @@ fn testnet_genesis( .map(|k| (k, 1 << 60)) .collect(), }), - aura: Some(AuraConfig { + pallet_aura: Some(AuraConfig { authorities: initial_authorities.iter().map(|x| (x.0.clone())).collect(), }), - grandpa: Some(GrandpaConfig { + pallet_grandpa: Some(GrandpaConfig { authorities: initial_authorities .iter() .map(|x| (x.1.clone(), 1)) .collect(), }), - sudo: Some(SudoConfig { + pallet_sudo: Some(SudoConfig { // Assign network admin rights. key: root_key, }), diff --git a/test-node/src/command.rs b/test-node/src/command.rs index c8196d2291..f4d7e82fd9 100644 --- a/test-node/src/command.rs +++ b/test-node/src/command.rs @@ -18,7 +18,6 @@ use crate::{ chain_spec, cli::Cli, service, - service::new_full_params, }; use sc_cli::{ ChainSpec, @@ -26,7 +25,7 @@ use sc_cli::{ RuntimeVersion, SubstrateCli, }; -use sc_service::ServiceParams; +use sc_service::PartialComponents; impl SubstrateCli for Cli { fn impl_name() -> String { @@ -78,16 +77,13 @@ pub fn run() -> sc_cli::Result<()> { Some(subcommand) => { let runner = cli.create_runner(subcommand)?; runner.run_subcommand(subcommand, |config| { - let ( - ServiceParams { - client, - backend, - task_manager, - import_queue, - .. - }, - .., - ) = new_full_params(config)?; + let PartialComponents { + client, + backend, + task_manager, + import_queue, + .. + } = service::new_partial(&config)?; Ok((client, backend, import_queue, task_manager)) }) } diff --git a/test-node/src/service.rs b/test-node/src/service.rs index 601d19fdc1..0bb9ce1b77 100644 --- a/test-node/src/service.rs +++ b/test-node/src/service.rs @@ -25,13 +25,12 @@ pub use sc_executor::NativeExecutor; use sc_finality_grandpa::{ FinalityProofProvider as GrandpaFinalityProofProvider, SharedVoterState, - StorageAndProofProvider, }; use sc_service::{ error::Error as ServiceError, Configuration, + PartialComponents, RpcHandlers, - ServiceComponents, TaskManager, }; use sp_consensus_aura::sr25519::AuthorityPair as AuraPair; @@ -57,28 +56,25 @@ type FullClient = sc_service::TFullClient; type FullBackend = sc_service::TFullBackend; type FullSelectChain = sc_consensus::LongestChain; -pub fn new_full_params( - config: Configuration, +pub fn new_partial( + config: &Configuration, ) -> Result< - ( - sc_service::ServiceParams< - Block, - FullClient, - sc_consensus_aura::AuraImportQueue, - sc_transaction_pool::FullPool, - (), - FullBackend, - >, + sc_service::PartialComponents< + FullClient, + FullBackend, FullSelectChain, - sp_inherents::InherentDataProviders, - sc_finality_grandpa::GrandpaBlockImport< - FullBackend, - Block, - FullClient, - FullSelectChain, - >, - sc_finality_grandpa::LinkHalf, - ), + sp_consensus::DefaultImportQueue, + sc_transaction_pool::FullPool, + ( + sc_finality_grandpa::GrandpaBlockImport< + FullBackend, + Block, + FullClient, + FullSelectChain, + >, + sc_finality_grandpa::LinkHalf, + ), + >, ServiceError, > { let inherent_data_providers = sp_inherents::InherentDataProviders::new(); @@ -89,13 +85,8 @@ pub fn new_full_params( let select_chain = sc_consensus::LongestChain::new(backend.clone()); - let pool_api = sc_transaction_pool::FullChainApi::new( - client.clone(), - config.prometheus_registry(), - ); let transaction_pool = sc_transaction_pool::BasicPool::new_full( config.transaction_pool.clone(), - std::sync::Arc::new(pool_api), config.prometheus_registry(), task_manager.spawn_handle(), client.clone(), @@ -112,7 +103,7 @@ pub fn new_full_params( client.clone(), ); - let import_queue = sc_consensus_aura::import_queue::<_, _, _, AuraPair, _>( + let import_queue = sc_consensus_aura::import_queue::<_, _, _, AuraPair, _, _>( sc_consensus_aura::slot_duration(&*client)?, aura_block_import, Some(Box::new(grandpa_block_import.clone())), @@ -121,81 +112,86 @@ pub fn new_full_params( inherent_data_providers.clone(), &task_manager.spawn_handle(), config.prometheus_registry(), + sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone()), )?; - let provider = client.clone() as Arc>; - let finality_proof_provider = - Arc::new(GrandpaFinalityProofProvider::new(backend.clone(), provider)); - - let params = sc_service::ServiceParams { - backend, + Ok(sc_service::PartialComponents { client, + backend, + task_manager, import_queue, keystore, - task_manager, - transaction_pool, - config, - block_announce_validator_builder: None, - finality_proof_request_builder: None, - finality_proof_provider: Some(finality_proof_provider), - on_demand: None, - remote_blockchain: None, - rpc_extensions_builder: Box::new(|_| ()), - }; - - Ok(( - params, select_chain, + transaction_pool, inherent_data_providers, - grandpa_block_import, - grandpa_link, - )) + other: (grandpa_block_import, grandpa_link), + }) } /// Builds a new service for a full client. pub fn new_full( config: Configuration, -) -> Result<(TaskManager, Arc), ServiceError> { - let (params, select_chain, inherent_data_providers, block_import, grandpa_link) = - new_full_params(config)?; - - let ( - role, - force_authoring, - name, - enable_grandpa, - prometheus_registry, +) -> Result<(TaskManager, RpcHandlers), ServiceError> { + let PartialComponents { client, - transaction_pool, + backend, + mut task_manager, + import_queue, keystore, - ) = { - let sc_service::ServiceParams { - config, - client, - transaction_pool, - keystore, - .. - } = ¶ms; + select_chain, + transaction_pool, + inherent_data_providers, + other: (block_import, grandpa_link), + } = new_partial(&config)?; - ( - config.role.clone(), - config.force_authoring, - config.network.node_name.clone(), - !config.disable_grandpa, - config.prometheus_registry().cloned(), + let finality_proof_provider = + GrandpaFinalityProofProvider::new_for_service(backend.clone(), client.clone()); + + let (network, network_status_sinks, system_rpc_tx, network_starter) = + sc_service::build_network(sc_service::BuildNetworkParams { + config: &config, + client: client.clone(), + transaction_pool: transaction_pool.clone(), + spawn_handle: task_manager.spawn_handle(), + import_queue, + on_demand: None, + block_announce_validator_builder: None, + finality_proof_request_builder: None, + finality_proof_provider: Some(finality_proof_provider.clone()), + })?; + + if config.offchain_worker.enabled { + sc_service::build_offchain_workers( + &config, + backend.clone(), + task_manager.spawn_handle(), client.clone(), - transaction_pool.clone(), - keystore.clone(), - ) - }; + network.clone(), + ); + } - let ServiceComponents { - task_manager, - rpc_handlers, - network, - telemetry_on_connect_sinks, - .. - } = sc_service::build(params)?; + let role = config.role.clone(); + let force_authoring = config.force_authoring; + let name = config.network.node_name.clone(); + let enable_grandpa = !config.disable_grandpa; + let prometheus_registry = config.prometheus_registry().cloned(); + let telemetry_connection_sinks = sc_service::TelemetryConnectionSinks::default(); + + let rpc_handlers = sc_service::spawn_tasks(sc_service::SpawnTasksParams { + network: network.clone(), + client: client.clone(), + keystore: keystore.clone(), + task_manager: &mut task_manager, + transaction_pool: transaction_pool.clone(), + telemetry_connection_sinks: telemetry_connection_sinks.clone(), + rpc_extensions_builder: Box::new(|_, _| ()), + on_demand: None, + remote_blockchain: None, + backend, + network_status_sinks, + system_rpc_tx, + config, + })?; if role.is_authority() { let proposer = sc_basic_authorship::ProposerFactory::new( @@ -256,7 +252,7 @@ pub fn new_full( link: grandpa_link, network, inherent_data_providers, - telemetry_on_connect: Some(telemetry_on_connect_sinks.on_connect_stream()), + telemetry_on_connect: Some(telemetry_connection_sinks.on_connect_stream()), voting_rule: sc_finality_grandpa::VotingRulesBuilder::default().build(), prometheus_registry, shared_voter_state: SharedVoterState::empty(), @@ -276,26 +272,24 @@ pub fn new_full( )?; } + network_starter.start_network(); Ok((task_manager, rpc_handlers)) } /// Builds a new service for a light client. pub fn new_light( config: Configuration, -) -> Result<(TaskManager, Arc), ServiceError> { - let (client, backend, keystore, task_manager, on_demand) = +) -> Result<(TaskManager, RpcHandlers), ServiceError> { + let (client, backend, keystore, mut task_manager, on_demand) = sc_service::new_light_parts::(&config)?; - let transaction_pool_api = Arc::new(sc_transaction_pool::LightChainApi::new( - client.clone(), - on_demand.clone(), - )); - let transaction_pool = sc_transaction_pool::BasicPool::new_light( + let transaction_pool = Arc::new(sc_transaction_pool::BasicPool::new_light( config.transaction_pool.clone(), - transaction_pool_api, config.prometheus_registry(), task_manager.spawn_handle(), - ); + client.clone(), + on_demand.clone(), + )); let grandpa_block_import = sc_finality_grandpa::light_block_import( client.clone(), @@ -307,7 +301,7 @@ pub fn new_light( let finality_proof_request_builder = finality_proof_import.create_finality_proof_request_builder(); - let import_queue = sc_consensus_aura::import_queue::<_, _, _, AuraPair, _>( + let import_queue = sc_consensus_aura::import_queue::<_, _, _, AuraPair, _, _>( sc_consensus_aura::slot_duration(&*client)?, grandpa_block_import, None, @@ -316,33 +310,52 @@ pub fn new_light( InherentDataProviders::new(), &task_manager.spawn_handle(), config.prometheus_registry(), + sp_consensus::NeverCanAuthor, )?; - let finality_proof_provider = Arc::new(GrandpaFinalityProofProvider::new( - backend.clone(), - client.clone() as Arc<_>, - )); + let finality_proof_provider = + GrandpaFinalityProofProvider::new_for_service(backend.clone(), client.clone()); + + let (network, network_status_sinks, system_rpc_tx, network_starter) = + sc_service::build_network(sc_service::BuildNetworkParams { + config: &config, + client: client.clone(), + transaction_pool: transaction_pool.clone(), + spawn_handle: task_manager.spawn_handle(), + import_queue, + on_demand: Some(on_demand.clone()), + block_announce_validator_builder: None, + finality_proof_request_builder: Some(finality_proof_request_builder), + finality_proof_provider: Some(finality_proof_provider), + })?; + + if config.offchain_worker.enabled { + sc_service::build_offchain_workers( + &config, + backend.clone(), + task_manager.spawn_handle(), + client.clone(), + network.clone(), + ); + } - sc_service::build(sc_service::ServiceParams { - block_announce_validator_builder: None, - finality_proof_request_builder: Some(finality_proof_request_builder), - finality_proof_provider: Some(finality_proof_provider), - on_demand: Some(on_demand), + let rpc_handlers = sc_service::spawn_tasks(sc_service::SpawnTasksParams { remote_blockchain: Some(backend.remote_blockchain()), - rpc_extensions_builder: Box::new(|_| ()), - transaction_pool: Arc::new(transaction_pool), + transaction_pool, + task_manager: &mut task_manager, + on_demand: Some(on_demand), + rpc_extensions_builder: Box::new(|_, _| ()), + telemetry_connection_sinks: sc_service::TelemetryConnectionSinks::default(), config, client, - import_queue, keystore, backend, - task_manager, - }) - .map( - |ServiceComponents { - task_manager, - rpc_handlers, - .. - }| (task_manager, rpc_handlers), - ) + network, + network_status_sinks, + system_rpc_tx, + })?; + + network_starter.start_network(); + + Ok((task_manager, rpc_handlers)) } From e1a843d4cb299fd41662078d1a6d1bff9a03aa48 Mon Sep 17 00:00:00 2001 From: David Craven Date: Mon, 24 Aug 2020 22:13:27 +0200 Subject: [PATCH 2/2] Fix clippy warnings. --- client/src/lib.rs | 7 +++---- test-node/runtime/src/lib.rs | 1 + test-node/src/service.rs | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/client/src/lib.rs b/client/src/lib.rs index 6420086f52..e6c02ad05e 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -91,12 +91,11 @@ impl SubxtClient { let (to_front, from_back) = mpsc01::channel(4); let session = RpcSession::new(to_front.clone()); - let session2 = session.clone(); task::spawn( select( Box::pin(from_front.for_each(move |message: String| { let rpc = rpc.clone(); - let session = session2.clone(); + let session = session.clone(); let mut to_front = to_front.clone().sink_compat(); async move { let response = rpc.rpc_query(&session, &message).await; @@ -123,7 +122,7 @@ impl SubxtClient { config: SubxtClientConfig, builder: impl Fn(Configuration) -> Result<(TaskManager, RpcHandlers), ServiceError>, ) -> Result { - let config = config.to_service_config(); + let config = config.into_service_config(); let (task_manager, rpc_handlers) = (builder)(config)?; Ok(Self::new(task_manager, rpc_handlers)) } @@ -221,7 +220,7 @@ pub struct SubxtClientConfig { impl SubxtClientConfig { /// Creates a service configuration. - pub fn to_service_config(self) -> Configuration { + pub fn into_service_config(self) -> Configuration { let mut network = NetworkConfiguration::new( format!("{} (subxt client)", self.chain_spec.name()), "unknown", diff --git a/test-node/runtime/src/lib.rs b/test-node/runtime/src/lib.rs index 146b0ebcca..85abd73d32 100644 --- a/test-node/runtime/src/lib.rs +++ b/test-node/runtime/src/lib.rs @@ -19,6 +19,7 @@ #![cfg_attr(not(feature = "std"), no_std)] // `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256. #![recursion_limit = "256"] +#![allow(clippy::large_enum_variant)] // Make the WASM binary available. #[cfg(feature = "std")] diff --git a/test-node/src/service.rs b/test-node/src/service.rs index 0bb9ce1b77..454f7f41a9 100644 --- a/test-node/src/service.rs +++ b/test-node/src/service.rs @@ -15,6 +15,7 @@ // along with substrate-subxt. If not, see . //! Service and ServiceFactory implementation. Specialized wrapper over substrate service. +#![allow(clippy::type_complexity)] use sc_client_api::{ ExecutorProvider, @@ -157,7 +158,7 @@ pub fn new_full( on_demand: None, block_announce_validator_builder: None, finality_proof_request_builder: None, - finality_proof_provider: Some(finality_proof_provider.clone()), + finality_proof_provider: Some(finality_proof_provider), })?; if config.offchain_worker.enabled {