You need an Ethereum wallet to use Bithoven

Connect to one of our available wallet providers or create a new one

Don't have a crypto wallet yet?

How to connect
MetaMask Polygon (MATIC) Ankr (ANKR) DASH (Dash) Solana (SOL) Cosmos (ATOM) Cardano (ADA) Polkadot (DOT) Avalanche (AVAX) Everscale (EVER) PoW and PoS Algorand (ALGO) Metaverse Stablecoins Monero (XMR) Litecoin (LTC) Tron (TRX) DeFi Zcash (ZEC) Введение в ИИ Ethereum (ETH) Tezos (XTZ) Ripple (XRP) Bithoven Guide CBDC Uniswap (UNI) Web3 ИИ The Graph (GRT) Chainlink (LINK) Icon (ICX) BTH-keys CEX and DEX Stellar (XLM) Qtum (QTUM) Sharding Blockchain Bitcoin Compound (COMP) Introduction to Blockchain EVM not EVM network L2E NEAR Protocol (NEAR)
Bithoven company logo
Bithoven company logo
Link successfully copied!
Articles

Introduction to Blockchain: Consensus (Part 4)

Blockchain Consensus

Blockchains are designed for distributed, decentralized networks. Part of this involves the exclusion of a central authority, which is used in many other systems. In the traditional financial system, banks centralize power by maintaining control over the ledger that indicates how much money is stored in each account. If there is a dispute over the ledger, the bank has the final say on which version is official.

Blockchain was designed as a decentralized financial alternative to centralized banks. Instead, a blockchain network maintains a shared decentralized ledger, with each node in the network retaining a copy and updating it as each new block is created.

The challenge is to ensure that all nodes update their ledger copies with the same updates with each block. Since the network has no permanent authority to create an official version of the ledger, it selects temporary authorities to create and share each block. The mechanism for achieving this is called a blockchain consensus algorithm.

Basics of Consensus

The goal of the consensus algorithm is to ensure decentralized management of the blockchain, so that no user has the ability to control the network. The means by which this is achieved is by making control over the blockchain network dependent on control over a scarce resource.

Regardless of which consensus algorithm you choose, it comes down to the control over a scarce resource being equivalent to power in the blockchain. In Proof of Work, this resource is computational power. In Proof of Stake, it is the blockchain's cryptocurrency.

The rationale for using a scarce resource as an analogy for the power of the blockchain is that it enables the use of economic incentives to protect the blockchain. The law of supply and demand states that if there is increased demand for a resource with limited supply, the price increases.

When a malicious actor attempts to gain control of a blockchain network (to execute a 51% attack or something similar), they need to acquire more of the limited resource. As a result, they increase the demand for the resource, which drives up its price. Hopefully, the cost of acquiring enough resources to carry out a successful attack will be higher than the attacker's resources. If not, we have seen successful 51% attacks on small cryptocurrency networks, which have certainly occurred.

How common algorithms implement consensus

When Satoshi Nakamoto created Bitcoin, it was the only existing blockchain. The official Bitcoin document described the Proof of Work consensus algorithm used in the Bitcoin network. Since then, many other consensus algorithms have been developed for different blockchain implementations. Proof of Stake has also received a lot of attention, partly because of its presence on the Ethereum roadmap.

Proof of Work

Proof-of-Work (PoW) is the original consensus algorithm, and as the name suggests, it is based on computational work. In Proof of Work, miners are the ones attempting to create a new block. The method of selecting the creator of the block is a competition between miners, where the winner creates the block (and receives the corresponding rewards).

This computational competition involves creating a valid block, where the condition for validity is that the block header is hashed to a value less than a specified threshold. Due to the properties of hash functions, the best way to achieve this is through random guessing. As a result, miners in the network try random hashes until they stumble upon a nonce that creates the desired hash output. The first miner to find a valid block then broadcasts it to the rest of the network to build the next block on top of it.

The main issue with PoW is that the criterion for creating a block is the ability to create a valid block. It cannot be said that two different miners cannot find different versions of a block at roughly the same time. If this happens, a diverging chain of blocks can be created, where different parts of the network are built on top of different blocks. Blockchain solves this problem by using the rule of the longest chain, which states that in the event of a conflict between two versions of the blockchain, the longer version should be accepted.

PoW also attempts to minimize the likelihood of diverging blockchains by using the concept of difficulty. The threshold value that must be less than the acceptable hash of the block header can be updated in a distributed manner. Difficulty is updated at regular intervals to ensure that block creation (at the current computational power of the blockchain network) occurs at the desired block rate.

Proof of Stake

Proof-Of-Stake (PoS) uses a different approach to secure the blockchain by using a limited resource. Instead of using computational power (like Proof of Work), Proof of Stake uses the cryptocurrency of the blockchain.

Proof of Stake is very similar to investing in a company. By giving a portion of your money to the company, you have the right to receive investor dividends. In PoS, you promise not to spend a portion of your cryptocurrency (or make stakes) in exchange for the opportunity to become a block creator (and earn corresponding rewards).

The mechanism for selecting block creators based on staking depends on the implementation. In some implementations, the probability of being chosen is directly proportional to the size of the user's stake in staking. In others, the concept of coin age is introduced, where stakers who have not been chosen to create a block for a certain period of time have an increased chance of being selected. Nevertheless, controlling a larger share of the cryptocurrency in PoS is equated to increasing control over the blockchain.

Consensus attack

Consensus mechanisms are key to managing a blockchain. As a result, many attacks on a blockchain are focused on gaining this control. If successful, an attacker can execute a double-spending attack, which allows them to complete a transaction and then remove it from the ledger later. Some consensus-based attacks have been known from the beginning (e.g., the 51% attack), while others (e.g., long-range attacks) have been developed later.

Attack 51%

51% attacks are probably the simplest way to attack a Proof of Work blockchain and occur when the economic incentives of the blockchain fail. According to the rule of the longest chain, every honest node is required to choose the longer version when presented with two conflicting versions of the blockchain. If a malicious actor is able to create a longer version at will, then they control the blockchain.

In PoW, this is achieved by controlling half of the computing power of the blockchain network. Since creating valid blocks requires random searching through a space of potential options, whoever can search the space faster can create blocks more quickly. Similar attacks are possible in PoS, but they require a higher level of control over a scarce resource. In PoW, you need 50% of the computing power to have a 100% chance of finding the next block. In PoS, you need 100% of the staked cryptocurrency to have a 100% chance of forging the next block. Since this is unlikely, an attacker attempting to control a Proof of Stake blockchain must resign themselves to the impossibility of realizing this idea.

Next: smart contracts

So far, we have covered consensus. The remaining two articles in this series will focus on the technology built on top of the original blockchain: smart contracts and blockchain extensions.

Read Part 5 - Smart Contracts

You may be interested