-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Batch P2P Messages #1149
Batch P2P Messages #1149
Conversation
79de04c
to
eafd32e
Compare
|
||
let (own_message, outgoing_messages) = match self.processor.init() { | ||
DataToSend::Broadcast(stage_data) => { | ||
let ceremony_data: D = stage_data.clone().into(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let ceremony_data: D = stage_data.clone().into(); | |
let ceremony_data: Self::Message = stage_data.clone().into(); |
Same below
engine/src/multisig_p2p.rs
Outdated
Ok(_) => slog::info!(logger, "Sent P2P message to: {}", account_id), | ||
Err(error) => slog::error!(logger, "Failed to send P2P message to: {}. {}", account_id, error) | ||
Some(messages) = outgoing_p2p_message_receiver.recv() => { | ||
async fn send_messages<'a, AccountIds: 'a + IntoIterator<Item = &'a AccountId> + Clone>(client: &P2PRpcClient, account_to_peer: &BTreeMap<AccountId, (PeerId, u16, Ipv6Addr)>, account_ids: AccountIds, message: MultisigMessage, logger: &slog::Logger) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we reconsider the practice of defining named functions (lambdas are a different story) inside other functions? It reduces readability in my opinion, and doesn't add any real benefit (e.g. I can't see at glance what this loop does, but with send_messages
taken out the entire loop fits entirely in one screen). Like, you don't reduce the scope of this function by that much as long as it is private.
The formatting is also much nicer when the function is taken out:
async fn send_messages<'a, AccountIds: 'a + IntoIterator<Item = &'a AccountId> + Clone>(
client: &P2PRpcClient,
account_to_peer: &BTreeMap<AccountId, (PeerId, u16, Ipv6Addr)>,
account_ids: AccountIds,
message: MultisigMessage,
logger: &slog::Logger,
) {
9b54117
to
856e5bc
Compare
eafd32e
to
c7f2742
Compare
f5660b9
to
0058f82
Compare
Merging as we got three approvals. |
This will batch the p2p messages decreasing the RPC bandwidth for broadcast multisig stages (By not sending the same message repeatedly via RPC).
I also did this now to simplify the existing multisig tests to help abit when refactoring them for the oneshot.
I've chosen to not change the SC's p2p rpc interface here because we are likely to remove all the p2p code in the SC and handle peering manually in the CFE.
Note I did remove this log message from the tests (println!("recv secret3 keygen, i: {}", i);), and added assert_channel_empty in all cases after receiving p2p messages via the channel in the tests. Otherwise behaviour is the same.