Planetarium Engineering Snack

Libplanet 0.8 Released

(English한국어)

Hello All.

Our team has released the eighth minor version of Libplanet, Version 0.8.

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.

With the new version updated in nearly three months, there have been many improvements in version 0.8 including storage optimization. This article will cover major changes of Version 0.8.

Genesis Block Anticipation

BlockChain<T> now anticipates a particular genesis block. This is to prevent mistakes such as multiple games attempting to connect to the wrong network. Mistakes like above might occur because although games made from Libplanet form separate networks, Libplanet behaves in a type of metaprotocol.

BlockChain<T>() constructor takes the Block<T> object as a factor and the block becomes the first block. If genesis block contained in IStore and the genesis block expected by the BlockChain<T>() constructor do not match, InvalidGenesisBlockException will occur.

Currently, the constructor receives the entire Block<T> object, but the next version will have the constructor only receive the genesis block hash and the actual block content to be received from other nodes on the network.

DefaultStoreLiteDBStore

LiteDBStore, a built-in IStore implementation, has been removed and DefaultStore has replaced it.

The reason for this replacement is that while only a single LiteDB file was stored before, more files with multiple formats have been added to be stored within a directory from this version.

Another reason was our intention to remove implementation details from the name, with efforts to optimize the repository until the 1.0.0 release.

In addition, a compress option has been created in the DefaultStore() constructor to reduce storage space. Although the option is still turned off by default in this version, the default will be changed to true in the next version.

ICryptoBackend

To be used on a variety of platforms, Libplanet has been using a cryptographic library written in pure C#, Bouncy Castle. Although pure C# implementations are a great advantage in portability, they serve as a penalty in performance.

In the new version, an abstraction layer called ICryptoBackend has been added to allow game developers to choose between portability and performance. While the default implementation, DefaultCryptoBackend, is still internally dependent on Bouncy Castle, game developers can achieve performance benefits by implementing the ICryptoBackend interface appropriately, depending on the game’s target platform.

For example, if you want Libplanet to use MyCryptoBackend class that implements ICryptoBackend, you can overwrite CryptoConfig.CryptoBackend property as shown below.

CryptoConfig.CryptoBackend = new MyCryptoBackend();

In the case of Nine Chronicles, a game currently being developed by our team, we have also improved game performance by implementing ICryptoBackend interface that calls secp256k1 C library unveiled in the Bitcoin project.

Routing Table Improvement

Because Libplanet uses DHT to communicate with other peers, it stores information about the peers associated with itself on the routing table.

Traditionally, this routing table only stored the most recent communication points with that peer. But now, we’ve also added a communication delay info to give you more information about the network environment.

Developers can use the newly added Swarm<T>.CheckAllPeersAsync() method to update peers stored on routing tables, and access Swarm<T>.Peers property from outside Libplanet to identify the peers currently on its routing tables.

Changed Block Structure and Serialization

A block that is a component of the blockchain can be divided into two parts: the transactions and the metadata excluding the transactions.

As with many blockchain projects, we’ve defined the part minus the transactions as block headers, and we are now able to compute more efficiently than ever before by using a block header that contains more information compared to only using block hash for computation.

In addition, when serializing blocks and transactions, field keys are shortened and the empty fields are completely excluded, making the serialized expression lighter.

Documentation Improvement

Although not a change to the library itself, there have been improvements in the design of the docs website and a new Overview document written by Swen Mun has been added.

Furthermore,

In addition, there have been a number of other changes while fixing many problems that we found during our 3 months of Nine Chronicles public testing. Details can be found in the entire change history.

If you’re curious, install it and try it. 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!