Planetarium Engineering Snack

Libplanet 0.5 Released

(English한국어)

Hello all, we’re delighted to announce that the 5th minor version of LibplanetVersion 0.5 along with patch versions, 0.5.1 and 0.5.2, has been released.

Libplanet is a common library that solves game implementation problems such as P2P communication and data synchronization when creating online multiplayer games that run on distributed P2P.

Version 0.5 includes extensive performance and reliability improvements addressed while testing games developed with Libplanet. This post will cover those major changes of Version 0.5.

IBD Speed Improvement

Previously, IBD used to take a long time to execute, even for a small number of blocks. This was because after downloading the blocks, you had to calculate the final state starting from the first block.

However, if you have a reliable node, it is quite possible to effectively reduce computing time by using precalculated results from that node.

So, from Version 0.5, by handing over trusted nodes as parameters to Swarm<T>.PreloadAsync(), we’re now able to receive, store, and use the most recent state values already computed from those trusted nodes.

If there aren’t any trusted nodes or the process fails for another reason, IBD computes in the same process as previous versions.

IRandom.NextDouble() Removed

Quoting from the System.Double section of .NET Standard Official Document, it states:

In addition, the result of arithmetic and assignment operations with Double values may differ slightly by platform because of the loss of precision of the Double type. For example, the result of assigning a literal Double value may differ in the 32-bit and 64-bit versions of the .NET Framework.

As stated above, arithmetic operations and substitution of Double can cause indeterminant results. Because of this, we’ve decided not to provide IRandom.NextDouble() from this version onwards.

Please refer to this article for further information.

Block Action

In order to keep chains secure, we need miners to mine the blocks, and we need to reward miners to recruit and keep them.

Previously for miners to be rewarded, they had to add a transaction with reward actions to the block each time. But from this version, the new IBlockPolicy<T>.BlockAction property, which is executed for every block, enables code implementation that rewards miners for each block action.

FileStore Removed

Libplanet had been providing an interface called IStore, FileStore (a file-based implementation of IStore), as well as LiteDBStore (implementation based on LiteDB) since Version 0.4 to simplify the storage layer. Despite the benefits of its simplistic implementation, however, FileStore also had the following limitations:

As we started using LiteDB, FileStore usage rate began to diminish. And so, considering the difficulty of continuously managing FileStore, we decided not to provide FileStore implementation from Version 0.5.

More Detailed Preload Progress

To carry out the IBD mentioned above, you can call the Swarm<T>.PreloadAsync() method. And previously, sending IProgress<BlockDownloadState> to this method’s parameter could tell us about the progress of the block download, but it couldn’t tell us about the specific progress from running actions to the final status after the block download (or from a trusted node).

Therefore, the waiting time of this previous method had to be quite boring for players since the loading message only showed either loading or 100% and no specific progress of the block download.

However, from Version 0.5, by receiving the IProgress<PreloadState> type parameter instead of IProgress<BlockDownloadState>, this allows us to get a detailed view of the entire preload progress.

Through IProgress<PreloadState> object which receives BlockDownloadState, BlockStateDownloadState, StateReferenceDownloadState and ActionExecutionState as parameters inherited from PreloadState, users are provided with more detailed information.

Furthermore

You can learn more about additional changes in our 0.5.0, 0.5.1, 0.5.2 release notes.

And as always, if you have any questions about the new release or Libplanet in general, please visit our Discord chatroom and let’s chat!