fix: Incorrect P2PContext in bcast example#347
Conversation
| .await | ||
| .expect("Failed to register demo bcast message"); | ||
|
|
||
| let mut component = None; |
There was a problem hiding this comment.
This handle approach is similar to what we have in parsigex: #291 (comment).
The design is very cumbersome to use so it requires some further work.
| args.filter_private_addrs, | ||
| known_peers, | ||
| |builder, keypair, relay_client| { | ||
| let p2p_context = builder.p2p_context(); |
There was a problem hiding this comment.
can you try to remove this and use the outer p2p_context, that will be cleaner without having the mut component
There was a problem hiding this comment.
We can, I was just following the patterns that we already have in bootnode and parsigex:
pluto/crates/p2p/examples/bootnode.rs
Lines 141 to 163 in 0de6cdc
pluto/crates/parsigex/examples/parsigex.rs
Lines 264 to 296 in 0de6cdc
There was a problem hiding this comment.
Maybe we will revisit these examples to see if we can have a cleaner approach. LGTM now
| ); | ||
| print_cluster_overview(&cluster_info); | ||
|
|
||
| let mut connected_cluster_peers = HashSet::<PeerId>::new(); |
There was a problem hiding this comment.
This set duplicates the information that P2PContext and its PeerStore already manage. ClusterInfo is in the same situation, where pretty much all information is duplicated in some way.
The
bcastexample (https://github.com/NethermindEth/pluto/blob/c4c922a19c0efc29baf882d3ed438e4ccdc73f82/crates/dkg/examples/bcast.rs) is currently broken due to the usage of an incorrectP2PContextwhich results in active connections to known peers not getting updated, thus failing to broadcast despite the connections actually being active.This PR implements the minimal fix required to sort out the issue, but some comments are included to avoid similar situations in the future.