Introduction to æternity’s Bitcoin-NG Implementation

æternity’s consensus mechanism explained.

“A distributed Excel spreadsheet”

That’s how the hosts of the Grumpy Old Geeks podcast once explained blockchain and it’s funny because it’s (kind of) true. Let’s go into some more detail about how this “distributed Excel spreadsheet” works.

Imagine blockchain as a whole bunch of distributed computers that form a network. For this network to be useful to us, we need to make sure that each participant in it receives an identical “spreadsheet”. Coming up with an algorithm to achieve such a level of synchronization within distributed networks is one of the classic old-school computer science problems, and one of the hardest. It first arose in the ’70s, during the nascent development of distributed systems. Some of the greatest computer scientists and mathematicians in the world worked on this problem. Their solution? Consensus algorithms. The idea was first presented in the ’80s but it took a couple more decades for it to be developed. Then, in the ’00s, it was immediately integrated into various kinds of distributed and cloud-computing networks.

A similar consensus algorithm, augmented by the function of solving cryptographic puzzles, is found at the center of all blockchains. It is this mechanism that allows the state of the blockchain network to be securely updated. It tracks and records all transactions between all participants. The same “spreadsheet” is distributed across the whole blockchain to each participant, and then verified. At this point you might be thinking to yourself “Well, that sounds simple enough. If consensus algorithms have been a thing since the ’80s, why did we have to wait such a long time for the blockchain to be invented?”

Unfortunately, the classic consensus algorithm setup is not compatible with blockchains. It only works if we know all the actors within the distributed network. With a blockchain, however, we have a dynamic deployment of untrusted actors/hosts. Not only are they untrusted, some of them could be downright malicious. Their agenda is unknown to us; they can lie to us, introduce new information or broadcast false information to one host and correct information to another host. Satoshi Nakamoto’s idea about the addition of a cryptographic puzzle-solving functionality to a consensus algorithm was the one revolutionary solution that gave us the usefulness of blockchains. When all participants on the blockchain are solving the same crypto puzzle then the Byzantine actor threat becomes a non-issue. That’s known as a Proof of Work (PoW) consensus algorithm.

However, despite its strong points, PoW has one major weakness. In Nakamoto’s original protocol, the participant who manages to solve the crypto puzzle the fastest becomes the winner and is awarded with the job of confirming a set of transactions that occurs on the blockchain. Known as SHA-256 hashing, this process requires the winning miner to confirm the entire block of data before proposing to extend the blockchain with a new block. At the end, each participant receives a new block, verifies it on their own and updates their “Excel spreadsheet” with the latest list of transactions. This is how transactions are verified in Bitcoin and other PoW blockchains. It is a secure but cumbersome process that takes 10 minutes on average, which is far from ideal. In fact, this kind of delay severely limits the real-world scaling of blockchains.

If we want to see any kind of meaningful mass adoption in the near future, we need to have transactions on the blockchain happen and be verified much more quickly.

This is Where the Bitcoin-NG Consensus Algorithm Comes In

As implied in its name (NG stands for Next Generation), this is an updated version of the tried-and-tested Bitcoin consensus protocol. Bitcoin-NG is a general mechanism that can be applied to both Proof of Work and Proof of Stake (PoS) blockchains. Waves, for example, is PoS + NG.

Applied to æternity, Bitcoin-NG inherits all the security guarantees of Bitcoin’s PoW model, but reverses its approach in building the chain (the “spreadsheet”) itself.

Instead of building it out of blocks containing past events (transactions), Bitcoin-NG allows for the generation of microblocks by a temporary leader who verifies/signs incoming transactions almost instantaneously.

In the old Nakamoto consensus model, we have a mempool where all transactions go and wait for miners to pick them up. Bitcoin-NG also sends data to a mempool but the leader picks it up immediately and packs it into microblocks, which are dispatched right away. This whole operation takes only a few seconds, unlike with Nakamoto’s Bitcoin Core model where a transaction goes to the mempool and might stay there for a long time before a miner picks it up and includes it in a block they are building (due to a low transaction fee, for example).

Bitcoin-NG works, it is stable, and we just implemented it in æternity.

Fast, Secure, and Decentralized — You Can Only Choose Two?

Different types of blockchain protocols will always differ in performance. Bitcoin Core currently manages 4 tps (transactions per second). More “advanced” blockchains claim to achieve thousands, even millions, of transactions per second.

Bitcoin-NG achieves the somewhat more realistic number of around 100+ tps. While that is, indeed, orders of magnitude slower than the likes of EOS or Zilliqa, it is not all about speed. Unlike those examples, Bitcoin-NG allows the blockchain to remain decentralized. And let’s not forget:

True decentralization is the single most important thing that public blockchains must have.

It’s what guarantees the security of the whole system. What’s more, æternity employs additional mechanisms such as state channels to greatly enhance the continuous real-time performance and scalability of transactions and æpps, without compromising their security and that of the blockchain.

Bitcoin-NG has already been implemented into æternity’s Testnet via Erlang, a functional programming language that could prove to be perfect for developing blockchains. The difference between Erlang and other blockchain coding languages is that Erlang was designed especially for scalable, global networks. That’s why it has been working so well in distributed systems for decades.

Currently about 90% of all internet traffic goes through Erlang controlled nodes.

Built by the Swedish multinational networking and telecommunications company Ericsson in the ’90s, Erlang was first applied in their communication software and has been widely used every since. In fact, if you know WhatsApp, they also use Erlang in the backend.

Yes, it’s true what they say about blockchains — you can’t make them fast, secure and decentralized. You will always be forced to pick 2 out of 3. Is it going to stay that way for the foreseeable future? Not if we can help it.

The æternity protocol and æpps have been developed with a solution to this problem in mind. It features a unique combination of both on-chain scaling (thanks to Bitcoin-NG) and off-chain scaling (via state channels).

æternity’s goal is to have one of the most powerful blockchain platforms in the industry with a very reliable on-chain and off-chain performance, while still remaining decentralized.

In a way, æternity is aiming to achieve the seemingly impossible: scalable, decentralized on-chain performance, which allows for quick and cheap access to off-chain state channels that improve scalability even further.

Learn more about æternity’s Bitcoin-NG implementation in GitHub:

Interested in æternity? Get in touch:

GitHub | Forum | Reddit | Telegram | Twitter | Facebook | Mail

This article was realized in collaboration with George Koynov. Thanks, George!

Leave a Reply

Your email address will not be published. Required fields are marked *