-
Notifications
You must be signed in to change notification settings - Fork 919
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
[WIP]feat(shwap): add RangeNamespaceDataID along with the RangeNamespaceData #3709
base: shwap
Are you sure you want to change the base?
Conversation
c708e7e
to
9aebbdf
Compare
d5c6f0f
to
8905eb9
Compare
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.
First look. The thing which is still unclear to me is why we need to have Sample in the container and why NamespaceData isn't enough
namespacedShares := make([]share.Share, count) | ||
copy(namespacedShares, shares[from:from+count]) | ||
|
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.
There is a reason it was copied iirc and was a bug.
Cc @walldiss
There is also a few optimizations we can do there
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.
Discussed internally with @walldiss. No reason for copying.
// Proofs iterates over each row and collects proofs. | ||
func (nd NamespaceData) Proofs() []*nmt.Proof { |
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.
nit: move closer to Flatten
above
if endIndex > uint16(edsSize) { | ||
return errors.New("RangeNamespaceDataID: end index exceeds ODS length") | ||
} | ||
return nil |
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.
Verify should call Validate
return RangeNamespaceDataID{}, fmt.Errorf("converting SampleId from binary: %w", err) | ||
} | ||
|
||
return RangeNamespaceDataID{ |
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.
Should call Validate as well
root.RowRoots[rowStart+i], | ||
) | ||
if !verified { | ||
return fmt.Errorf("RangeNamespaceData: proof verification failed at row: %d", rowStart+i) |
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.
Should wrap ErrVerificationFailed
// Length is a number of shares to of the requested range. | ||
Length uint16 |
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.
In other shwap types we use int in ID struct and convert to the wire type in marshal functions
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.
Also, do you think uint16 is enough? Why not uint32?
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 uint32 is better. Thanks.
func RangedNamespaceDataFromShares( | ||
rawShares [][]share.Share, | ||
namespace share.Namespace, | ||
rowIndex, from, to int, | ||
) (NamespaceData, error) { |
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 not make it return RangeNamespaceData? To avoid handling proofs only in it?
We need to additionally check the |
No description provided.