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

shred: expose chained merkle root #435

Merged
merged 2 commits into from
Mar 27, 2024

Conversation

AshwinSekar
Copy link

Split from #102

Expose the chained merkle root from shred layout and impl for use in blockstore.

Contributes to solana-labs#34897

@@ -334,6 +334,16 @@ macro_rules! dispatch {
Self::ShredData(shred) => shred.$name($($arg, )?),
}
}
};
(allow_dead $vis:vis fn $name:ident(&self $(, $arg:ident : $ty:ty)?) $(-> $out:ty)?) => {
Copy link
Author

Choose a reason for hiding this comment

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

temporarily adding this for clippy checks, will remove in #102

Choose a reason for hiding this comment

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

Instead of adding a new variant for the macro, can you just add #[allow(dead_code)] in line 313?

@@ -334,6 +334,16 @@ macro_rules! dispatch {
Self::ShredData(shred) => shred.$name($($arg, )?),
}
}
};
(allow_dead $vis:vis fn $name:ident(&self $(, $arg:ident : $ty:ty)?) $(-> $out:ty)?) => {

Choose a reason for hiding this comment

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

Instead of adding a new variant for the macro, can you just add #[allow(dead_code)] in line 313?

chained: true,
resigned,
} => merkle::ShredData::get_chained_merkle_root_offset(proof_size, resigned).ok(),
_ => None,

Choose a reason for hiding this comment

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

_ => will silently ignore new variants added to the enum.
Can you please use the explicit:

ShredVariant::MerkleCode { proof_size:_, chained: false, resigned:_ } => None,
ShredVariant::MerkleData { proof_size:_, chained: false, resigned:_ } => None,

so that we get compile errors when new variants are added?

Self::get_chained_merkle_root_offset(proof_size, resigned)
}

pub(crate) fn get_chained_merkle_root_offset(

Choose a reason for hiding this comment

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

shouldn't these be pub(super) as well?
similarly the other one below?

Copy link
Author

Choose a reason for hiding this comment

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

ah ya good call, still get confused on how module hierarchy works sometimes.

shred.rs declares mod merkle, and the mod layout is able to access ShredData/ShredCode::get_merkle_root as a parent module? 😕 . i would've assumed they are siblings.

              /- shred_code
              /- shred_data
ledger - shred - layout

@AshwinSekar AshwinSekar merged commit cfd5b71 into anza-xyz:master Mar 27, 2024
37 checks passed
Copy link

mergify bot commented Mar 27, 2024

Backports to the beta branch are to be avoided unless absolutely necessary for fixing bugs, security issues, and perf regressions. Changes intended for backport should be structured such that a minimum effective diff can be committed separately from any refactoring, plumbing, cleanup, etc that are not strictly necessary to achieve the goal. Any of the latter should go only into master and ride the normal stabilization schedule. Exceptions include CI/metrics changes, CLI improvements and documentation updates on a case by case basis.

mergify bot pushed a commit that referenced this pull request Mar 27, 2024
* shred: expose chained merkle root

* pr feedback: macro, pub(super), _=> none

(cherry picked from commit cfd5b71)
mergify bot added a commit that referenced this pull request Mar 28, 2024
shred: expose chained merkle root (#435)

* shred: expose chained merkle root

* pr feedback: macro, pub(super), _=> none

(cherry picked from commit cfd5b71)

Co-authored-by: Ashwin Sekar <ashwin@anza.xyz>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants