diff --git a/substrate/consensus/src/import.rs b/substrate/consensus/src/import.rs index 0a02976c..62fd39bb 100644 --- a/substrate/consensus/src/import.rs +++ b/substrate/consensus/src/import.rs @@ -76,7 +76,18 @@ where type Error = Error; type Transaction = TransactionFor; - async fn check_block(&mut self, block: BlockCheckParams) -> Result { + async fn check_block( + &mut self, + mut block: BlockCheckParams, + ) -> Result { + let info = self.client.info(); + if (info.best_hash != block.parent_hash) || ((info.best_number + 1u16.into()) != block.number) { + Err(Error::Other("non-sequential import".into()))?; + } + + block.allow_missing_state = false; + block.allow_missing_parent = false; + self.inner.check_block(block).await.map_err(Into::into) } @@ -85,11 +96,6 @@ where mut block: BlockImportParams, new_cache: HashMap>, ) -> Result { - let parent_hash = *block.header.parent_hash(); - if self.client.info().best_hash != parent_hash { - Err(Error::Other("non-sequential import".into()))?; - } - if let Some(body) = block.body.clone() { if let Some(justifications) = block.justifications { let mut iter = justifications.iter(); @@ -111,7 +117,7 @@ where self .check_inherents( B::new(block.header.clone(), body), - self.providers.create_inherent_data_providers(parent_hash, ()).await?, + self.providers.create_inherent_data_providers(*block.header.parent_hash(), ()).await?, ) .await?; }