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

add suffix tree decoder #74

Merged
merged 4 commits into from
Oct 14, 2024
Merged

Conversation

matkt
Copy link
Contributor

@matkt matkt commented Oct 14, 2024

PR description

Add suffix tree decoder in the besu verkle trie library

Fixed Issue(s)

Signed-off-by: Karim Taam <[email protected]>
Copy link

  • I thought about the changelog.

decodedFields[2] =
extractField(value, NONCE_OFFSET, NONCE_VALUE_MASK).slice(0, NONCE_BYTE_SIZE);
decodedFields[3] =
extractField(value, BALANCE_OFFSET, BALANCE_VALUE_MASK).slice(0, BALANCE_BYTE_SIZE);
Copy link
Contributor

Choose a reason for hiding this comment

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

if you're slicing do you need to shift them? Can't you just slice on the range? E.g. for code size value.slice(CODE_SIZE_OFFSET, CODE_SIZE_BYTE_SIZE) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch, I modified the code

return value;
}

public static Bytes[] decodeBasicDataLeaf(final Bytes32 value) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure how are you using this on the caller side, don't you need to convert from Bytes -> int, long, UInt256, etc... ? Fields have different sizes so I'm not sure if it won't be beneficial to have a method for each value:

int decodeCodeSize()
long decodeNonce()
Wei decodeBalance()
...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For the moment I prefer to let the logic of the conversion to the VerkleAccount decoder class in Besu. will see later if it's better to move it into this class

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will add the two way, an user can chose

Signed-off-by: Karim Taam <[email protected]>
@matkt matkt requested a review from lu-pinto October 14, 2024 10:31
Copy link
Contributor

@lu-pinto lu-pinto left a comment

Choose a reason for hiding this comment

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

LGTM

@matkt matkt merged commit 7fa75d7 into hyperledger:main Oct 14, 2024
5 checks passed
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