-
Notifications
You must be signed in to change notification settings - Fork 847
Introduces SliceRoot
#9130
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
Introduces SliceRoot
#9130
Conversation
0421c44 to
7ffe975
Compare
7ffe975 to
28d4e7b
Compare
9823850 to
030c2b6
Compare
030c2b6 to
a35ce2f
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #9130 +/- ##
=======================================
Coverage 82.6% 82.6%
=======================================
Files 890 891 +1
Lines 320729 320758 +29
=======================================
+ Hits 265011 265062 +51
+ Misses 55718 55696 -22 🚀 New features to boost your workflow:
|
| @@ -0,0 +1,33 @@ | |||
| //! Module to define [`SliceRoot`]. | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AlpenglowBlockId will also go in here so maybe name this differently or just put them in consensus_message.rs IDK
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even though I ended up not making the fields of Sliceroot private, in general, when introducing new types, it is a good idea to try to make them private. In which case, it also helps if the types are in their own module otherwise other code can access the internal fields. So I think I would prefer to introduce AlpenglowBlockId in yet another module.
|
Can you link a design doc to the PR so we keep a better record of why this is happening? |
@kobi-lizard: have you written something down somewhere? The only "design" that I am aware of is anza-xyz/alpenglow#518. |
votor-messages/src/slice_root.rs
Outdated
| Copy, Clone, Default, Debug, Hash, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize, | ||
| )] | ||
| #[repr(transparent)] | ||
| pub struct SliceRoot(pub Hash); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we placing it in Votor if this deals with shreds? Maybe time for rotor crate?
Also not sure why do we need a wrapper around Hash at all. Could we define an alias instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we placing it in Votor if this deals with shreds? Maybe time for rotor crate?
I am definitely not happy with the current placement. I like the idea of introducing a rotor crate.
Also not sure why do we need a wrapper around Hash at all. Could we define an alias instead?
With type aliases, the compiler will not hold my hand to ensure that I am using the right type. I can use any old Hash. Using a wrapper struct helps in providing documentation and the additional feedback at the call sites to help the developer check that they are using the right type and not just some random Hash.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. Ether way, making turbine depend on Votor feels wrong :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed with Alex (and Ashwin from https://github.com/anza-xyz/agave/pull/9130/files#r2560958890) - I don't think votor is the right place for this. Rather, I agree with Ashwin's comment from linked comment:
Then the hash relevant to shreds could be named -> FecSetRoot and could live in ledger or turbine crates.
Since the erasure coding and FEC sets are created in solana-ledger, my vote would be solana-ledger
|
Why this is happening and why alias is wrong: |
votor-messages/src/slice_root.rs
Outdated
| Copy, Clone, Default, Debug, Hash, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize, | ||
| )] | ||
| #[repr(transparent)] | ||
| pub struct SliceRoot(pub Hash); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find this name pretty confusing as slice is already pretty overloaded, could we rename this to FECSetRoot or SetRoot?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed with Ashwin, I'm not a fan of SliceRoot. We already have terminology to refer to this concept (FEC Set) so I see no need to introduce more terminology especially when slice is already a Rust keyword.
I think something like FecSetRoot or FecSetMerkleRoot makes sense; given that elements of a merkle tree are hashes, we probably don't need to include Hash in the name but I'd probably be fine with it too
| } | ||
|
|
||
| pub fn parent_block_id(&self) -> Option<Hash> { | ||
| pub fn parent_block_id(&self) -> Option<SliceRoot> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if we're going to rename the types we could do something like:
Block id hash -> ChainedMerkleBlockId
new block id hash -> DoubleMerkleBlockId
Both of these can live in votor-messages since they are primarily used for consensus and then we can remove the runtime dependency
Then the hash relevant to shreds could be named -> FecSetRoot and could live in ledger or turbine crates.
I haven't walked all the dependencies to see if this is feasible but if we split into a higher level of granularity then we might be able to avoid setting up a new crate or having everything depend on votor-messages
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AshwinSekar: not sure I completely understand the proposal.
When we do introduce double merkle, won't we need to update the ledger and turnbine crates accordingly?
9ff23f9 to
266510c
Compare
|
A conceptual question: why are we renaming FEC sets into slices in this PR? |
266510c to
0545153
Compare
I am sure Quentin (who somehow I cannot tag here) and @kobi-lizard can explain this better. The general idea is that FEC set refers to the specific technology being used instead of what the actual data structure is. The idea is that a block is made up of some data structure that can be called I agree with you though that sneaking in new terminology like this is probably not a good idea and we should get wider buy-in before we do that. I plan on renaming the structs based on #9130 (comment). |
What benefit does renaming bring? I can see a bunch of problems it creates (code churn, mess in discussions etc), which problems does it solve? Once there is a meaningful change in the logic of the protocol we should consider name changes. |
Indeed... these are precisely the reasons to not shoehorn in a renaming and get general consensus before attempting it. |
|
Ended up creating #9504 instead of modifying this one as updating this seemed to be more work. Closing this. |
Problem
We are in the process of introducing double merkle for alpenglow. In particular, we will be supporting chain and double merkle tree.
Summary of Changes
Introducing a new type to represent the root hash will help in improving the readability of the code and make it easier to understand.
Note to reviewers
I am not happy with how many new crates depend upon
votor-messagesin this PR. Happy to receive feedback on alternative locations to defineSliceRoot.