Change request-response protocol names to include genesis hash & fork id (#5870)

This commit is contained in:
Dmitry Markin
2022-08-12 15:07:13 +03:00
committed by GitHub
parent 596b5df747
commit 4def0da0dc
17 changed files with 206 additions and 72 deletions
@@ -22,7 +22,7 @@ use parity_scale_codec::{Decode, Encode};
use polkadot_node_network_protocol::{
request_response::{
v1::{StatementFetchingRequest, StatementFetchingResponse},
IncomingRequest, Recipient, Requests,
IncomingRequest, Recipient, ReqProtocolNames, Requests,
},
view, ObservedRole,
};
@@ -44,6 +44,9 @@ use sp_keyring::Sr25519Keyring;
use sp_keystore::{CryptoStore, SyncCryptoStore, SyncCryptoStorePtr};
use std::{iter::FromIterator as _, sync::Arc, time::Duration};
// Some deterministic genesis hash for protocol names
const GENESIS_HASH: Hash = Hash::repeat_byte(0xff);
#[test]
fn active_head_accepts_only_2_seconded_per_validator() {
let validators = vec![
@@ -724,7 +727,8 @@ fn receiving_from_one_sends_to_another_and_to_candidate_backing() {
let pool = sp_core::testing::TaskExecutor::new();
let (ctx, mut handle) = polkadot_node_subsystem_test_helpers::make_subsystem_context(pool);
let (statement_req_receiver, _) = IncomingRequest::get_config_receiver();
let req_protocol_names = ReqProtocolNames::new(&GENESIS_HASH, None);
let (statement_req_receiver, _) = IncomingRequest::get_config_receiver(&req_protocol_names);
let bg = async move {
let s = StatementDistributionSubsystem::new(
@@ -917,7 +921,9 @@ fn receiving_large_statement_from_one_sends_to_another_and_to_candidate_backing(
let pool = sp_core::testing::TaskExecutor::new();
let (ctx, mut handle) = polkadot_node_subsystem_test_helpers::make_subsystem_context(pool);
let (statement_req_receiver, mut req_cfg) = IncomingRequest::get_config_receiver();
let req_protocol_names = ReqProtocolNames::new(&GENESIS_HASH, None);
let (statement_req_receiver, mut req_cfg) =
IncomingRequest::get_config_receiver(&req_protocol_names);
let bg = async move {
let s = StatementDistributionSubsystem::new(
@@ -1429,7 +1435,9 @@ fn share_prioritizes_backing_group() {
let pool = sp_core::testing::TaskExecutor::new();
let (ctx, mut handle) = polkadot_node_subsystem_test_helpers::make_subsystem_context(pool);
let (statement_req_receiver, mut req_cfg) = IncomingRequest::get_config_receiver();
let req_protocol_names = ReqProtocolNames::new(&GENESIS_HASH, None);
let (statement_req_receiver, mut req_cfg) =
IncomingRequest::get_config_receiver(&req_protocol_names);
let bg = async move {
let s = StatementDistributionSubsystem::new(
@@ -1724,7 +1732,8 @@ fn peer_cant_flood_with_large_statements() {
let pool = sp_core::testing::TaskExecutor::new();
let (ctx, mut handle) = polkadot_node_subsystem_test_helpers::make_subsystem_context(pool);
let (statement_req_receiver, _) = IncomingRequest::get_config_receiver();
let req_protocol_names = ReqProtocolNames::new(&GENESIS_HASH, None);
let (statement_req_receiver, _) = IncomingRequest::get_config_receiver(&req_protocol_names);
let bg = async move {
let s = StatementDistributionSubsystem::new(
make_ferdie_keystore(),
@@ -1928,7 +1937,8 @@ fn handle_multiple_seconded_statements() {
let pool = sp_core::testing::TaskExecutor::new();
let (ctx, mut handle) = polkadot_node_subsystem_test_helpers::make_subsystem_context(pool);
let (statement_req_receiver, _) = IncomingRequest::get_config_receiver();
let req_protocol_names = ReqProtocolNames::new(&GENESIS_HASH, None);
let (statement_req_receiver, _) = IncomingRequest::get_config_receiver(&req_protocol_names);
let virtual_overseer_fut = async move {
let s = StatementDistributionSubsystem::new(