AntelopeIO / leap

C++ implementation of the Antelope protocol
Other
113 stars 69 forks source link

IF: Create new efficient incremental Merkle tree #2361

Closed greg7mdp closed 2 months ago

greg7mdp commented 3 months ago

Resolves #2333

This PR provides a new Merkle tree implementation which does not unnecessarily store extra digests and does not do extra hashes.

Previous versions are renamed: incremental_merkle_tree_legacy, calculate_merkle_legacy. New versions are named: incremental_merkle_tree, calculate_merkle.

Note: Even though the files have been renamed incremental_merkle_legacy.hpp and merkle_legacy.hpp, the implementation has not been modified (besides remoning the canonical template parameter).

New incremental_merkle_tree

New calculate_merkle

New performance tests

This PR adds two performance tests comparing the legacy and new merkle tree implementations

New consistency test

This PR adds a test checking consistency between incremental_merkle_tree and calculate_merkle when adding from 1 to 1000 digests:

ericpassmore commented 3 months ago

Note:start group: IF category: INTERNALS summary: Improved Merkle Tree, no longer storing unneeded digests, switched to incremental calculations. Note:end