From 8fb389fe8de3b66ea6cae974a629737319e88020 Mon Sep 17 00:00:00 2001 From: behzad nouri Date: Tue, 6 Feb 2024 20:04:47 +0000 Subject: [PATCH] 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. --- .../fail_entry_verification_broadcast_run.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/turbine/src/broadcast_stage/fail_entry_verification_broadcast_run.rs b/turbine/src/broadcast_stage/fail_entry_verification_broadcast_run.rs index b98972690..e9ed6a1a6 100644 --- a/turbine/src/broadcast_stage/fail_entry_verification_broadcast_run.rs +++ b/turbine/src/broadcast_stage/fail_entry_verification_broadcast_run.rs @@ -15,6 +15,7 @@ pub(super) struct FailEntryVerificationBroadcastRun { shred_version: u16, good_shreds: Vec, current_slot: Slot, + chained_merkle_root: Hash, next_shred_index: u32, next_code_index: u32, cluster_nodes_cache: Arc>, @@ -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) });