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

[WIP]feat(shwap): add RangeNamespaceDataID along with the RangeNamespaceData #3709

Draft
wants to merge 2 commits into
base: shwap
Choose a base branch
from

Conversation

vgonkivs
Copy link
Member

@vgonkivs vgonkivs commented Sep 3, 2024

No description provided.

@vgonkivs vgonkivs self-assigned this Sep 3, 2024
Copy link
Member

@Wondertan Wondertan left a 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

Comment on lines -87 to -89
namespacedShares := make([]share.Share, count)
copy(namespacedShares, shares[from:from+count])

Copy link
Member

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

Copy link
Member Author

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.

Comment on lines +84 to +85
// Proofs iterates over each row and collects proofs.
func (nd NamespaceData) Proofs() []*nmt.Proof {
Copy link
Member

@Wondertan Wondertan Sep 21, 2024

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
Copy link
Member

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{
Copy link
Member

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)
Copy link
Member

Choose a reason for hiding this comment

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

Should wrap ErrVerificationFailed

Comment on lines +22 to +23
// Length is a number of shares to of the requested range.
Length uint16
Copy link
Member

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

Copy link
Member

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?

Copy link
Member Author

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.

Comment on lines +20 to +24
func RangedNamespaceDataFromShares(
rawShares [][]share.Share,
namespace share.Namespace,
rowIndex, from, to int,
) (NamespaceData, error) {
Copy link
Member

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?

@vgonkivs
Copy link
Member Author

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

We need to additionally check the from share, to ensure that the whole range is valid. Since the request contains SampleID, I decided to return Sample as well. The other way is to build a sub-range proof for the from share and verify(but the nmt hasn't supported it)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants