-
Notifications
You must be signed in to change notification settings - Fork 261
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
feat: new ParseShare
API
#828
Conversation
1b97b06
to
ca0486b
Compare
Codecov Report
@@ Coverage Diff @@
## main #828 +/- ##
==========================================
+ Coverage 23.38% 25.49% +2.10%
==========================================
Files 71 75 +4
Lines 8846 9261 +415
==========================================
+ Hits 2069 2361 +292
- Misses 6601 6679 +78
- Partials 176 221 +45
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
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.
[question]
should we also be checking that the length delimiter matches the sequence length?
pkg/shares/share_merging.go
Outdated
if !infoByte.IsMessageStart() { | ||
if !bytes.Equal(currentSequence.NamespaceID, share.NamespaceID()) { |
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.
[comment for other reviewers/posterity]
this isn't actually consensus breaking (see below comment) I don't think, even tho we weren't previously checking for this, because is order for this to be hit, the incorrect info byte has to be used which won't happen due to validators inserting it themselves and comparing the data root.
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.
on second thought, once we start using this, it could be consensus breaking with a dishonest majority. Honest full nodes will reject blocks that hit this error where we previously were not.
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.
once we start using this
I thought ParseShares
was for celestia-node consumption. Do we expect the state machine to invoke this API? I didn't expect this API to be consensus breaking because I assumed the state machine would not call it.
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 if light clients are the only ones rejecting a block, then that is still consensus breaking (just like a change to fraud proofs)
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.
at least, I think its consensus breaking... 😅
imo, it makes sense to eventually use this code when we merge shares. It keeps things consistent and can possibly even inform other implementations on how to use universal shares.
It's possible to add this check to the contents of
|
do we need to trim if we're only checking sequence length, not the exact length of bytes? edit: like, we should use something similar to celestia-app/pkg/shares/utils.go Lines 18 to 29 in e69283f
|
We need to trim the last share of padding if we want to compare the total data length varint to the exact sequence length. We don't need to trim if we want this check to compare the total data length varint to an approximate sequence length (i.e. for message shares) (len(shareSequence.Shares) - 1) * appconsts. SparseShareContentSize <= varint <= len(shareSequence.Shares) * appconsts. SparseShareContentSize |
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.
left one remaining change request for the testing we're using.
While I still think we should check for the length of the sequence (len(shareSequence.Shares))
, that would require a large enough change to the existing code that doing this in a different PR makes sense
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.
dope! thanks! preapprooovvviinnngggggg
Closes #723
Opens #839