Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

blockstore: add merkle root to ErasureMeta column family #33848

Closed
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
pr feedback: use ErasureMetaLegacy naming scheme
AshwinSekar committed Oct 25, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 2e357435087d26629af69b0388dbd04c732947a6
4 changes: 2 additions & 2 deletions gossip/src/duplicate_shred.rs
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ use {
itertools::Itertools,
solana_ledger::{
blockstore::BlockstoreError,
blockstore_meta::{DuplicateSlotProof, MerkleErasureMeta},
blockstore_meta::{DuplicateSlotProof, ErasureMeta},
shred::{self, Shred, ShredType},
},
solana_sdk::{
@@ -141,7 +141,7 @@ where
// a part of the same fec set. Further work to enhance detection is planned in
// https://github.com/solana-labs/solana/issues/33037
if shred1.fec_set_index() == shred2.fec_set_index()
&& !MerkleErasureMeta::check_erasure_consistency(shred1, shred2)
&& !ErasureMeta::check_erasure_consistency(shred1, shred2)
{
return Ok(());
}
24 changes: 12 additions & 12 deletions ledger/src/blockstore.rs
Original file line number Diff line number Diff line change
@@ -457,7 +457,7 @@ impl Blockstore {
false
}

fn erasure_meta(&self, erasure_set: ErasureSetId) -> Result<Option<MerkleErasureMeta>> {
fn erasure_meta(&self, erasure_set: ErasureSetId) -> Result<Option<ErasureMeta>> {
self.erasure_meta_cf.get_new_or_old(erasure_set.store_key())
}

@@ -594,7 +594,7 @@ impl Blockstore {
fn get_recovery_data_shreds<'a>(
index: &'a Index,
slot: Slot,
erasure_meta: &'a MerkleErasureMeta,
erasure_meta: &'a ErasureMeta,
prev_inserted_shreds: &'a HashMap<ShredId, Shred>,
data_cf: &'a LedgerColumn<cf::ShredData>,
) -> impl Iterator<Item = Shred> + 'a {
@@ -619,7 +619,7 @@ impl Blockstore {
fn get_recovery_coding_shreds<'a>(
index: &'a Index,
slot: Slot,
erasure_meta: &'a MerkleErasureMeta,
erasure_meta: &'a ErasureMeta,
prev_inserted_shreds: &'a HashMap<ShredId, Shred>,
code_cf: &'a LedgerColumn<cf::ShredCode>,
) -> impl Iterator<Item = Shred> + 'a {
@@ -643,7 +643,7 @@ impl Blockstore {

fn recover_shreds(
index: &Index,
erasure_meta: &MerkleErasureMeta,
erasure_meta: &ErasureMeta,
prev_inserted_shreds: &HashMap<ShredId, Shred>,
recovered_shreds: &mut Vec<Shred>,
data_cf: &LedgerColumn<cf::ShredData>,
@@ -677,7 +677,7 @@ impl Blockstore {

fn submit_metrics(
slot: Slot,
erasure_meta: &MerkleErasureMeta,
erasure_meta: &ErasureMeta,
attempted: bool,
status: String,
recovered: usize,
@@ -725,7 +725,7 @@ impl Blockstore {

fn try_shred_recovery(
&self,
erasure_metas: &HashMap<ErasureSetId, MerkleErasureMeta>,
erasure_metas: &HashMap<ErasureSetId, ErasureMeta>,
index_working_set: &mut HashMap<u64, IndexMetaWorkingSetEntry>,
prev_inserted_shreds: &HashMap<ShredId, Shred>,
reed_solomon_cache: &ReedSolomonCache,
@@ -1164,7 +1164,7 @@ impl Blockstore {
fn check_insert_coding_shred(
&self,
shred: Shred,
erasure_metas: &mut HashMap<ErasureSetId, MerkleErasureMeta>,
erasure_metas: &mut HashMap<ErasureSetId, ErasureMeta>,
index_working_set: &mut HashMap<u64, IndexMetaWorkingSetEntry>,
write_batch: &mut WriteBatch,
just_received_shreds: &mut HashMap<ShredId, Shred>,
@@ -1202,7 +1202,7 @@ impl Blockstore {
let erasure_meta = erasure_metas.entry(erasure_set).or_insert_with(|| {
self.erasure_meta(erasure_set)
.expect("Expect database get to succeed")
.unwrap_or_else(|| MerkleErasureMeta::from_coding_shred(&shred).unwrap())
.unwrap_or_else(|| ErasureMeta::from_coding_shred(&shred).unwrap())
});

if !erasure_meta.check_coding_shred(&shred) {
@@ -1275,7 +1275,7 @@ impl Blockstore {
&self,
shred: &Shred,
slot: Slot,
erasure_meta: &MerkleErasureMeta,
erasure_meta: &ErasureMeta,
just_received_shreds: &HashMap<ShredId, Shred>,
) -> Option<Vec<u8>> {
// Search for the shred which set the initial erasure config, either inserted,
@@ -1340,7 +1340,7 @@ impl Blockstore {
fn check_insert_data_shred(
&self,
shred: Shred,
erasure_metas: &mut HashMap<ErasureSetId, MerkleErasureMeta>,
erasure_metas: &mut HashMap<ErasureSetId, ErasureMeta>,
index_working_set: &mut HashMap<u64, IndexMetaWorkingSetEntry>,
slot_meta_working_set: &mut HashMap<u64, SlotMetaWorkingSetEntry>,
write_batch: &mut WriteBatch,
@@ -7515,7 +7515,7 @@ pub mod tests {
num_data: 1,
num_coding: 17,
};
let erasure_meta_old = ErasureMeta {
let erasure_meta_old = ErasureMetaLegacy {
set_index: 5,
first_coding_index: 8,
config,
@@ -7535,7 +7535,7 @@ pub mod tests {
assert_eq!(erasure_meta.config(), erasure_meta_old.config);
assert_eq!(erasure_meta.merkle_root(), Hash::default());

let erasure_meta_new = ErasureMeta {
let erasure_meta_new = ErasureMetaLegacy {
set_index: 3,
first_coding_index: 2,
config,
6 changes: 3 additions & 3 deletions ledger/src/blockstore_db.rs
Original file line number Diff line number Diff line change
@@ -220,7 +220,7 @@ pub mod columns {
/// and a FEC (Forward Error Correction) set index.
///
/// * index type: `crate::shred::ErasureSetId` `(Slot, fec_set_index: u64)`
/// * value type: [`blockstore_meta::MerkleErasureMeta`]
/// * value type: [`blockstore_meta::ErasureMeta`]
pub struct ErasureMeta;

#[derive(Debug)]
@@ -1222,11 +1222,11 @@ impl ColumnName for columns::ErasureMeta {
const NAME: &'static str = ERASURE_META_CF;
}
impl TypedColumn for columns::ErasureMeta {
type Type = blockstore_meta::MerkleErasureMeta;
type Type = blockstore_meta::ErasureMeta;
}
impl BincodeTypeTransition for columns::ErasureMeta {
#[allow(deprecated)]
type OldType = blockstore_meta::ErasureMeta;
type OldType = blockstore_meta::ErasureMetaLegacy;
}

impl SlotColumn for columns::OptimisticSlots {}
18 changes: 9 additions & 9 deletions ledger/src/blockstore_meta.rs
Original file line number Diff line number Diff line change
@@ -118,10 +118,10 @@ pub struct ShredIndex {
index: BTreeSet<u64>,
}

#[deprecated = "Use MerkleErasureMeta"]
#[deprecated = "Use ErasureMeta"]
#[derive(Clone, Copy, Debug, Deserialize, Serialize, Eq, PartialEq)]
/// Erasure coding information
pub struct ErasureMeta {
pub struct ErasureMetaLegacy {
/// Which erasure set in the slot this is
pub(crate) set_index: u64,
/// First coding index in the FEC set
@@ -135,7 +135,7 @@ pub struct ErasureMeta {

#[derive(Clone, Copy, Debug, Deserialize, Serialize, Eq, PartialEq)]
/// Erasure coding information for merkle shreds
pub struct MerkleErasureMeta {
pub struct ErasureMeta {
/// Which erasure set in the slot this is
set_index: u64,
/// First coding index in the FEC set
@@ -335,7 +335,7 @@ impl SlotMeta {
}
}

impl MerkleErasureMeta {
impl ErasureMeta {
pub(crate) fn from_coding_shred(shred: &Shred) -> Option<Self> {
match shred.shred_type() {
ShredType::Data => None,
@@ -346,7 +346,7 @@ impl MerkleErasureMeta {
};
let first_coding_index = u64::from(shred.first_coding_index()?);
let merkle_root = Hash::default();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

next change in master will populate this from the coding shred, but I don't think that needs to be part of this backport change.

let erasure_meta = MerkleErasureMeta {
let erasure_meta = ErasureMeta {
set_index: u64::from(shred.fec_set_index()),
config,
first_coding_index,
@@ -425,9 +425,9 @@ impl MerkleErasureMeta {
}
}

impl From<ErasureMeta> for MerkleErasureMeta {
fn from(erasure_meta: ErasureMeta) -> MerkleErasureMeta {
MerkleErasureMeta {
impl From<ErasureMetaLegacy> for ErasureMeta {
fn from(erasure_meta: ErasureMetaLegacy) -> ErasureMeta {
ErasureMeta {
set_index: erasure_meta.set_index,
first_coding_index: erasure_meta.first_coding_index,
config: erasure_meta.config,
@@ -551,7 +551,7 @@ mod test {
num_data: 8,
num_coding: 16,
};
let e_meta = MerkleErasureMeta {
let e_meta = ErasureMeta {
set_index,
first_coding_index: set_index,
config: erasure_config,