Skip to content

feat: Defer packet signature verification in gossip #5977

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

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions gossip/src/cluster_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2013,6 +2013,14 @@ impl ClusterInfo {
let mut ping_messages = vec![];
let mut pong_messages = vec![];
for (from_addr, packet) in packets.drain(..).flatten() {
// Deferred verification - we now do this later (here) instead of in verify_packet because it is expensive
if !packet.par_verify() {
continue;
}

// Verification passed, increment stats
self.stats.packets_received_verified_count.add_relaxed(1);

match packet {
Protocol::PullRequest(filter, caller) => {
if !check_pull_request_shred_version(self_shred_version, &caller) {
Expand Down Expand Up @@ -2129,10 +2137,7 @@ impl ClusterInfo {
return None;
}
}
protocol.par_verify().then(|| {
stats.packets_received_verified_count.add_relaxed(1);
(packet.meta().socket_addr(), protocol)
})
Some((packet.meta().socket_addr(), protocol))
}
let stakes = epoch_specs
.map(EpochSpecs::current_epoch_staked_nodes)
Expand Down