Update to rc6. (#155)

* Update to rc6.

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