diff --git a/substrate/bin/node/cli/benches/block_production.rs b/substrate/bin/node/cli/benches/block_production.rs index e4b48497e0f88fabf3d6cf52c11cce9eaf52a885..501d69fc287b7ae54c69edf5efb2b879bf1b85aa 100644 --- a/substrate/bin/node/cli/benches/block_production.rs +++ b/substrate/bin/node/cli/benches/block_production.rs @@ -137,7 +137,7 @@ fn import_block( params.state_action = StateAction::ApplyChanges(sc_consensus::StorageChanges::Changes(built.storage_changes)); params.fork_choice = Some(ForkChoiceStrategy::LongestChain); - futures::executor::block_on(client.import_block(params, Default::default())) + futures::executor::block_on(client.import_block(params)) .expect("importing a block doesn't fail"); } diff --git a/substrate/bin/node/cli/src/service.rs b/substrate/bin/node/cli/src/service.rs index 6e000a4755ecfe2f8e178f7d7164017a2f51da79..e9a34b2a5c72803065369890106bb2d41cf5ee26 100644 --- a/substrate/bin/node/cli/src/service.rs +++ b/substrate/bin/node/cli/src/service.rs @@ -760,7 +760,7 @@ mod tests { ); params.fork_choice = Some(ForkChoiceStrategy::LongestChain); - futures::executor::block_on(block_import.import_block(params, Default::default())) + futures::executor::block_on(block_import.import_block(params)) .expect("error importing test block"); }, |service, _| { diff --git a/substrate/bin/node/testing/src/bench.rs b/substrate/bin/node/testing/src/bench.rs index ccce6dc23cfeb4ad3f3c4ddfc1b3d16587e41ea0..1a9af13028483c45d3fc517b6c434f163278de52 100644 --- a/substrate/bin/node/testing/src/bench.rs +++ b/substrate/bin/node/testing/src/bench.rs @@ -682,10 +682,8 @@ impl BenchContext { assert_eq!(self.client.chain_info().best_number, 0); assert_eq!( - futures::executor::block_on( - self.client.import_block(import_params, Default::default()) - ) - .expect("Failed to import block"), + futures::executor::block_on(self.client.import_block(import_params)) + .expect("Failed to import block"), ImportResult::Imported(ImportedAux { header_only: false, clear_justification_requests: false, diff --git a/substrate/client/api/src/backend.rs b/substrate/client/api/src/backend.rs index 26a0cf03519981750ea14eb7a76614a9f1733054..b88feafb6ca3aec37b6727fac19d1047713291fd 100644 --- a/substrate/client/api/src/backend.rs +++ b/substrate/client/api/src/backend.rs @@ -18,12 +18,10 @@ //! Substrate Client data backend -use crate::{ - blockchain::{well_known_cache_keys, Backend as BlockchainBackend}, - UsageInfo, -}; +use std::collections::HashSet; + use parking_lot::RwLock; -use sp_blockchain; + use sp_consensus::BlockOrigin; use sp_core::offchain::OffchainStorage; use sp_runtime::{ @@ -35,7 +33,8 @@ use sp_state_machine::{ OffchainChangesCollection, StorageCollection, StorageIterator, }; use sp_storage::{ChildInfo, StorageData, StorageKey}; -use std::collections::{HashMap, HashSet}; + +use crate::{blockchain::Backend as BlockchainBackend, UsageInfo}; pub use sp_state_machine::{Backend as StateBackend, KeyValueStates}; @@ -179,9 +178,6 @@ pub trait BlockImportOperation<Block: BlockT> { state: NewBlockState, ) -> sp_blockchain::Result<()>; - /// Update cached data. - fn update_cache(&mut self, cache: HashMap<well_known_cache_keys::Id, Vec<u8>>); - /// Inject storage data into the database. fn update_db_storage( &mut self, diff --git a/substrate/client/api/src/in_mem.rs b/substrate/client/api/src/in_mem.rs index 7096910e10b93bf256450a8fd9b43567530b5d4a..27a74ddd79ed6e028ff0c4db6b20bb31a94e94d4 100644 --- a/substrate/client/api/src/in_mem.rs +++ b/substrate/client/api/src/in_mem.rs @@ -40,7 +40,7 @@ use std::{ use crate::{ backend::{self, NewBlockState}, - blockchain::{self, well_known_cache_keys::Id as CacheKeyId, BlockStatus, HeaderBackend}, + blockchain::{self, BlockStatus, HeaderBackend}, leaves::LeafSet, UsageInfo, }; @@ -549,8 +549,6 @@ where Ok(()) } - fn update_cache(&mut self, _cache: HashMap<CacheKeyId, Vec<u8>>) {} - fn update_db_storage( &mut self, update: <InMemoryBackend<HashFor<Block>> as StateBackend<HashFor<Block>>>::Transaction, diff --git a/substrate/client/consensus/aura/src/import_queue.rs b/substrate/client/consensus/aura/src/import_queue.rs index 99b5af0818dc9aeb2c0afbf7788a9d0f8eadfeb0..46e0ccb4e302a6fa1039c07414dceb45b3841206 100644 --- a/substrate/client/consensus/aura/src/import_queue.rs +++ b/substrate/client/consensus/aura/src/import_queue.rs @@ -34,7 +34,7 @@ use sc_consensus_slots::{check_equivocation, CheckedHeader, InherentDataProvider use sc_telemetry::{telemetry, TelemetryHandle, CONSENSUS_DEBUG, CONSENSUS_TRACE}; use sp_api::{ApiExt, ProvideRuntimeApi}; use sp_block_builder::BlockBuilder as BlockBuilderApi; -use sp_blockchain::{well_known_cache_keys::Id as CacheKeyId, HeaderBackend}; +use sp_blockchain::HeaderBackend; use sp_consensus::Error as ConsensusError; use sp_consensus_aura::{digests::CompatibleDigestItem, inherents::AuraInherentData, AuraApi}; use sp_consensus_slots::Slot; @@ -184,7 +184,7 @@ where async fn verify( &mut self, mut block: BlockImportParams<B, ()>, - ) -> Result<(BlockImportParams<B, ()>, Option<Vec<(CacheKeyId, Vec<u8>)>>), String> { + ) -> Result<BlockImportParams<B, ()>, String> { // Skip checks that include execution, if being told so or when importing only state. // // This is done for example when gap syncing and it is expected that the block after the gap @@ -194,7 +194,7 @@ where // When we are importing only the state of a block, it will be the best block. block.fork_choice = Some(ForkChoiceStrategy::Custom(block.with_state())); - return Ok((block, Default::default())) + return Ok(block) } let hash = block.header.hash(); @@ -278,7 +278,7 @@ where block.fork_choice = Some(ForkChoiceStrategy::LongestChain); block.post_hash = Some(hash); - Ok((block, None)) + Ok(block) }, CheckedHeader::Deferred(a, b) => { debug!(target: LOG_TARGET, "Checking {:?} failed; {:?}, {:?}.", hash, a, b); diff --git a/substrate/client/consensus/babe/src/lib.rs b/substrate/client/consensus/babe/src/lib.rs index 271e3f648c26150dfdc3cf6468eb1f3a57ad2193..1d42057a36b239cff9fcd30e4083a42790288e0d 100644 --- a/substrate/client/consensus/babe/src/lib.rs +++ b/substrate/client/consensus/babe/src/lib.rs @@ -67,7 +67,7 @@ #![warn(missing_docs)] use std::{ - collections::{HashMap, HashSet}, + collections::HashSet, future::Future, pin::Pin, sync::Arc, @@ -114,9 +114,7 @@ use sp_blockchain::{ Backend as _, BlockStatus, Error as ClientError, ForkBackend, HeaderBackend, HeaderMetadata, Result as ClientResult, }; -use sp_consensus::{ - BlockOrigin, CacheKeyId, Environment, Error as ConsensusError, Proposer, SelectChain, -}; +use sp_consensus::{BlockOrigin, Environment, Error as ConsensusError, Proposer, SelectChain}; use sp_consensus_babe::inherents::BabeInherentData; use sp_consensus_slots::Slot; use sp_core::{crypto::ByteArray, ExecutionContext}; @@ -1131,9 +1129,6 @@ where } } -type BlockVerificationResult<Block> = - Result<(BlockImportParams<Block, ()>, Option<Vec<(CacheKeyId, Vec<u8>)>>), String>; - #[async_trait::async_trait] impl<Block, Client, SelectChain, CIDP> Verifier<Block> for BabeVerifier<Block, Client, SelectChain, CIDP> @@ -1153,7 +1148,7 @@ where async fn verify( &mut self, mut block: BlockImportParams<Block, ()>, - ) -> BlockVerificationResult<Block> { + ) -> Result<BlockImportParams<Block, ()>, String> { trace!( target: LOG_TARGET, "Verifying origin: {:?} header: {:?} justification(s): {:?} body: {:?}", @@ -1177,7 +1172,7 @@ where // read it from the state after import. We also skip all verifications // because there's no parent state and we trust the sync module to verify // that the state is correct and finalized. - return Ok((block, Default::default())) + return Ok(block) } debug!( @@ -1296,7 +1291,7 @@ where ); block.post_hash = Some(hash); - Ok((block, Default::default())) + Ok(block) }, CheckedHeader::Deferred(a, b) => { debug!(target: LOG_TARGET, "Checking {:?} failed; {:?}, {:?}.", hash, a, b); @@ -1368,7 +1363,6 @@ where async fn import_state( &mut self, mut block: BlockImportParams<Block, sp_api::TransactionFor<Client, Block>>, - new_cache: HashMap<CacheKeyId, Vec<u8>>, ) -> Result<ImportResult, ConsensusError> { let hash = block.post_hash(); let parent_hash = *block.header.parent_hash(); @@ -1383,7 +1377,7 @@ where }); // First make the client import the state. - let import_result = self.inner.import_block(block, new_cache).await; + let import_result = self.inner.import_block(block).await; let aux = match import_result { Ok(ImportResult::Imported(aux)) => aux, Ok(r) => @@ -1433,7 +1427,6 @@ where async fn import_block( &mut self, mut block: BlockImportParams<Block, Self::Transaction>, - new_cache: HashMap<CacheKeyId, Vec<u8>>, ) -> Result<ImportResult, Self::Error> { let hash = block.post_hash(); let number = *block.header.number(); @@ -1454,11 +1447,11 @@ where // In case of initial sync intermediates should not be present... let _ = block.remove_intermediate::<BabeIntermediate<Block>>(INTERMEDIATE_KEY); block.fork_choice = Some(ForkChoiceStrategy::Custom(false)); - return self.inner.import_block(block, new_cache).await.map_err(Into::into) + return self.inner.import_block(block).await.map_err(Into::into) } if block.with_state() { - return self.import_state(block, new_cache).await + return self.import_state(block).await } let pre_digest = find_pre_digest::<Block>(&block.header).expect( @@ -1694,7 +1687,7 @@ where epoch_changes.release_mutex() }; - let import_result = self.inner.import_block(block, new_cache).await; + let import_result = self.inner.import_block(block).await; // revert to the original epoch changes in case there's an error // importing the block diff --git a/substrate/client/consensus/babe/src/tests.rs b/substrate/client/consensus/babe/src/tests.rs index fcdada94c453841cf92c9f2e8b7bf5374e11d73c..25f1f87235702ecaa78acf6cfed054d175a045ff 100644 --- a/substrate/client/consensus/babe/src/tests.rs +++ b/substrate/client/consensus/babe/src/tests.rs @@ -209,9 +209,8 @@ where async fn import_block( &mut self, block: BlockImportParams<TestBlock, Self::Transaction>, - new_cache: HashMap<CacheKeyId, Vec<u8>>, ) -> Result<ImportResult, Self::Error> { - Ok(self.0.import_block(block, new_cache).await.expect("importing block failed")) + Ok(self.0.import_block(block).await.expect("importing block failed")) } async fn check_block( @@ -258,7 +257,7 @@ impl Verifier<TestBlock> for TestVerifier { async fn verify( &mut self, mut block: BlockImportParams<TestBlock, ()>, - ) -> Result<(BlockImportParams<TestBlock, ()>, Option<Vec<(CacheKeyId, Vec<u8>)>>), String> { + ) -> Result<BlockImportParams<TestBlock, ()>, String> { // apply post-sealing mutations (i.e. stripping seal, if desired). (self.mutator)(&mut block.header, Stage::PostSeal); self.inner.verify(block).await @@ -743,7 +742,7 @@ async fn propose_and_import_block<Transaction: Send + 'static>( import .insert_intermediate(INTERMEDIATE_KEY, BabeIntermediate::<TestBlock> { epoch_descriptor }); import.fork_choice = Some(ForkChoiceStrategy::LongestChain); - let import_result = block_import.import_block(import, Default::default()).await.unwrap(); + let import_result = block_import.import_block(import).await.unwrap(); match import_result { ImportResult::Imported(_) => {}, diff --git a/substrate/client/consensus/beefy/src/import.rs b/substrate/client/consensus/beefy/src/import.rs index 177a99b1066b2315feff91c6b7b2ce517044596b..dd2ed92ef83536005cfbb8ca71c1fd3ae41e2f29 100644 --- a/substrate/client/consensus/beefy/src/import.rs +++ b/substrate/client/consensus/beefy/src/import.rs @@ -16,13 +16,13 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see <https://www.gnu.org/licenses/>. +use std::sync::Arc; + use log::debug; -use sp_consensus_beefy::{BeefyApi, BEEFY_ENGINE_ID}; -use std::{collections::HashMap, sync::Arc}; use sp_api::{ProvideRuntimeApi, TransactionFor}; -use sp_blockchain::well_known_cache_keys; use sp_consensus::Error as ConsensusError; +use sp_consensus_beefy::{BeefyApi, BEEFY_ENGINE_ID}; use sp_runtime::{ traits::{Block as BlockT, Header as HeaderT, NumberFor}, EncodedJustification, @@ -132,7 +132,6 @@ where async fn import_block( &mut self, mut block: BlockImportParams<Block, Self::Transaction>, - new_cache: HashMap<well_known_cache_keys::Id, Vec<u8>>, ) -> Result<ImportResult, Self::Error> { let hash = block.post_hash(); let number = *block.header.number(); @@ -146,7 +145,7 @@ where }); // Run inner block import. - let inner_import_result = self.inner.import_block(block, new_cache).await?; + let inner_import_result = self.inner.import_block(block).await?; match (beefy_encoded, &inner_import_result) { (Some(encoded), ImportResult::Imported(_)) => { diff --git a/substrate/client/consensus/beefy/src/tests.rs b/substrate/client/consensus/beefy/src/tests.rs index fb1c45b90a83a1f906aa75a61737de7e6d98f151..44920aaa6faa9f5f7289a01659ae5a8ebf500ad5 100644 --- a/substrate/client/consensus/beefy/src/tests.rs +++ b/substrate/client/consensus/beefy/src/tests.rs @@ -61,7 +61,7 @@ use sp_runtime::{ traits::{Header as HeaderT, NumberFor}, BuildStorage, DigestItem, EncodedJustification, Justifications, Storage, }; -use std::{collections::HashMap, marker::PhantomData, sync::Arc, task::Poll}; +use std::{marker::PhantomData, sync::Arc, task::Poll}; use substrate_test_runtime_client::{runtime::Header, ClientExt}; use tokio::time::Duration; @@ -766,14 +766,11 @@ async fn beefy_importing_justifications() { // Import block 1 without justifications. assert_eq!( - block_import - .import_block(params(block.clone(), None), HashMap::new()) - .await - .unwrap(), + block_import.import_block(params(block.clone(), None)).await.unwrap(), ImportResult::Imported(ImportedAux { is_new_best: true, ..Default::default() }), ); assert_eq!( - block_import.import_block(params(block, None), HashMap::new()).await.unwrap(), + block_import.import_block(params(block, None)).await.unwrap(), ImportResult::AlreadyInChain, ); @@ -788,7 +785,7 @@ async fn beefy_importing_justifications() { let encoded = versioned_proof.encode(); let justif = Some(Justifications::from((BEEFY_ENGINE_ID, encoded))); assert_eq!( - block_import.import_block(params(block, justif), HashMap::new()).await.unwrap(), + block_import.import_block(params(block, justif)).await.unwrap(), ImportResult::Imported(ImportedAux { bad_justification: false, is_new_best: true, @@ -820,7 +817,7 @@ async fn beefy_importing_justifications() { let justif = Some(Justifications::from((BEEFY_ENGINE_ID, encoded))); let mut justif_recv = justif_stream.subscribe(100_000); assert_eq!( - block_import.import_block(params(block, justif), HashMap::new()).await.unwrap(), + block_import.import_block(params(block, justif)).await.unwrap(), ImportResult::Imported(ImportedAux { bad_justification: false, is_new_best: true, @@ -856,7 +853,7 @@ async fn beefy_importing_justifications() { let justif = Some(Justifications::from((BEEFY_ENGINE_ID, encoded))); let mut justif_recv = justif_stream.subscribe(100_000); assert_eq!( - block_import.import_block(params(block, justif), HashMap::new()).await.unwrap(), + block_import.import_block(params(block, justif)).await.unwrap(), ImportResult::Imported(ImportedAux { // Still `false` because we don't want to fail import on bad BEEFY justifications. bad_justification: false, diff --git a/substrate/client/consensus/common/src/block_import.rs b/substrate/client/consensus/common/src/block_import.rs index 98accc1d2f8c4a533e4d28adc12bf14ec45b0abb..70bf0283af2d9f59673c9bb7172f6a7d882181f6 100644 --- a/substrate/client/consensus/common/src/block_import.rs +++ b/substrate/client/consensus/common/src/block_import.rs @@ -25,7 +25,7 @@ use sp_runtime::{ }; use std::{any::Any, borrow::Cow, collections::HashMap, sync::Arc}; -use sp_consensus::{BlockOrigin, CacheKeyId, Error}; +use sp_consensus::{BlockOrigin, Error}; /// Block import result. #[derive(Debug, PartialEq, Eq)] @@ -348,12 +348,9 @@ pub trait BlockImport<B: BlockT> { ) -> Result<ImportResult, Self::Error>; /// Import a block. - /// - /// Cached data can be accessed through the blockchain cache. async fn import_block( &mut self, block: BlockImportParams<B, Self::Transaction>, - cache: HashMap<CacheKeyId, Vec<u8>>, ) -> Result<ImportResult, Self::Error>; } @@ -374,14 +371,11 @@ where } /// Import a block. - /// - /// Cached data can be accessed through the blockchain cache. async fn import_block( &mut self, block: BlockImportParams<B, Transaction>, - cache: HashMap<CacheKeyId, Vec<u8>>, ) -> Result<ImportResult, Self::Error> { - (**self).import_block(block, cache).await + (**self).import_block(block).await } } @@ -405,9 +399,8 @@ where async fn import_block( &mut self, block: BlockImportParams<B, Transaction>, - cache: HashMap<CacheKeyId, Vec<u8>>, ) -> Result<ImportResult, Self::Error> { - (&**self).import_block(block, cache).await + (&**self).import_block(block).await } } diff --git a/substrate/client/consensus/common/src/import_queue.rs b/substrate/client/consensus/common/src/import_queue.rs index 66ff5e6d5e12f94de0a62311d6c953dcbd1e46ee..cec9aca47e29f0acbb0726ebbb123f50a8bbd84e 100644 --- a/substrate/client/consensus/common/src/import_queue.rs +++ b/substrate/client/consensus/common/src/import_queue.rs @@ -27,9 +27,9 @@ //! instantiated. The `BasicQueue` and `BasicVerifier` traits allow serial //! queues to be instantiated simply. -use std::{collections::HashMap, iter::FromIterator}; - use log::{debug, trace}; + +use sp_consensus::{error::Error as ConsensusError, BlockOrigin}; use sp_runtime::{ traits::{Block as BlockT, Header as _, NumberFor}, Justifications, @@ -42,8 +42,8 @@ use crate::{ }, metrics::Metrics, }; + pub use basic_queue::BasicQueue; -use sp_consensus::{error::Error as ConsensusError, BlockOrigin, CacheKeyId}; const LOG_TARGET: &str = "sync::import-queue"; @@ -96,13 +96,12 @@ pub struct IncomingBlock<B: BlockT> { /// Verify a justification of a block #[async_trait::async_trait] pub trait Verifier<B: BlockT>: Send + Sync { - /// Verify the given data and return the BlockImportParams and an optional - /// new set of validators to import. If not, err with an Error-Message - /// presented to the User in the logs. + /// Verify the given block data and return the `BlockImportParams` to + /// continue the block import process. async fn verify( &mut self, block: BlockImportParams<B, ()>, - ) -> Result<(BlockImportParams<B, ()>, Option<Vec<(CacheKeyId, Vec<u8>)>>), String>; + ) -> Result<BlockImportParams<B, ()>, String>; } /// Blocks import queue API. @@ -328,7 +327,7 @@ pub(crate) async fn import_single_block_metered< import_block.state_action = StateAction::ExecuteIfPossible; } - let (import_block, maybe_keys) = verifier.verify(import_block).await.map_err(|msg| { + let import_block = verifier.verify(import_block).await.map_err(|msg| { if let Some(ref peer) = peer { trace!( target: LOG_TARGET, @@ -351,9 +350,8 @@ pub(crate) async fn import_single_block_metered< metrics.report_verification(true, started.elapsed()); } - let cache = HashMap::from_iter(maybe_keys.unwrap_or_default()); let import_block = import_block.clear_storage_changes_and_mutate(); - let imported = import_handle.import_block(import_block, cache).await; + let imported = import_handle.import_block(import_block).await; if let Some(metrics) = metrics.as_ref() { metrics.report_verification_and_import(started.elapsed()); } diff --git a/substrate/client/consensus/common/src/import_queue/basic_queue.rs b/substrate/client/consensus/common/src/import_queue/basic_queue.rs index 6404708151f008818094e1b646903c00a1404f0b..653c88321554efb8848ab13252268744d13b8d35 100644 --- a/substrate/client/consensus/common/src/import_queue/basic_queue.rs +++ b/substrate/client/consensus/common/src/import_queue/basic_queue.rs @@ -504,19 +504,18 @@ mod tests { block_import::{ BlockCheckParams, BlockImport, BlockImportParams, ImportResult, JustificationImport, }, - import_queue::{CacheKeyId, Verifier}, + import_queue::Verifier, }; use futures::{executor::block_on, Future}; use sp_test_primitives::{Block, BlockNumber, Extrinsic, Hash, Header}; - use std::collections::HashMap; #[async_trait::async_trait] impl Verifier<Block> for () { async fn verify( &mut self, block: BlockImportParams<Block, ()>, - ) -> Result<(BlockImportParams<Block, ()>, Option<Vec<(CacheKeyId, Vec<u8>)>>), String> { - Ok((BlockImportParams::new(block.origin, block.header), None)) + ) -> Result<BlockImportParams<Block, ()>, String> { + Ok(BlockImportParams::new(block.origin, block.header)) } } @@ -535,7 +534,6 @@ mod tests { async fn import_block( &mut self, _block: BlockImportParams<Block, Self::Transaction>, - _cache: HashMap<CacheKeyId, Vec<u8>>, ) -> Result<ImportResult, Self::Error> { Ok(ImportResult::imported(true)) } diff --git a/substrate/client/consensus/grandpa/src/import.rs b/substrate/client/consensus/grandpa/src/import.rs index c1f6cb566dae9f134bdb7de74efd9f1f30ce28db..cd13f832ce6dc55f6d38a1157d8ba77cca5a44c5 100644 --- a/substrate/client/consensus/grandpa/src/import.rs +++ b/substrate/client/consensus/grandpa/src/import.rs @@ -29,7 +29,7 @@ use sc_consensus::{ use sc_telemetry::TelemetryHandle; use sc_utils::mpsc::TracingUnboundedSender; use sp_api::{Core, RuntimeApiInfo, TransactionFor}; -use sp_blockchain::{well_known_cache_keys, BlockStatus}; +use sp_blockchain::BlockStatus; use sp_consensus::{BlockOrigin, Error as ConsensusError, SelectChain}; use sp_consensus_grandpa::{ConsensusLog, GrandpaApi, ScheduledChange, SetId, GRANDPA_ENGINE_ID}; use sp_core::hashing::twox_128; @@ -460,13 +460,12 @@ where async fn import_state( &mut self, mut block: BlockImportParams<Block, TransactionFor<Client, Block>>, - new_cache: HashMap<well_known_cache_keys::Id, Vec<u8>>, ) -> Result<ImportResult, ConsensusError> { let hash = block.post_hash(); let number = *block.header.number(); // Force imported state finality. block.finalized = true; - let import_result = (&*self.inner).import_block(block, new_cache).await; + let import_result = (&*self.inner).import_block(block).await; match import_result { Ok(ImportResult::Imported(aux)) => { // We've just imported a new state. We trust the sync module has verified @@ -526,7 +525,6 @@ where async fn import_block( &mut self, mut block: BlockImportParams<Block, Self::Transaction>, - new_cache: HashMap<well_known_cache_keys::Id, Vec<u8>>, ) -> Result<ImportResult, Self::Error> { let hash = block.post_hash(); let number = *block.header.number(); @@ -537,14 +535,14 @@ where Ok(BlockStatus::InChain) => { // Strip justifications when re-importing an existing block. let _justifications = block.justifications.take(); - return (&*self.inner).import_block(block, new_cache).await + return (&*self.inner).import_block(block).await }, Ok(BlockStatus::Unknown) => {}, Err(e) => return Err(ConsensusError::ClientImport(e.to_string())), } if block.with_state() { - return self.import_state(block, new_cache).await + return self.import_state(block).await } if number <= self.inner.info().finalized_number { @@ -570,7 +568,7 @@ where }, ); } - return (&*self.inner).import_block(block, new_cache).await + return (&*self.inner).import_block(block).await } // on initial sync we will restrict logging under info to avoid spam. @@ -580,7 +578,7 @@ where // we don't want to finalize on `inner.import_block` let mut justifications = block.justifications.take(); - let import_result = (&*self.inner).import_block(block, new_cache).await; + let import_result = (&*self.inner).import_block(block).await; let mut imported_aux = { match import_result { diff --git a/substrate/client/consensus/grandpa/src/tests.rs b/substrate/client/consensus/grandpa/src/tests.rs index f7747a20301f51b368746b527b6a56212e9ab0d8..f5e5c45e7420713285bb4b88885e961b39f42e6a 100644 --- a/substrate/client/consensus/grandpa/src/tests.rs +++ b/substrate/client/consensus/grandpa/src/tests.rs @@ -47,10 +47,7 @@ use sp_runtime::{ traits::{Block as BlockT, Header as HeaderT}, Justifications, }; -use std::{ - collections::{HashMap, HashSet}, - pin::Pin, -}; +use std::{collections::HashSet, pin::Pin}; use substrate_test_runtime_client::runtime::BlockNumber; use tokio::runtime::Handle; @@ -906,7 +903,7 @@ async fn allows_reimporting_change_blocks() { }; assert_eq!( - block_import.import_block(block(), HashMap::new()).await.unwrap(), + block_import.import_block(block()).await.unwrap(), ImportResult::Imported(ImportedAux { needs_justification: true, clear_justification_requests: false, @@ -916,10 +913,7 @@ async fn allows_reimporting_change_blocks() { }), ); - assert_eq!( - block_import.import_block(block(), HashMap::new()).await.unwrap(), - ImportResult::AlreadyInChain - ); + assert_eq!(block_import.import_block(block()).await.unwrap(), ImportResult::AlreadyInChain); } #[tokio::test] @@ -955,7 +949,7 @@ async fn test_bad_justification() { }; assert_eq!( - block_import.import_block(block(), HashMap::new()).await.unwrap(), + block_import.import_block(block()).await.unwrap(), ImportResult::Imported(ImportedAux { needs_justification: true, clear_justification_requests: false, @@ -965,10 +959,7 @@ async fn test_bad_justification() { }), ); - assert_eq!( - block_import.import_block(block(), HashMap::new()).await.unwrap(), - ImportResult::AlreadyInChain - ); + assert_eq!(block_import.import_block(block()).await.unwrap(), ImportResult::AlreadyInChain); } #[tokio::test] @@ -1938,7 +1929,7 @@ async fn imports_justification_for_regular_blocks_on_import() { import.fork_choice = Some(ForkChoiceStrategy::LongestChain); assert_eq!( - block_import.import_block(import, HashMap::new()).await.unwrap(), + block_import.import_block(import).await.unwrap(), ImportResult::Imported(ImportedAux { needs_justification: false, clear_justification_requests: false, diff --git a/substrate/client/consensus/manual-seal/src/consensus/babe.rs b/substrate/client/consensus/manual-seal/src/consensus/babe.rs index 476d2f0f4094d2d45d9b91a965bf697396e51eaf..3d21fd73d95aecaec3b51ef0475ee6cc52d076ba 100644 --- a/substrate/client/consensus/manual-seal/src/consensus/babe.rs +++ b/substrate/client/consensus/manual-seal/src/consensus/babe.rs @@ -35,7 +35,6 @@ use std::{marker::PhantomData, sync::Arc}; use sc_consensus::{BlockImportParams, ForkChoiceStrategy, Verifier}; use sp_api::{ProvideRuntimeApi, TransactionFor}; use sp_blockchain::{HeaderBackend, HeaderMetadata}; -use sp_consensus::CacheKeyId; use sp_consensus_babe::{ digests::{NextEpochDescriptor, PreDigest, SecondaryPlainPreDigest}, inherents::BabeInherentData, @@ -99,7 +98,7 @@ where async fn verify( &mut self, mut import_params: BlockImportParams<B, ()>, - ) -> Result<(BlockImportParams<B, ()>, Option<Vec<(CacheKeyId, Vec<u8>)>>), String> { + ) -> Result<BlockImportParams<B, ()>, String> { import_params.finalized = false; import_params.fork_choice = Some(ForkChoiceStrategy::LongestChain); @@ -128,7 +127,7 @@ where import_params .insert_intermediate(INTERMEDIATE_KEY, BabeIntermediate::<B> { epoch_descriptor }); - Ok((import_params, None)) + Ok(import_params) } } diff --git a/substrate/client/consensus/manual-seal/src/lib.rs b/substrate/client/consensus/manual-seal/src/lib.rs index 41f1f443355251da25ae63d7f34682f6040ca37a..b277b34366577a098a67ff002dd1a26866d51ccd 100644 --- a/substrate/client/consensus/manual-seal/src/lib.rs +++ b/substrate/client/consensus/manual-seal/src/lib.rs @@ -27,7 +27,7 @@ use sc_consensus::{ import_queue::{BasicQueue, BoxBlockImport, Verifier}, }; use sp_blockchain::HeaderBackend; -use sp_consensus::{CacheKeyId, Environment, Proposer, SelectChain}; +use sp_consensus::{Environment, Proposer, SelectChain}; use sp_inherents::CreateInherentDataProviders; use sp_runtime::{traits::Block as BlockT, ConsensusEngineId}; use std::{marker::PhantomData, sync::Arc}; @@ -62,10 +62,10 @@ impl<B: BlockT> Verifier<B> for ManualSealVerifier { async fn verify( &mut self, mut block: BlockImportParams<B, ()>, - ) -> Result<(BlockImportParams<B, ()>, Option<Vec<(CacheKeyId, Vec<u8>)>>), String> { + ) -> Result<BlockImportParams<B, ()>, String> { block.finalized = false; block.fork_choice = Some(ForkChoiceStrategy::LongestChain); - Ok((block, None)) + Ok(block) } } diff --git a/substrate/client/consensus/manual-seal/src/seal_block.rs b/substrate/client/consensus/manual-seal/src/seal_block.rs index eda3d91c9782b4c602519dde510f34f122043489..e6133bccae885b1c34f1e917fc294eac98917b46 100644 --- a/substrate/client/consensus/manual-seal/src/seal_block.rs +++ b/substrate/client/consensus/manual-seal/src/seal_block.rs @@ -27,7 +27,7 @@ use sp_blockchain::HeaderBackend; use sp_consensus::{self, BlockOrigin, Environment, Proposer, SelectChain}; use sp_inherents::{CreateInherentDataProviders, InherentDataProvider}; use sp_runtime::traits::{Block as BlockT, Header as HeaderT}; -use std::{collections::HashMap, sync::Arc, time::Duration}; +use std::{sync::Arc, time::Duration}; /// max duration for creating a proposal in secs pub const MAX_PROPOSAL_DURATION: u64 = 10; @@ -153,7 +153,7 @@ pub async fn seal_block<B, BI, SC, C, E, TP, CIDP, P>( let mut post_header = header.clone(); post_header.digest_mut().logs.extend(params.post_digests.iter().cloned()); - match block_import.import_block(params, HashMap::new()).await? { + match block_import.import_block(params).await? { ImportResult::Imported(aux) => Ok(CreatedBlock { hash: <B as BlockT>::Header::hash(&post_header), aux }), other => Err(other.into()), diff --git a/substrate/client/consensus/pow/src/lib.rs b/substrate/client/consensus/pow/src/lib.rs index 513386fb22ac092ba769c3b47df0d0b940eec0a9..913686b7bf36da23e5bb0edd730bdf6348bd0578 100644 --- a/substrate/client/consensus/pow/src/lib.rs +++ b/substrate/client/consensus/pow/src/lib.rs @@ -55,7 +55,7 @@ use sc_consensus::{ }; use sp_api::ProvideRuntimeApi; use sp_block_builder::BlockBuilder as BlockBuilderApi; -use sp_blockchain::{well_known_cache_keys::Id as CacheKeyId, HeaderBackend}; +use sp_blockchain::HeaderBackend; use sp_consensus::{Environment, Error as ConsensusError, Proposer, SelectChain, SyncOracle}; use sp_consensus_pow::{Seal, TotalDifficulty, POW_ENGINE_ID}; use sp_core::ExecutionContext; @@ -65,7 +65,7 @@ use sp_runtime::{ traits::{Block as BlockT, Header as HeaderT}, RuntimeString, }; -use std::{cmp::Ordering, collections::HashMap, marker::PhantomData, sync::Arc, time::Duration}; +use std::{cmp::Ordering, marker::PhantomData, sync::Arc, time::Duration}; const LOG_TARGET: &str = "pow"; @@ -325,7 +325,6 @@ where async fn import_block( &mut self, mut block: BlockImportParams<B, Self::Transaction>, - new_cache: HashMap<CacheKeyId, Vec<u8>>, ) -> Result<ImportResult, Self::Error> { let best_header = self .select_chain @@ -399,7 +398,7 @@ where )); } - self.inner.import_block(block, new_cache).await.map_err(Into::into) + self.inner.import_block(block).await.map_err(Into::into) } } @@ -449,7 +448,7 @@ where async fn verify( &mut self, mut block: BlockImportParams<B, ()>, - ) -> Result<(BlockImportParams<B, ()>, Option<Vec<(CacheKeyId, Vec<u8>)>>), String> { + ) -> Result<BlockImportParams<B, ()>, String> { let hash = block.header.hash(); let (checked_header, seal) = self.check_header(block.header)?; @@ -459,7 +458,7 @@ where block.insert_intermediate(INTERMEDIATE_KEY, intermediate); block.post_hash = Some(hash); - Ok((block, None)) + Ok(block) } } diff --git a/substrate/client/consensus/pow/src/worker.rs b/substrate/client/consensus/pow/src/worker.rs index 1a423895770fb3afd100e0e9fce4fdd3f09f9685..3cb5dfcc09260a6d9dec050f7febdd61954a7c5d 100644 --- a/substrate/client/consensus/pow/src/worker.rs +++ b/substrate/client/consensus/pow/src/worker.rs @@ -32,7 +32,6 @@ use sp_runtime::{ DigestItem, }; use std::{ - collections::HashMap, pin::Pin, sync::{ atomic::{AtomicUsize, Ordering}, @@ -203,7 +202,7 @@ where let header = import_block.post_header(); let mut block_import = self.block_import.lock(); - match block_import.import_block(import_block, HashMap::default()).await { + match block_import.import_block(import_block).await { Ok(res) => { res.handle_justification( &header.hash(), diff --git a/substrate/client/consensus/slots/src/lib.rs b/substrate/client/consensus/slots/src/lib.rs index ec6481a87f6d4ebc36e84848acde16d9293d248e..c18284de6a088e68a2c7a1cbe3b42b6cc792287f 100644 --- a/substrate/client/consensus/slots/src/lib.rs +++ b/substrate/client/consensus/slots/src/lib.rs @@ -424,7 +424,7 @@ pub trait SimpleSlotWorker<B: BlockT> { ); let header = block_import_params.post_header(); - match self.block_import().import_block(block_import_params, Default::default()).await { + match self.block_import().import_block(block_import_params).await { Ok(res) => { res.handle_justification( &header.hash(), diff --git a/substrate/client/db/src/lib.rs b/substrate/client/db/src/lib.rs index b78c66228390de2a900926fec279a3f5db27b311..c62b9ce0e7a6156e7b47d89a898168cb87729ed8 100644 --- a/substrate/client/db/src/lib.rs +++ b/substrate/client/db/src/lib.rs @@ -68,8 +68,8 @@ use sc_client_api::{ use sc_state_db::{IsPruned, LastCanonicalized, StateDb}; use sp_arithmetic::traits::Saturating; use sp_blockchain::{ - well_known_cache_keys, Backend as _, CachedHeaderMetadata, Error as ClientError, HeaderBackend, - HeaderMetadata, HeaderMetadataCache, Result as ClientResult, + Backend as _, CachedHeaderMetadata, Error as ClientError, HeaderBackend, HeaderMetadata, + HeaderMetadataCache, Result as ClientResult, }; use sp_core::{ offchain::OffchainOverlayedChange, @@ -913,10 +913,6 @@ impl<Block: BlockT> sc_client_api::backend::BlockImportOperation<Block> Ok(()) } - fn update_cache(&mut self, _cache: HashMap<well_known_cache_keys::Id, Vec<u8>>) { - // Currently cache isn't implemented on full nodes. - } - fn update_db_storage(&mut self, update: PrefixedMemoryDB<HashFor<Block>>) -> ClientResult<()> { self.db_updates = update; Ok(()) diff --git a/substrate/client/network/src/service/tests/mod.rs b/substrate/client/network/src/service/tests/mod.rs index 3ac7829003f458c09a85b52a723b8dc669df5cc4..f29e43e6ce3660db47036a1f000ba3783e4c9af1 100644 --- a/substrate/client/network/src/service/tests/mod.rs +++ b/substrate/client/network/src/service/tests/mod.rs @@ -33,7 +33,7 @@ use sc_network_sync::{ service::network::{NetworkServiceHandle, NetworkServiceProvider}, state_request_handler::StateRequestHandler, }; -use sp_runtime::traits::{Block as BlockT, Header as _}; +use sp_runtime::traits::Block as BlockT; use std::sync::Arc; use substrate_test_runtime_client::{ runtime::{Block as TestBlock, Hash as TestHash}, @@ -135,31 +135,10 @@ impl TestNetworkBuilder { async fn verify( &mut self, mut block: sc_consensus::BlockImportParams<B, ()>, - ) -> Result< - ( - sc_consensus::BlockImportParams<B, ()>, - Option<Vec<(sp_blockchain::well_known_cache_keys::Id, Vec<u8>)>>, - ), - String, - > { - let maybe_keys = block - .header - .digest() - .log(|l| { - l.try_as_raw(sp_runtime::generic::OpaqueDigestItemId::Consensus(b"aura")) - .or_else(|| { - l.try_as_raw(sp_runtime::generic::OpaqueDigestItemId::Consensus( - b"babe", - )) - }) - }) - .map(|blob| { - vec![(sp_blockchain::well_known_cache_keys::AUTHORITIES, blob.to_vec())] - }); - + ) -> Result<sc_consensus::BlockImportParams<B, ()>, String> { block.finalized = self.0; block.fork_choice = Some(sc_consensus::ForkChoiceStrategy::LongestChain); - Ok((block, maybe_keys)) + Ok(block) } } diff --git a/substrate/client/network/test/src/lib.rs b/substrate/client/network/test/src/lib.rs index 95381dd7b4cf1279bffd9ff19a1bc3ef6d1baf9a..a79e17e2fb6d1156c49702493ecb52f04570009a 100644 --- a/substrate/client/network/test/src/lib.rs +++ b/substrate/client/network/test/src/lib.rs @@ -67,7 +67,6 @@ use sc_network_sync::{ }; use sc_service::client::Client; use sp_blockchain::{ - well_known_cache_keys::{self, Id as CacheKeyId}, Backend as BlockchainBackend, HeaderBackend, Info as BlockchainInfo, Result as ClientResult, }; use sp_consensus::{ @@ -77,7 +76,7 @@ use sp_consensus::{ use sp_core::H256; use sp_runtime::{ codec::{Decode, Encode}, - generic::{BlockId, OpaqueDigestItemId}, + generic::BlockId, traits::{Block as BlockT, Header as HeaderT, NumberFor}, Justification, Justifications, }; @@ -112,20 +111,12 @@ impl<B: BlockT> Verifier<B> for PassThroughVerifier { async fn verify( &mut self, mut block: BlockImportParams<B, ()>, - ) -> Result<(BlockImportParams<B, ()>, Option<Vec<(CacheKeyId, Vec<u8>)>>), String> { - let maybe_keys = block - .header - .digest() - .log(|l| { - l.try_as_raw(OpaqueDigestItemId::Consensus(b"aura")) - .or_else(|| l.try_as_raw(OpaqueDigestItemId::Consensus(b"babe"))) - }) - .map(|blob| vec![(well_known_cache_keys::AUTHORITIES, blob.to_vec())]); + ) -> Result<BlockImportParams<B, ()>, String> { if block.fork_choice.is_none() { block.fork_choice = Some(ForkChoiceStrategy::LongestChain); }; block.finalized = self.finalized; - Ok((block, maybe_keys)) + Ok(block) } } @@ -224,9 +215,8 @@ impl BlockImport<Block> for PeersClient { async fn import_block( &mut self, block: BlockImportParams<Block, ()>, - cache: HashMap<well_known_cache_keys::Id, Vec<u8>>, ) -> Result<ImportResult, Self::Error> { - self.client.import_block(block.clear_storage_changes_and_mutate(), cache).await + self.client.import_block(block.clear_storage_changes_and_mutate()).await } } @@ -392,15 +382,10 @@ where let mut import_block = BlockImportParams::new(origin, header.clone()); import_block.body = if headers_only { None } else { Some(block.extrinsics) }; import_block.fork_choice = Some(fork_choice); - let (import_block, cache) = + let import_block = futures::executor::block_on(self.verifier.verify(import_block)).unwrap(); - let cache = if let Some(cache) = cache { - cache.into_iter().collect() - } else { - Default::default() - }; - futures::executor::block_on(self.block_import.import_block(import_block, cache)) + futures::executor::block_on(self.block_import.import_block(import_block)) .expect("block_import failed"); if announce_block { self.sync_service.announce_block(hash, None); @@ -633,9 +618,8 @@ where async fn import_block( &mut self, block: BlockImportParams<Block, Self::Transaction>, - cache: HashMap<well_known_cache_keys::Id, Vec<u8>>, ) -> Result<ImportResult, Self::Error> { - self.inner.import_block(block.clear_storage_changes_and_mutate(), cache).await + self.inner.import_block(block.clear_storage_changes_and_mutate()).await } } @@ -650,7 +634,7 @@ impl<B: BlockT> Verifier<B> for VerifierAdapter<B> { async fn verify( &mut self, block: BlockImportParams<B, ()>, - ) -> Result<(BlockImportParams<B, ()>, Option<Vec<(CacheKeyId, Vec<u8>)>>), String> { + ) -> Result<BlockImportParams<B, ()>, String> { let hash = block.header.hash(); self.verifier.lock().await.verify(block).await.map_err(|e| { self.failed_verifications.lock().insert(hash, e.clone()); diff --git a/substrate/client/service/src/client/client.rs b/substrate/client/service/src/client/client.rs index 9a2a376ebc19f7509b21f880d87a02c21149e1a8..3613cc760f569493f1c4c6727e345d2c7dcd9f63 100644 --- a/substrate/client/service/src/client/client.rs +++ b/substrate/client/service/src/client/client.rs @@ -51,8 +51,8 @@ use sp_api::{ ProvideRuntimeApi, }; use sp_blockchain::{ - self as blockchain, well_known_cache_keys::Id as CacheKeyId, Backend as ChainBackend, - CachedHeaderMetadata, Error, HeaderBackend as ChainHeaderBackend, HeaderMetadata, + self as blockchain, Backend as ChainBackend, CachedHeaderMetadata, Error, + HeaderBackend as ChainHeaderBackend, HeaderMetadata, }; use sp_consensus::{BlockOrigin, BlockStatus, Error as ConsensusError}; @@ -504,7 +504,6 @@ where &self, operation: &mut ClientImportOperation<Block, B>, import_block: BlockImportParams<Block, backend::TransactionFor<B, Block>>, - new_cache: HashMap<CacheKeyId, Vec<u8>>, storage_changes: Option< sc_consensus::StorageChanges<Block, backend::TransactionFor<B, Block>>, >, @@ -559,7 +558,6 @@ where body, indexed_body, storage_changes, - new_cache, finalized, auxiliary, fork_choice, @@ -599,7 +597,6 @@ where storage_changes: Option< sc_consensus::StorageChanges<Block, backend::TransactionFor<B, Block>>, >, - new_cache: HashMap<CacheKeyId, Vec<u8>>, finalized: bool, aux: Vec<(Vec<u8>, Option<Vec<u8>>)>, fork_choice: ForkChoiceStrategy, @@ -712,7 +709,6 @@ where }, }; - operation.op.update_cache(new_cache); storage_changes }, None => None, @@ -1770,7 +1766,6 @@ where async fn import_block( &mut self, mut import_block: BlockImportParams<Block, backend::TransactionFor<B, Block>>, - new_cache: HashMap<CacheKeyId, Vec<u8>>, ) -> Result<ImportResult, Self::Error> { let span = tracing::span!(tracing::Level::DEBUG, "import_block"); let _enter = span.enter(); @@ -1785,7 +1780,7 @@ where }; self.lock_import_and_run(|operation| { - self.apply_block(operation, import_block, new_cache, storage_changes) + self.apply_block(operation, import_block, storage_changes) }) .map_err(|e| { warn!("Block import error: {}", e); @@ -1875,9 +1870,8 @@ where async fn import_block( &mut self, import_block: BlockImportParams<Block, Self::Transaction>, - new_cache: HashMap<CacheKeyId, Vec<u8>>, ) -> Result<ImportResult, Self::Error> { - (&*self).import_block(import_block, new_cache).await + (&*self).import_block(import_block).await } async fn check_block( diff --git a/substrate/client/service/test/src/client/mod.rs b/substrate/client/service/test/src/client/mod.rs index c7b19ca8ba27f276a799405995785d69bfe78879..cae69413c7a020437026168978e7f6c1391c27c7 100644 --- a/substrate/client/service/test/src/client/mod.rs +++ b/substrate/client/service/test/src/client/mod.rs @@ -930,7 +930,7 @@ fn finality_target_with_best_not_on_longest_chain() { let mut import_params = BlockImportParams::new(BlockOrigin::Own, header); import_params.body = Some(extrinsics); import_params.fork_choice = Some(ForkChoiceStrategy::Custom(false)); - block_on(client.import_block(import_params, Default::default())).unwrap(); + block_on(client.import_block(import_params)).unwrap(); // double check that B3 is still the best... assert_eq!(client.info().best_hash, b3.hash()); @@ -1963,7 +1963,7 @@ fn cleans_up_closed_notification_sinks_on_block_import() { let mut import = BlockImportParams::new(origin, header); import.body = Some(extrinsics); import.fork_choice = Some(ForkChoiceStrategy::LongestChain); - block_on(client.import_block(import, Default::default())).unwrap(); + block_on(client.import_block(import)).unwrap(); }; // after importing a block we should still have 4 notification sinks diff --git a/substrate/primitives/blockchain/src/backend.rs b/substrate/primitives/blockchain/src/backend.rs index 227559239d011abb7bf0fb2edcc78119ce7e7323..e9278be1d5d3c4c1d213fbf61db350831c604572 100644 --- a/substrate/primitives/blockchain/src/backend.rs +++ b/substrate/primitives/blockchain/src/backend.rs @@ -288,18 +288,3 @@ pub enum BlockStatus { /// Not in the queue or the blockchain. Unknown, } - -/// A list of all well known keys in the blockchain cache. -pub mod well_known_cache_keys { - /// The type representing cache keys. - pub type Id = sp_consensus::CacheKeyId; - - /// A list of authorities. - pub const AUTHORITIES: Id = *b"auth"; - - /// Current Epoch data. - pub const EPOCH: Id = *b"epch"; - - /// Changes trie configuration. - pub const CHANGES_TRIE_CONFIG: Id = *b"chtr"; -} diff --git a/substrate/primitives/consensus/common/src/lib.rs b/substrate/primitives/consensus/common/src/lib.rs index e02564654bd52b8a8b0afa397b2ab717e2102568..215b4448b4a8e5e4d7425b5060cbf40a32c26afa 100644 --- a/substrate/primitives/consensus/common/src/lib.rs +++ b/substrate/primitives/consensus/common/src/lib.rs @@ -39,9 +39,6 @@ pub use select_chain::SelectChain; pub use sp_inherents::InherentData; pub use sp_state_machine::Backend as StateBackend; -/// Type of keys in the blockchain cache that consensus module could use for its needs. -pub type CacheKeyId = [u8; 4]; - /// Block status. #[derive(Debug, PartialEq, Eq)] pub enum BlockStatus { diff --git a/substrate/test-utils/client/src/client_ext.rs b/substrate/test-utils/client/src/client_ext.rs index c73ea76a3a244e4d376256f5e00cdf86a49d16e4..a258faa5e03e39608fb757f87a8e41e84a47edd9 100644 --- a/substrate/test-utils/client/src/client_ext.rs +++ b/substrate/test-utils/client/src/client_ext.rs @@ -17,7 +17,6 @@ //! Client extension for tests. -use codec::alloc::collections::hash_map::HashMap; use sc_client_api::{backend::Finalizer, client::BlockBackend}; use sc_consensus::{BlockImport, BlockImportParams, ForkChoiceStrategy}; use sc_service::client::Client; @@ -100,7 +99,7 @@ where import.body = Some(extrinsics); import.fork_choice = Some(ForkChoiceStrategy::LongestChain); - BlockImport::import_block(self, import, HashMap::new()).await.map(|_| ()) + BlockImport::import_block(self, import).await.map(|_| ()) } async fn import_as_best( @@ -113,7 +112,7 @@ where import.body = Some(extrinsics); import.fork_choice = Some(ForkChoiceStrategy::Custom(true)); - BlockImport::import_block(self, import, HashMap::new()).await.map(|_| ()) + BlockImport::import_block(self, import).await.map(|_| ()) } async fn import_as_final( @@ -127,7 +126,7 @@ where import.finalized = true; import.fork_choice = Some(ForkChoiceStrategy::Custom(true)); - BlockImport::import_block(self, import, HashMap::new()).await.map(|_| ()) + BlockImport::import_block(self, import).await.map(|_| ()) } async fn import_justified( @@ -143,7 +142,7 @@ where import.finalized = true; import.fork_choice = Some(ForkChoiceStrategy::LongestChain); - BlockImport::import_block(self, import, HashMap::new()).await.map(|_| ()) + BlockImport::import_block(self, import).await.map(|_| ()) } } @@ -162,7 +161,7 @@ where import.body = Some(extrinsics); import.fork_choice = Some(ForkChoiceStrategy::LongestChain); - BlockImport::import_block(self, import, HashMap::new()).await.map(|_| ()) + BlockImport::import_block(self, import).await.map(|_| ()) } async fn import_as_best( @@ -175,7 +174,7 @@ where import.body = Some(extrinsics); import.fork_choice = Some(ForkChoiceStrategy::Custom(true)); - BlockImport::import_block(self, import, HashMap::new()).await.map(|_| ()) + BlockImport::import_block(self, import).await.map(|_| ()) } async fn import_as_final( @@ -189,7 +188,7 @@ where import.finalized = true; import.fork_choice = Some(ForkChoiceStrategy::Custom(true)); - BlockImport::import_block(self, import, HashMap::new()).await.map(|_| ()) + BlockImport::import_block(self, import).await.map(|_| ()) } async fn import_justified( @@ -205,6 +204,6 @@ where import.finalized = true; import.fork_choice = Some(ForkChoiceStrategy::LongestChain); - BlockImport::import_block(self, import, HashMap::new()).await.map(|_| ()) + BlockImport::import_block(self, import).await.map(|_| ()) } }