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

blockstore: use u32 for fec_set_index in erasure set index store key #34268

Merged
Merged
Show file tree
Hide file tree
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
14 changes: 8 additions & 6 deletions ledger/src/blockstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -464,11 +464,12 @@ impl Blockstore {
}

fn erasure_meta(&self, erasure_set: ErasureSetId) -> Result<Option<ErasureMeta>> {
self.erasure_meta_cf.get(erasure_set.store_key())
let (slot, fec_set_index) = erasure_set.store_key();
self.erasure_meta_cf.get((slot, u64::from(fec_set_index)))
}

fn merkle_root_meta(&self, erasure_set: ErasureSetId) -> Result<Option<MerkleRootMeta>> {
self.merkle_root_meta_cf.get(erasure_set.key())
self.merkle_root_meta_cf.get(erasure_set.store_key())
}

/// Check whether the specified slot is an orphan slot which does not
Expand Down Expand Up @@ -1018,11 +1019,12 @@ impl Blockstore {
)?;

for (erasure_set, erasure_meta) in erasure_metas {
write_batch.put::<cf::ErasureMeta>(erasure_set.store_key(), &erasure_meta)?;
let (slot, fec_set_index) = erasure_set.store_key();
write_batch.put::<cf::ErasureMeta>((slot, u64::from(fec_set_index)), &erasure_meta)?;
}

for (erasure_set, merkle_root_meta) in merkle_root_metas {
write_batch.put::<cf::MerkleRootMeta>(erasure_set.key(), &merkle_root_meta)?;
write_batch.put::<cf::MerkleRootMeta>(erasure_set.store_key(), &merkle_root_meta)?;
}

for (&slot, index_working_set_entry) in index_working_set.iter() {
Expand Down Expand Up @@ -6828,7 +6830,7 @@ pub mod tests {

for (erasure_set, merkle_root_meta) in merkle_root_metas {
write_batch
.put::<cf::MerkleRootMeta>(erasure_set.key(), &merkle_root_meta)
.put::<cf::MerkleRootMeta>(erasure_set.store_key(), &merkle_root_meta)
.unwrap();
}
blockstore.db.write(write_batch).unwrap();
Expand Down Expand Up @@ -7008,7 +7010,7 @@ pub mod tests {

for (erasure_set, merkle_root_meta) in merkle_root_metas {
write_batch
.put::<cf::MerkleRootMeta>(erasure_set.key(), &merkle_root_meta)
.put::<cf::MerkleRootMeta>(erasure_set.store_key(), &merkle_root_meta)
.unwrap();
}
blockstore.db.write(write_batch).unwrap();
Expand Down
9 changes: 3 additions & 6 deletions ledger/src/shred.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,12 +283,9 @@ impl ErasureSetId {
self.0
}

// Storage key for ErasureMeta in blockstore db.
pub(crate) fn store_key(&self) -> (Slot, /*fec_set_index:*/ u64) {
(self.0, u64::from(self.1))
}

pub(crate) fn key(&self) -> (Slot, /*fec_set_index:*/ u32) {
// Storage key for ErasureMeta and MerkleRootMeta in blockstore db.
// Note: ErasureMeta column uses u64 so this will need to be typecast
pub(crate) fn store_key(&self) -> (Slot, /*fec_set_index:*/ u32) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please add a comment here that ErasureMeta uses u64 for fec_set_index?

(self.0, self.1)
}
}
Expand Down