planetarium / libplanet

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

♻️ In memory "next state root hash" #3842

Closed greymistcube closed 1 week ago

greymistcube commented 1 week ago

The general meaning of "next state root hash" has changed to be simpler:

On top of this, the next state root hash of any Block is considered ephemeral until it can be derived from the BlockChain itself:

I have (temporarily) moved a possible lock inside GetNextStateRootHash() to a more appropriate place, i.e. ConsensusContext. This doesn't actually resolve the (issue)[#3833], but should be handled separately.

Internally, the next state root hash of the BlockChain (i.e., BlockChain.GetNextStateRootHash()) is kept up to date by managing it through BlockChain(), Fork(), and Swap().

greymistcube commented 1 week ago

@OnedgeLee I've made the suggested changes except for the indexing issue in ConsensusContext.NewHeight() method, which will be handled in a separate PR.