Name changes for GrandPa and Beefy notifications protocols (#10463)

* grandpa: update notif protocol name

* grandpa: add chain id prefix to protocol name

* grandpa: beautify protocol name handling

* grandpa: prepend genesis hash to protocol name

* chain-spec: add optional 'fork_id'

'fork_id' is used to uniquely identify forks of the same chain/network
'ChainSpec' trait provides default 'None' implementation, meaning this
chain hasn't been forked.

* grandpa: protocol_name mod instead of struct

* beefy: add genesis hash prefix to protocol name

* chainspec: add fork_id

* grandpa: simplify protocol name

* grandpa: contain protocol name building logic

* beefy: contain protocol name building logic

* grandpa: fix tests

* fix merge damage

* fix docs reference visibility

Signed-off-by: acatangiu <adrian@parity.io>

* Update client/finality-grandpa/src/lib.rs

Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com>

* Update client/finality-grandpa/src/communication/mod.rs

Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com>

* Update client/beefy/src/lib.rs

Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com>

* Update client/beefy/src/lib.rs

Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com>

* avoid using hash default, even for protocol names

Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com>
This commit is contained in:
Adrian Catangiu
2022-01-05 19:01:44 +02:00
committed by GitHub
parent 223d929f86
commit c1865988df
18 changed files with 163 additions and 46 deletions
+2
View File
@@ -481,6 +481,7 @@ dependencies = [
"log 0.4.14",
"parity-scale-codec",
"parking_lot 0.11.2",
"sc-chain-spec",
"sc-client-api",
"sc-keystore",
"sc-network",
@@ -8159,6 +8160,7 @@ dependencies = [
"parking_lot 0.11.2",
"rand 0.8.4",
"sc-block-builder",
"sc-chain-spec",
"sc-client-api",
"sc-consensus",
"sc-keystore",
@@ -68,6 +68,7 @@ pub fn development_config() -> Result<ChainSpec, String> {
None,
// Protocol ID
None,
None,
// Properties
None,
// Extensions
@@ -117,6 +118,7 @@ pub fn local_testnet_config() -> Result<ChainSpec, String> {
None,
// Properties
None,
None,
// Extensions
None,
))
@@ -1,7 +1,7 @@
//! Service and ServiceFactory implementation. Specialized wrapper over substrate service.
use node_template_runtime::{self, opaque::Block, RuntimeApi};
use sc_client_api::ExecutorProvider;
use sc_client_api::{BlockBackend, ExecutorProvider};
use sc_consensus_aura::{ImportQueueParams, SlotProportion, StartAuraParams};
pub use sc_executor::NativeElseWasmExecutor;
use sc_finality_grandpa::SharedVoterState;
@@ -180,8 +180,15 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
))),
};
}
let grandpa_protocol_name = sc_finality_grandpa::protocol_standard_name(
&client.block_hash(0).ok().flatten().expect("Genesis block exists; qed"),
&config.chain_spec,
);
config.network.extra_sets.push(sc_finality_grandpa::grandpa_peers_set_config());
config
.network
.extra_sets
.push(sc_finality_grandpa::grandpa_peers_set_config(grandpa_protocol_name.clone()));
let warp_sync = Arc::new(sc_finality_grandpa::warp_proof::NetworkProvider::new(
backend.clone(),
grandpa_link.shared_authority_set().clone(),
@@ -306,6 +313,7 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
keystore,
local_role: role,
telemetry: telemetry.as_ref().map(|x| x.handle()),
protocol_name: grandpa_protocol_name,
};
if enable_grandpa {
+5
View File
@@ -196,6 +196,7 @@ pub fn staging_testnet_config() -> ChainSpec {
),
None,
None,
None,
Default::default(),
)
}
@@ -386,6 +387,7 @@ pub fn development_config() -> ChainSpec {
None,
None,
None,
None,
Default::default(),
)
}
@@ -410,6 +412,7 @@ pub fn local_testnet_config() -> ChainSpec {
None,
None,
None,
None,
Default::default(),
)
}
@@ -441,6 +444,7 @@ pub(crate) mod tests {
None,
None,
None,
None,
Default::default(),
)
}
@@ -456,6 +460,7 @@ pub(crate) mod tests {
None,
None,
None,
None,
Default::default(),
)
}
+9 -1
View File
@@ -326,8 +326,15 @@ pub fn new_full_base(
let shared_voter_state = rpc_setup;
let auth_disc_publish_non_global_ips = config.network.allow_non_globals_in_dht;
let grandpa_protocol_name = grandpa::protocol_standard_name(
&client.block_hash(0).ok().flatten().expect("Genesis block exists; qed"),
&config.chain_spec,
);
config.network.extra_sets.push(grandpa::grandpa_peers_set_config());
config
.network
.extra_sets
.push(grandpa::grandpa_peers_set_config(grandpa_protocol_name.clone()));
let warp_sync = Arc::new(grandpa::warp_proof::NetworkProvider::new(
backend.clone(),
import_setup.1.shared_authority_set().clone(),
@@ -488,6 +495,7 @@ pub fn new_full_base(
keystore,
local_role: role,
telemetry: telemetry.as_ref().map(|x| x.handle()),
protocol_name: grandpa_protocol_name,
};
if enable_grandpa {
@@ -155,6 +155,7 @@ fn generate_chain_spec(
None,
None,
None,
None,
Default::default(),
);
+1
View File
@@ -26,6 +26,7 @@ sp-core = { version = "4.1.0-dev", path = "../../primitives/core" }
sp-keystore = { version = "0.10.0", path = "../../primitives/keystore" }
sp-runtime = { version = "4.0.0", path = "../../primitives/runtime" }
sc-chain-spec = { version = "4.0.0-dev", path = "../../client/chain-spec" }
sc-utils = { version = "4.0.0-dev", path = "../utils" }
sc-client-api = { version = "4.0.0-dev", path = "../api" }
sc-keystore = { version = "4.0.0-dev", path = "../keystore" }
+33 -6
View File
@@ -39,15 +39,40 @@ mod round;
mod worker;
pub mod notification;
pub use beefy_protocol_name::standard_name as protocol_standard_name;
pub const BEEFY_PROTOCOL_NAME: &str = "/paritytech/beefy/1";
pub(crate) mod beefy_protocol_name {
use sc_chain_spec::ChainSpec;
const NAME: &'static str = "/beefy/1";
/// Old names for the notifications protocol, used for backward compatibility.
pub(crate) const LEGACY_NAMES: [&'static str; 1] = ["/paritytech/beefy/1"];
/// Name of the notifications protocol used by BEEFY.
///
/// Must be registered towards the networking in order for BEEFY to properly function.
pub fn standard_name<Hash: std::fmt::Display>(
genesis_hash: &Hash,
chain_spec: &Box<dyn ChainSpec>,
) -> std::borrow::Cow<'static, str> {
let chain_prefix = match chain_spec.fork_id() {
Some(fork_id) => format!("/{}/{}", genesis_hash, fork_id),
None => format!("/{}", genesis_hash),
};
format!("{}{}", chain_prefix, NAME).into()
}
}
/// Returns the configuration value to put in
/// [`sc_network::config::NetworkConfiguration::extra_sets`].
pub fn beefy_peers_set_config() -> sc_network::config::NonDefaultSetConfig {
let mut cfg =
sc_network::config::NonDefaultSetConfig::new(BEEFY_PROTOCOL_NAME.into(), 1024 * 1024);
/// For standard protocol name see [`beefy_protocol_name::standard_name`].
pub fn beefy_peers_set_config(
protocol_name: std::borrow::Cow<'static, str>,
) -> sc_network::config::NonDefaultSetConfig {
let mut cfg = sc_network::config::NonDefaultSetConfig::new(protocol_name, 1024 * 1024);
cfg.allow_non_reserved(25, 25);
cfg.add_fallback_names(beefy_protocol_name::LEGACY_NAMES.iter().map(|&n| n.into()).collect());
cfg
}
@@ -101,6 +126,8 @@ where
pub min_block_delta: u32,
/// Prometheus metric registry
pub prometheus_registry: Option<Registry>,
/// Chain specific GRANDPA protocol name. See [`beefy_protocol_name::standard_name`].
pub protocol_name: std::borrow::Cow<'static, str>,
}
/// Start the BEEFY gadget.
@@ -122,11 +149,11 @@ where
signed_commitment_sender,
min_block_delta,
prometheus_registry,
protocol_name,
} = beefy_params;
let gossip_validator = Arc::new(gossip::GossipValidator::new());
let gossip_engine =
GossipEngine::new(network, BEEFY_PROTOCOL_NAME, gossip_validator.clone(), None);
let gossip_engine = GossipEngine::new(network, protocol_name, gossip_validator.clone(), None);
let metrics =
prometheus_registry.as_ref().map(metrics::Metrics::register).and_then(
@@ -164,6 +164,7 @@ struct ClientSpec<E> {
boot_nodes: Vec<MultiaddrWithPeerId>,
telemetry_endpoints: Option<TelemetryEndpoints>,
protocol_id: Option<String>,
fork_id: Option<String>,
properties: Option<Properties>,
#[serde(flatten)]
extensions: E,
@@ -226,6 +227,11 @@ impl<G, E> ChainSpec<G, E> {
self.client_spec.protocol_id.as_deref()
}
/// Optional network fork identifier.
pub fn fork_id(&self) -> Option<&str> {
self.client_spec.fork_id.as_ref().map(String::as_str)
}
/// Additional loosly-typed properties of the chain.
///
/// Returns an empty JSON object if 'properties' not defined in config
@@ -257,6 +263,7 @@ impl<G, E> ChainSpec<G, E> {
boot_nodes: Vec<MultiaddrWithPeerId>,
telemetry_endpoints: Option<TelemetryEndpoints>,
protocol_id: Option<&str>,
fork_id: Option<&str>,
properties: Option<Properties>,
extensions: E,
) -> Self {
@@ -267,6 +274,7 @@ impl<G, E> ChainSpec<G, E> {
boot_nodes,
telemetry_endpoints,
protocol_id: protocol_id.map(str::to_owned),
fork_id: fork_id.map(str::to_owned),
properties,
extensions,
consensus_engine: (),
@@ -384,6 +392,10 @@ where
ChainSpec::protocol_id(self)
}
fn fork_id(&self) -> Option<&str> {
ChainSpec::fork_id(self)
}
fn properties(&self) -> Properties {
ChainSpec::properties(self)
}
+2
View File
@@ -165,6 +165,8 @@ pub trait ChainSpec: BuildStorage + Send + Sync {
fn telemetry_endpoints(&self) -> &Option<TelemetryEndpoints>;
/// Network protocol id.
fn protocol_id(&self) -> Option<&str>;
/// Optional network fork identifier. `None` by default.
fn fork_id(&self) -> Option<&str>;
/// Additional loosly-typed properties of the chain.
///
/// Returns an empty JSON object if 'properties' not defined in config
@@ -144,6 +144,7 @@ mod tests {
None,
None,
None,
None,
NoExtension::None,
)))
}
@@ -27,6 +27,7 @@ parity-scale-codec = { version = "2.3.1", features = ["derive"] }
sp-application-crypto = { version = "4.0.0", path = "../../primitives/application-crypto" }
sp-arithmetic = { version = "4.0.0", path = "../../primitives/arithmetic" }
sp-runtime = { version = "4.0.0", path = "../../primitives/runtime" }
sc-chain-spec = { version = "4.0.0-dev", path = "../../client/chain-spec" }
sc-utils = { version = "4.0.0-dev", path = "../utils" }
sp-consensus = { version = "0.10.0-dev", path = "../../primitives/consensus/common" }
sc-consensus = { version = "0.10.0-dev", path = "../consensus/common" }
@@ -1664,6 +1664,7 @@ pub(super) struct PeerReport {
#[cfg(test)]
mod tests {
use super::{environment::SharedVoterSetState, *};
use crate::communication;
use sc_network::config::Role;
use sc_network_gossip::Validator as GossipValidatorT;
use sc_network_test::Block;
@@ -1679,6 +1680,7 @@ mod tests {
local_role: Role::Authority,
observer_enabled: true,
telemetry: None,
protocol_name: communication::grandpa_protocol_name::NAME.into(),
}
}
@@ -1840,13 +1842,13 @@ mod tests {
// messages from old rounds are expired.
for round_num in 1u64..last_kept_round {
let topic = crate::communication::round_topic::<Block>(round_num, 1);
let topic = communication::round_topic::<Block>(round_num, 1);
assert!(is_expired(topic, &[1, 2, 3]));
}
// messages from not-too-old rounds are not expired.
for round_num in last_kept_round..10 {
let topic = crate::communication::round_topic::<Block>(round_num, 1);
let topic = communication::round_topic::<Block>(round_num, 1);
assert!(!is_expired(topic, &[1, 2, 3]));
}
}
@@ -2262,7 +2264,7 @@ mod tests {
// we accept messages from rounds 9, 10 and 11
// therefore neither of those should be considered expired
for round in &[9, 10, 11] {
assert!(!is_expired(crate::communication::round_topic::<Block>(*round, 1), &[]))
assert!(!is_expired(communication::round_topic::<Block>(*round, 1), &[]))
}
}
@@ -2310,7 +2312,7 @@ mod tests {
if message_allowed(
peer,
MessageIntent::Broadcast,
&crate::communication::round_topic::<Block>(1, 0),
&communication::round_topic::<Block>(1, 0),
&[],
) {
allowed += 1;
@@ -2374,7 +2376,7 @@ mod tests {
assert!(!val.message_allowed()(
&light_peer,
MessageIntent::Broadcast,
&crate::communication::round_topic::<Block>(1, 0),
&communication::round_topic::<Block>(1, 0),
&[],
));
@@ -2388,7 +2390,7 @@ mod tests {
assert!(!val.message_allowed()(
&light_peer,
MessageIntent::Broadcast,
&crate::communication::round_topic::<Block>(1, 0),
&communication::round_topic::<Block>(1, 0),
&[],
));
@@ -2412,8 +2414,8 @@ mod tests {
auth_data: Vec::new(),
};
crate::communication::gossip::GossipMessage::<Block>::Commit(
crate::communication::gossip::FullCommitMessage {
communication::gossip::GossipMessage::<Block>::Commit(
communication::gossip::FullCommitMessage {
round: Round(2),
set_id: SetId(0),
message: commit,
@@ -2426,7 +2428,7 @@ mod tests {
assert!(val.message_allowed()(
&light_peer,
MessageIntent::Broadcast,
&crate::communication::global_topic::<Block>(0),
&communication::global_topic::<Block>(0),
&commit,
));
}
@@ -2466,8 +2468,8 @@ mod tests {
auth_data: Vec::new(),
};
crate::communication::gossip::GossipMessage::<Block>::Commit(
crate::communication::gossip::FullCommitMessage {
communication::gossip::GossipMessage::<Block>::Commit(
communication::gossip::FullCommitMessage {
round: Round(1),
set_id: SetId(1),
message: commit,
@@ -2485,7 +2487,7 @@ mod tests {
assert!(message_allowed(
&peer1,
MessageIntent::Broadcast,
&crate::communication::global_topic::<Block>(1),
&communication::global_topic::<Block>(1),
&commit,
));
@@ -2494,7 +2496,7 @@ mod tests {
assert!(!message_allowed(
&peer2,
MessageIntent::Broadcast,
&crate::communication::global_topic::<Block>(1),
&communication::global_topic::<Block>(1),
&commit,
));
}
@@ -2511,8 +2513,8 @@ mod tests {
auth_data: Vec::new(),
};
crate::communication::gossip::GossipMessage::<Block>::Commit(
crate::communication::gossip::FullCommitMessage {
communication::gossip::GossipMessage::<Block>::Commit(
communication::gossip::FullCommitMessage {
round: Round(round),
set_id: SetId(set_id),
message: commit,
@@ -2532,15 +2534,13 @@ mod tests {
// a commit message for round 1 that finalizes the same height as we
// have observed previously should not be expired
assert!(
!message_expired(crate::communication::global_topic::<Block>(1), &commit(1, 1, 2),)
);
assert!(!message_expired(communication::global_topic::<Block>(1), &commit(1, 1, 2),));
// it should be expired if it is for a lower block
assert!(message_expired(crate::communication::global_topic::<Block>(1), &commit(1, 1, 1)));
assert!(message_expired(communication::global_topic::<Block>(1), &commit(1, 1, 1)));
// or the same block height but from the previous round
assert!(message_expired(crate::communication::global_topic::<Block>(1), &commit(0, 1, 2)));
assert!(message_expired(communication::global_topic::<Block>(1), &commit(0, 1, 2)));
}
#[test]
@@ -67,9 +67,27 @@ mod periodic;
#[cfg(test)]
pub(crate) mod tests;
/// Name of the notifications protocol used by Grandpa. Must be registered towards the networking
/// in order for Grandpa to properly function.
pub const GRANDPA_PROTOCOL_NAME: &'static str = "/paritytech/grandpa/1";
pub mod grandpa_protocol_name {
use sc_chain_spec::ChainSpec;
pub(crate) const NAME: &'static str = "/grandpa/1";
/// Old names for the notifications protocol, used for backward compatibility.
pub(crate) const LEGACY_NAMES: [&'static str; 1] = ["/paritytech/grandpa/1"];
/// Name of the notifications protocol used by GRANDPA.
///
/// Must be registered towards the networking in order for GRANDPA to properly function.
pub fn standard_name<Hash: std::fmt::Display>(
genesis_hash: &Hash,
chain_spec: &Box<dyn ChainSpec>,
) -> std::borrow::Cow<'static, str> {
let chain_prefix = match chain_spec.fork_id() {
Some(fork_id) => format!("/{}/{}", genesis_hash, fork_id),
None => format!("/{}", genesis_hash),
};
format!("{}{}", chain_prefix, NAME).into()
}
}
// cost scalars for reporting peers.
mod cost {
@@ -220,13 +238,14 @@ impl<B: BlockT, N: Network<B>> NetworkBridge<B, N> {
prometheus_registry: Option<&Registry>,
telemetry: Option<TelemetryHandle>,
) -> Self {
let protocol = config.protocol_name.clone();
let (validator, report_stream) =
GossipValidator::new(config, set_state.clone(), prometheus_registry, telemetry.clone());
let validator = Arc::new(validator);
let gossip_engine = Arc::new(Mutex::new(GossipEngine::new(
service.clone(),
GRANDPA_PROTOCOL_NAME,
protocol,
validator.clone(),
prometheus_registry,
)));
@@ -22,7 +22,7 @@ use super::{
gossip::{self, GossipValidator},
Round, SetId, VoterSet,
};
use crate::{communication::GRANDPA_PROTOCOL_NAME, environment::SharedVoterSetState};
use crate::{communication::grandpa_protocol_name, environment::SharedVoterSetState};
use futures::prelude::*;
use parity_scale_codec::Encode;
use sc_network::{config::Role, Event as NetworkEvent, ObservedRole, PeerId};
@@ -97,7 +97,7 @@ impl sc_network_gossip::ValidatorContext<Block> for TestNetwork {
<Self as sc_network_gossip::Network<Block>>::write_notification(
self,
who.clone(),
GRANDPA_PROTOCOL_NAME.into(),
grandpa_protocol_name::NAME.into(),
data,
);
}
@@ -148,6 +148,7 @@ fn config() -> crate::Config {
local_role: Role::Authority,
observer_enabled: true,
telemetry: None,
protocol_name: grandpa_protocol_name::NAME.into(),
}
}
@@ -286,7 +287,7 @@ fn good_commit_leads_to_relay() {
// Add the sending peer and send the commit
let _ = sender.unbounded_send(NetworkEvent::NotificationStreamOpened {
remote: sender_id.clone(),
protocol: GRANDPA_PROTOCOL_NAME.into(),
protocol: grandpa_protocol_name::NAME.into(),
negotiated_fallback: None,
role: ObservedRole::Full,
});
@@ -294,7 +295,7 @@ fn good_commit_leads_to_relay() {
let _ = sender.unbounded_send(NetworkEvent::NotificationsReceived {
remote: sender_id.clone(),
messages: vec![(
GRANDPA_PROTOCOL_NAME.into(),
grandpa_protocol_name::NAME.into(),
commit_to_send.clone().into(),
)],
});
@@ -303,7 +304,7 @@ fn good_commit_leads_to_relay() {
let receiver_id = sc_network::PeerId::random();
let _ = sender.unbounded_send(NetworkEvent::NotificationStreamOpened {
remote: receiver_id.clone(),
protocol: GRANDPA_PROTOCOL_NAME.into(),
protocol: grandpa_protocol_name::NAME.into(),
negotiated_fallback: None,
role: ObservedRole::Full,
});
@@ -321,7 +322,10 @@ fn good_commit_leads_to_relay() {
sender.unbounded_send(NetworkEvent::NotificationsReceived {
remote: receiver_id,
messages: vec![(GRANDPA_PROTOCOL_NAME.into(), msg.encode().into())],
messages: vec![(
grandpa_protocol_name::NAME.into(),
msg.encode().into(),
)],
})
};
@@ -433,14 +437,14 @@ fn bad_commit_leads_to_report() {
Event::EventStream(sender) => {
let _ = sender.unbounded_send(NetworkEvent::NotificationStreamOpened {
remote: sender_id.clone(),
protocol: GRANDPA_PROTOCOL_NAME.into(),
protocol: grandpa_protocol_name::NAME.into(),
negotiated_fallback: None,
role: ObservedRole::Full,
});
let _ = sender.unbounded_send(NetworkEvent::NotificationsReceived {
remote: sender_id.clone(),
messages: vec![(
GRANDPA_PROTOCOL_NAME.into(),
grandpa_protocol_name::NAME.into(),
commit_to_send.clone().into(),
)],
});
+10 -3
View File
@@ -123,6 +123,7 @@ pub mod warp_proof;
pub use authorities::{AuthoritySet, AuthoritySetChanges, SharedAuthoritySet};
pub use aux_schema::best_justification;
pub use communication::grandpa_protocol_name::standard_name as protocol_standard_name;
pub use finality_grandpa::voter::report;
pub use finality_proof::{FinalityProof, FinalityProofError, FinalityProofProvider};
pub use import::{find_forced_change, find_scheduled_change, GrandpaBlockImport};
@@ -263,6 +264,8 @@ pub struct Config {
pub keystore: Option<SyncCryptoStorePtr>,
/// TelemetryHandle instance.
pub telemetry: Option<TelemetryHandle>,
/// Chain specific GRANDPA protocol name. See [`crate::protocol_standard_name`].
pub protocol_name: std::borrow::Cow<'static, str>,
}
impl Config {
@@ -714,10 +717,14 @@ pub struct GrandpaParams<Block: BlockT, C, N, SC, VR> {
/// Returns the configuration value to put in
/// [`sc_network::config::NetworkConfiguration::extra_sets`].
pub fn grandpa_peers_set_config() -> sc_network::config::NonDefaultSetConfig {
/// For standard protocol name see [`crate::protocol_standard_name`].
pub fn grandpa_peers_set_config(
protocol_name: std::borrow::Cow<'static, str>,
) -> sc_network::config::NonDefaultSetConfig {
use communication::grandpa_protocol_name;
sc_network::config::NonDefaultSetConfig {
notifications_protocol: communication::GRANDPA_PROTOCOL_NAME.into(),
fallback_names: Vec::new(),
notifications_protocol: protocol_name,
fallback_names: grandpa_protocol_name::LEGACY_NAMES.iter().map(|&n| n.into()).collect(),
// Notifications reach ~256kiB in size at the time of writing on Kusama and Polkadot.
max_notification_size: 1024 * 1024,
set_config: sc_network::config::SetConfig {
+12 -2
View File
@@ -56,6 +56,7 @@ use substrate_test_runtime_client::runtime::BlockNumber;
use tokio::runtime::{Handle, Runtime};
use authorities::AuthoritySet;
use communication::grandpa_protocol_name;
use sc_block_builder::BlockBuilderProvider;
use sc_consensus::LongestChain;
use sc_keystore::LocalKeystore;
@@ -97,7 +98,7 @@ impl GrandpaTestNet {
impl GrandpaTestNet {
fn add_authority_peer(&mut self) {
self.add_full_peer_with_config(FullPeerConfig {
notifications_protocols: vec![communication::GRANDPA_PROTOCOL_NAME.into()],
notifications_protocols: vec![grandpa_protocol_name::NAME.into()],
is_authority: true,
..Default::default()
})
@@ -121,7 +122,7 @@ impl TestNetFactory for GrandpaTestNet {
fn add_full_peer(&mut self) {
self.add_full_peer_with_config(FullPeerConfig {
notifications_protocols: vec![communication::GRANDPA_PROTOCOL_NAME.into()],
notifications_protocols: vec![grandpa_protocol_name::NAME.into()],
is_authority: false,
..Default::default()
})
@@ -274,6 +275,7 @@ fn initialize_grandpa(
local_role: Role::Authority,
observer_enabled: true,
telemetry: None,
protocol_name: grandpa_protocol_name::NAME.into(),
},
link,
network: net_service,
@@ -423,6 +425,7 @@ fn finalize_3_voters_1_full_observer() {
local_role: Role::Authority,
observer_enabled: true,
telemetry: None,
protocol_name: grandpa_protocol_name::NAME.into(),
},
link,
network: net_service,
@@ -513,6 +516,7 @@ fn transition_3_voters_twice_1_full_observer() {
local_role: Role::Authority,
observer_enabled: true,
telemetry: None,
protocol_name: grandpa_protocol_name::NAME.into(),
},
link,
network: net_service,
@@ -971,6 +975,7 @@ fn voter_persists_its_votes() {
local_role: Role::Authority,
observer_enabled: true,
telemetry: None,
protocol_name: grandpa_protocol_name::NAME.into(),
};
let set_state = {
@@ -1010,6 +1015,7 @@ fn voter_persists_its_votes() {
local_role: Role::Authority,
observer_enabled: true,
telemetry: None,
protocol_name: grandpa_protocol_name::NAME.into(),
},
link,
network: net_service,
@@ -1050,6 +1056,7 @@ fn voter_persists_its_votes() {
local_role: Role::Authority,
observer_enabled: true,
telemetry: None,
protocol_name: grandpa_protocol_name::NAME.into(),
},
link,
network: net_service,
@@ -1213,6 +1220,7 @@ fn finalize_3_voters_1_light_observer() {
local_role: Role::Full,
observer_enabled: true,
telemetry: None,
protocol_name: grandpa_protocol_name::NAME.into(),
},
net.peers[3].data.lock().take().expect("link initialized at startup; qed"),
net.peers[3].network_service().clone(),
@@ -1259,6 +1267,7 @@ fn voter_catches_up_to_latest_round_when_behind() {
local_role: Role::Authority,
observer_enabled: true,
telemetry: None,
protocol_name: grandpa_protocol_name::NAME.into(),
},
link,
network: net.lock().peer(peer_id).network_service().clone(),
@@ -1376,6 +1385,7 @@ where
local_role: Role::Authority,
observer_enabled: true,
telemetry: None,
protocol_name: grandpa_protocol_name::NAME.into(),
};
let network =
+7
View File
@@ -603,6 +603,13 @@ impl NonDefaultSetConfig {
pub fn add_reserved(&mut self, peer: MultiaddrWithPeerId) {
self.set_config.reserved_nodes.push(peer);
}
/// Add a list of protocol names used for backward compatibility.
///
/// See the explanations in [`NonDefaultSetConfig::fallback_names`].
pub fn add_fallback_names(&mut self, fallback_names: Vec<Cow<'static, str>>) {
self.fallback_names.extend(fallback_names);
}
}
/// Configuration for the transport layer.