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

optimize serialization of single-slot leaves #433

Merged
merged 3 commits into from
Jun 25, 2024

Conversation

gballet
Copy link
Member

@gballet gballet commented Apr 26, 2024

Another serialization optimization, for the case of a single leaf.

This could be extended to a group of leaves.

@gballet gballet requested a review from jsign April 26, 2024 08:44
@gballet gballet changed the base branch from master to small-eoa-serialization April 26, 2024 12:57
Copy link
Collaborator

@jsign jsign left a 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:
Copy link
Collaborator

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
Comment on lines 1819 to 1818
baseSize := nodeTypeSize + StemSize + 2*banderwagon.UncompressedSize + leafValueIndexSize + leafSlotSize
result = make([]byte, baseSize)
Copy link
Collaborator

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.

@gballet gballet force-pushed the pack-leaf-with-single-slot branch from dd9ba8e to c6236f8 Compare June 21, 2024 15:34
@gballet gballet merged commit aeb6236 into small-eoa-serialization Jun 25, 2024
2 checks passed
gballet added a commit that referenced this pull request Jun 26, 2024
* 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]>
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