consensus: remove caching functionality from block import pipeline (#13551)

* consensus: remove caching functionality from block import pipeline

* client: update docs on Verifier::verify

* node: fix block production benchmark
This commit is contained in:
André Silva
2023-03-07 11:19:19 +00:00
committed by GitHub
parent d86a32630b
commit 13b0f24abd
29 changed files with 103 additions and 214 deletions
@@ -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);
+9 -16
View File
@@ -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
+3 -4
View File
@@ -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(_) => {},
@@ -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(_)) => {
@@ -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,
@@ -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
}
}
@@ -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());
}
@@ -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))
}
@@ -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 {
@@ -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,
@@ -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)
}
}
@@ -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)
}
}
@@ -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()),
+5 -6
View File
@@ -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)
}
}
+1 -2
View File
@@ -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(),
+1 -1
View File
@@ -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(),