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
+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 =