Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
chains Merkle shreds in fail-entry-verification broadcast (#35060)
Browse files Browse the repository at this point in the history
The commit migrates
    turbine/src/broadcast_stage/fail_entry_verification_broadcast_run.rs
to use chained Merkle shreds variant.
  • Loading branch information
behzadnouri authored Feb 6, 2024
1 parent 8d0ca9d commit 8fb389f
Showing 1 changed file with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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>>,
Expand All @@ -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,
Expand All @@ -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();
Expand Down Expand Up @@ -92,14 +100,17 @@ 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
&self.reed_solomon_cache,
&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;
Expand All @@ -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
Expand All @@ -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)
});
Expand Down

0 comments on commit 8fb389f

Please sign in to comment.