mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-30 14:17:56 +00:00
Fix warp sync (#12281)
This commit is contained in:
@@ -225,15 +225,16 @@ where
|
||||
|
||||
inherent_data.aura_replace_inherent_data(slot);
|
||||
|
||||
// skip the inherents verification if the runtime API is old.
|
||||
if self
|
||||
.client
|
||||
.runtime_api()
|
||||
.has_api_with::<dyn BlockBuilderApi<B>, _>(
|
||||
&BlockId::Hash(parent_hash),
|
||||
|v| v >= 2,
|
||||
)
|
||||
.map_err(|e| e.to_string())?
|
||||
// skip the inherents verification if the runtime API is old or not expected to
|
||||
// exist.
|
||||
if !block.state_action.skip_execution_checks() &&
|
||||
self.client
|
||||
.runtime_api()
|
||||
.has_api_with::<dyn BlockBuilderApi<B>, _>(
|
||||
&BlockId::Hash(parent_hash),
|
||||
|v| v >= 2,
|
||||
)
|
||||
.map_err(|e| e.to_string())?
|
||||
{
|
||||
self.check_inherents(
|
||||
new_block.clone(),
|
||||
|
||||
@@ -1237,24 +1237,26 @@ where
|
||||
warn!(target: "babe", "Error checking/reporting BABE equivocation: {}", err);
|
||||
}
|
||||
|
||||
// if the body is passed through, we need to use the runtime
|
||||
// to check that the internally-set timestamp in the inherents
|
||||
// actually matches the slot set in the seal.
|
||||
if let Some(inner_body) = block.body {
|
||||
let mut inherent_data = create_inherent_data_providers
|
||||
.create_inherent_data()
|
||||
.map_err(Error::<Block>::CreateInherents)?;
|
||||
inherent_data.babe_replace_inherent_data(slot);
|
||||
let new_block = Block::new(pre_header.clone(), inner_body);
|
||||
if !block.state_action.skip_execution_checks() {
|
||||
// if the body is passed through and the block was executed,
|
||||
// we need to use the runtime to check that the internally-set
|
||||
// timestamp in the inherents actually matches the slot set in the seal.
|
||||
let mut inherent_data = create_inherent_data_providers
|
||||
.create_inherent_data()
|
||||
.map_err(Error::<Block>::CreateInherents)?;
|
||||
inherent_data.babe_replace_inherent_data(slot);
|
||||
|
||||
self.check_inherents(
|
||||
new_block.clone(),
|
||||
BlockId::Hash(parent_hash),
|
||||
inherent_data,
|
||||
create_inherent_data_providers,
|
||||
block.origin.into(),
|
||||
)
|
||||
.await?;
|
||||
self.check_inherents(
|
||||
new_block.clone(),
|
||||
BlockId::Hash(parent_hash),
|
||||
inherent_data,
|
||||
create_inherent_data_providers,
|
||||
block.origin.into(),
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
|
||||
let (_, inner_body) = new_block.deconstruct();
|
||||
block.body = Some(inner_body);
|
||||
|
||||
@@ -153,6 +153,18 @@ pub enum StateAction<Block: BlockT, Transaction> {
|
||||
Skip,
|
||||
}
|
||||
|
||||
impl<Block: BlockT, Transaction> StateAction<Block, Transaction> {
|
||||
/// Check if execution checks that require runtime calls should be skipped.
|
||||
pub fn skip_execution_checks(&self) -> bool {
|
||||
match self {
|
||||
StateAction::ApplyChanges(_) |
|
||||
StateAction::Execute |
|
||||
StateAction::ExecuteIfPossible => false,
|
||||
StateAction::Skip => true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Data required to import a Block.
|
||||
#[non_exhaustive]
|
||||
pub struct BlockImportParams<Block: BlockT, Transaction> {
|
||||
|
||||
@@ -341,15 +341,17 @@ where
|
||||
if let Some(inner_body) = block.body.take() {
|
||||
let check_block = B::new(block.header.clone(), inner_body);
|
||||
|
||||
self.check_inherents(
|
||||
check_block.clone(),
|
||||
BlockId::Hash(parent_hash),
|
||||
self.create_inherent_data_providers
|
||||
.create_inherent_data_providers(parent_hash, ())
|
||||
.await?,
|
||||
block.origin.into(),
|
||||
)
|
||||
.await?;
|
||||
if !block.state_action.skip_execution_checks() {
|
||||
self.check_inherents(
|
||||
check_block.clone(),
|
||||
BlockId::Hash(parent_hash),
|
||||
self.create_inherent_data_providers
|
||||
.create_inherent_data_providers(parent_hash, ())
|
||||
.await?,
|
||||
block.origin.into(),
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
|
||||
block.body = Some(check_block.deconstruct().1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user