You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the file libraries/concurrent-merkle-tree/src/concurrent_merkle_tree.rs at line 109, an empty_node_cache is defined but it is immutable. Even though empty_node_cached generates rightmost_proof and path, it cannot utilize the cache when cache[target] == EMPTY. My understanding is that empty_node_cache should be able to store the results from previous levels and use them for generating the current level, thereby avoiding recursive calls.
Verification:
To verify the issue, insert println!("level: {}", level) in the empty_node_cached func to output the current level. Then, run the following test code:
Description:
In the file
libraries/concurrent-merkle-tree/src/concurrent_merkle_tree.rs
at line 109, anempty_node_cache
is defined but it is immutable. Even thoughempty_node_cached
generatesrightmost_proof
andpath
, it cannot utilize the cache whencache[target] == EMPTY
. My understanding is thatempty_node_cache
should be able to store the results from previous levels and use them for generating the current level, thereby avoiding recursive calls.Verification:
To verify the issue, insert
println!("level: {}", level)
in theempty_node_cached
func to output the current level. Then, run the following test code:For better observation of the output, insert a line after each node generation:
When running the
cargo test
with stdout, you will observe:This pattern introduces an O(n(n+1)/2) computational overhead which is unnecessary.
The text was updated successfully, but these errors were encountered: