planetarium / libplanet

Blockchain in C#/.NET for on-chain, decentralized gaming
https://docs.libplanet.io/
GNU Lesser General Public License v2.1
506 stars 139 forks source link

perf(trie): improve `MerkleTrieExtensiosn.DifferentNodes()` #3355

Closed moreal closed 9 months ago

moreal commented 11 months ago

Currently, there is a MerkleTrieExtensions.DifferentNodes() static public method that compares two different tries. But it is too slow because it looks up all states and then compares states. Since it is a Merkle-tree data structure, it can skip traversal if HashNode is the same.

https://github.com/planetarium/libplanet/blob/c4191c2dd3df5a888173120792073cde01bdd894/Libplanet.Store/Trie/MerkleTrieExtensions.cs

greymistcube commented 9 months ago

Resolved by #3410.