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

Consider switching to the merklix tree #2

Open
chjj opened this issue Jul 24, 2018 · 2 comments
Open

Consider switching to the merklix tree #2

chjj opened this issue Jul 24, 2018 · 2 comments

Comments

@chjj
Copy link
Contributor

chjj commented Jul 24, 2018

There's a merklix tree implementation on the merklix branch.

You could say the way the urkel tree currently handles bit collisions is naive, but in benchmarks, there are no noticeable differences between the urkel tree and a merklix tree in terms of performance or storage. The average case proof size is also identical.

Still, we have to consider the possibility that people may try to DoS the tree. In this case, the merklix tree holds up better.

So, I'm hesitating here for two reasons:

  1. This adds massive complexity to the implementation of the tree and proof verification.
  2. In order to reduce storage, nodes have to be stored as a variable size. I've been given advice to try a "merklix-2" or "merklix-4" tree (where only 2/4 colliding bits are stored on internal nodes, thus allowing us a constant size node), but I find this even more convoluted since it basically requires combining both methods of handling bit collisions. This also adds complexity with a new "pointer" system you'll notice on the merklix branch.
  3. As a result of the last issue, memory usage increases a lot, I want to say it's nearly double, since we now have a lot more properties/objects in memory to track size/bits/etc.

If we can solve the memory issue, I have no issue with using our merklix implementation.

Opening this up to discussion.

@chjj
Copy link
Contributor Author

chjj commented Jul 24, 2018

I managed to reduce memory usage with some hacks.

If we want to switch to the merklix tree, I think we should wait until it's more tested and understood. Having people audit the code would be good. It's a lot more complex than the urkel tree in its current state.

@chjj
Copy link
Contributor Author

chjj commented Aug 7, 2018

Update: implementation moved to: https://github.com/handshake-org/urkel/tree/master/lib/radix

chasesmith95 pushed a commit to chasesmith95/urkel that referenced this issue Jun 28, 2019
chasesmith95 pushed a commit to chasesmith95/urkel that referenced this issue Jul 18, 2019
chasesmith95 pushed a commit to chasesmith95/urkel that referenced this issue Jul 18, 2019
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

No branches or pull requests

1 participant