Companion for substrate#12124: add BEEFY request response protocol (#6035)

* service: add BEEFY request response proto

* update lockfile for {"substrate"}

* update lockfile for substrate
This commit is contained in:
Adrian Catangiu
2022-10-03 17:32:27 +03:00
committed by GitHub
parent d7eaaeee65
commit 32ccf86a43
3 changed files with 200 additions and 180 deletions
+174 -174
View File
File diff suppressed because it is too large Load Diff
+23 -5
View File
@@ -849,13 +849,24 @@ where
.extra_sets .extra_sets
.push(grandpa::grandpa_peers_set_config(grandpa_protocol_name.clone())); .push(grandpa::grandpa_peers_set_config(grandpa_protocol_name.clone()));
let beefy_protocol_name = let beefy_gossip_proto_name =
beefy_gadget::protocol_standard_name(&genesis_hash, &config.chain_spec); beefy_gadget::gossip_protocol_name(&genesis_hash, config.chain_spec.fork_id());
// `beefy_on_demand_justifications_handler` is given to `beefy-gadget` task to be run,
// while `beefy_req_resp_cfg` is added to `config.network.request_response_protocols`.
let (beefy_on_demand_justifications_handler, beefy_req_resp_cfg) =
beefy_gadget::communication::request_response::BeefyJustifsRequestHandler::new(
&genesis_hash,
config.chain_spec.fork_id(),
client.clone(),
);
if enable_beefy { if enable_beefy {
config config
.network .network
.extra_sets .extra_sets
.push(beefy_gadget::beefy_peers_set_config(beefy_protocol_name.clone())); .push(beefy_gadget::communication::beefy_peers_set_config(
beefy_gossip_proto_name.clone(),
));
config.network.request_response_protocols.push(beefy_req_resp_cfg);
} }
let peerset_protocol_names = let peerset_protocol_names =
@@ -1174,16 +1185,23 @@ where
if role.is_authority() { Some(keystore_container.sync_keystore()) } else { None }; if role.is_authority() { Some(keystore_container.sync_keystore()) } else { None };
if enable_beefy { if enable_beefy {
let justifications_protocol_name = beefy_on_demand_justifications_handler.protocol_name();
let network_params = beefy_gadget::BeefyNetworkParams {
network: network.clone(),
gossip_protocol_name: beefy_gossip_proto_name,
justifications_protocol_name,
_phantom: core::marker::PhantomData::<Block>,
};
let beefy_params = beefy_gadget::BeefyParams { let beefy_params = beefy_gadget::BeefyParams {
client: client.clone(), client: client.clone(),
backend: backend.clone(), backend: backend.clone(),
runtime: client.clone(), runtime: client.clone(),
key_store: keystore_opt.clone(), key_store: keystore_opt.clone(),
network: network.clone(), network_params,
min_block_delta: if chain_spec.is_wococo() { 4 } else { 8 }, min_block_delta: if chain_spec.is_wococo() { 4 } else { 8 },
prometheus_registry: prometheus_registry.clone(), prometheus_registry: prometheus_registry.clone(),
protocol_name: beefy_protocol_name,
links: beefy_links, links: beefy_links,
on_demand_justifications_handler: beefy_on_demand_justifications_handler,
}; };
let gadget = beefy_gadget::start_beefy_gadget::<_, _, _, _, _>(beefy_params); let gadget = beefy_gadget::start_beefy_gadget::<_, _, _, _, _>(beefy_params);
+3 -1
View File
@@ -61,7 +61,9 @@ pub struct GrandpaDeps<B> {
pub finality_provider: Arc<FinalityProofProvider<B, Block>>, pub finality_provider: Arc<FinalityProofProvider<B, Block>>,
} }
use beefy_gadget::notification::{BeefyBestBlockStream, BeefyVersionedFinalityProofStream}; use beefy_gadget::communication::notification::{
BeefyBestBlockStream, BeefyVersionedFinalityProofStream,
};
/// Dependencies for BEEFY /// Dependencies for BEEFY
pub struct BeefyDeps { pub struct BeefyDeps {
/// Receives notifications about finality proof events from BEEFY. /// Receives notifications about finality proof events from BEEFY.