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

[Merge] Implement SszUnion structure #4361

Merged
merged 6 commits into from
Sep 15, 2021

Conversation

Nashatyrev
Copy link
Contributor

PR Description

Implement SszUnion

Fixed Issue(s)

Part of #4226

Documentation

  • I thought about documentation and added the documentation label to this PR if updates are required.

Changelog

  • I thought about adding a changelog entry, and added one if I deemed necessary.

@Nashatyrev Nashatyrev mentioned this pull request Sep 14, 2021
20 tasks
@Nashatyrev Nashatyrev changed the title Implement SszUnion structure [Merge] Implement SszUnion structure Sep 14, 2021
Copy link
Contributor

@ajsutton ajsutton left a comment

Choose a reason for hiding this comment

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

LGTM. Nice work - just a couple of small suggestions which probably don't matter for the merge branch but I think we could probably pick this up pretty much as is and merge into master when it's needed.

Comment on lines +185 to +188
final int selector =
nodeSource
.loadLeafNode(selectorHash, GIndexUtil.gIdxRightGIndex(rootGIndex))
.getInt(0, ByteOrder.LITTLE_ENDIAN);
Copy link
Contributor

Choose a reason for hiding this comment

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

Could/should this just use getSelectorFromSelectorNode(nodeSource.loadLeafNode(selectorHash, GIndexUtil.gIdxRightGIndex(rootGIndex))?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tried your suggestion, but nodeSource.loadLeafNode(selectorHash, GIndexUtil.gIdxRightGIndex(rootGIndex)) returns me 0x0100000000000000000000000000000000000000000000000000000000000000 instead of 0x01.
Is it a bug or expected behavior? (the actual value of selector leaf node is 0x01)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, leaving it 'as is' for now. At least the same code is in the SszListSchemaImpl (borrowed it from there). And probably this needs to be sorted out separately

Copy link
Contributor

Choose a reason for hiding this comment

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

ah yeah of course. We don't store leaf nodes with data shorter than 32 bytes because the hash is just the data padded out to 32 bytes which means they don't have a unique hash. So you have to trim the data back down to the right length after loading. So yeah, the way you have it makes sense (pretty sure I went round this loop doing the list schema code too)...

@Nashatyrev Nashatyrev merged commit ce2f645 into Consensys:merge-interop Sep 15, 2021
@Nashatyrev Nashatyrev deleted the merge/union branch November 18, 2021 16:34
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