Skip to content

Commit db832de

Browse files
BLS cert all to all. (#300)
Co-authored-by: Ashwin Sekar <[email protected]>
1 parent 5b5c49f commit db832de

File tree

11 files changed

+496
-243
lines changed

11 files changed

+496
-243
lines changed

core/src/tvu.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use {
2222
window_service::{WindowService, WindowServiceChannels},
2323
},
2424
bytes::Bytes,
25-
crossbeam_channel::{unbounded, Receiver, Sender},
25+
crossbeam_channel::{bounded, unbounded, Receiver, Sender},
2626
solana_client::connection_cache::ConnectionCache,
2727
solana_geyser_plugin_manager::block_metadata_notifier_interface::BlockMetadataNotifierArc,
2828
solana_gossip::{
@@ -298,7 +298,10 @@ impl Tvu {
298298
let (cost_update_sender, cost_update_receiver) = unbounded();
299299
let (drop_bank_sender, drop_bank_receiver) = unbounded();
300300
let (voting_sender, voting_receiver) = unbounded();
301-
let (bls_sender, bls_receiver) = unbounded();
301+
// The BLS sender channel should be mostly used during standstill handling,
302+
// there could be 10s/400ms = 25 slots, <=5 votes and <=5 certificates per slot,
303+
// we cap the channel at 512 to give some headroom.
304+
let (bls_sender, bls_receiver) = bounded(512);
302305

303306
let replay_senders = ReplaySenders {
304307
rpc_subscriptions: rpc_subscriptions.clone(),

core/src/voting_service.rs

Lines changed: 54 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,18 @@ impl VotingService {
260260
staked_validators_cache,
261261
);
262262
}
263+
BLSOp::PushCertificate { certificate } => {
264+
let vote_slot = certificate.certificate.slot;
265+
let bls_message = BLSMessage::Certificate((*certificate).clone());
266+
Self::broadcast_alpenglow_message(
267+
vote_slot,
268+
cluster_info,
269+
&bls_message,
270+
connection_cache,
271+
additional_listeners,
272+
staked_validators_cache,
273+
);
274+
}
263275
}
264276
}
265277

@@ -308,9 +320,11 @@ mod tests {
308320
super::*,
309321
crate::consensus::tower_storage::NullTowerStorage,
310322
alpenglow_vote::{
311-
bls_message::{BLSMessage, VoteMessage},
323+
bls_message::{BLSMessage, CertificateMessage, VoteMessage},
324+
certificate::{Certificate, CertificateType},
312325
vote::Vote,
313326
},
327+
bitvec::prelude::*,
314328
solana_bls_signatures::Signature as BLSSignature,
315329
solana_gossip::{cluster_info::ClusterInfo, contact_info::ContactInfo},
316330
solana_ledger::{
@@ -326,10 +340,7 @@ mod tests {
326340
ValidatorVoteKeypairs,
327341
},
328342
},
329-
solana_sdk::{
330-
hash::Hash,
331-
signer::{keypair::Keypair, Signer},
332-
},
343+
solana_sdk::signer::{keypair::Keypair, Signer},
333344
solana_streamer::{
334345
packet::{Packet, PacketBatch},
335346
recvmmsg::recv_mmsg,
@@ -342,6 +353,7 @@ mod tests {
342353
net::SocketAddr,
343354
sync::{atomic::AtomicBool, Arc, RwLock},
344355
},
356+
test_case::test_case,
345357
};
346358

347359
fn create_voting_service(
@@ -397,9 +409,41 @@ mod tests {
397409
)
398410
}
399411

400-
#[allow(clippy::disallowed_methods)]
401-
#[test]
402-
fn test_send_bls_message() {
412+
#[test_case(BLSOp::PushVote {
413+
bls_message: Arc::new(BLSMessage::Vote(VoteMessage {
414+
vote: Vote::new_skip_vote(5),
415+
signature: BLSSignature::default(),
416+
rank: 1,
417+
})),
418+
slot: 5,
419+
saved_vote_history: SavedVoteHistoryVersions::Current(SavedVoteHistory::default()),
420+
}, BLSMessage::Vote(VoteMessage {
421+
vote: Vote::new_skip_vote(5),
422+
signature: BLSSignature::default(),
423+
rank: 1,
424+
}))]
425+
#[test_case(BLSOp::PushCertificate {
426+
certificate: Arc::new(CertificateMessage {
427+
certificate: Certificate {
428+
certificate_type: CertificateType::Skip,
429+
slot: 5,
430+
block_id: None,
431+
replayed_bank_hash: None,
432+
},
433+
signature: BLSSignature::default(),
434+
bitmap: BitVec::new(),
435+
}),
436+
}, BLSMessage::Certificate(CertificateMessage {
437+
certificate: Certificate {
438+
certificate_type: CertificateType::Skip,
439+
slot: 5,
440+
block_id: None,
441+
replayed_bank_hash: None,
442+
},
443+
signature: BLSSignature::default(),
444+
bitmap: BitVec::new(),
445+
}))]
446+
fn test_send_bls_message(bls_op: BLSOp, expected_bls_message: BLSMessage) {
403447
solana_logger::setup();
404448
let (_vote_sender, vote_receiver) = crossbeam_channel::unbounded();
405449
let (bls_sender, bls_receiver) = crossbeam_channel::unbounded();
@@ -413,19 +457,7 @@ mod tests {
413457
let _ = create_voting_service(vote_receiver, bls_receiver, listener_addr);
414458

415459
// Send a BLS message via the VotingService
416-
let bls_message = BLSMessage::Vote(VoteMessage {
417-
vote: Vote::new_notarization_vote(5, Hash::new_unique(), Hash::new_unique()),
418-
signature: BLSSignature::default(),
419-
rank: 1,
420-
});
421-
let saved_vote_history = SavedVoteHistoryVersions::Current(SavedVoteHistory::default());
422-
assert!(bls_sender
423-
.send(BLSOp::PushVote {
424-
bls_message: bls_message.clone(),
425-
slot: 5,
426-
saved_vote_history,
427-
})
428-
.is_ok());
460+
assert!(bls_sender.send(bls_op).is_ok());
429461

430462
// Wait for the listener to receive the message
431463
let mut packet_batch = PacketBatch::new(vec![Packet::default()]);
@@ -443,6 +475,6 @@ mod tests {
443475
err
444476
)
445477
});
446-
assert_eq!(received_bls_message, bls_message);
478+
assert_eq!(received_bls_message, expected_bls_message);
447479
}
448480
}

programs/sbf/Cargo.lock

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

svm/examples/Cargo.lock

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)