From 598f4c6b550fed897f050b74481718783425e53c Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Fri, 25 Aug 2023 06:16:22 +0300 Subject: [PATCH] cli: disallow BEEFY and warp sync together (#7661) Signed-off-by: Adrian Catangiu --- cli/src/command.rs | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/cli/src/command.rs b/cli/src/command.rs index 6b36e6895b6e..a2a00d0ebd3f 100644 --- a/cli/src/command.rs +++ b/cli/src/command.rs @@ -17,7 +17,7 @@ use crate::cli::{Cli, Subcommand, NODE_VERSION}; use frame_benchmarking_cli::{BenchmarkCmd, ExtrinsicFactory, SUBSTRATE_REFERENCE_HARDWARE}; use futures::future::TryFutureExt; -use log::info; +use log::{info, warn}; use sc_cli::SubstrateCli; use service::{ self, @@ -240,8 +240,24 @@ where .map_err(Error::from)?; let chain_spec = &runner.config().chain_spec; - // By default, enable BEEFY on all networks except Polkadot (for now). - let enable_beefy = !chain_spec.is_polkadot() && !cli.run.no_beefy; + // By default, enable BEEFY on all networks except Polkadot (for now), unless + // explicitly disabled through CLI. + let mut enable_beefy = !chain_spec.is_polkadot() && !cli.run.no_beefy; + // BEEFY doesn't (yet) support warp sync: + // Until we implement https://github.com/paritytech/substrate/issues/14756 + // - disallow warp sync for validators, + // - disable BEEFY when warp sync for non-validators. + if enable_beefy && runner.config().network.sync_mode.is_warp() { + if runner.config().role.is_authority() { + return Err(Error::Other( + "Warp sync not supported for validator nodes running BEEFY.".into(), + )) + } else { + // disable BEEFY for non-validator nodes that are warp syncing + warn!("🥩 BEEFY not supported when warp syncing. Disabling BEEFY."); + enable_beefy = false; + } + } set_default_ss58_version(chain_spec);