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
@@ -220,7 +220,9 @@ impl RequestResponsesBehaviour {
max_request_size: protocol.max_request_size,
max_response_size: protocol.max_response_size,
},
iter::once((protocol.name.as_bytes().to_vec(), protocol_support)),
iter::once(protocol.name.as_bytes().to_vec())
.chain(protocol.fallback_names.iter().map(|name| name.as_bytes().to_vec()))
.zip(iter::repeat(protocol_support)),
cfg,
);
@@ -1027,6 +1029,7 @@ mod tests {
let protocol_config = ProtocolConfig {
name: From::from(protocol_name),
fallback_names: Vec::new(),
max_request_size: 1024,
max_response_size: 1024 * 1024,
request_timeout: Duration::from_secs(30),
@@ -1127,6 +1130,7 @@ mod tests {
let protocol_config = ProtocolConfig {
name: From::from(protocol_name),
fallback_names: Vec::new(),
max_request_size: 1024,
max_response_size: 8, // <-- important for the test
request_timeout: Duration::from_secs(30),
@@ -1223,6 +1227,7 @@ mod tests {
let protocol_configs = vec![
ProtocolConfig {
name: From::from(protocol_name_1),
fallback_names: Vec::new(),
max_request_size: 1024,
max_response_size: 1024 * 1024,
request_timeout: Duration::from_secs(30),
@@ -1230,6 +1235,7 @@ mod tests {
},
ProtocolConfig {
name: From::from(protocol_name_2),
fallback_names: Vec::new(),
max_request_size: 1024,
max_response_size: 1024 * 1024,
request_timeout: Duration::from_secs(30),
@@ -1247,6 +1253,7 @@ mod tests {
let protocol_configs = vec![
ProtocolConfig {
name: From::from(protocol_name_1),
fallback_names: Vec::new(),
max_request_size: 1024,
max_response_size: 1024 * 1024,
request_timeout: Duration::from_secs(30),
@@ -1254,6 +1261,7 @@ mod tests {
},
ProtocolConfig {
name: From::from(protocol_name_2),
fallback_names: Vec::new(),
max_request_size: 1024,
max_response_size: 1024 * 1024,
request_timeout: Duration::from_secs(30),