Qtum Blockchain Ported POS 3.0 to Bitcoin Core 0.13
Qtuamtum(Qtum) open-source community has been committed to developing a third blockchain system after Bitcoin and Ethereum. Qtum gives itself a mission to let ordinary internet users to experience the value of blockchain.
Qtum blockchain (www.qtum.org) today announces that it has already ported classic POS 3.0 to Bitcoin v0.13 source code.
Here is the detailed introduction of it.
（Quantum Blockchain (Qtum) Porting POS 3.0 to Bitcoin Core 0.13）
Proof-of-Stake (POS) is a consensus model for digital currencies, in which a Blockchain can be secured by using coins to generate blocks, as opposed to large networks of specialized hardware. The Proof-of-Work (PoW) consensus model requires complex problems be solved in order to generate a block. The problem becomes more difficult based on the amount of computing power being utilized.
The POS model allows for Qtum owners to use their personal devices to secure the Blockchain. This means instead of requiring an expensive Application Specific Integrated Circuit (ASIC), Field Programmable Graphics Array (FPGA), or Graphics Processor Unit (GPU), a laptop or personal computer can be used.
At the time of this document’s writing, there are currently about 2 million trillion hashes per second trying to solve a block. Let’s assume everyone is using the latest ASIC device, the Antminer S9 14 Terahash per second, that would be over 140,000 devices. Each device uses 1400 watts of power, and currently costs around USD $1200.00, so that is USD $168,000,000 for the equipment, and 196,000,000 Watts. At 10 cents USD per kilowatt hour, that is about USD $470,000 per day. Please keep in mind the cost of electricity varies greatly, and there are still many older (less efficient) generations of ASIC hardware used to secure Bitcoin’s Blockchain. So long as the cost of electricity is less than the cost of mining and selling the Bitcoins, the difficulty will continue to rise.
The energy cost of securing Qtum’s POS blockchain is a tiny fraction of traditional POW models. Perhaps as little as 10,000 watts would be considered very safe. This would require about 100 devices actively trying to use their ‘network weight’ to solve blocks. As we can see by this comparison, the POS model is environmentally friendly compared to POW.
Qtum is based on Bitcoin Core version 0.13, and plans to incorporate Blackcoin’s POS 3.0 consensus model. This method is not without challenges, which we will overcome by following 8 steps.
1) Researching and Choosing a POS Consensus Model.
Blackcoin has implemented 3 POS versions since its inception in 2014. Version 2 addressed many potential security issues, and discouraged network abuse. Version 3 implemented a few updates, most notably a change from the 1% annual POS rewards to a static 1.5BLK (Blackcoins) per staked block. This meant that only Blackcoin owners who participated in securing the network, by keeping their wallets online, had a chance to stake a block.
After looking at multiple POS census models, Qtum decided to adopt Blackcoin POS 3.0 for integration into Bitcoin Core 0.12
2) Implementing Blackcoin POS 3.0 Into Qtum Core
This section requires close investigation as to how Blackcoin POS 3.0 functions in their ecosystem. It appears that Blackcoin Core’s ancestry comes from a version of Bitcoin Core from 2013, so making it work with version 0.12 required translations to the code in order to make it compile.
Blackcoin’s POS 3.0 implementation is sophisticated, and there are no clear explanations in the code that describe which sections associate with others. The code is distributed into multiple files, and the challenge was to identify markers that allowed Qtum developers to start tagging portions that can be ported.
The way Bitcoin and Blackcoin synchronize their Blockchains is different; Blackcoin downloads the entire block, while Bitcoin distinguishes between the header of the block for faster usage. The ported code from Blackcoin was modified to take this into account when implementing into Bitcoin Core 0.12, along with a few other changes. Modifications were made in the way Blackcoin accepted and processed blocks. The Blackcoin ‘mining’ software was also ported, in order to allow Qtum Core to allow users to solve the equations required to generate coins.
Contributions to this section were performed by a code analyst and 2 Blockchain developers.
3) Testing Qtum’s POS Implementation Without Nodes.
Once the Blackcoin mining software was implemented into Bitcoin Core 0.12, it was accessed using an RPC call to the Daemon. These modifications allowed mining to be performed on a single computer. The algorithms were checked, and this phase was successful.
4) The First Testnet
The first test network was created using 10 nodes, 5 of which were hardcoded into the newly created Qtum Core. The other 5 were compiled and executed on various cloud computing providers. These were discovered successfully. Once the Genesis Block was created, the network was instructed to produce new blocks approximately every 64 seconds, and adjust the difficulty every 16 minutes. The POS block reward was set to 5 coins for testing purposes. Each node was funded with pre-mined coins, and were set to mine coins once the daemon was launched.
5) Qtum POS Fixes Required
This phase resulted in some issues, and a lot of log output allowed developers to work on fixing issues. Some errors in the code resulted in communication problems, some nodes were banned and created their own chain. The difficulty did not adjust properly, and some of the wallets became corrupted.
Once these issues were fixed, the network was monitored for several days just to ensure stability.
6) Building Qtum Core on Multiple Platforms
Linux was used for the first Testnet, simply because it’s the easiest environment to build. Changes were made in order for the build environment to compile for Mac. MingW and Msys2 were used initially, but library issues were encountered. Eventually MingW and Cross-compile on Linux were used. This allowed working wallet executables to be compiled for Mac and Windows 64 bit.
7) Porting Qtum to Bitcoin Core 0.13
This implementation of Blackcoin POS 3.0 onto Bitcoin Core 0.12 was successful, but recent changes made to Bitcoin’s wallet during testing caused development to take a step back and reassess. The decision was made to launch Qtum with the best functionality. Bitcoin Core 0.13 allowed the wallet to synchronize faster, by not downloading the entire Blockchain, just the block headers. This would make the user experience for Qtum owners a lot smoother than sticking with 0.12
Some problems were encountered during this phase, wallet transactions created errors in the log files. The Testnet was left running to observe any errors.
8) Qtum Quality Assurance Testing
Testing a new Blockchain takes time, each block takes approximately 60 seconds to generate, and the idea is to let it run as long as possible. Multiple Testnets were set up, utilizing 130 cloud based Linux sessions for nodes. Each Testnet ran for 15,000 blocks.
Some of the POS blocks were partially downloaded when trying to synchronize, which were due to the Bitcoin Core 0.13 implementation. This was quickly fixed when the code was updated to accommodate POS and POW blocks. Each Testnet successfully minted 15,000 blocks without further issues.
Note: Qtum has released its Whitepaper in August 2016. Please see http://8btc.com/doc-view-783.html
To know more about Quantum, please see :https: //qtum.org/