Consensus Algorithms: Proof of Stake and Proof of Work


Blockchain is a distributed system that can have thousands of participants. Unlike conventional distributed databases, blockchain almost always does not have a central administrator who configures the network nodes, so it turns out that the blockchain architecture is not only distributed, but decentralized

. In this regard, the problem of distributed consensus is relevant for blockchain: “How can network nodes achieve the same point of view on the blockchain transaction log in a distributed network, given that arbitrary nodes can “fall” or freeze, guided only by the general rules for processing messages in the network?”

We will talk about how consensus is achieved in blockchains in our material today.

/image by jgbarah

Difference between Protocol and Consensus Algorithm

These terms are often confused and identified, but they are not the same thing. A protocol is a set of rules by which the Blockchain exists. The consensus algorithm is the mechanism by which these rules will be followed.

A simple example: Bitcoin and Ethereum are protocols. They themselves determine the rules for the existence of the network. And the consensus algorithms are Proof of Work or Proof of Stake. Using the example of Ethereum, we can see that the protocol always remains unchanged, and the consensus algorithm can be changed, although this is a very complex and lengthy process.

What is Consensus?

The term Consensus (Latin Consensus - agreement) is generally interpreted as the process of a group of people making a single decision, reaching agreement on any issue. In this case, no voting is carried out as such - the decision is made on the basis of the absence of objections from the majority of participants.

It is worth noting that consensus is called not only the decision-making process itself, but also the decision itself made as a result of such a procedure, that is, the result.

The task of the Byzantine generals

This is a problem from cryptography, when several participants remote from each other are given an order from a single center. Depending on what order they receive and which of these generals (participants) will obey the order and who will not, there will be different outcomes of events:

  • If all the generals attack, Byzantium will destroy the enemy (favorable outcome).
  • If all the generals retreat, Byzantium will retain its army (intermediate outcome).
  • If some generals attack and some retreat, the enemy will eventually destroy the entire Byzantine army piece by piece (unfavorable outcome).

The blockchain consensus algorithm is supposed to solve this problem. Either everyone attacks or retreats. Otherwise, when sending cryptocurrency, there is no guarantee that someone will not change the amount. All network participants must follow the protocol and reach a general consensus. Based on this problem, a whole family of BFT consensus algorithms was born. Many cryptocurrencies like Ripple (XRP) and Solana (SOL) use their own validation algorithms. On the contrary, most stableblocks use other people’s algorithms and blockchains to operate.

Why consensus is so important in blockchain

Consensus algorithms are vital for blockchains to remain fully decentralized. Due to the decentralized nature of blockchain, there will never be a centralized authority that verifies and updates the ledger with transactions and fresh data. Therefore, stakeholders in the network must decide on an equal basis which transactions should be added to the blockchain.


How consensus works in blockchain

This process of reaching consensus on a widely shared database would not be possible if not for an intelligent algorithm that can automatically validate new transactions and associate them with all the equipment on the network.

Without a suitable consensus algorithm in place, decentralized systems would have to succumb to a centralized source that stores and processes data in one place, making the information it stores vulnerable to digital attacks and interference by those who manage to gain access to its location.

PoW – Proof of Work

Everyone is accustomed to calling this consensus algorithm mining. It works on a proof-of-work principle, meaning transactions are validated by miners using hash calculations. The main disadvantage is the growing complexity of mining and constantly growing computing power. Blockchain scaling is only possible with the development of technology.

The mining equipment validates the block with transactions, after which the block enters the blockchain, and miners receive a reward. This is one of the most famous digital currency consensus algorithms.

Cryptocurrencies:

  • Bitcoin
  • Ethereum
  • Litecoin
  • Zcash
  • Monero

Proof of Work - PoW

Proof of work was “invented” long before Bitcoin back in the early 90s and was used in a different context: to protect against spam.
For example, one version of proof of work (Hashcash) was proposed by English cryptographer Adam Back, who is now the CEO of one of the largest blockchain startups. In a proof-of-work case, the hash of the message combined with a special field (nonce) must be less than a certain value (or start with a certain number of zero bits). Nonce has no meaning for the message itself - this field is iterated by the author of the proof until a suitable value is found. The name “proof of work” reflects the fact that in order to find a nonce, one must perform computational work, the expected amount of which is measurable. For example, if you want the first 16 bits of a hash to be zero, then on average you need to go through 65536 nonce values.

This can be illustrated using a Python program:

import itertools from hashlib import sha256 # Interprets a sequence of characters as a little-endian number to_long = lambda x: sum(ord(b) << (8*i) for i, b in enumerate(x)) # Combines nonce and message to calculate hash. combine = lambda nonce, msg: str(nonce) + ":" + msg # Verifies proof of work def verify_pow(msg, nonce, difficulty): h = sha256(combine(nonce, msg)).digest() # Are the first ones equal difficulty hash bits to zero? return to_long(h) % (1 << difficulty) == 0 # Creates a proof of work for the message def create_pow(msg, difficulty): for nonce in itertools.count(0): if verify_pow(msg, nonce, difficulty): return nonce msg = "blockchain" nonce = create_pow(msg, 16) combine(nonce, msg), sha256(combine(nonce, msg)).hexdigest() #43952:blockchain 000027b5022f88d2da21bd2802268966050f5a0b031058ce4562939c13 727303 Clarification about the expected amount of work is important. Theoretically, with a lot of luck, a suitable nonce can be found very quickly. If the program above is run with the message “Bl0Ckchain”, then the nonce value will be 6571, which is ten times less than expected. Therefore, looking at a proof of work can only estimate the resources spent on it, but for high complexity of the proof (that is, the expected amount of work completed), this estimate will be quite accurate.

Proof of work is similar to digital signatures - it ensures the integrity of the message, since the likelihood of the same nonce matching different messages is very low. The proofs are also easy to verify—it only takes one hashing operation. Unlike signatures, creating a proof of work does not require knowledge of secrets, but it does consume more computing resources. For example, in the above program, generating a proof of work for a 32-bit “blockchain” message requires several hours of computation on a regular personal computer, but verifies the proof almost instantly.

sha256("5263268363:blockchain") = 000000007cf39dfc8fccae534b39b5f362c16891abca02d0e7b1dbd5a129ee17

PoS – Proof of Stake

The second most popular consensus algorithm. It works on the principle of proof of stake, that is, only those network participants who have a certain number of coins can validate transactions. Validators in PoS are also called forgers or minters, which translates to “forging” and “minting coins,” respectively. The scheme is one-on-one, like in a bank: you put your money in an account for a certain time and it is frozen. You receive your profit as a percentage.

The popularity of this algorithm is due to the long-term transition of Ethereum from PoW to PoS. After the transition, the ether will be called Ethereum 2.0. ETH mining using the PoS consensus algorithm is called staking; it has already been launched on the Binance exchange. This transition is necessary for security, scaling, and token maintenance.

Technically, validators are servers that process data. Nominators propose a block, validators approve it.

Cryptocurrencies:

  • Peercoin
  • NXT
  • Blackcoin

Main Disadvantages of PoW

Given mining's intensive use of computing resources, PoW is considered costly, wasteful, and inefficient. Having thousands of miners working on a single solution each time is an excessive use of resources, especially since only the block in which the solution was found is subsequently valuable. Consequently, with each new block mined, a mass of practically useless by-products accumulates.

Moreover, mining is expensive. According to some estimates, the cost of all the electricity used to mine Bitcoin each year is about $500 million. One study even compared the entire energy consumption of Bitcoin mining to the average electricity consumption of Ireland. And that's just Bitcoin - there are a ton of new cryptocurrencies that use some variation of the PoW algorithm.

In addition, the mining process usually uses advanced and expensive proprietary equipment. As a result, miners are buying this equipment en masse, which, in turn, has led to active development by manufacturers of the most advanced specialized hardware for mining. Take, for example, application-specific integrated circuits (ASICs), highly specialized hardware specifically designed for mining Bitcoin and other cryptocurrencies. While ASICs greatly improve the efficiency of the mining process, the unique nature of such niche hardware makes them quite expensive. ASIC development is now largely concentrated in China, a country where electricity is also relatively cheap. Since Chinese ASIC manufacturers are heavily incentivized to simply mine Bitcoin for themselves - and indeed do so - this has led to an estimated 60-70% of all Bitcoin hashing power being concentrated in this single country.

Consequently, the problem of excessive centralization of power arises - which contradicts the fundamental principles of blockchain. There is little to prevent such closely adjacent miners from colluding to control a significant and influential share of the blockchain's computing power, which means they can then sneakily write data that deviates from the truth onto the blockchain. If we return to the analogy with the Byzantine generals, then this will be tantamount to a conspiracy among some of the generals.

DPOS – Delegated Proof Of Stake

Delegated share ownership is another type of Proof of Stake, but it is fundamentally different. Network participants (nodes) choose through voting the nodes that will validate blocks. The more coins there are in one node, the more weight its vote has. Let’s say that out of 100 nodes, 21 stakeholders will be randomly selected each time.

A model of digital democracy that works many times faster than other consensus algorithms. Thanks to this, the throughput of the blockchain increases significantly.

The first coin based on this algorithm was BitShares, and the most popular was the EOS project.

Cryptocurrencies:

  • TRON
  • Cardano
  • Tezos
  • Lisk

Protocols gaining popularity

Delegated Proof-of-Stake (DPoS)

This algorithm is very similar to PoS, but users with more coins can vote and elect representatives (other users they trust) to verify transactions, and leading representatives (those with the most votes) get the right to verify transactions.

Users can even delegate their voting power to other users they trust so that they can vote for other members of the community on their behalf.

Leased Proof of Stake (LPoS)

Leased Proof of Stake is an improved version of the Proof of Stake (PoS) algorithm. Traditionally, in the Proof of Stake algorithm, each node holds a certain amount of cryptocurrency and can add the next block to the blockchain. However, with Leased Proof of Stake, users can lease their coins to users holding full nodes.


LPoS operating principle

The higher the node's value (including coins borrowed), the greater the chance that a full node will be chosen to create the next block. If a node is selected, the user will receive a percentage of the transaction fees that node collects. The protocol allows you to make money on mining activities without conducting the mining itself.

Proof of Elapsed Time (PoET)

Proof of time spent is a mechanism that prevents high resource utilization and high energy consumption. The concept was invented in early 2016 by Intel.

Each participating node in the network must wait a randomly selected amount of time, and the first one to complete the assigned wait time finds a new block.

Each node in the blockchain generates a random timeout and goes into sleep mode for a specified amount of time. The one who “wakes up” first is the participant with the shortest waiting time. It “wakes up” and includes a new block in the chain, transmitting the necessary information to the entire peer-to-peer network. The same process is then repeated to discover the next block.

Simplified Byzantine Fault Tolerance (SBFT)

In SBFT, one designated block generator collects and validates proposed transactions, periodically merging them into a new block. Consensus is provided by the Generator, which applies the rules (checks) agreed upon by the nodes (chain cores) to the block and the designated subscriber of the block. Other (multiple) designated block subscribers ratify the proposed block with their signatures.

All members of the network know the IDs of the block signers and only accept blocks if they are signed by a sufficient number of signers.

Delegated Byzantine Fault Tolerance (DBFT)

DBFT is called a Delegated Byzantine Fault Tolerant Consensus Mechanism that enables large-scale participation in consensus through proxy voting. The owner of the token, by voting, can choose the accountant he supports.

A selected group of accountants, through the BFT algorithm, reaches consensus and generates new blocks.

Directed Acyclic Graphs (DAG)

DAG does not have a Blockchain data structure and is capable of processing transactions asynchronously.

Proof of Activity (POA)

Proof of activity. It is a hybrid approach that combines two other commonly used algorithms, namely proof of work (POW) and proof of stake (POS).

In POA, the mining process begins as a standard POW process with different miners trying to beat each other to finding a solution to a new block using higher computing power. When a new block is detected, the system switches to the POS with the new block found, containing only the header and the miner's reward address.

Proof of Importance (Pol)

Proof of importance is the mechanism that is used to determine which network participants (nodes) have the right to add a block to the blockchain. This process is known as block collection. In exchange for collecting blocks, nodes can charge fees for transactions in that block.

Accounts with a higher importance score will have a higher probability of being selected for block harvesting.

Proof of Capacity (PoC)

Proof of Capacity (POC) is a consistency algorithm used in the blockchain and allows mining hardware to use the network's available hard drive space to determine mining privileges instead of using the device's processing power.

Proof of Burn (PoB)

Burn proof. The protocol works on the principle of allowing miners to burn or destroy virtual currency tokens, which gives them the right to write blocks in proportion to the coins burned.

Proof of Weight (PoWeight)

Proof of weight (PoWeight) is a model of the consensus algorithm of each user and determines his weight depending on the number of coins he owns. The more coins the better. This algorithm is highly scalable and energy efficient, which are its strengths.

PoWeight guarantees that the majority of users will agree with the decision made. However, the big disadvantage of this algorithm is the system for receiving block rewards - it is quite complex.

PoC – Proof of Capacity

Proof of participation occurs through various values ​​other than computing power. For example, Filecoin rewards participants who store more data more often. Chia coin uses a similar consensus which is known as HDD mining.

Cryptocurrencies:

  • Filecoin
  • Chai coin
  • Algorand
  • Digital Ocean
  • Burstcoin

A few words about nodes and blockchain design

Blockchain technology combines several types of messages:

  1. Transactions. Financial transactions (transactions) are the product of the users themselves. In this case, they do not need the blockchain consensus algorithm - after all, in order to transfer a certain amount of coins (coins) to someone, no compromise is necessary. For this operation, it is enough to know the private key.
  2. Blocks. With this component of the distribution structure, everything is exactly the opposite. The block itself is already a product of the consensus protocol, which determines the order of financial transactions in the “ledger” of all transactions.

This algorithm of actions is necessary to level out repeated operations with the same coin. For example, a certain citizen wants to send 1 Bitcoin (BTC) to two other participants in the ecosystem, and therefore launches two payments over the network. In the case where two recipients do not have an agreed upon history of financial transactions, they both receive this payment, since the transaction has an EDS (electronic digital signature) and the sender actually had this amount of cyber money before the payment was executed. After the “ledger” of financial transactions has been agreed upon, only one payment will become valid.

Consensus nodes are blocks generated by a separate category of nodes - “gold miners” or miners, who are rewarded with BTC during the “mining” process. This group is actively involved in the formation of a distribution network (blockchain), daily collecting financial transactions into blocks with their further distribution throughout the ecosystem. In addition to miners, there are several other types of nodes:

  • Audit nodes that are not involved in the trade-off discussion, but have the entire transaction history, to constantly audit the activities of miners and distribute the load across the digital construct, acting as couriers delivering content for the blockchain data (CDN).
  • Light nodes (cryptocurrency wallets) that do not have the entire history of financial transactions, but have the necessary data so that the client can carry out the necessary transactions.

Fact! As of the first quarter of 2022, there were 7,025 nodes on the Bitcoin blockchain with a complete history of financial transactions. The vast majority are audit nodes. Several dozen are miners. It is interesting that during the same period the number of users of the ecosystem exceeded 13 million people. This suggests that an ordinary network participant does not need to download the entire history of the blockchain; it is enough to have a private key with which the electronic payment is signed.

BFT algorithm

They use Hyperledger, Stellar, Dispatch, and Ripple.

Practical Byzantine Generals Problem (PBFT): One of the first solutions to this problem was developed by this algorithm. It is currently used by Hyperledger Fabric. It is high transaction throughput, but centralized.

Federated Byzantine Agreement (FBA): Another solution to the Byzantine generals problem used by Stellar and Ripple. The general idea is that each general, responsible for his own chain, sorts messages to determine the truth. In Ripple, generals (validators) are pre-selected by the founders of Ripple. In Stellar, anyone can be a validator, so you choose which validators you trust.

This gives high throughput, low transaction costs and scalability.

Where is the best place to buy cryptocurrency? TOP 5 exchanges

For a safe and convenient purchase of cryptocurrencies with a minimum commission, we have prepared a rating of the most reliable and popular cryptocurrency exchanges that support deposits and withdrawals of funds in rubles, hryvnias, dollars and euros .

The reliability of the site is primarily determined by the trading volume and the number of users. By all key metrics, the largest cryptocurrency exchange in the world is Binance. Binance is also the most popular crypto exchange in Russia and the CIS, since it has the largest cash turnover and supports transfers in rubles from Visa/MasterCard and payment systems QIWI, Advcash, Payeer .

Especially for beginners, we have prepared a detailed guide: How to buy Bitcoin on a crypto exchange for rubles?

Rating of cryptocurrency exchanges:

#Exchange:Website:Grade:
1Binance (Editor's Choice)https://binance.com9.7
2Huobihttps://huobi.com7.4
3Exmohttps://exmo.me6.9
4OKExhttps://okex.com6.5
5Bybithttps://bybit.com6.3

The criteria by which the rating is given in our rating of crypto exchanges:

  • Reliability of operation
    - stable access to all functions of the platform, including uninterrupted trading, deposits and withdrawals of funds, as well as the period of operation on the market and daily trading volume.
  • Commissions – the amount of commission for trading operations within the platform and withdrawal of assets.
  • Additional features and services - futures, options, staking, NFT marketplace.
  • Reviews and support – we analyze user reviews and the quality of technical support.
  • Interface convenience – we evaluate the functionality and intuitiveness of the interface, possible errors and failures when working with the exchange.
  • The final score is the average number of points for all indicators, determines the place in the ranking.
Rating
( 1 rating, average 5 out of 5 )
Did you like the article? Share with friends:
For any suggestions regarding the site: [email protected]
Для любых предложений по сайту: [email protected]