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

Rewrite in-memory Merkle tree #2700

Merged
merged 12 commits into from
Apr 20, 2022
Merged

Conversation

pav-kv
Copy link
Contributor

@pav-kv pav-kv commented Apr 12, 2022

The code for internal/merkle/inmemory is old and needs a refresh. This change rewrites
the in-memory Merkle tree concisely, and updates all the call sites.

The previous implementation quoted C++ code, used a lot of non-Go constructs, and did
not have the benefit of reusing other Merkle primitives. All of these are good reasons for a
complete rewrite.

@pav-kv pav-kv requested a review from a team as a code owner April 12, 2022 14:42
@pav-kv pav-kv requested a review from AlCutter April 12, 2022 14:42
@pav-kv
Copy link
Contributor Author

pav-kv commented Apr 12, 2022

Review commit-by-commit to see the progression, and observe that the new code is equivalent.

@pav-kv
Copy link
Contributor Author

pav-kv commented Apr 12, 2022

Or review the whole thing, it can be clearer.

@pav-kv
Copy link
Contributor Author

pav-kv commented Apr 12, 2022

@AlCutter @mhutchinson I noticed that this code hasn't been moved to merkle repo. I think this implementation can a) be used for testing in many places, b) serve as a PoC implementation of a Merkle tree with compact and proof types (i.e. implementations with storage would be similar in principle, but have DB/files instead of the in-memory variable). A bit more polish (particularly in the area of unit-tests) for this type, and it can be placed in merkle.

@pav-kv pav-kv requested a review from mhutchinson April 12, 2022 15:02
@pav-kv pav-kv force-pushed the inmemory_merkle_tree branch from 42b2800 to 86264bf Compare April 12, 2022 18:44
@pav-kv pav-kv force-pushed the inmemory_merkle_tree branch from 86264bf to 61d18af Compare April 13, 2022 10:55
@pav-kv
Copy link
Contributor Author

pav-kv commented Apr 13, 2022

ping

@mhutchinson
Copy link
Contributor

Between being ill and oncall, I'm unlikely to get to this in the next few days. And I'm off next week. This is one for @AlCutter

pav-kv added 2 commits April 13, 2022 13:59
Expect the clients giving correct tree sizes, otherwise panic.
@pav-kv
Copy link
Contributor Author

pav-kv commented Apr 13, 2022

@AlCutter I made a few more simplifications. It's strictly more convenient to review the latest state of the code. You may look at individual commits mainly to understand my "thinking process".

@pav-kv pav-kv merged commit a7f069c into google:master Apr 20, 2022
@pav-kv pav-kv deleted the inmemory_merkle_tree branch April 20, 2022 09:59
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.

3 participants