diff --git a/substrate/Cargo.lock b/substrate/Cargo.lock index 7371d9ebfd..7c8a4d25f4 100644 --- a/substrate/Cargo.lock +++ b/substrate/Cargo.lock @@ -5409,6 +5409,7 @@ dependencies = [ "sp-runtime 2.0.0", "sp-transaction-pool 2.0.0", "substrate-test-runtime-client 2.0.0", + "substrate-test-runtime-transaction-pool 2.0.0", "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5985,6 +5986,7 @@ dependencies = [ "sp-runtime 2.0.0", "sp-transaction-pool 2.0.0", "substrate-test-runtime-client 2.0.0", + "substrate-test-runtime-transaction-pool 2.0.0", ] [[package]] @@ -7103,6 +7105,20 @@ dependencies = [ "substrate-test-runtime 2.0.0", ] +[[package]] +name = "substrate-test-runtime-transaction-pool" +version = "2.0.0" +dependencies = [ + "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-transaction-graph 2.0.0", + "sp-runtime 2.0.0", + "sp-transaction-pool 2.0.0", + "substrate-test-runtime-client 2.0.0", +] + [[package]] name = "substrate-test-utils" version = "2.0.0" diff --git a/substrate/Cargo.toml b/substrate/Cargo.toml index 5dd85091cb..10465042de 100644 --- a/substrate/Cargo.toml +++ b/substrate/Cargo.toml @@ -147,6 +147,7 @@ members = [ "test-utils/client", "test-utils/runtime", "test-utils/runtime/client", + "test-utils/runtime/transaction-pool", "utils/browser", "utils/build-script-utils", "utils/fork-tree", diff --git a/substrate/bin/node-template/src/service.rs b/substrate/bin/node-template/src/service.rs index b23ada78f1..d113f90866 100644 --- a/substrate/bin/node-template/src/service.rs +++ b/substrate/bin/node-template/src/service.rs @@ -41,7 +41,7 @@ macro_rules! new_full_start { })? .with_transaction_pool(|config, client, _fetcher| { let pool_api = sc_transaction_pool::FullChainApi::new(client.clone()); - let pool = sc_transaction_pool::BasicPool::new(config, pool_api); + let pool = sc_transaction_pool::BasicPool::new(config, std::sync::Arc::new(pool_api)); Ok(pool) })? .with_import_queue(|_config, client, mut select_chain, transaction_pool| { @@ -207,7 +207,7 @@ pub fn new_light(config: Configuration) let pool_api = sc_transaction_pool::LightChainApi::new(client.clone(), fetcher.clone()); let pool = sc_transaction_pool::BasicPool::with_revalidation_type( - config, pool_api, sc_transaction_pool::RevalidationType::Light, + config, Arc::new(pool_api), sc_transaction_pool::RevalidationType::Light, ); Ok(pool) })? diff --git a/substrate/bin/node/cli/src/service.rs b/substrate/bin/node/cli/src/service.rs index e72430e93d..c462a60836 100644 --- a/substrate/bin/node/cli/src/service.rs +++ b/substrate/bin/node/cli/src/service.rs @@ -63,7 +63,7 @@ macro_rules! new_full_start { })? .with_transaction_pool(|config, client, _fetcher| { let pool_api = sc_transaction_pool::FullChainApi::new(client.clone()); - let pool = sc_transaction_pool::BasicPool::new(config, pool_api); + let pool = sc_transaction_pool::BasicPool::new(config, std::sync::Arc::new(pool_api)); Ok(pool) })? .with_import_queue(|_config, client, mut select_chain, _transaction_pool| { @@ -313,7 +313,7 @@ pub fn new_light(config: NodeConfiguration) .ok_or_else(|| "Trying to start light transaction pool without active fetcher")?; let pool_api = sc_transaction_pool::LightChainApi::new(client.clone(), fetcher.clone()); let pool = sc_transaction_pool::BasicPool::with_revalidation_type( - config, pool_api, sc_transaction_pool::RevalidationType::Light, + config, Arc::new(pool_api), sc_transaction_pool::RevalidationType::Light, ); Ok(pool) })? diff --git a/substrate/client/basic-authorship/src/basic_authorship.rs b/substrate/client/basic-authorship/src/basic_authorship.rs index 6c5b063020..fafc63a114 100644 --- a/substrate/client/basic-authorship/src/basic_authorship.rs +++ b/substrate/client/basic-authorship/src/basic_authorship.rs @@ -306,7 +306,9 @@ mod tests { fn should_cease_building_block_when_deadline_is_reached() { // given let client = Arc::new(substrate_test_runtime_client::new()); - let txpool = Arc::new(BasicPool::new(Default::default(), FullChainApi::new(client.clone()))); + let txpool = Arc::new( + BasicPool::new(Default::default(), Arc::new(FullChainApi::new(client.clone()))) + ); futures::executor::block_on( txpool.submit_at(&BlockId::number(0), vec![extrinsic(0), extrinsic(1)]) @@ -346,7 +348,9 @@ mod tests { let (client, backend) = substrate_test_runtime_client::TestClientBuilder::new() .build_with_backend(); let client = Arc::new(client); - let txpool = Arc::new(BasicPool::new(Default::default(), FullChainApi::new(client.clone()))); + let txpool = Arc::new( + BasicPool::new(Default::default(), Arc::new(FullChainApi::new(client.clone()))) + ); let genesis_hash = client.info().best_hash; let block_id = BlockId::Hash(genesis_hash); diff --git a/substrate/client/basic-authorship/src/lib.rs b/substrate/client/basic-authorship/src/lib.rs index f62134ce42..9f2bc6a761 100644 --- a/substrate/client/basic-authorship/src/lib.rs +++ b/substrate/client/basic-authorship/src/lib.rs @@ -26,7 +26,7 @@ //! # use substrate_test_runtime_client::{self, runtime::{Extrinsic, Transfer}, AccountKeyring}; //! # use sc_transaction_pool::{BasicPool, FullChainApi}; //! # let client = Arc::new(substrate_test_runtime_client::new()); -//! # let txpool = Arc::new(BasicPool::new(Default::default(), FullChainApi::new(client.clone()))); +//! # let txpool = Arc::new(BasicPool::new(Default::default(), Arc::new(FullChainApi::new(client.clone())))); //! // The first step is to create a `ProposerFactory`. //! let mut proposer_factory = ProposerFactory { //! client: client.clone(), diff --git a/substrate/client/consensus/manual-seal/Cargo.toml b/substrate/client/consensus/manual-seal/Cargo.toml index 821b314501..de601b4ab3 100644 --- a/substrate/client/consensus/manual-seal/Cargo.toml +++ b/substrate/client/consensus/manual-seal/Cargo.toml @@ -18,7 +18,7 @@ serde = { version = "1.0", features=["derive"] } sc-client = { path = "../../../client" } sc-client-api = { path = "../../../client/api" } -sc-transaction-pool = { path = "../../transaction-pool", features = ["test-helpers"] } +sc-transaction-pool = { path = "../../transaction-pool" } sp-blockchain = { path = "../../../primitives/blockchain" } sp-consensus = { package = "sp-consensus", path = "../../../primitives/consensus/common" } sp-inherents = { path = "../../../primitives/inherents" } @@ -28,6 +28,7 @@ sp-transaction-pool = { path = "../../../primitives/transaction-pool" } [dev-dependencies] sc-basic-authorship = { path = "../../basic-authorship" } substrate-test-runtime-client = { path = "../../../test-utils/runtime/client" } +substrate-test-runtime-transaction-pool = { path = "../../../test-utils/runtime/transaction-pool" } tokio = { version = "0.2", features = ["rt-core", "macros"] } env_logger = "0.7.0" tempfile = "3.1.0" diff --git a/substrate/client/consensus/manual-seal/src/lib.rs b/substrate/client/consensus/manual-seal/src/lib.rs index 7262a62d12..029f746e62 100644 --- a/substrate/client/consensus/manual-seal/src/lib.rs +++ b/substrate/client/consensus/manual-seal/src/lib.rs @@ -231,8 +231,8 @@ mod tests { use sc_transaction_pool::{ BasicPool, txpool::Options, - testing::api::*, }; + use substrate_test_runtime_transaction_pool::{TestApi, uxt}; use sp_transaction_pool::TransactionPool; use sp_runtime::generic::BlockId; use sp_blockchain::HeaderBackend; @@ -241,8 +241,8 @@ mod tests { use sp_inherents::InherentDataProviders; use sc_basic_authorship::ProposerFactory; - fn api() -> TestApi { - TestApi::empty() + fn api() -> Arc { + Arc::new(TestApi::empty()) } #[tokio::test] @@ -385,7 +385,8 @@ mod tests { let client = Arc::new(builder.build()); let select_chain = LongestChain::new(backend.clone()); let inherent_data_providers = InherentDataProviders::new(); - let pool = Arc::new(BasicPool::new(Options::default(), api())); + let pool_api = api(); + let pool = Arc::new(BasicPool::new(Options::default(), pool_api.clone())); let env = ProposerFactory { transaction_pool: pool.clone(), client: client.clone(), @@ -419,7 +420,7 @@ mod tests { finalize: false, }).await.unwrap(); let created_block = rx.await.unwrap().unwrap(); - pool.api().increment_nonce(Alice.into()); + pool_api.increment_nonce(Alice.into()); // assert that the background task returns ok assert_eq!( @@ -449,7 +450,7 @@ mod tests { }).await.is_ok()); assert!(rx1.await.unwrap().is_ok()); assert!(backend.blockchain().header(BlockId::Number(1)).unwrap().is_some()); - pool.api().increment_nonce(Alice.into()); + pool_api.increment_nonce(Alice.into()); assert!(pool.submit_one(&BlockId::Number(2), uxt(Alice, 2)).await.is_ok()); let (tx2, rx2) = futures::channel::oneshot::channel(); diff --git a/substrate/client/offchain/src/lib.rs b/substrate/client/offchain/src/lib.rs index 3cd3b2cba5..f0a10a5409 100644 --- a/substrate/client/offchain/src/lib.rs +++ b/substrate/client/offchain/src/lib.rs @@ -202,7 +202,10 @@ mod tests { // given let _ = env_logger::try_init(); let client = Arc::new(substrate_test_runtime_client::new()); - let pool = Arc::new(TestPool(BasicPool::new(Default::default(), FullChainApi::new(client.clone())))); + let pool = Arc::new(TestPool(BasicPool::new( + Default::default(), + Arc::new(FullChainApi::new(client.clone())), + ))); client.execution_extensions() .register_transaction_pool(Arc::downgrade(&pool.clone()) as _); let db = sc_client_db::offchain::LocalStorage::new_test(); diff --git a/substrate/client/rpc/src/author/tests.rs b/substrate/client/rpc/src/author/tests.rs index 7de109bc5d..ba9b9d344c 100644 --- a/substrate/client/rpc/src/author/tests.rs +++ b/substrate/client/rpc/src/author/tests.rs @@ -56,8 +56,15 @@ struct TestSetup { impl Default for TestSetup { fn default() -> Self { let keystore = KeyStore::new(); - let client = Arc::new(substrate_test_runtime_client::TestClientBuilder::new().set_keystore(keystore.clone()).build()); - let pool = Arc::new(BasicPool::new(Default::default(), FullChainApi::new(client.clone()))); + let client = Arc::new( + substrate_test_runtime_client::TestClientBuilder::new() + .set_keystore(keystore.clone()) + .build() + ); + let pool = Arc::new(BasicPool::new( + Default::default(), + Arc::new(FullChainApi::new(client.clone())), + )); TestSetup { runtime: runtime::Runtime::new().expect("Failed to create runtime in test setup"), client, diff --git a/substrate/client/rpc/src/state/state_full.rs b/substrate/client/rpc/src/state/state_full.rs index cd77e8b080..3f7470ae4e 100644 --- a/substrate/client/rpc/src/state/state_full.rs +++ b/substrate/client/rpc/src/state/state_full.rs @@ -36,7 +36,6 @@ use sp_core::{ Bytes, storage::{well_known_keys, StorageKey, StorageData, StorageChangeSet, ChildInfo}, }; use sp_version::RuntimeVersion; -use sp_state_machine::ExecutionStrategy; use sp_runtime::{ generic::BlockId, traits::{Block as BlockT, NumberFor, SaturatedConversion}, }; diff --git a/substrate/client/service/src/lib.rs b/substrate/client/service/src/lib.rs index 5ba6474da6..dc158f1300 100644 --- a/substrate/client/service/src/lib.rs +++ b/substrate/client/service/src/lib.rs @@ -700,7 +700,10 @@ mod tests { // given let (client, longest_chain) = TestClientBuilder::new().build_with_longest_chain(); let client = Arc::new(client); - let pool = Arc::new(BasicPool::new(Default::default(), FullChainApi::new(client.clone()))); + let pool = Arc::new(BasicPool::new( + Default::default(), + Arc::new(FullChainApi::new(client.clone())), + )); let best = longest_chain.best_chain().unwrap(); let transaction = Transfer { amount: 5, diff --git a/substrate/client/transaction-pool/Cargo.toml b/substrate/client/transaction-pool/Cargo.toml index 0bdf5efaa6..e151e9adbe 100644 --- a/substrate/client/transaction-pool/Cargo.toml +++ b/substrate/client/transaction-pool/Cargo.toml @@ -12,17 +12,15 @@ futures = { version = "0.3.1", features = ["compat"] } futures-diagnose = "1.0" log = "0.4.8" parking_lot = "0.9.0" -sp-core = { path = "../../primitives/core" } -sp-api = { path = "../../primitives/api" } -sp-runtime = { path = "../../primitives/runtime" } -sc-transaction-graph = { path = "./graph" } -sp-transaction-pool = { path = "../../primitives/transaction-pool" } -sc-client-api = { path = "../api" } -sp-blockchain = { path = "../../primitives/blockchain" } -substrate-test-runtime-client = { path = "../../test-utils/runtime/client" } +sp-core = { version = "2.0.0", path = "../../primitives/core" } +sp-api = { version = "2.0.0", path = "../../primitives/api" } +sp-runtime = { version = "2.0.0", path = "../../primitives/runtime" } +sc-transaction-graph = { version = "2.0.0", path = "./graph" } +sp-transaction-pool = { version = "2.0.0", path = "../../primitives/transaction-pool" } +sc-client-api = { version = "2.0.0", path = "../api" } +sp-blockchain = { version = "2.0.0", path = "../../primitives/blockchain" } [dev-dependencies] sp-keyring = { version = "2.0.0", path = "../../primitives/keyring" } - -[features] -test-helpers = [] +substrate-test-runtime-transaction-pool = { version = "2.0.0", path = "../../test-utils/runtime/transaction-pool" } +substrate-test-runtime-client = { version = "2.0.0", path = "../../test-utils/runtime/client" } diff --git a/substrate/client/transaction-pool/src/lib.rs b/substrate/client/transaction-pool/src/lib.rs index 5f116dfd02..85bf2fd327 100644 --- a/substrate/client/transaction-pool/src/lib.rs +++ b/substrate/client/transaction-pool/src/lib.rs @@ -42,8 +42,6 @@ use sp_transaction_pool::{ MaintainedTransactionPool, PoolFuture, }; -type PoolResult = PoolFuture; - /// Basic implementation of transaction pool that can be customized by providing PoolApi. pub struct BasicPool where @@ -80,7 +78,7 @@ impl BasicPool /// Create new basic transaction pool with provided api. pub fn new( options: sc_transaction_graph::Options, - pool_api: PoolApi, + pool_api: Arc, ) -> Self { Self::with_revalidation_type(options, pool_api, RevalidationType::Full) } @@ -89,14 +87,13 @@ impl BasicPool /// revalidation type. pub fn with_revalidation_type( options: sc_transaction_graph::Options, - pool_api: PoolApi, + pool_api: Arc, revalidation_type: RevalidationType, ) -> Self { - let api = Arc::new(pool_api); - let cloned_api = api.clone(); + let cloned_api = pool_api.clone(); BasicPool { api: cloned_api, - pool: Arc::new(sc_transaction_graph::Pool::new(options, api)), + pool: Arc::new(sc_transaction_graph::Pool::new(options, pool_api)), revalidation_strategy: Arc::new(Mutex::new( match revalidation_type { RevalidationType::Light => RevalidationStrategy::Light(RevalidationStatus::NotScheduled), @@ -111,29 +108,23 @@ impl BasicPool pub fn pool(&self) -> &Arc> { &self.pool } - - /// Get reference to the inner chain api, for tests only. - #[cfg(any(feature = "test-helpers", test))] - pub fn api(&self) -> &Arc { - &self.api - } } impl TransactionPool for BasicPool where Block: BlockT, - PoolApi: 'static + sc_transaction_graph::ChainApi, + PoolApi: 'static + sc_transaction_graph::ChainApi, { type Block = PoolApi::Block; type Hash = sc_transaction_graph::ExHash; type InPoolTransaction = sc_transaction_graph::base_pool::Transaction, TransactionFor>; - type Error = error::Error; + type Error = PoolApi::Error; fn submit_at( &self, at: &BlockId, xts: Vec>, - ) -> PoolResult, Self::Error>>> { + ) -> PoolFuture, Self::Error>>, Self::Error> { let pool = self.pool.clone(); let at = *at; async move { @@ -145,7 +136,7 @@ impl TransactionPool for BasicPool &self, at: &BlockId, xt: TransactionFor, - ) -> PoolResult> { + ) -> PoolFuture, Self::Error> { let pool = self.pool.clone(); let at = *at; async move { @@ -157,7 +148,7 @@ impl TransactionPool for BasicPool &self, at: &BlockId, xt: TransactionFor, - ) -> PoolResult>> { + ) -> PoolFuture>, Self::Error> { let at = *at; let pool = self.pool.clone(); @@ -287,7 +278,7 @@ impl RevalidationStatus { impl MaintainedTransactionPool for BasicPool where Block: BlockT, - PoolApi: 'static + sc_transaction_graph::ChainApi, + PoolApi: 'static + sc_transaction_graph::ChainApi, { fn maintain(&self, id: &BlockId, retracted: &[BlockHash]) -> Pin + Send>> diff --git a/substrate/client/transaction-pool/src/testing/mod.rs b/substrate/client/transaction-pool/src/testing/mod.rs index c216a17ee6..a8f40c6b64 100644 --- a/substrate/client/transaction-pool/src/testing/mod.rs +++ b/substrate/client/transaction-pool/src/testing/mod.rs @@ -16,8 +16,4 @@ //! Tests for top-level transaction pool api -#[cfg(any(feature = "test-helpers", test))] -pub mod api; - -#[cfg(test)] -mod pool; \ No newline at end of file +mod pool; diff --git a/substrate/client/transaction-pool/src/testing/pool.rs b/substrate/client/transaction-pool/src/testing/pool.rs index 30a48fbec6..d4f3d0ccb4 100644 --- a/substrate/client/transaction-pool/src/testing/pool.rs +++ b/substrate/client/transaction-pool/src/testing/pool.rs @@ -1,6 +1,21 @@ +// Copyright 2020 Parity Technologies (UK) Ltd. +// This file is part of Substrate. + +// Substrate is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Substrate is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Substrate. If not, see . use crate::*; -use sc_transaction_graph::{self, Pool}; +use sc_transaction_graph::Pool; use futures::executor::block_on; use sp_runtime::{ generic::BlockId, @@ -10,14 +25,14 @@ use substrate_test_runtime_client::{ runtime::{Block, Hash, Index}, AccountKeyring::*, }; -use crate::testing::api::{TestApi, uxt}; +use substrate_test_runtime_transaction_pool::{TestApi, uxt}; fn pool() -> Pool { Pool::new(Default::default(), TestApi::with_alice_nonce(209).into()) } fn maintained_pool() -> BasicPool { - BasicPool::new(Default::default(), TestApi::with_alice_nonce(209)) + BasicPool::new(Default::default(), std::sync::Arc::new(TestApi::with_alice_nonce(209))) } #[test] diff --git a/substrate/test-utils/runtime/transaction-pool/Cargo.toml b/substrate/test-utils/runtime/transaction-pool/Cargo.toml new file mode 100644 index 0000000000..c10a34f938 --- /dev/null +++ b/substrate/test-utils/runtime/transaction-pool/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "substrate-test-runtime-transaction-pool" +version = "2.0.0" +authors = ["Parity Technologies "] +edition = "2018" +license = "GPL-3.0" + +[dependencies] +substrate-test-runtime-client = { version = "2.0.0", path = "../client" } +parking_lot = "0.9.0" +codec = { package = "parity-scale-codec", version = "1.0.0" } +sp-runtime = { version = "2.0.0", path = "../../../primitives/runtime" } +sp-transaction-pool = { version = "2.0.0", path = "../../../primitives/transaction-pool" } +sc-transaction-graph = { version = "2.0.0", path = "../../../client/transaction-pool/graph" } +futures = { version = "0.3.1", features = ["compat"] } +derive_more = "0.99.2" diff --git a/substrate/client/transaction-pool/src/testing/api.rs b/substrate/test-utils/runtime/transaction-pool/src/lib.rs similarity index 84% rename from substrate/client/transaction-pool/src/testing/api.rs rename to substrate/test-utils/runtime/transaction-pool/src/lib.rs index c8e4b62883..58c801d8d6 100644 --- a/substrate/client/transaction-pool/src/testing/api.rs +++ b/substrate/test-utils/runtime/transaction-pool/src/lib.rs @@ -14,22 +14,41 @@ // You should have received a copy of the GNU General Public License // along with Substrate. If not, see . -//! Test ChainApi +//! Test utils for the transaction pool together with the test runtime. +//! +//! See [`TestApi`] for more information. -use crate::*; use codec::Encode; use parking_lot::RwLock; use sp_runtime::{ generic::{self, BlockId}, traits::{BlakeTwo256, Hash as HashT}, - transaction_validity::{TransactionValidity, ValidTransaction, TransactionValidityError, InvalidTransaction}, + transaction_validity::{ + TransactionValidity, ValidTransaction, TransactionValidityError, InvalidTransaction, + }, }; -use std::collections::HashSet; +use std::collections::{HashSet, HashMap}; use substrate_test_runtime_client::{ runtime::{Index, AccountId, Block, BlockNumber, Extrinsic, Hash, Header, Transfer}, AccountKeyring::{self, *}, }; +/// Error type used by [`TestApi`]. +#[derive(Debug, derive_more::From, derive_more::Display)] +pub struct Error(sp_transaction_pool::error::Error); + +impl sp_transaction_pool::error::IntoPoolError for Error { + fn into_pool_error(self) -> Result { + Ok(self.0) + } +} + +impl std::error::Error for Error { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + Some(&self.0) + } +} + #[derive(Default)] struct ChainState { pub block_by_number: HashMap>, @@ -47,7 +66,6 @@ pub struct TestApi { } impl TestApi { - /// Test Api with Alice nonce set initially. pub fn with_alice_nonce(nonce: u64) -> Self { let api = TestApi { @@ -128,9 +146,9 @@ impl TestApi { impl sc_transaction_graph::ChainApi for TestApi { type Block = Block; type Hash = Hash; - type Error = error::Error; - type ValidationFuture = futures::future::Ready>; - type BodyFuture = futures::future::Ready>>>; + type Error = Error; + type ValidationFuture = futures::future::Ready>; + type BodyFuture = futures::future::Ready>, Error>>; fn validate_transaction( &self, @@ -149,7 +167,7 @@ impl sc_transaction_graph::ChainApi for TestApi { if self.chain.read().invalid_hashes.contains(&self.hash_and_length(&uxt).0) { return futures::future::ready(Ok( - Err(TransactionValidityError::Invalid(InvalidTransaction::Custom(0))) + Err(TransactionValidityError::Invalid(InvalidTransaction::Custom(0)).into()) )) } @@ -169,14 +187,14 @@ impl sc_transaction_graph::ChainApi for TestApi { fn block_id_to_number( &self, at: &BlockId, - ) -> error::Result>> { + ) -> Result>, Error> { Ok(Some(number_of(at))) } fn block_id_to_hash( &self, at: &BlockId, - ) -> error::Result>> { + ) -> Result>, Error> { Ok(match at { generic::BlockId::Hash(x) => Some(x.clone()), _ => Some(Default::default()), diff --git a/substrate/utils/frame/rpc/system/src/lib.rs b/substrate/utils/frame/rpc/system/src/lib.rs index f909e66fd6..d26821caf2 100644 --- a/substrate/utils/frame/rpc/system/src/lib.rs +++ b/substrate/utils/frame/rpc/system/src/lib.rs @@ -235,7 +235,9 @@ mod tests { // given let _ = env_logger::try_init(); let client = Arc::new(substrate_test_runtime_client::new()); - let pool = Arc::new(BasicPool::new(Default::default(), FullChainApi::new(client.clone()))); + let pool = Arc::new( + BasicPool::new(Default::default(), Arc::new(FullChainApi::new(client.clone()))) + ); let new_transaction = |nonce: u64| { let t = Transfer {