Menu

MagnaChain - code review and functional test

MagnaChain

MagnaChain intends to solve two problems existing in most popular blockchain platforms today: low throughput rates and excessive data accumulation. Their solution is the introduction of a new sidechain architecture and as well as a brand new variant of a PoS (Proof of Stake) consensus algorithm.

Ultimately the goal is to have the chain serving as a multi-purpose platform, although the first use case is as a platform for gaming.

Looking at the track record of the team, we conclude that the members are well equipped to target the gaming industry with their background ranging from names such as Sony Playstation to Blizzard and The9. (Starting here we will get into the technical details of MagnaChain, uninterested readers are invited to skip to the conclusion at the end)

Within MagnaChain, the entire network will have a unique mainchain where all currency is exclusively issued. However, there can also be any number of sidechains, and the previous block of each sidechain can be either a block in the mainchain or in another sidechain. This overall data structure will therefore act as a tree rather than a true chain.

The sidechain technology of MagnaChain adds multiple sidechains in the system. These Sidechains are free to generate and able to be trimmed as required, by this the mainchain will not be over-expanded. As for nodes, only the mainchain is necessary, while sidechains can be downloaded and processed as required, which is friendlier for verification and disk space.

Miners will be able to choose which chains they would like to mine on, and whether they would like to mine on multiple chains. Although there are no new tokens issued on the sidechains, there will still be transaction fees awarded to miners. The more transactions, the greater the fees. If there are fewer miners (actually stakers, since no PoW is involved) in a chain, mining will be more profitable, which will attract new miners. If there are many miners in a chain but there are few transactions, the number of miners will therefore decrease.

The token output mechanism of MagnaChain is in strict accordance with that of Bitcoin, i.e. daily output will be reduced by half when half of the total quantity is mined.


MagnaChain technical architecture

  • First Layer The bottom layer consists of the basic library, including an encryption and consensus algorithm, P2P network, memory management, threads, and process management.

  • Second layer is the basic function module. At this layer, the basic account and wallet management, blockchain generation and synchronization, and basic transaction functions will be implemented. All the functions of traditional blockchain systems are completed at this layer.

  • The third layer is an extension function that includes VM-based smart contract and a multi-chain management system. This layer primarily provides the smart contract and a set of high TPS solutions implemented through multiple chains.

  • The fourth layer is the API layer, which provides a set of API- and system-integrated SDKs for app innovations.

 

VirtualHash-PoS is introduced, an own invented re-enforced PoS consensus protocol that combines elements of PoW/PoS protocols while preventing DDoS and 51% attack vectors. The main idea is to mitigate the predictability of the DPoS model, where often a limited amount of delegates are responsible for validating transactions. With Magnachains VH-PoS model an attacker cannot pre-calculate the cost of a successful attack and will therefore make it practically unfeasible to perform.

Even though the daily output of MagnaChain is determined, it is relating to Coindays instead of hash rate. In this way it is similar to Bitcoin PoW. While Bitcoin mining is depending on the hash rate of nodes, MagnaChain is comparing the amount of coins held for a certain period of time. The weight of Coindays in the consensus algorithm is capped, in order to make the selection for block rewards non-predictable.

A benefit is that miners have to at least re-invest a part of new mining earnings in the next round of mining so as to maintain yield, otherwise they will lose to competition. It decreases miners’ motivation to exchange the mining earnings and is in favor of a relatively stable price of token.

For applications MagnaChain has selected the most common scripting languages in game development and are allowing them to be used in developing smart contracts on the platform. This to make the development of smart contracts as similar as possible to coding the back-end of a traditional video game.

Additionally, MagnaChain provides plugins for the most commonly used tools in game development, to make the process of building games on the blockchain convenient. For experienced game developers, this process will mimic the day-to-day work they are already familiar with.


Download, installation and functional test of binary (compiled) code

Executable code provided by Magnachain was downloaded and installed on one of InCodeWeTrust servers.

An Ubuntu 17.10 Virtual Machine (Virtual Box) was used as target platform running on top of a Windows Server with a typical development environment including C++, Python, Go and other programming language library support.

The code package was deployed to our download folder, execution permissions were added to the files and the first script was started.

./loadlib.sh

This script did set file permissions and copied files to the lib folder. The installation worked without any issues on our test machine and Ubuntu version.

The other executable versions provided for Windows and centOS deployment showed the same solid behavior as the Ubuntu version (here we need to point out that all distributions where very good fits for their respective target OS).

We configured the system further by create a Folder L1_1 and added a file called bitcoin.conf.

The background process (daemon) for the mainchain started without issues:

Subsequently a branch and a branch chain were created without incidents:

After which the mining was started, since we needed funds to run the sidechain. The funds needed to be mined and the mining failed initially as the usage of rpcport 8201 didn’t work well. A different port is needed as standard as 8201 might be blocked on a VM installation.

After verifying the executables, we proceeded to attempt building (compiling) the project directly from the supplied source code files. The source code builds without any issues and we verify that the executable is identical to one we have tested.


Source code review

The C++ code is clean and easy to follow, however the documentation of code is lacking. Some C++ files are entirely uncommented, e.g . ./chain/branchdb.cpp (see extract below).

The Code gives a well developed and tested impression. It partly uses Bitcoin as code base with enhancements. E.g. ./key/pubkey.h

Most of the core functions are complete and working – (as seem above in the runtime test section).

Overall the code looks well rounded and organized. This also applies to the folder structure of the project. Consistent coding standards are used and apart from the partial absence of code comments the quality is high.

Overall we deem the code to be in advanced beta stage.


Conclusion: From a development point of view we find the project very well in progress, and deem the product being at late beta stage, very close to actual release (in fact it could already be released at this point with a few minor modifications).

The Magnchain team has produced a well working stable product targeting multiple platforms, such as MS Windows and Linux, which further adds to the adoption potential among developers. However, we would recommend the team to implement a one-click deployment function for cloud servers in order to further ease the accessibility for developers and validator nodes. This would be a logical step at this point given the maturity of the product.

As a development platform for gaming dApps, the provisioning of an environment that mimics the one that professional game developers use on a daily basis, makes MagnaChain a strong proposition. This combines with the team’s strong background within the gaming industry makes us believe that MagnaChain has more than a fair chance to reach adoption as a blockchain based gaming platform, and possibly within other use cases as well.

 

Stay Connected

 
cryptodiffer logo
rss subscription
 
© 2024 InCodeWeTrust