Change on-the-wire protocol names to include genesis hash & fork id (#11938)

* Rename transactions protocol to include genesis hash

* Add protocol name generation to sc_network::utils

* Use utils functions for transactions protocol name generation

* Extract protocol name generation into public module

* Use sc_network::protocol_name::standard_protocol_name() for BEEFY and GRANDPA

* minor: add missing newline at EOF

* Change block-announces protocol name to include genesis_hash & fork_id

* Change protocol names to include genesis hash and fork id

Protocols changed:
    - sync
    - state
    - light
    - sync/warp

* Revert "Use sc_network::protocol_name::standard_protocol_name() for BEEFY and GRANDPA"

This reverts commit cd60a95a3face397e1b67f4bc95dd0f2b581bfae.

* Get rid of `protocol_name` module
This commit is contained in:
Dmitry Markin
2022-08-05 09:50:57 +03:00
committed by GitHub
parent 946f6a2818
commit 6eda842cf0
17 changed files with 226 additions and 50 deletions
+16 -5
View File
@@ -808,23 +808,25 @@ where
let protocol_id = ProtocolId::from("test-protocol-name");
let fork_id = Some(String::from("test-fork-id"));
let block_request_protocol_config = {
let (handler, protocol_config) =
BlockRequestHandler::new(&protocol_id, client.clone(), 50);
BlockRequestHandler::new(&protocol_id, None, client.clone(), 50);
self.spawn_task(handler.run().boxed());
protocol_config
};
let state_request_protocol_config = {
let (handler, protocol_config) =
StateRequestHandler::new(&protocol_id, client.clone(), 50);
StateRequestHandler::new(&protocol_id, None, client.clone(), 50);
self.spawn_task(handler.run().boxed());
protocol_config
};
let light_client_request_protocol_config = {
let (handler, protocol_config) =
LightClientRequestHandler::new(&protocol_id, client.clone());
LightClientRequestHandler::new(&protocol_id, None, client.clone());
self.spawn_task(handler.run().boxed());
protocol_config
};
@@ -832,8 +834,16 @@ where
let warp_sync = Arc::new(TestWarpSyncProvider(client.clone()));
let warp_protocol_config = {
let (handler, protocol_config) =
warp_request_handler::RequestHandler::new(protocol_id.clone(), warp_sync.clone());
let (handler, protocol_config) = warp_request_handler::RequestHandler::new(
protocol_id.clone(),
client
.block_hash(0u32.into())
.ok()
.flatten()
.expect("Genesis block exists; qed"),
None,
warp_sync.clone(),
);
self.spawn_task(handler.run().boxed());
protocol_config
};
@@ -867,6 +877,7 @@ where
chain: client.clone(),
transaction_pool: Arc::new(EmptyTransactionPool),
protocol_id,
fork_id,
import_queue,
chain_sync: Box::new(chain_sync),
metrics_registry: None,