Skip to content

Commit

Permalink
enables merkle shreds for devnet and development clusters
Browse files Browse the repository at this point in the history
  • Loading branch information
behzadnouri committed Jul 19, 2023
1 parent 6d30429 commit 2e79ba9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
3 changes: 2 additions & 1 deletion ledger/src/blockstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6162,7 +6162,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);
Expand Down
2 changes: 1 addition & 1 deletion ledger/src/shred.rs
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,7 @@ pub fn max_entries_per_n_shred(
num_shreds: u64,
shred_data_size: Option<usize>,
) -> 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();
Expand Down
15 changes: 7 additions & 8 deletions turbine/src/broadcast_stage/standard_broadcast_run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ impl StandardBroadcastRun {
let shredder =
Shredder::new(state.slot, state.parent, reference_tick, self.shred_version)
.unwrap();
let merkle_variant =
should_use_merkle_variant(state.slot, cluster_type, self.shred_version);
let merkle_variant = should_use_merkle_variant(state.slot, cluster_type);
let (mut shreds, coding_shreds) = shredder.entries_to_shreds(
keypair,
&[], // entries
Expand Down Expand Up @@ -146,7 +145,7 @@ impl StandardBroadcastRun {
};
let shredder =
Shredder::new(slot, parent_slot, reference_tick, self.shred_version).unwrap();
let merkle_variant = should_use_merkle_variant(slot, cluster_type, self.shred_version);
let merkle_variant = should_use_merkle_variant(slot, cluster_type);
let (data_shreds, coding_shreds) = shredder.entries_to_shreds(
keypair,
entries,
Expand Down Expand Up @@ -507,10 +506,10 @@ impl BroadcastRun for StandardBroadcastRun {
}
}

fn should_use_merkle_variant(slot: Slot, cluster_type: ClusterType, shred_version: u16) -> bool {
fn should_use_merkle_variant(slot: Slot, cluster_type: ClusterType) -> bool {
match cluster_type {
ClusterType::Testnet => shred_version == 28353,
_ => (slot % 19) == 1,
ClusterType::Testnet | ClusterType::Devnet | ClusterType::Development => true,
ClusterType::MainnetBeta => (slot % 19) == 1,
}
}

Expand Down Expand Up @@ -788,13 +787,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]
Expand Down

0 comments on commit 2e79ba9

Please sign in to comment.