mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 21:37:56 +00:00
Move syncing code from sc-network-common to sc-network-sync (#1912)
This PR moves syncing-related code from `sc-network-common` to `sc-network-sync`. Unfortunately, some parts are tightly integrated with networking, so they were left in `sc-network-common` for now: 1. `SyncMode` in `common/src/sync.rs` (used in `NetworkConfiguration`). 2. `BlockAnnouncesHandshake`, `BlockRequest`, `BlockResponse`, etc. in `common/src/sync/message.rs` (used in `src/protocol.rs` and `src/protocol/message.rs`). More substantial refactoring is needed to decouple syncing and networking completely, including getting rid of the hardcoded sync protocol. ## Release notes Move syncing-related code from `sc-network-common` to `sc-network-sync`. Delete `ChainSync` trait as it's never used (the only implementation is accessed directly from `SyncingEngine` and exposes a lot of public methods that are not part of the trait). Some new trait(s) for syncing will likely be introduced as part of Sync 2.0 refactoring to represent syncing strategies.
This commit is contained in:
@@ -24,12 +24,21 @@ use crate::{
|
||||
BlockAnnounceValidationResult, BlockAnnounceValidator as BlockAnnounceValidatorStream,
|
||||
},
|
||||
block_relay_protocol::{BlockDownloader, BlockResponseError},
|
||||
block_request_handler::MAX_BLOCKS_IN_RESPONSE,
|
||||
chain_sync::{
|
||||
BlockRequestAction, ChainSync, ImportBlocksAction, ImportJustificationsAction,
|
||||
OnBlockResponse,
|
||||
},
|
||||
pending_responses::{PendingResponses, ResponseEvent},
|
||||
schema::v1::{StateRequest, StateResponse},
|
||||
service::{self, chain_sync::ToServiceCommand},
|
||||
warp::WarpSyncParams,
|
||||
BlockRequestAction, ChainSync, ClientError, ImportBlocksAction, ImportJustificationsAction,
|
||||
OnBlockResponse, SyncingService,
|
||||
service::{
|
||||
self,
|
||||
chain_sync::{SyncingService, ToServiceCommand},
|
||||
},
|
||||
types::{
|
||||
BadPeer, ExtendedPeerInfo, OpaqueStateRequest, OpaqueStateResponse, PeerRequest, SyncEvent,
|
||||
},
|
||||
warp::{EncodedProof, WarpProofRequest, WarpSyncParams},
|
||||
};
|
||||
|
||||
use codec::{Decode, Encode};
|
||||
@@ -61,15 +70,10 @@ use sc_network::{
|
||||
};
|
||||
use sc_network_common::{
|
||||
role::Roles,
|
||||
sync::{
|
||||
message::{BlockAnnounce, BlockAnnouncesHandshake, BlockRequest, BlockState},
|
||||
warp::{EncodedProof, WarpProofRequest},
|
||||
BadPeer, ChainSync as ChainSyncT, ExtendedPeerInfo, OpaqueStateRequest,
|
||||
OpaqueStateResponse, PeerRequest, SyncEvent,
|
||||
},
|
||||
sync::message::{BlockAnnounce, BlockAnnouncesHandshake, BlockRequest, BlockState},
|
||||
};
|
||||
use sc_utils::mpsc::{tracing_unbounded, TracingUnboundedReceiver, TracingUnboundedSender};
|
||||
use sp_blockchain::HeaderMetadata;
|
||||
use sp_blockchain::{Error as ClientError, HeaderMetadata};
|
||||
use sp_consensus::block_validation::BlockAnnounceValidator;
|
||||
use sp_runtime::traits::{Block as BlockT, Header, NumberFor, Zero};
|
||||
|
||||
@@ -363,18 +367,17 @@ where
|
||||
) -> Result<(Self, SyncingService<B>, NonDefaultSetConfig), ClientError> {
|
||||
let mode = net_config.network_config.sync_mode;
|
||||
let max_parallel_downloads = net_config.network_config.max_parallel_downloads;
|
||||
let max_blocks_per_request = if net_config.network_config.max_blocks_per_request >
|
||||
crate::MAX_BLOCKS_IN_RESPONSE as u32
|
||||
{
|
||||
log::info!(
|
||||
target: LOG_TARGET,
|
||||
"clamping maximum blocks per request to {}",
|
||||
crate::MAX_BLOCKS_IN_RESPONSE,
|
||||
);
|
||||
crate::MAX_BLOCKS_IN_RESPONSE as u32
|
||||
} else {
|
||||
net_config.network_config.max_blocks_per_request
|
||||
};
|
||||
let max_blocks_per_request =
|
||||
if net_config.network_config.max_blocks_per_request > MAX_BLOCKS_IN_RESPONSE as u32 {
|
||||
log::info!(
|
||||
target: LOG_TARGET,
|
||||
"clamping maximum blocks per request to {}",
|
||||
MAX_BLOCKS_IN_RESPONSE,
|
||||
);
|
||||
MAX_BLOCKS_IN_RESPONSE as u32
|
||||
} else {
|
||||
net_config.network_config.max_blocks_per_request
|
||||
};
|
||||
let cache_capacity = (net_config.network_config.default_peers_set.in_peers +
|
||||
net_config.network_config.default_peers_set.out_peers)
|
||||
.max(1);
|
||||
|
||||
Reference in New Issue
Block a user