mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-01 01:01:01 +00:00
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:
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user