From 397ff3481bd971bfec877a0126ca39cef31e93d6 Mon Sep 17 00:00:00 2001 From: Joshy Orndorff Date: Tue, 12 Nov 2019 23:14:08 +0100 Subject: [PATCH 1/3] Update super runtime --- kitchen/runtimes/super-runtime/Cargo.toml | 28 ++++++++++++++++++---- kitchen/runtimes/super-runtime/src/lib.rs | 29 ++++++++++------------- 2 files changed, 37 insertions(+), 20 deletions(-) diff --git a/kitchen/runtimes/super-runtime/Cargo.toml b/kitchen/runtimes/super-runtime/Cargo.toml index c91e36de2..f8b89f19a 100644 --- a/kitchen/runtimes/super-runtime/Cargo.toml +++ b/kitchen/runtimes/super-runtime/Cargo.toml @@ -136,10 +136,27 @@ git = 'https://github.com/paritytech/substrate.git' package = 'sr-primitives' branch = 'master' -[dependencies.client] +[dependencies.sr-api] default_features = false git = 'https://github.com/paritytech/substrate.git' -package = 'substrate-client' +branch = 'master' + +[dependencies.block-builder-api] +default_features = false +git = 'https://github.com/paritytech/substrate.git' +package = 'substrate-block-builder-runtime-api' +branch = 'master' + +[dependencies.tx-pool-api] +default_features = false +git = 'https://github.com/paritytech/substrate.git' +package = 'substrate-transaction-pool-runtime-api' +branch = 'master' + +[dependencies.inherents] +default_features = false +git = 'https://github.com/paritytech/substrate.git' +package = 'substrate-inherents' branch = 'master' [dependencies.offchain-primitives] @@ -156,7 +173,7 @@ wasm-builder-runner = { package = "substrate-wasm-builder-runner", version = "1. default = ["std"] std = [ "parity-scale-codec/std", - "client/std", + "sr-api/std", "rstd/std", "runtime-io/std", "support/std", @@ -191,5 +208,8 @@ std = [ "basic-token/std", "check-membership/std", "schedule-on-finalize/std", - "transaction-payment/std" + "transaction-payment/std", + "block-builder-api/std", + "tx-pool-api/std", + "inherents/std", ] diff --git a/kitchen/runtimes/super-runtime/src/lib.rs b/kitchen/runtimes/super-runtime/src/lib.rs index 1b2fb8501..e346de268 100644 --- a/kitchen/runtimes/super-runtime/src/lib.rs +++ b/kitchen/runtimes/super-runtime/src/lib.rs @@ -18,12 +18,9 @@ use sr_primitives::{ use sr_primitives::traits::{NumberFor, BlakeTwo256, Block as BlockT, StaticLookup, Verify, ConvertInto}; use sr_primitives::weights::Weight; use babe::{AuthorityId as BabeId, SameAuthoritiesForever}; -use grandpa::{AuthorityId as GrandpaId, AuthorityWeight as GrandpaWeight}; +use grandpa::AuthorityList as GrandpaAuthorityList; use grandpa::fg_primitives; -use client::{ - block_builder::api::{CheckInherentsResult, InherentData, self as block_builder_api}, - runtime_api as client_api, impl_runtime_apis -}; +use sr_api::impl_runtime_apis; use version::RuntimeVersion; #[cfg(feature = "std")] use version::NativeVersion; @@ -98,10 +95,8 @@ pub mod opaque { impl_opaque_keys! { pub struct SessionKeys { - #[id(key_types::GRANDPA)] - pub grandpa: GrandpaId, - #[id(key_types::BABE)] - pub babe: BabeId, + pub grandpa: Grandpa, + pub babe: Babe, } } } @@ -395,7 +390,7 @@ pub type CheckedExtrinsic = generic::CheckedExtrinsic, Runtime, AllModules>; impl_runtime_apis! { - impl client_api::Core for Runtime { + impl sr_api::Core for Runtime { fn version() -> RuntimeVersion { VERSION } @@ -409,7 +404,7 @@ impl_runtime_apis! { } } - impl client_api::Metadata for Runtime { + impl sr_api::Metadata for Runtime { fn metadata() -> OpaqueMetadata { Runtime::metadata().into() } @@ -424,11 +419,14 @@ impl_runtime_apis! { Executive::finalize_block() } - fn inherent_extrinsics(data: InherentData) -> Vec<::Extrinsic> { + fn inherent_extrinsics(data: inherents::InherentData) -> Vec<::Extrinsic> { data.create_extrinsics() } - fn check_inherents(block: Block, data: InherentData) -> CheckInherentsResult { + fn check_inherents( + block: Block, + data: inherents::InherentData + ) -> inherents::CheckInherentsResult { data.check_extrinsics(&block) } @@ -437,7 +435,7 @@ impl_runtime_apis! { } } - impl client_api::TaggedTransactionQueue for Runtime { + impl tx_pool_api::TaggedTransactionQueue for Runtime { fn validate_transaction(tx: ::Extrinsic) -> TransactionValidity { Executive::validate_transaction(tx) } @@ -450,7 +448,7 @@ impl_runtime_apis! { } impl fg_primitives::GrandpaApi for Runtime { - fn grandpa_authorities() -> Vec<(GrandpaId, GrandpaWeight)> { + fn grandpa_authorities() -> GrandpaAuthorityList { Grandpa::grandpa_authorities() } } @@ -475,7 +473,6 @@ impl_runtime_apis! { impl substrate_session::SessionKeys for Runtime { fn generate_session_keys(seed: Option>) -> Vec { - let seed = seed.as_ref().map(|s| rstd::str::from_utf8(&s).expect("Seed is an utf8 string")); opaque::SessionKeys::generate(seed) } } From 600eae38bcaa8ab03da3a6047893f77c75ceda8d Mon Sep 17 00:00:00 2001 From: Joshy Orndorff Date: Tue, 12 Nov 2019 23:29:26 +0100 Subject: [PATCH 2/3] Fix weight-fee-runtime --- .../runtimes/weight-fee-runtime/Cargo.toml | 26 ++++++++++++++++--- .../runtimes/weight-fee-runtime/src/lib.rs | 25 ++++++++---------- 2 files changed, 34 insertions(+), 17 deletions(-) diff --git a/kitchen/runtimes/weight-fee-runtime/Cargo.toml b/kitchen/runtimes/weight-fee-runtime/Cargo.toml index d9d3bb85d..313ae20ce 100644 --- a/kitchen/runtimes/weight-fee-runtime/Cargo.toml +++ b/kitchen/runtimes/weight-fee-runtime/Cargo.toml @@ -122,10 +122,27 @@ git = 'https://github.com/paritytech/substrate.git' package = 'sr-primitives' branch = 'master' -[dependencies.client] +[dependencies.sr-api] default_features = false git = 'https://github.com/paritytech/substrate.git' -package = 'substrate-client' +branch = 'master' + +[dependencies.block-builder-api] +default_features = false +git = 'https://github.com/paritytech/substrate.git' +package = 'substrate-block-builder-runtime-api' +branch = 'master' + +[dependencies.tx-pool-api] +default_features = false +git = 'https://github.com/paritytech/substrate.git' +package = 'substrate-transaction-pool-runtime-api' +branch = 'master' + +[dependencies.inherents] +default_features = false +git = 'https://github.com/paritytech/substrate.git' +package = 'substrate-inherents' branch = 'master' [dependencies.offchain-primitives] @@ -142,7 +159,7 @@ wasm-builder-runner = { package = "substrate-wasm-builder-runner", version = "1. default = ["std"] std = [ "parity-scale-codec/std", - "client/std", + "sr-api/std", "rstd/std", "runtime-io/std", "support/std", @@ -164,5 +181,8 @@ std = [ "offchain-primitives/std", "substrate-session/std", "transaction-payment/std", + "block-builder-api/std", + "tx-pool-api/std", + "inherents/std", "weights/std", ] diff --git a/kitchen/runtimes/weight-fee-runtime/src/lib.rs b/kitchen/runtimes/weight-fee-runtime/src/lib.rs index 4632007bf..004cad792 100644 --- a/kitchen/runtimes/weight-fee-runtime/src/lib.rs +++ b/kitchen/runtimes/weight-fee-runtime/src/lib.rs @@ -21,10 +21,7 @@ use sr_primitives::weights::Weight; use babe::{AuthorityId as BabeId, SameAuthoritiesForever}; use grandpa::{AuthorityId as GrandpaId, AuthorityWeight as GrandpaWeight}; use grandpa::fg_primitives; -use client::{ - block_builder::api::{CheckInherentsResult, InherentData, self as block_builder_api}, - runtime_api as client_api, impl_runtime_apis -}; +use sr_api::impl_runtime_apis; use version::RuntimeVersion; #[cfg(feature = "std")] use version::NativeVersion; @@ -83,10 +80,8 @@ pub mod opaque { impl_opaque_keys! { pub struct SessionKeys { - #[id(key_types::GRANDPA)] - pub grandpa: GrandpaId, - #[id(key_types::BABE)] - pub babe: BabeId, + pub grandpa: Grandpa, + pub babe: Babe, } } } @@ -364,7 +359,7 @@ pub type CheckedExtrinsic = generic::CheckedExtrinsic, Runtime, AllModules>; impl_runtime_apis! { - impl client_api::Core for Runtime { + impl sr_api::Core for Runtime { fn version() -> RuntimeVersion { VERSION } @@ -378,7 +373,7 @@ impl_runtime_apis! { } } - impl client_api::Metadata for Runtime { + impl sr_api::Metadata for Runtime { fn metadata() -> OpaqueMetadata { Runtime::metadata().into() } @@ -393,11 +388,14 @@ impl_runtime_apis! { Executive::finalize_block() } - fn inherent_extrinsics(data: InherentData) -> Vec<::Extrinsic> { + fn inherent_extrinsics(data: inherents::InherentData) -> Vec<::Extrinsic> { data.create_extrinsics() } - fn check_inherents(block: Block, data: InherentData) -> CheckInherentsResult { + fn check_inherents( + block: Block, + data: inherents::InherentData + ) -> inherents::CheckInherentsResult { data.check_extrinsics(&block) } @@ -406,7 +404,7 @@ impl_runtime_apis! { } } - impl client_api::TaggedTransactionQueue for Runtime { + impl tx_pool_api::TaggedTransactionQueue for Runtime { fn validate_transaction(tx: ::Extrinsic) -> TransactionValidity { Executive::validate_transaction(tx) } @@ -444,7 +442,6 @@ impl_runtime_apis! { impl substrate_session::SessionKeys for Runtime { fn generate_session_keys(seed: Option>) -> Vec { - let seed = seed.as_ref().map(|s| rstd::str::from_utf8(&s).expect("Seed is an utf8 string")); opaque::SessionKeys::generate(seed) } } From 4f84247b3410f7e872ebb306a95164150e427744 Mon Sep 17 00:00:00 2001 From: Joshy Orndorff Date: Tue, 12 Nov 2019 23:36:49 +0100 Subject: [PATCH 3/3] Fix outer node --- kitchen/node/src/cli.rs | 2 +- kitchen/node/src/service.rs | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/kitchen/node/src/cli.rs b/kitchen/node/src/cli.rs index 6a0b0dd70..0a26556e2 100644 --- a/kitchen/node/src/cli.rs +++ b/kitchen/node/src/cli.rs @@ -38,7 +38,7 @@ pub fn run(args: I, exit: E, version: VersionInfo) -> error::Result<()> ), }.map_err(|e| format!("{:?}", e)) }), - ParseAndPrepare::BuildSpec(cmd) => cmd.run(load_spec), + ParseAndPrepare::BuildSpec(cmd) => cmd.run::(load_spec), ParseAndPrepare::ExportBlocks(cmd) => cmd.run_with_builder(|config: Config<_>| Ok(new_full_start!(config).0), load_spec, exit), ParseAndPrepare::ImportBlocks(cmd) => cmd.run_with_builder(|config: Config<_>| diff --git a/kitchen/node/src/service.rs b/kitchen/node/src/service.rs index c3db838c9..56bd6bf91 100644 --- a/kitchen/node/src/service.rs +++ b/kitchen/node/src/service.rs @@ -48,7 +48,7 @@ macro_rules! new_full_start { let select_chain = select_chain.take() .ok_or_else(|| substrate_service::Error::SelectChainRequired)?; let (grandpa_block_import, grandpa_link) = - grandpa::block_import::<_, _, _, runtime::RuntimeApi, _, _>( + grandpa::block_import::<_, _, _, runtime::RuntimeApi, _>( client.clone(), &*client, select_chain )?; let justification_import = grandpa_block_import.clone(); @@ -136,7 +136,9 @@ pub fn new_full(config: Configuration(config: Configuration( - client.clone(), backend, Arc::new(fetch_checker), client.clone() + let grandpa_block_import = grandpa::light_block_import::<_, _, _, RuntimeApi>( + client.clone(), backend, &*client.clone(), Arc::new(fetch_checker) )?; let finality_proof_import = grandpa_block_import.clone();