From 2060c366fb1402deab188911551a43c3c41b36c0 Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Fri, 11 Aug 2023 17:35:29 +0300 Subject: [PATCH] sc-cli: add no-beefy flag to cli config (#14754) Signed-off-by: Adrian Catangiu --- bin/node/cli/benches/block_production.rs | 1 + bin/node/cli/benches/transaction_pool.rs | 1 + client/cli/src/commands/run_cmd.rs | 8 ++++++++ client/cli/src/config.rs | 8 ++++++++ client/cli/src/runner.rs | 1 + client/service/src/config.rs | 2 ++ client/service/test/src/lib.rs | 1 + 7 files changed, 22 insertions(+) diff --git a/bin/node/cli/benches/block_production.rs b/bin/node/cli/benches/block_production.rs index 5ee538d18d6a8..fd4deeaed3522 100644 --- a/bin/node/cli/benches/block_production.rs +++ b/bin/node/cli/benches/block_production.rs @@ -88,6 +88,7 @@ fn new_node(tokio_handle: Handle) -> node_cli::service::NewFullBase { offchain_worker: OffchainWorkerConfig { enabled: true, indexing_enabled: false }, force_authoring: false, disable_grandpa: false, + disable_beefy: false, dev_key_seed: Some(Sr25519Keyring::Alice.to_seed()), tracing_targets: None, tracing_receiver: Default::default(), diff --git a/bin/node/cli/benches/transaction_pool.rs b/bin/node/cli/benches/transaction_pool.rs index d3e8c02a958f7..39a94b21cc282 100644 --- a/bin/node/cli/benches/transaction_pool.rs +++ b/bin/node/cli/benches/transaction_pool.rs @@ -84,6 +84,7 @@ fn new_node(tokio_handle: Handle) -> node_cli::service::NewFullBase { offchain_worker: OffchainWorkerConfig { enabled: true, indexing_enabled: false }, force_authoring: false, disable_grandpa: false, + disable_beefy: false, dev_key_seed: Some(Sr25519Keyring::Alice.to_seed()), tracing_targets: None, tracing_receiver: Default::default(), diff --git a/client/cli/src/commands/run_cmd.rs b/client/cli/src/commands/run_cmd.rs index 5dda488b13330..e6a6218517497 100644 --- a/client/cli/src/commands/run_cmd.rs +++ b/client/cli/src/commands/run_cmd.rs @@ -51,6 +51,10 @@ pub struct RunCmd { #[arg(long)] pub no_grandpa: bool, + /// Disable BEEFY voter when running in validator mode, otherwise disable the BEEFY observer. + #[arg(long)] + pub no_beefy: bool, + /// Listen to all RPC interfaces. /// Default is local. Note: not all RPC methods are safe to be exposed publicly. Use an RPC /// proxy server to filter out dangerous methods. More details: @@ -313,6 +317,10 @@ impl CliConfiguration for RunCmd { Ok(self.no_grandpa) } + fn disable_beefy(&self) -> Result { + Ok(self.no_beefy) + } + fn rpc_max_connections(&self) -> Result { Ok(self.rpc_max_connections) } diff --git a/client/cli/src/config.rs b/client/cli/src/config.rs index 4d218da6aa898..0c3bf98a2f5db 100644 --- a/client/cli/src/config.rs +++ b/client/cli/src/config.rs @@ -381,6 +381,13 @@ pub trait CliConfiguration: Sized { Ok(Default::default()) } + /// Returns `Ok(true)` if BEEFY should be disabled + /// + /// By default this is `false`. + fn disable_beefy(&self) -> Result { + Ok(Default::default()) + } + /// Get the development key seed from the current object /// /// By default this is `None`. @@ -508,6 +515,7 @@ pub trait CliConfiguration: Sized { offchain_worker: self.offchain_worker(&role)?, force_authoring: self.force_authoring()?, disable_grandpa: self.disable_grandpa()?, + disable_beefy: self.disable_beefy()?, dev_key_seed: self.dev_key_seed(is_dev)?, tracing_targets: self.tracing_targets()?, tracing_receiver: self.tracing_receiver()?, diff --git a/client/cli/src/runner.rs b/client/cli/src/runner.rs index 59f53200a192b..2a536044d2fcf 100644 --- a/client/cli/src/runner.rs +++ b/client/cli/src/runner.rs @@ -280,6 +280,7 @@ mod tests { offchain_worker: Default::default(), force_authoring: false, disable_grandpa: false, + disable_beefy: false, dev_key_seed: None, tracing_targets: None, tracing_receiver: Default::default(), diff --git a/client/service/src/config.rs b/client/service/src/config.rs index 39b7ee0507906..abf54588556ce 100644 --- a/client/service/src/config.rs +++ b/client/service/src/config.rs @@ -112,6 +112,8 @@ pub struct Configuration { pub force_authoring: bool, /// Disable GRANDPA when running in validator mode pub disable_grandpa: bool, + /// Disable BEEFY when running in validator mode + pub disable_beefy: bool, /// Development key seed. /// /// When running in development mode, the seed will be used to generate authority keys by the diff --git a/client/service/test/src/lib.rs b/client/service/test/src/lib.rs index 38a811acc7401..e095f61a7da3e 100644 --- a/client/service/test/src/lib.rs +++ b/client/service/test/src/lib.rs @@ -260,6 +260,7 @@ fn node_config< offchain_worker: Default::default(), force_authoring: false, disable_grandpa: false, + disable_beefy: false, dev_key_seed: key_seed, tracing_targets: None, tracing_receiver: Default::default(),