chains Merkle shreds in fail-entry-verification broadcast (#35060)

The commit migrates
    turbine/src/broadcast_stage/fail_entry_verification_broadcast_run.rs
to use chained Merkle shreds variant.
This commit is contained in:
behzad nouri 2024-02-06 20:04:47 +00:00 committed by GitHub
parent 8d0ca9db78
commit 8fb389fe8d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 16 additions and 3 deletions

View File

@ -15,6 +15,7 @@ pub(super) struct FailEntryVerificationBroadcastRun {
shred_version: u16,
good_shreds: Vec<Shred>,
current_slot: Slot,
chained_merkle_root: Hash,
next_shred_index: u32,
next_code_index: u32,
cluster_nodes_cache: Arc<ClusterNodesCache<BroadcastStage>>,
@ -31,6 +32,7 @@ impl FailEntryVerificationBroadcastRun {
shred_version,
good_shreds: vec![],
current_slot: 0,
chained_merkle_root: Hash::default(),
next_shred_index: 0,
next_code_index: 0,
cluster_nodes_cache,
@ -54,6 +56,12 @@ impl BroadcastRun for FailEntryVerificationBroadcastRun {
let last_tick_height = receive_results.last_tick_height;
if bank.slot() != self.current_slot {
self.chained_merkle_root = broadcast_utils::get_chained_merkle_root_from_parent(
bank.slot(),
bank.parent_slot(),
blockstore,
)
.unwrap();
self.next_shred_index = 0;
self.next_code_index = 0;
self.current_slot = bank.slot();
@ -92,7 +100,7 @@ impl BroadcastRun for FailEntryVerificationBroadcastRun {
keypair,
&receive_results.entries,
last_tick_height == bank.max_tick_height() && last_entries.is_none(),
None, // chained_merkle_root
Some(self.chained_merkle_root),
self.next_shred_index,
self.next_code_index,
true, // merkle_variant
@ -100,6 +108,9 @@ impl BroadcastRun for FailEntryVerificationBroadcastRun {
&mut ProcessShredsStats::default(),
);
if let Some(shred) = data_shreds.iter().max_by_key(|shred| shred.index()) {
self.chained_merkle_root = shred.merkle_root().unwrap();
}
self.next_shred_index += data_shreds.len() as u32;
if let Some(index) = coding_shreds.iter().map(Shred::index).max() {
self.next_code_index = index + 1;
@ -109,7 +120,7 @@ impl BroadcastRun for FailEntryVerificationBroadcastRun {
keypair,
&[good_last_entry],
true,
None, // chained_merkle_root
Some(self.chained_merkle_root),
self.next_shred_index,
self.next_code_index,
true, // merkle_variant
@ -123,13 +134,15 @@ impl BroadcastRun for FailEntryVerificationBroadcastRun {
keypair,
&[bad_last_entry],
false,
None, // chained_merkle_root
Some(self.chained_merkle_root),
self.next_shred_index,
self.next_code_index,
true, // merkle_variant
&self.reed_solomon_cache,
&mut ProcessShredsStats::default(),
);
assert_eq!(good_last_data_shred.len(), 1);
self.chained_merkle_root = good_last_data_shred.last().unwrap().merkle_root().unwrap();
self.next_shred_index += 1;
(good_last_data_shred, bad_last_data_shred)
});