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

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

Merged

Conversation

AshwinSekar
Copy link
Contributor

@AshwinSekar AshwinSekar commented Nov 29, 2023

Problem

fec_set_index is u32 but in some places we use u64 which makes the code confusing.

Summary of Changes

Unify the type of store_key in ErasureSetId to u32 and perform the type conversion at the call site.

Contributes to #33644

Copy link

codecov bot commented Nov 29, 2023

Codecov Report

Merging #34268 (2461df4) into master (c5368a3) will decrease coverage by 0.1%.
Report is 2 commits behind head on master.
The diff coverage is 100.0%.

Additional details and impacted files
@@            Coverage Diff            @@
##           master   #34268     +/-   ##
=========================================
- Coverage    81.9%    81.9%   -0.1%     
=========================================
  Files         819      819             
  Lines      219893   219892      -1     
=========================================
- Hits       180200   180158     -42     
- Misses      39693    39734     +41     

Copy link
Contributor

@behzadnouri behzadnouri left a comment

Choose a reason for hiding this comment

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

The commit is good.

But wondering if there is any easy way to change ErasureMeta key to use u32 for fec_set_index. cc @steviez

@@ -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, fec_set_index as u64))
Copy link
Contributor

Choose a reason for hiding this comment

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

as is not type-safe.
Can we use u64::from here?

@@ -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, fec_set_index as u64), &erasure_meta)?;
Copy link
Contributor

Choose a reason for hiding this comment

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

Similarly here re as -> u64::from.


pub(crate) fn key(&self) -> (Slot, /*fec_set_index:*/ u32) {
// Storage key for ErasureMeta and MerkleRootMeta in blockstore db.
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?

@steviez
Copy link
Contributor

steviez commented Nov 30, 2023

But wondering if there is any easy way to change ErasureMeta key to use u32 for fec_set_index. cc @steviez

Not so easy unfortunately due to backwards compatibility concerns. Tyera did something recently, altho she did it while she was explicitly fixing another bug: #33419

The basic gist is you need to write code that is capable of handling both key formats (one with u32 / one with u64). That being said, v1.18 will already have breaks for the RPC columns so if you did feel strongly about changing, it'd probably make sense to lump all the column re-keys into one release

@AshwinSekar AshwinSekar merged commit d84dcd3 into solana-labs:master Dec 1, 2023
18 checks passed
@AshwinSekar AshwinSekar deleted the erasure-set-id-store-key branch December 1, 2023 00:18
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants