planetarium / libplanet

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

Remove `BlockChain<T>.Fork()` and `BlockChain<T>.Swap()` in `Swarm.PreloadAsync()` #2797

Open riemannulus opened 1 year ago

riemannulus commented 1 year ago

Context

BlockChain<T>.Swap() and BlockChain<T>.Fork in Swarm.PrealodAsync() and Swarm.CompleteBlocksAsync() is useless in the PBFT scenario. There is only one canonical chain in the network so we do not support multiple chain branches.

And BlockChain<T>.Swap() is slow as much as when branches are long. So we suggest removing BlockChain<T>.Swap() in Swarm.PreloadAsync()

riemannulus commented 1 year ago

If we remove BlockChain<T>.Swap() in Swarm.PreloadAsync(), we need to decision for inevitable behavior changes.

riemannulus commented 1 year ago

rn, I have some trade-offs for solving this problem.

Have any ideas? @longfin /cc. @libplanet

longfin commented 1 year ago

Rollback lazy-execute behavior. But I'm not sure this is the best solution.

Also, I'm not sure if BlockChain<T>.Append() is atomic and quit-proof(?).

I agree that this can be difficult, but also think it's easier this way than complicating others.

riemannulus commented 1 year ago

So, your idea is rollback lazy-execute behavior is not the worst plan in this situation?

I have no strong opinion about this so if you think so, I'll do it like that.

longfin commented 1 year ago

So, your idea is rollback lazy-execute behavior is not the worst plan in this situation?

Right. 😄

stale[bot] commented 1 year ago

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