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

v2.1: blockstore: mark slot as dead on data shred merkle root conflict (backport of #3970) #4075

Merged
merged 2 commits into from
Dec 20, 2024
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
40 changes: 20 additions & 20 deletions ledger/src/blockstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1692,6 +1692,13 @@ impl Blockstore {
&shred,
duplicate_shreds,
) {
// This indicates there is an alternate version of this block.
// Similar to the last index case above, we might never get all the
// shreds for our current version, never replay this slot, and make no
// progress. We cannot determine if we have the version that will eventually
// be complete, so we take the conservative approach and mark the slot as dead
// so that replay can dump and repair the correct version.
write_batch.put::<cf::DeadSlots>(slot, &true).unwrap();
return Err(InsertDataShredError::InvalidShred);
}
}
Expand Down Expand Up @@ -5950,21 +5957,6 @@ pub mod tests {
.insert_shreds(shreds, None, false)
.expect("Expected successful write of shreds");

let mut shreds1 = entries_to_test_shreds(
&entries[4..],
1,
0,
false,
0,
false, // merkle_variant
);
for (i, b) in shreds1.iter_mut().enumerate() {
b.set_index(8 + i as u32);
}
blockstore
.insert_shreds(shreds1, None, false)
.expect("Expected successful write of shreds");

assert_eq!(
blockstore.get_slot_entries(1, 0).unwrap()[2..4],
entries[2..4],
Expand Down Expand Up @@ -7857,6 +7849,11 @@ pub mod tests {
index
);

// Block is now dead
blockstore.db.write(write_batch).unwrap();
assert!(blockstore.is_dead(slot));
blockstore.remove_dead_slot(slot).unwrap();

// Blockstore should also have the merkle root meta of the original shred
assert_eq!(
blockstore
Expand Down Expand Up @@ -7888,6 +7885,7 @@ pub mod tests {
fec_set_index + 30,
);

let mut write_batch = blockstore.db.batch().unwrap();
blockstore
.check_insert_data_shred(
new_data_shred.clone(),
Expand All @@ -7904,23 +7902,25 @@ pub mod tests {
ShredSource::Turbine,
)
.unwrap();
blockstore.db.write(write_batch).unwrap();

// Verify that we still have the merkle root meta for the original shred
// and the new shred
assert_eq!(merkle_root_metas.len(), 2);
assert_eq!(
merkle_root_metas
.get(&data_shred.erasure_set())
blockstore
.merkle_root_meta(data_shred.erasure_set())
.unwrap()
.as_ref()
.unwrap()
.merkle_root(),
data_shred.merkle_root().ok()
);
assert_eq!(
merkle_root_metas
.get(&data_shred.erasure_set())
blockstore
.merkle_root_meta(data_shred.erasure_set())
.unwrap()
.as_ref()
.unwrap()
.first_received_shred_index(),
index
);
Expand Down
Loading