-
Notifications
You must be signed in to change notification settings - Fork 67
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
optimize serialization of single-slot leaves #433
Conversation
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.
LGTM, left some comments.
@@ -86,6 +88,8 @@ func ParseNode(serializedNode []byte, depth byte) (VerkleNode, error) { | |||
return CreateInternalNode(serializedNode[internalBitlistOffset:internalCommitmentOffset], serializedNode[internalCommitmentOffset:], depth) | |||
case eoAccountType: | |||
return parseEoAccountNode(serializedNode, depth) | |||
case singleSlotType: |
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.
Add bullet to method's comment. (Be aware that base branch has a similar comment)
tree.go
Outdated
baseSize := nodeTypeSize + StemSize + 2*banderwagon.UncompressedSize + leafValueIndexSize + leafSlotSize | ||
result = make([]byte, baseSize) |
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.
Similar suggestion as in base branch. baseSize
is constant, so we can avoid make
and prob avoid an allocation by using an array.
dd9ba8e
to
c6236f8
Compare
* special serialization for EoAs * fix breaking test * reduce the flexibility of the encoding * optimize serialization of single-slot leaves (#433) * pack single slot leaf * silence linter * review feedback * review feedback * Apply suggestions from code review Co-authored-by: Ignacio Hagopian <[email protected]> * linter fix --------- Co-authored-by: Ignacio Hagopian <[email protected]>
Another serialization optimization, for the case of a single leaf.
This could be extended to a group of leaves.