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

Sparse merkle tree part1 #58

Closed
wants to merge 11 commits into from

Conversation

NIC619
Copy link
Contributor

@NIC619 NIC619 commented Jul 16, 2018

What was wrong?

Try out Sparse Merkle Tree for sharding research.

How was it fixed?

Implement Sparse Merkle Tree as described in #37.

Cute Animal Picture

Cute animal picture

from eth_hash.auto import keccak
EMPTY_LEAF_NODE_HASH = BLANK_HASH
EMPTY_NODE_HASHES = [EMPTY_LEAF_NODE_HASH]
for _ in range(159):

Choose a reason for hiding this comment

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

As 160 (and 159) is used a couple of times, it would make sense to make it a constant. Maybe NODE_BIT_LENGTH?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree, what do you think about maybe something more straight forward like TREE_HEIGHT?

Choose a reason for hiding this comment

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

TREE_HEIGHT sounds good

target_bit >>= 1

if self.db[node_hash] is b'':
return None
Copy link
Member

Choose a reason for hiding this comment

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

Reason for returning None instead of raising a KeyError? We've found that return value checking is way easier to forget than exception handling.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No particular reason. Just that in hexary trie, BLANK_NODE is returned for non-existent key. Raising an exception does make more sense.

@NIC619
Copy link
Contributor Author

NIC619 commented Jul 20, 2018

@pipermerriam Updated the behavior for handling non-existent key and ready for review again.

@NIC619 NIC619 closed this Dec 29, 2018
kclowes added a commit to kclowes/py-trie that referenced this pull request Nov 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants