Skip to content
Merged
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
60 changes: 38 additions & 22 deletions ledger/src/blockstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5315,7 +5315,7 @@ pub mod tests {
crate::{
genesis_utils::{create_genesis_config, GenesisConfigInfo},
leader_schedule::{FixedSchedule, IdentityKeyedLeaderSchedule},
shred::{max_ticks_per_n_shreds, ShredFlags},
shred::max_ticks_per_n_shreds,
},
assert_matches::assert_matches,
bincode::{serialize, Options},
Expand Down Expand Up @@ -7542,18 +7542,25 @@ pub mod tests {
index
);

// Add a shred from different fec set
let shredder = Shredder::new(slot, slot.saturating_sub(1), 0, 0).unwrap();
let keypair = Keypair::new();
let reed_solomon_cache = ReedSolomonCache::default();
let new_index = fec_set_index + 31;
let new_data_shred = Shred::new_from_data(
slot,
new_index,
1, // parent_offset
&[3, 3, 3], // data
ShredFlags::empty(),
0, // reference_tick,
0, // version
fec_set_index + 30,
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this +30 here seems a bit odd here, not sure what it is trying to achieve.

);
// Add a shred from different fec set
let new_data_shred = shredder
.make_shreds_from_data_slice(
&keypair,
&[3, 3, 3],
false,
Some(Hash::default()),
new_index,
new_index,
&reed_solomon_cache,
&mut ProcessShredsStats::default(),
)
.unwrap()
.next()
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we generate full FEC set as usual but only pick the first shred, which should have the exact index we need.

.unwrap();

let mut shred_insertion_tracker =
ShredInsertionTracker::new(data_shreds.len(), blockstore.db.batch().unwrap());
Expand Down Expand Up @@ -7868,16 +7875,25 @@ pub mod tests {
);

// Insert an empty shred that won't deshred into entries
let shreds = vec![Shred::new_from_data(
slot,
next_shred_index as u32,
1,
&[1, 1, 1],
ShredFlags::LAST_SHRED_IN_SLOT,
0,
0,
next_shred_index as u32,
)];

let shredder = Shredder::new(slot, slot.saturating_sub(1), 0, 0).unwrap();
let keypair = Keypair::new();
let reed_solomon_cache = ReedSolomonCache::default();

let shreds: Vec<Shred> = shredder
.make_shreds_from_data_slice(
&keypair,
&[1, 1, 1],
true,
Some(Hash::default()),
next_shred_index as u32,
next_shred_index as u32,
&reed_solomon_cache,
&mut ProcessShredsStats::default(),
)
.unwrap()
.take(DATA_SHREDS_PER_FEC_BLOCK)
.collect();

// With the corruption, nothing should be returned, even though an
// earlier data block was valid
Expand Down
Loading