mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-09 22:18:00 +00:00
service: use deny-list instead of allow-list for BEEFY (#5331)
* use deny-list instead of allow-list for BEEFY Instead of allowing BEEFY to run on specific test nets, inverse the condition to explicitly disallow BEEFY on production chains that we don't want it to run on yet. This allows other test chains (other than Rococo/Wococo) that use the polkadot service file to enable and test BEEFY. Signed-off-by: Adrian Catangiu <adrian@parity.io> * address review comments * throw error if BEEFY enabled on production networks Signed-off-by: acatangiu <adrian@parity.io>
This commit is contained in:
@@ -273,6 +273,13 @@ where
|
||||
.map_err(Error::from)?;
|
||||
let chain_spec = &runner.config().chain_spec;
|
||||
|
||||
// Disallow BEEFY on production networks.
|
||||
if cli.run.beefy &&
|
||||
(chain_spec.is_polkadot() || chain_spec.is_kusama() || chain_spec.is_westend())
|
||||
{
|
||||
return Err(Error::Other("BEEFY disallowed on production networks".to_string()))
|
||||
}
|
||||
|
||||
set_default_ss58_version(chain_spec);
|
||||
|
||||
let grandpa_pause = if cli.run.grandpa_pause.is_empty() {
|
||||
|
||||
@@ -239,6 +239,9 @@ pub enum Error {
|
||||
|
||||
/// Can be called for a `Configuration` to identify which network the configuration targets.
|
||||
pub trait IdentifyVariant {
|
||||
/// Returns if this is a configuration for the `Polkadot` network.
|
||||
fn is_polkadot(&self) -> bool;
|
||||
|
||||
/// Returns if this is a configuration for the `Kusama` network.
|
||||
fn is_kusama(&self) -> bool;
|
||||
|
||||
@@ -259,6 +262,9 @@ pub trait IdentifyVariant {
|
||||
}
|
||||
|
||||
impl IdentifyVariant for Box<dyn ChainSpec> {
|
||||
fn is_polkadot(&self) -> bool {
|
||||
self.id().starts_with("polkadot") || self.id().starts_with("dot")
|
||||
}
|
||||
fn is_kusama(&self) -> bool {
|
||||
self.id().starts_with("kusama") || self.id().starts_with("ksm")
|
||||
}
|
||||
@@ -713,6 +719,15 @@ where
|
||||
Some(backoff)
|
||||
};
|
||||
|
||||
// If not on a known test network, warn the user that BEEFY is still experimental.
|
||||
if enable_beefy &&
|
||||
!config.chain_spec.is_rococo() &&
|
||||
!config.chain_spec.is_wococo() &&
|
||||
!config.chain_spec.is_versi()
|
||||
{
|
||||
gum::warn!("BEEFY is still experimental, usage on a production network is discouraged.");
|
||||
}
|
||||
|
||||
let disable_grandpa = config.disable_grandpa;
|
||||
let name = config.network.node_name.clone();
|
||||
|
||||
@@ -782,7 +797,7 @@ where
|
||||
&client.block_hash(0).ok().flatten().expect("Genesis block exists; qed"),
|
||||
&config.chain_spec,
|
||||
);
|
||||
if chain_spec.is_rococo() || chain_spec.is_wococo() || chain_spec.is_versi() {
|
||||
if enable_beefy {
|
||||
config
|
||||
.network
|
||||
.extra_sets
|
||||
@@ -1125,8 +1140,7 @@ where
|
||||
let keystore_opt =
|
||||
if role.is_authority() { Some(keystore_container.sync_keystore()) } else { None };
|
||||
|
||||
// We currently only run the BEEFY gadget on the Rococo and Wococo testnets.
|
||||
if enable_beefy && (chain_spec.is_rococo() || chain_spec.is_wococo() || chain_spec.is_versi()) {
|
||||
if enable_beefy {
|
||||
let beefy_params = beefy_gadget::BeefyParams {
|
||||
client: client.clone(),
|
||||
backend: backend.clone(),
|
||||
|
||||
Reference in New Issue
Block a user