From 2958cc33c18883e4c6613671be7e9b32b7928a82 Mon Sep 17 00:00:00 2001 From: Ashwin Sekar Date: Sun, 18 Aug 2024 21:23:48 -0400 Subject: [PATCH] blockstore: store merkle root duplicate proofs immediately on detection (#2638) --- core/src/window_service.rs | 17 ++--------------- ledger/src/blockstore.rs | 11 +++++++++++ 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/core/src/window_service.rs b/core/src/window_service.rs index 511da236958af3..ff902e414ee017 100644 --- a/core/src/window_service.rs +++ b/core/src/window_service.rs @@ -166,21 +166,8 @@ fn run_check_duplicate( ); let (shred1, shred2) = match shred { PossibleDuplicateShred::LastIndexConflict(shred, conflict) - | PossibleDuplicateShred::ErasureConflict(shred, conflict) => (shred, conflict), - PossibleDuplicateShred::MerkleRootConflict(shred, conflict) => { - // 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) - } + | PossibleDuplicateShred::ErasureConflict(shred, conflict) + | PossibleDuplicateShred::MerkleRootConflict(shred, conflict) => (shred, conflict), PossibleDuplicateShred::ChainedMerkleRootConflict(shred, conflict) => { if chained_merkle_conflict_duplicate_proofs { // Although this proof can be immediately stored on detection, we wait until diff --git a/ledger/src/blockstore.rs b/ledger/src/blockstore.rs index 55377cb31557eb..b5bca01a8b2078 100644 --- a/ledger/src/blockstore.rs +++ b/ledger/src/blockstore.rs @@ -1811,6 +1811,17 @@ impl Blockstore { ); return true; }; + if let Err(e) = self.store_duplicate_slot( + slot, + conflicting_shred.clone(), + shred.clone().into_payload(), + ) { + warn!( + "Unable to store conflicting merkle root duplicate proof for {slot} \ + {:?} {e}", + shred.erasure_set(), + ); + } duplicate_shreds.push(PossibleDuplicateShred::MerkleRootConflict( shred.clone(), conflicting_shred,