mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-17 12:31:03 +00:00
Fix warp sync (#12281)
This commit is contained in:
@@ -225,15 +225,16 @@ where
|
|||||||
|
|
||||||
inherent_data.aura_replace_inherent_data(slot);
|
inherent_data.aura_replace_inherent_data(slot);
|
||||||
|
|
||||||
// skip the inherents verification if the runtime API is old.
|
// skip the inherents verification if the runtime API is old or not expected to
|
||||||
if self
|
// exist.
|
||||||
.client
|
if !block.state_action.skip_execution_checks() &&
|
||||||
.runtime_api()
|
self.client
|
||||||
.has_api_with::<dyn BlockBuilderApi<B>, _>(
|
.runtime_api()
|
||||||
&BlockId::Hash(parent_hash),
|
.has_api_with::<dyn BlockBuilderApi<B>, _>(
|
||||||
|v| v >= 2,
|
&BlockId::Hash(parent_hash),
|
||||||
)
|
|v| v >= 2,
|
||||||
.map_err(|e| e.to_string())?
|
)
|
||||||
|
.map_err(|e| e.to_string())?
|
||||||
{
|
{
|
||||||
self.check_inherents(
|
self.check_inherents(
|
||||||
new_block.clone(),
|
new_block.clone(),
|
||||||
|
|||||||
@@ -1237,24 +1237,26 @@ where
|
|||||||
warn!(target: "babe", "Error checking/reporting BABE equivocation: {}", err);
|
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 {
|
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);
|
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(
|
self.check_inherents(
|
||||||
new_block.clone(),
|
new_block.clone(),
|
||||||
BlockId::Hash(parent_hash),
|
BlockId::Hash(parent_hash),
|
||||||
inherent_data,
|
inherent_data,
|
||||||
create_inherent_data_providers,
|
create_inherent_data_providers,
|
||||||
block.origin.into(),
|
block.origin.into(),
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
}
|
||||||
|
|
||||||
let (_, inner_body) = new_block.deconstruct();
|
let (_, inner_body) = new_block.deconstruct();
|
||||||
block.body = Some(inner_body);
|
block.body = Some(inner_body);
|
||||||
|
|||||||
@@ -153,6 +153,18 @@ pub enum StateAction<Block: BlockT, Transaction> {
|
|||||||
Skip,
|
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.
|
/// Data required to import a Block.
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
pub struct BlockImportParams<Block: BlockT, Transaction> {
|
pub struct BlockImportParams<Block: BlockT, Transaction> {
|
||||||
|
|||||||
@@ -341,15 +341,17 @@ where
|
|||||||
if let Some(inner_body) = block.body.take() {
|
if let Some(inner_body) = block.body.take() {
|
||||||
let check_block = B::new(block.header.clone(), inner_body);
|
let check_block = B::new(block.header.clone(), inner_body);
|
||||||
|
|
||||||
self.check_inherents(
|
if !block.state_action.skip_execution_checks() {
|
||||||
check_block.clone(),
|
self.check_inherents(
|
||||||
BlockId::Hash(parent_hash),
|
check_block.clone(),
|
||||||
self.create_inherent_data_providers
|
BlockId::Hash(parent_hash),
|
||||||
.create_inherent_data_providers(parent_hash, ())
|
self.create_inherent_data_providers
|
||||||
.await?,
|
.create_inherent_data_providers(parent_hash, ())
|
||||||
block.origin.into(),
|
.await?,
|
||||||
)
|
block.origin.into(),
|
||||||
.await?;
|
)
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
|
||||||
block.body = Some(check_block.deconstruct().1);
|
block.body = Some(check_block.deconstruct().1);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user