Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enables merkle shreds for devnet and development clusters #32533

Merged
merged 1 commit into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 3 additions & 1 deletion ledger/src/shred.rs
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,9 @@ 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();
// Default 32:32 erasure batches yields 64 shreds; log2(64) = 6.
let merkle_proof_size = Some(6);
let data_buffer_size = ShredData::capacity(merkle_proof_size).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