Skip to content

Commit

Permalink
add feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
AshwinSekar committed Dec 23, 2023
1 parent 329b4b9 commit ffc9039
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
21 changes: 20 additions & 1 deletion core/src/window_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@ fn run_check_duplicate(
shred_slot,
&root_bank,
);
let send_merkle_root_conflicts = cluster_nodes::check_feature_activation(
&feature_set::merkle_conflict_duplicate_proofs::id(),
shred_slot,
&root_bank,
);
let (shred1, shred2) = match shred {
PossibleDuplicateShred::LastIndexConflict(shred, conflict)
| PossibleDuplicateShred::ErasureConflict(shred, conflict) => {
Expand All @@ -173,7 +178,21 @@ fn run_check_duplicate(
return Ok(());
}
}
PossibleDuplicateShred::MerkleRootConflict(shred, conflict) => (shred, conflict),
PossibleDuplicateShred::MerkleRootConflict(shred, conflict) => {
if send_merkle_root_conflicts {
// 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
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
8 changes: 1 addition & 7 deletions ledger/src/blockstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1597,7 +1597,7 @@ impl Blockstore {
/// the existing `merkle_root_meta` and `shred`
///
/// Otherwise return false and if not already present, add duplicate proof to
/// blockstore and `duplicate_shreds`.
/// `duplicate_shreds`.
fn perform_merkle_check(
&self,
just_inserted_shreds: &HashMap<ShredId, Shred>,
Expand Down Expand Up @@ -1636,12 +1636,6 @@ impl Blockstore {
let conflicting_shred = self
.get_shred_from_just_inserted_or_db(just_inserted_shreds, shred_id)
.into_owned();
if self
.store_duplicate_slot(slot, conflicting_shred.clone(), shred.payload().clone())
.is_err()
{
warn!("store duplicate error");
}
duplicate_shreds.push(PossibleDuplicateShred::MerkleRootConflict(
shred.clone(),
conflicting_shred,
Expand Down
5 changes: 5 additions & 0 deletions sdk/src/feature_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,10 @@ pub mod index_erasure_conflict_duplicate_proofs {
solana_sdk::declare_id!("dupPajaLy2SSn8ko42aZz4mHANDNrLe8Nw8VQgFecLa");
}

pub mod merkle_conflict_duplicate_proofs {
solana_sdk::declare_id!("mrkPjRg79B2oK2ZLgd7S3AfEJaX9B6gAF3H9aEykRUS");
}

lazy_static! {
/// Map of feature identifiers to user-visible description
pub static ref FEATURE_NAMES: HashMap<Pubkey, &'static str> = [
Expand Down Expand Up @@ -930,6 +934,7 @@ lazy_static! {
(allow_commission_decrease_at_any_time::id(), "Allow commission decrease at any time in epoch #33843"),
(consume_blockstore_duplicate_proofs::id(), "consume duplicate proofs from blockstore in consensus #34372"),
(index_erasure_conflict_duplicate_proofs::id(), "generate duplicate proofs for index and erasure conflicts #34360"),
(merkle_conflict_duplicate_proofs::id(), "generate duplicate proofs for merkle root conflicts #34270"),
/*************** ADD NEW FEATURES HERE ***************/
]
.iter()
Expand Down

0 comments on commit ffc9039

Please sign in to comment.