Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
3cf86ef
grandpa: update notif protocol name
acatangiu Dec 9, 2021
fbf7cf5
grandpa: add chain id prefix to protocol name
acatangiu Dec 10, 2021
2b22762
grandpa: beautify protocol name handling
acatangiu Dec 10, 2021
206beaa
grandpa: prepend genesis hash to protocol name
acatangiu Dec 10, 2021
952e0a7
chain-spec: add optional 'fork_id'
acatangiu Dec 13, 2021
758ff84
grandpa: protocol_name mod instead of struct
acatangiu Dec 13, 2021
b3a0243
beefy: add genesis hash prefix to protocol name
acatangiu Dec 13, 2021
44baf42
chainspec: add fork_id
acatangiu Dec 14, 2021
0f9d6cc
grandpa: simplify protocol name
acatangiu Dec 14, 2021
393c8cf
Merge branch 'master' of github.com:paritytech/substrate into grandpa…
acatangiu Dec 14, 2021
482f0bc
grandpa: contain protocol name building logic
acatangiu Dec 16, 2021
1dda847
beefy: contain protocol name building logic
acatangiu Dec 16, 2021
1262cce
grandpa: fix tests
acatangiu Dec 16, 2021
f3a006d
Merge branch 'master' of github.com:paritytech/substrate into grandpa…
acatangiu Dec 16, 2021
b4b8a74
fix merge damage
acatangiu Dec 16, 2021
0de4362
fix docs reference visibility
acatangiu Dec 20, 2021
a07eec6
Update client/finality-grandpa/src/lib.rs
acatangiu Dec 20, 2021
1aa9753
Update client/finality-grandpa/src/communication/mod.rs
acatangiu Dec 20, 2021
5673f48
Update client/beefy/src/lib.rs
acatangiu Dec 20, 2021
5a6a7b2
Update client/beefy/src/lib.rs
acatangiu Dec 20, 2021
d70ed35
avoid using hash default, even for protocol names
acatangiu Jan 4, 2022
d5802f6
Merge branch 'master' of github.com:paritytech/substrate into grandpa…
acatangiu Jan 4, 2022
3c7f699
Merge branch 'master' of github.com:paritytech/substrate into grandpa…
acatangiu Jan 5, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
beefy: add genesis hash prefix to protocol name
  • Loading branch information
acatangiu committed Dec 13, 2021
commit b3a02437ea8cc96ae009115049bef2839f2a34fc
29 changes: 23 additions & 6 deletions client/beefy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,28 @@ mod worker;

pub mod notification;

pub const BEEFY_PROTOCOL_NAME: &str = "/paritytech/beefy/1";
pub(crate) mod beefy_protocol_name {
const NAME: &'static str = "/beefy/1";
/// Old names for the notifications protocol, used for backward compatibility.
pub 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 with_prefix(prefix: &str) -> String {
format!("{}{}", prefix, NAME)
}
}

/// 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);
pub fn beefy_peers_set_config(chain_prefix: &str) -> sc_network::config::NonDefaultSetConfig {
let mut cfg = sc_network::config::NonDefaultSetConfig::new(
beefy_protocol_name::with_prefix(chain_prefix).into(),
1024 * 1024,
);

cfg.allow_non_reserved(25, 25);
cfg.add_fallback_names(beefy_protocol_name::LEGACY_NAMES.iter().map(|&n| n.into()).collect());
cfg
}

Expand Down Expand Up @@ -101,6 +115,8 @@ where
pub min_block_delta: u32,
/// Prometheus metric registry
pub prometheus_registry: Option<Registry>,
/// Protocol name prefix - usually genesis hash and optional fork id.
pub protocol_name_prefix: String,
}

/// Start the BEEFY gadget.
Expand All @@ -122,11 +138,12 @@ where
signed_commitment_sender,
min_block_delta,
prometheus_registry,
protocol_name_prefix,
} = beefy_params;

let protocol_name = beefy_protocol_name::with_prefix(&protocol_name_prefix);
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(
Expand Down
5 changes: 5 additions & 0 deletions client/network/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,11 @@ 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.
pub fn add_fallback_names(&mut self, fallback_names: Vec<Cow<'static, str>>) {
self.fallback_names.extend(fallback_names);
}
}

/// Configuration for the transport layer.
Expand Down