planetarium / libplanet

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

Make Libplanet support another `IStateStore` implementations universally #1128

Closed moreal closed 2 years ago

moreal commented 3 years ago

This issue actually suggests making planetarium/libplanet support universally another IStateStore implementation, not only TrieStateStore. Currently, there are many type testing logics and fields run on only TrieStateStore. That makes the existence of IStateStore suspicious: whether to allow using another custom IStateStore implementation. Also, it doesn't seem like a good model to make fields of Block<T> nullable. So I want to suggest to update and to discuss for below:

Rename Block<T>.StateRootHash more universal.

The name, StateRootHash, was from other blockchain's naming using MPT (e.g. Ethereum) and means the root hash of the tree. It is not suitable for another IStateStore implementation not using MPT. So we should rename it into a more universal name to mean "prove for the state of the block".

If you have some ideas about the naming, please leave them as a comment. cc @planetarium/libplanet

Separate the logic to validate its state from BlockChain<T>

Currently, BlockChain<T> validates the state of the block when using TrieStateStore. And the logic is in the BlockChain<T> implementation and it should be separated as another interface IStateValidator or something with better naming.

IMHO BlockChain<T> should be just a replacement of its tip, which doesn't do anything like mining.


Except for the above things, it should need one more interface to calculate the proof of the state.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions.