Currently, there are IStateStore.PruneStates()(TrieStateStore.PruneStates()) method and MerkleTrie.IterateHashNodes() method. And TrieStateStore.PruneStates()' implementation is very inefficient so #1691 introduced TrieStateStore.CopyStates() and libplanet should suggest efficient way and deprecate inefficient way.
🤔 Furthermore
While I had worked for #1691, I felt confused about IStateStore's role. Currently, there is only IStateStore.GetStateRoot() method and it just returns MerkleTrie with IKeyValueStore, secure bool option received from its constructor. it doesn't do anything except for it. Historically, IStateStore was introduced to replace state stores based on state-reference smoothly. But, today, IStateStore seems useless because Libplanet is using MPT as blockchain protocol level and I believe it will not be replaced, at least in near days.
📔 Overview
Currently, there are
IStateStore.PruneStates()
(TrieStateStore.PruneStates()
) method andMerkleTrie.IterateHashNodes()
method. AndTrieStateStore.PruneStates()
' implementation is very inefficient so #1691 introducedTrieStateStore.CopyStates()
and libplanet should suggest efficient way and deprecate inefficient way.🤔 Furthermore
While I had worked for #1691, I felt confused about
IStateStore
's role. Currently, there is onlyIStateStore.GetStateRoot()
method and it just returnsMerkleTrie
withIKeyValueStore
,secure
bool option received from its constructor. it doesn't do anything except for it. Historically,IStateStore
was introduced to replace state stores based on state-reference smoothly. But, today,IStateStore
seems useless because Libplanet is using MPT as blockchain protocol level and I believe it will not be replaced, at least in near days.References
See also https://github.com/planetarium/libplanet/pull/1691#issuecomment-1018113164.