mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 03:31:10 +00:00
Warp sync part II (#9284)
* Gap sync * Gap epoch test * Simplified network requests * Update client/db/src/utils.rs Co-authored-by: cheme <emericchevalier.pro@gmail.com> * Fixed v1 migration and added some comments * Next epoch is always regular * Removed fork tree change * Apply suggestions from code review Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Added a comment and converted assert to error Co-authored-by: cheme <emericchevalier.pro@gmail.com> Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
use crate::error::Error;
|
||||
use codec::Encode;
|
||||
use futures::{future, prelude::*};
|
||||
use sc_client_api::{BlockBackend, UsageProvider};
|
||||
use sc_client_api::{BlockBackend, HeaderBackend};
|
||||
use sc_consensus::import_queue::ImportQueue;
|
||||
use sp_runtime::{generic::BlockId, traits::Block as BlockT};
|
||||
|
||||
@@ -33,7 +33,7 @@ pub fn check_block<B, IQ, C>(
|
||||
block_id: BlockId<B>,
|
||||
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>>
|
||||
where
|
||||
C: BlockBackend<B> + UsageProvider<B> + Send + Sync + 'static,
|
||||
C: BlockBackend<B> + HeaderBackend<B> + Send + Sync + 'static,
|
||||
B: BlockT + for<'de> serde::Deserialize<'de>,
|
||||
IQ: ImportQueue<B> + 'static,
|
||||
{
|
||||
|
||||
@@ -22,7 +22,7 @@ use futures::{future, prelude::*};
|
||||
use futures_timer::Delay;
|
||||
use log::{info, warn};
|
||||
use sc_chain_spec::ChainSpec;
|
||||
use sc_client_api::UsageProvider;
|
||||
use sc_client_api::HeaderBackend;
|
||||
use sc_consensus::import_queue::{
|
||||
BlockImportError, BlockImportStatus, ImportQueue, IncomingBlock, Link,
|
||||
};
|
||||
@@ -296,7 +296,7 @@ pub fn import_blocks<B, IQ, C>(
|
||||
binary: bool,
|
||||
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send>>
|
||||
where
|
||||
C: UsageProvider<B> + Send + Sync + 'static,
|
||||
C: HeaderBackend<B> + Send + Sync + 'static,
|
||||
B: BlockT + for<'de> serde::Deserialize<'de>,
|
||||
IQ: ImportQueue<B> + 'static,
|
||||
{
|
||||
@@ -438,7 +438,7 @@ where
|
||||
info!(
|
||||
"🎉 Imported {} blocks. Best: #{}",
|
||||
read_block_count,
|
||||
client.usage_info().chain.best_number
|
||||
client.info().best_number
|
||||
);
|
||||
return Poll::Ready(Ok(()))
|
||||
} else {
|
||||
@@ -469,7 +469,7 @@ where
|
||||
|
||||
queue.poll_actions(cx, &mut link);
|
||||
|
||||
let best_number = client.usage_info().chain.best_number;
|
||||
let best_number = client.info().best_number;
|
||||
speedometer.notify_user(best_number);
|
||||
|
||||
if link.has_error {
|
||||
|
||||
@@ -684,8 +684,6 @@ where
|
||||
..
|
||||
} = import_block;
|
||||
|
||||
assert!(justifications.is_some() && finalized || justifications.is_none());
|
||||
|
||||
if !intermediates.is_empty() {
|
||||
return Err(Error::IncompletePipeline)
|
||||
}
|
||||
@@ -779,11 +777,17 @@ where
|
||||
}
|
||||
|
||||
let info = self.backend.blockchain().info();
|
||||
let gap_block = info
|
||||
.block_gap
|
||||
.map_or(false, |(start, _)| *import_headers.post().number() == start);
|
||||
|
||||
assert!(justifications.is_some() && finalized || justifications.is_none() || gap_block);
|
||||
|
||||
// the block is lower than our last finalized block so it must revert
|
||||
// finality, refusing import.
|
||||
if status == blockchain::BlockStatus::Unknown &&
|
||||
*import_headers.post().number() <= info.finalized_number
|
||||
*import_headers.post().number() <= info.finalized_number &&
|
||||
!gap_block
|
||||
{
|
||||
return Err(sp_blockchain::Error::NotInFinalizedChain)
|
||||
}
|
||||
@@ -854,12 +858,13 @@ where
|
||||
None => None,
|
||||
};
|
||||
|
||||
let is_new_best = finalized ||
|
||||
match fork_choice {
|
||||
ForkChoiceStrategy::LongestChain =>
|
||||
import_headers.post().number() > &info.best_number,
|
||||
ForkChoiceStrategy::Custom(v) => v,
|
||||
};
|
||||
let is_new_best = !gap_block &&
|
||||
(finalized ||
|
||||
match fork_choice {
|
||||
ForkChoiceStrategy::LongestChain =>
|
||||
import_headers.post().number() > &info.best_number,
|
||||
ForkChoiceStrategy::Custom(v) => v,
|
||||
});
|
||||
|
||||
let leaf_state = if finalized {
|
||||
NewBlockState::Final
|
||||
|
||||
Reference in New Issue
Block a user