-
Notifications
You must be signed in to change notification settings - Fork 1.2k
SSZ-QL: calculate generalized indices for elements #15873
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
base: develop
Are you sure you want to change the base?
SSZ-QL: calculate generalized indices for elements #15873
Conversation
… no recursion. Extended test coverage for bitlist and bitvectors. vectors need more testing
…he beginning. Swap to regex to gain flexibility.
…pe (uint64 instead of uint8)
removed extractFieldName func.
…against vector.length/list.limit
ce17749
to
73e3ee7
Compare
Co-authored-by: Jun Song <[email protected]>
…e with length >= 1 If s does not contain sep and sep is not empty, Split returns a slice of length 1 whose only element is s.
…needed in extractFieldName function
…d more testing focused mainly in snake case conversion
…ded more tests with extended paths
c84b530
to
2718dc9
Compare
if element.Index != nil { | ||
return 0, fmt.Errorf("len() is not supported for indexed elements (multi-dimensional arrays)") | ||
} | ||
// Length field is only valid for List and Bitlist types | ||
if fieldSsz.sszType != List && fieldSsz.sszType != Bitlist { | ||
return 0, fmt.Errorf("len() is only supported for List and Bitlist types, got %s", fieldSsz.sszType) | ||
} | ||
// Length is a uint64 per SSZ spec | ||
currentInfo = &SszInfo{sszType: Uint64} | ||
root = root*2 + 1 | ||
continue |
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.
Is it possible to move this to a helper function?
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.
Regarding all these comments, yes. I really hate a switch
clause without helpers 😅
In my experience with Go, I’ve dealt with a few protoactor Receive()
handlers for message processing, and the pattern I liked the most were those that push as much logic as possible into helpers outside of the switch
. That way, the different cases you’re dealing with are crystal clear.
In this case, I didn’t use helpers because I thought the cases were already clear, but maybe they only felt clear to me because I had just written the code. I’ll export all this logic to helpers so that new readers can also benefit from that clarity.
Co-authored-by: Radosław Kapka <[email protected]>
Co-authored-by: Radosław Kapka <[email protected]>
Co-authored-by: Radosław Kapka <[email protected]>
…k and BytesPerChunk and updated code that use them
What type of PR is this?
Feature
Which issues(s) does this PR fix?
Partially #15598
What does this PR do? Why is it needed?
This PR develop a way to calculate the Generalized Indices of a given path within a SSZ Object. To do so, it follows Consensus Spec's Merkle proofs.
A conversion from PathElement to Generalized Index is necessary to work with fastssz proofs library.
The code implemented walks the path within the SSZInfo struct in a consensus layer spec way. We have to take into account that the "path" input is slightly different:
The pythonic version expects a Path input
[FieldA,"FieldB",3]
while the Go version expectsfield_a.field_b[3]
.Other notes for review
Acknowledgements