Blockchains and consensus (Article 7)

Al_ref
Decentralized Innovations
8 min readMay 13, 2022

While the Blockchain is itself a form of a database, it is stored at multiple servers or computers and is immutable. Blockchains allow for the existence of decentralized cryptocurrencies, but their use cases extend far beyond just facilitating digital currencies.

Multiple blockchains side by side
Photo by Shubham Dhage on Unsplash

The previous articles in the series have explained what the blockchain is and how it works. Today, we will focus on the different types of blockchains and their consensus mechanisms.

Blockchains have two main characteristics: 1) public/private and 2) permission/permissionless. Any permutation of these two characteristics is possible: for example, Bitcoin is a public and permissionless blockchain, while Ripple is a public and permission blockchain.

As we also explained previously, a blockchain can be most simply thought of as a ledger that can record transactions or account balances. Bitcoin is a transaction-based blockchain, which means that transactions are allowed only if there was a payment made to the wallet prior to spending the money. Ethereum, on the other hand, is an account-based blockchain, so every transaction updates the balance of a wallet.

So, what does each of these characteristics mean?

  • Public/Private: a public blockchain is open for anyone to join. In a private (or consortium) blockchain, only a few accounts have the access required to participate in the blockchain. Consortium blockchains are used by businesses or organizations to process private operations, such as the proposed blockchain of the Australian stock exchange. Public blockchains are ‘open-source’. Open-source means that the code for the blockchain is available on the internet for anyone to check and modify. Before any modification to the code can be implemented, a majority of nodes are required to approve it through a voting mechanism. Open-source code serves two purposes: 1) it increases the trust in the software, since everyone can check the code for malware or viruses, and 2) It has been proven over time that open-source software has superior security over closed-source software, since everyone checking the code can propose modifications that fix issues within the original code.
  • Permission/Permissionless: In permission blockchains, only nodes with permission can add new blocks, while in permissionless blockchains, anyone can add new blocks, provided they fulfil the requirements set by the consensus mechanism used in the blockchain.

Consensus — What is that?

You can think of consensus in blockchains as the mechanism by which trust is ensured among all participants. You may remember from previous articles that in Bitcoin, the consensus mechanism is Proof-of-Work (PoW). There are many different consensuses; the most popular types are:

  • Proof-of-Work (PoW): In this mechanism, the mining nodes must solve a hashing problem to be permitted to add the next block. The PoW mechanism consumes a lot of energy, which is often considered a disadvantage of Bitcoin and similar blockchains. Other consensus mechanisms have been developed to resolve this issue.
  • Proof-of-Stake (PoS): PoS was proposed as a solution to the energy problem of PoW. To be considered as a mining node in a blockchain using the PoS-mechanism, you need to stake a part of your cryptocurrency. Staking is simply a deposition of some cryptocurrency in a smart contract (smart contracts will be explained in detail in a later article). This way, the nodes are invested in the blockchain cryptocurrency, so it is not in their interest to spam or fraud the blockchain. In the simplest mechanism of PoS, a random selection of the node that mines the next block is performed. If a node has more staked coins, then its chance to mine the next block is higher. However, this system favours the richest node and makes it richer. A different approach is adding weight to the stacked coins in what is called ‘coin age.’ In this system, the longer the coin is staked, the higher chance the node gets to mine the next block. It is likely that you can already see how this solution is problematic. No fair solution for the problems with the PoS consensus has been found, which is why most blockchains — including Ethereum — still refrain from implementing a fully PoS mechanism at present. Despite its current problems, the PoS consensus mechanism does want to give the chance of becoming mining nodes to as many nodes as possible; and generally, setting a required minimum staking limit is not unreasonable, since nodes with low balances might otherwise try to scam the system. A penalty system was therefore implemented to prevent this, which functions as follows: if a node acts maliciously, the owner risks losing their staked cryptocurrency. However, this often will not be a good enough scam-deterrent for nodes with low staked amounts, that’s why a minimum staking limit is required to deter malicious actions.
  • Delegated Proof-of-stake (dPoS): In the dPoS system, nodes with staked cryptocurrency vote for delegated nodes that are potential miners for the next block, 1000 blocks or any other number of blocks; afterwards, another vote is cast to elect new miners, and so on. As in the PoS-mechanism, a random selection of the actual next block miner is then performed from the pool of delegated potential miners.
  • Proof-of-Importance (PoI): PoS and dPoS mechanisms encourage nodes to stake their money instead of using it for their purpose in transactions, which defies the whole purpose of a currency. Instead, the PoI-consensus mechanism favours the nodes with higher balances but also higher transactions.
  • Measure-of-Trust (MoT): What if I possess two nodes and I keep exchanging money back and forth between them? Those nodes’ Importance will increase, while the blockchain is cluttered with unnecessary transactions. As consensus is at its base a mechanism for trust, why not use historical behaviour as an indicator? The node with a lot of ‘good’ behaviour and minimal ‘bad’ behaviour gets a higher chance to mine the next block. The system encourages good behaviour in general, but it is susceptible to suffering from the same issue as with PoI, where nodes with so many ‘good’ transactions are being unnecessarily made just so the node increases its chances to mine the next block.
  • Proof-of-Space (PoSp): This approach is based on Nakamoto’s idea for Bitcoin that in order to participate in the mining game, users should be required to stake physical assets. However, instead of having multiple processors and spending a tremendous amount of energy, what is being staked by users is their hardware storage space. The more hard-drive space you commit to the blockchain, the higher the chance you get to be selected to mine the next block. But the problem that might arise is similar to the current main issue of the PoW approach: nodes start expanding and we end up with tons of unused hard drives plus the high amounts of energy that was required to produce them.
  • Minimum-Block-Hash (MBH): In this system, we revert back to the oldest trick for ensuring trust, namely selecting the node completely at random. But to avoid selecting a node that does not want to participate in the mining, we resort to a game of luck among those nodes willing to participate. In the MBH mechanism, nodes build the next block by adding transactions, a timestamp, the hash of the previous block and then each node gets to choose a nonce at random (nonce is just a random integer). Then each node hashes the block and the node with the lowest hash value gets to mine the next block. To understand this, you just need to remember that hashes have values: think of it as randomly selecting a 10-digit number, if my computer selects 0125393467 and your computer selects 0000358945, then you win and get to mine the next block. This is because your number starts with 4 zeros, while mine starts with only 1 zero. This, in a nutshell, is all there is to the MBH-mechanism. I am not going to discuss the potential issues with this system, but I would be curious what you think the potential problems might be, so please write your ideas in the comments!

Keep in mind that a consensus mechanism is only needed in a permissionless blockchain, as in permission blockchains nodes will only join if they have trust in the nodes with permission to add new blocks.

The exact number of blockchains in 2022 is not known, mainly because more and more blockchains are rapidly coming into existence while others disappear. Some estimates believe the number to be in the 1000s. Among the top blockchains are Bitcoin, Ethereum, Stellar, NEO, EOS, Dash, Tron, Polkadot, Solana, Terra, Avalanche, BSC, Polygon,… check out a list of most of the blockchains at defillama.

a comparison table between some blockchains
https://ieeexplore.ieee.org/document/8246573

The current online hype and seemingly boundless enthusiasm for the technology is usually tied to permissionless blockchains. However, enterprises, governments and other organisations favour permission blockchains to avoid losing control over their data. There are a few blockchain providers who are building blockchains for others; two of the most popular ones are corda and hyperledger.

The introduction of the first generation of blockchain technology is Bitcoin. Bitcoin blockchain’s lack of support for smart contracts led to the second generation of blockchains that support smart contracts, the most famous of which is Ethereum. However, 1st and 2nd generation blockchains suffer from a scalability problem. This scalability problem concerns 4 aspects of the blockchain:

  1. Space: as the blockchain ages, its length increases and storing it requires more storage space.
  2. Fees: transaction fees are large, which obstruct small transactions from happening.
  3. Block size: there is a limitation on the block size in both 1st and 2nd generation blockchains (for simplicity we use block size as a general measure). This size limitation is required to reduce latency when transmitting a block to the network.
  4. Validation time: as we saw with blockchains that utilize the PoW consensus, finding a hash requires some time (10 minutes in the case of Bitcoin) which is necessary to ensure security.
Blockchain trilemma, decentralization, scalability and security cannot be ensured simultaneously
Blockchain trilemma, decentralization, scalability and security cannot be ensured simultaneously

The scalability problem, also known as the “blockchain trilemma” concerns the coupling between decentralization, security and scalability. If a blockchain needs to improve its scalability, it must sacrifice some of its security and/or its decentralization-capacity. A new, 3rd generation of blockchains tries to solve this trilemma by improving the scalability without sacrificing either security or decentralization capabilities. 3rd generation blockchains will be discussed in a future article.

--

--