Skip to content

Commit 6f7591f

Browse files
bkchrgrishasobol
authored andcommitted
warp-sync: Return an error when trying to enable it for archive nodes. (paritytech#11086)
* warp-sync: Return an error when trying to enable it for archive nodes. * Fix checks * Ups * FMT
1 parent 788cb21 commit 6f7591f

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

client/network/src/config.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,8 +377,8 @@ impl From<multiaddr::Error> for ParseErr {
377377
}
378378
}
379379

380-
#[derive(Clone, Debug, Eq, PartialEq)]
381380
/// Sync operation mode.
381+
#[derive(Clone, Debug, Eq, PartialEq)]
382382
pub enum SyncMode {
383383
/// Full block download and verification.
384384
Full,
@@ -393,6 +393,18 @@ pub enum SyncMode {
393393
Warp,
394394
}
395395

396+
impl SyncMode {
397+
/// Returns if `self` is [`Self::Warp`].
398+
pub fn is_warp(&self) -> bool {
399+
matches!(self, Self::Warp)
400+
}
401+
402+
/// Returns if `self` is [`Self::Fast`].
403+
pub fn is_fast(&self) -> bool {
404+
matches!(self, Self::Fast { .. })
405+
}
406+
}
407+
396408
impl Default for SyncMode {
397409
fn default() -> Self {
398410
Self::Full

client/service/src/builder.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ use sc_executor::RuntimeVersionOf;
3939
use sc_keystore::LocalKeystore;
4040
use sc_network::{
4141
block_request_handler::{self, BlockRequestHandler},
42-
config::Role,
42+
config::{Role, SyncMode},
4343
light_client_requests::{self, handler::LightClientRequestHandler},
4444
state_request_handler::{self, StateRequestHandler},
4545
warp_request_handler::{self, RequestHandler as WarpSyncRequestHandler, WarpSyncProvider},
@@ -767,6 +767,18 @@ where
767767
warp_sync,
768768
} = params;
769769

770+
if warp_sync.is_none() && config.network.sync_mode.is_warp() {
771+
return Err("Warp sync enabled, but no warp sync provider configured.".into())
772+
}
773+
774+
if config.state_pruning.is_archive() {
775+
match config.network.sync_mode {
776+
SyncMode::Fast { .. } => return Err("Fast sync doesn't work for archive nodes".into()),
777+
SyncMode::Warp => return Err("Warp sync doesn't work for archive nodes".into()),
778+
SyncMode::Full => {},
779+
};
780+
}
781+
770782
let transaction_pool_adapter = Arc::new(TransactionPoolAdapter {
771783
imports_external_transactions: !matches!(config.role, Role::Light),
772784
pool: transaction_pool,

0 commit comments

Comments
 (0)