From 567d1eacf9f16c607e266e182bc65154dbc272ae Mon Sep 17 00:00:00 2001 From: behzad nouri Date: Wed, 19 Jul 2023 10:45:49 -0400 Subject: [PATCH] enables merkle shreds for devnet and development clusters --- ledger/src/blockstore.rs | 3 ++- ledger/src/shred.rs | 2 +- turbine/src/broadcast_stage/standard_broadcast_run.rs | 8 +++++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/ledger/src/blockstore.rs b/ledger/src/blockstore.rs index 9cdc01e64bf45b..ac9ea93ff92d0c 100644 --- a/ledger/src/blockstore.rs +++ b/ledger/src/blockstore.rs @@ -6163,7 +6163,8 @@ pub mod tests { let gap: u64 = 10; assert!(gap > 3); // Create enough entries to ensure there are at least two shreds created - let num_entries = max_ticks_per_n_shreds(1, None) + 1; + let data_buffer_size = ShredData::capacity(/*merkle_proof_size:*/ None).unwrap(); + let num_entries = max_ticks_per_n_shreds(1, Some(data_buffer_size)) + 1; let entries = create_ticks(num_entries, 0, Hash::default()); let mut shreds = entries_to_test_shreds(&entries, slot, 0, true, 0, /*merkle_variant:*/ false); diff --git a/ledger/src/shred.rs b/ledger/src/shred.rs index fc6dcf0d69e6e7..61c006918e445d 100644 --- a/ledger/src/shred.rs +++ b/ledger/src/shred.rs @@ -995,7 +995,7 @@ pub fn max_entries_per_n_shred( num_shreds: u64, shred_data_size: Option, ) -> u64 { - let data_buffer_size = ShredData::capacity(/*merkle_proof_size:*/ None).unwrap(); + let data_buffer_size = ShredData::capacity(/*merkle_proof_size:*/ Some(6)).unwrap(); let shred_data_size = shred_data_size.unwrap_or(data_buffer_size) as u64; let vec_size = bincode::serialized_size(&vec![entry]).unwrap(); let entry_size = bincode::serialized_size(entry).unwrap(); diff --git a/turbine/src/broadcast_stage/standard_broadcast_run.rs b/turbine/src/broadcast_stage/standard_broadcast_run.rs index 592d6e699d1d9c..02c8b3b342fe89 100644 --- a/turbine/src/broadcast_stage/standard_broadcast_run.rs +++ b/turbine/src/broadcast_stage/standard_broadcast_run.rs @@ -510,7 +510,9 @@ impl BroadcastRun for StandardBroadcastRun { fn should_use_merkle_variant(slot: Slot, cluster_type: ClusterType, shred_version: u16) -> bool { match cluster_type { ClusterType::Testnet => shred_version == 28353, - _ => (slot % 19) == 1, + ClusterType::MainnetBeta => (slot % 19) == 1, + ClusterType::Devnet => true, + ClusterType::Development => true, } } @@ -788,13 +790,13 @@ mod test { } // At least as many coding shreds as data shreds. assert!(shreds.len() >= 29 * 2); - assert_eq!(shreds.iter().filter(|shred| shred.is_data()).count(), 29); + assert_eq!(shreds.iter().filter(|shred| shred.is_data()).count(), 30); process_ticks(75); while let Ok((recv_shreds, _)) = brecv.recv_timeout(Duration::from_secs(1)) { shreds.extend(recv_shreds.deref().clone()); } assert!(shreds.len() >= 33 * 2); - assert_eq!(shreds.iter().filter(|shred| shred.is_data()).count(), 33); + assert_eq!(shreds.iter().filter(|shred| shred.is_data()).count(), 34); } #[test]