Skip to content

Commit

Permalink
v1.18: blockstore: scaffolding for chained merkle root conflict detec…
Browse files Browse the repository at this point in the history
…tion (backport of anza-xyz#719) (anza-xyz#729)

* blockstore: scaffolding for chained merkle root conflict detection (anza-xyz#719)

* blockstore: scaffolding for chained merkle root conflict detection

* pr feedback: use dummy feature key until final plumbing

(cherry picked from commit 411fdc9)

# Conflicts:
#	sdk/src/feature_set.rs

* fix feature_set conflicts

---------

Co-authored-by: Ashwin Sekar <[email protected]>
Co-authored-by: Ashwin Sekar <[email protected]>
  • Loading branch information
3 people authored and yihau committed Apr 26, 2024
1 parent 9d8d5f3 commit 3db1f54
Show file tree
Hide file tree
Showing 6 changed files with 463 additions and 14 deletions.
23 changes: 23 additions & 0 deletions core/src/window_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ fn run_check_duplicate(
shred_slot,
&root_bank,
);
let chained_merkle_conflict_duplicate_proofs = cluster_nodes::check_feature_activation(
&feature_set::chained_merkle_conflict_duplicate_proofs::id(),
shred_slot,
&root_bank,
);
let (shred1, shred2) = match shred {
PossibleDuplicateShred::LastIndexConflict(shred, conflict)
| PossibleDuplicateShred::ErasureConflict(shred, conflict) => {
Expand Down Expand Up @@ -196,6 +201,24 @@ fn run_check_duplicate(
return Ok(());
}
}
PossibleDuplicateShred::ChainedMerkleRootConflict(shred, conflict) => {
if chained_merkle_conflict_duplicate_proofs {
// Although this proof can be immediately stored on detection, we wait until
// here in order to check the feature flag, as storage in blockstore can
// preclude the detection of other duplicate proofs in this slot
if blockstore.has_duplicate_shreds_in_slot(shred_slot) {
return Ok(());
}
blockstore.store_duplicate_slot(
shred_slot,
conflict.clone(),
shred.clone().into_payload(),
)?;
(shred, conflict)
} else {
return Ok(());
}
}
PossibleDuplicateShred::Exists(shred) => {
// Unlike the other cases we have to wait until here to decide to handle the duplicate and store
// in blockstore. This is because the duplicate could have been part of the same insert batch,
Expand Down
Loading

0 comments on commit 3db1f54

Please sign in to comment.