Introduction & Outline
Lesson Plan
- Aim
- Consensus principles
- PoW and PoS
- Learning Objectives
- Understand the principles of consensus
- Two typical consenses mechanisms PoW and PoS
- Assumed Previous Knowledge
- none
Outline
- PoW
- PoS
- Metrics of Consensus
Proof-of-Work
Consensus
Consensus means to reach a common agreement.
Once this decision of consensus is reached, the decision must be communicated to other parties and the system state must be updated.
Consensus can be applied in different settings
When talking about consensus in a distributed environment, two types of nodes generally involved:
- The legitimate nodes, which are the honest nodes
- The malicious nodes, which act maliciously.
The system has to operate properly even if any failure occurs. There are two types of failures occur:
- Crash failure, which occurs if legitimate node cause any failure.
- Byzantine failure, which occurs if malicious node causes any failure.
The main responsibilities of consensus protocol is:
- Maintain the data in the ledger (blockchain) in terms of ordering, originality, and tamper-resistant.
- Reach agreement among the nodes in the blockchain network, i.e., to provide Byzantine agreement, even in the presence of misbehaving nodes.
Some well-known DLTs and the consensus algorithms used
Proof of Work (PoW) Consensus
Proof-of-Work (PoW) is one of the famous consensus algorithms used in blockchain networks.
It is the building block of Bitcoin blockchain and PoWis designed for public blockchain. In PoW, consensusfinality is not guaranteed. It is worth noting that in PoW, the mineracts as both leader and validator node.
PoW Main Idea
The higher the hash rate, the higher the chancesto solve the PoWcryptographic puzzle.
The node that solves the PoWpuzzle will be the winner and thus will be able to add block to the blockchainand deserve the reward.
PoW Nodes
Leader Node
A blockchain node which wins the mining process and receives the mining reward.
In PoW, this winning will be dependent upon solving a cryptographic puzzle.
PoW Winning Probability
i is the participating blockchain node,
N is the total number of nodes,
ϕ is the computation power of ith node.
Example of PoW Consensus Algorithm
Suppose a blockchain network with seven participating nodes (N1, N2, ..., N7), having computing power (hash rate) values (ϕ1, ϕ2, ϕ3, ..., ϕ7). Calculate the probability of wining the puzzle by each participating node? The computation power (hash rates) are ϕ1 = 8, ϕ2 = 4, ϕ3 =5, ϕ4 = 10, ϕ5 = 3, ϕ6 = 1, ϕ7 = 15.
The winning probability Pw of each participating node can be calculated as
The wining probability of participating node N1 can be calculated as
The winning probability of remaining participating nodes can be calculated in the similar manner.
Issues in PoW
- Double spending problem is associated with PoWconsensus algorithm.
- PoWis probabilistic in nature as two or more nodes may solve PoW puzzle simultaneously, which will result in the creation of “fork”.
- PoWhas a long latency issue, i.e., nodes take time to validate transactions.
- PoWis computationally expensive.
Fault-tolerant of PoW
- PoWconsensus is susceptible to 51% attack.
- PoWis fault-tolerant to Byzantine Failure.
- PoWis attack-resistant against Sybil attacks, where malicious blockchain nodes create multiple pseudo identities to launch this attack.
- Difficulty is one parameter which can be used to deal with attacks.
- When the difficulty level is high in the mining process, more computing resources are required to solve the mining puzzles; thus, it will be very hard for the attacker nodes to consume such high resources to continue their malicious activities.
Proof of Stake
PoS Main Idea
- In Proof-of-Stake (PoS) category of consensus protocol, the selection of miners is dependent upon the amount of stakes each node carries instead of its computational power.
- The higher the stake a node has, the higher the chances to select that node as a winning miner node.
PoS Advantages
- Less consumption of energy.
- Lower requirements in terms of nodes' computation power (hardware).
- Faster transaction confirmation speed due to single block generation in each round.
PoS Winner
In PoS consensus, the winner is the one which has a higher stake.
These stakes can be in any form like
- The amount of cryptocurrency a node owns.
- The amount of digital token a node carry.
- The amount of energy a node has.
- The amount of computational power a node has.
Issues in PoS
- The network/blockchain system is subject to dominance by the most significant token holders.
- more token -> high winning probability -> more rewards -> more token
- Issue related to message transmission loss and delay:
- If there is any delay or link connectivity issues, nodes may not have the recent copy of the ledger and thus, results in the synchronization problem.
- Issue related to message communication among the committee members of some PoS variants:
- Without timely sharing of messages among the committee members, the performance of PoS consensus algorithm can be seriously degraded.
- Issue related to reward and incentivization:
- In PoS, reward should be awarded in such a manner that all the nodes get equal opportunity to participate in the mining process.
- Otherwise, a situation will arise when only the mining node which has the higher stake will always get rewarded and always wins the mining process.
Comparison between PoS and PoW
Metrics of Consensus
Metrics
Performance and scalability of IT systems have always been the key non-functional metrics that are used to gauge a blockchain consensus.
- Performance
- Transaction Throughput
- Block Confirmation Time
- Scalability
Transaction Throughput
Transaction throughput is defined as the number of transactions per second a blockchain network can process.
- The basic component of blockchain is Transaction (Tx).
- These transactions are assembled to form a block.
- Different blocks are linked together to form the blockchain.
Transaction throughput is measured in Tx/s, where Tx is the number of transactions and ‘s’ means second. It can be calculated as
where “Block Size” is the size of the block and varies from blockchain to blockchain, and “Block Time” is the time required to add a block to the blockchain –average.
Block Confirmation Time
It is defined as the time to confirm the block and it tells us how quickly a block can be confirmed in a blockchain.
- Depending upon the underlying blockchain, it can further be dependent upon the number of blocks.
- A new block must wait before it is confirmed.
- It can be measured in seconds.
Impact of Tx Throughput and Block Size
The figure shows the impact of block size (MB) over Throughput (Tx/seconds)where we kept transaction size is 500 Bytes and block confirmation time is 10 s.
The figure shows the impact of block confirmation time (seconds) over Throughput (Tx/second). Here, we kept block size is 1MB Bytes and Tx size is 500 Bytes.
This figure shows the impact of transaction size (bytes) over Throughput (Tx/second). Here, we kept block confirmation time is 10 s and block size is 1 MB.
Example
Suppose a blockchain network has a block size of 2 MBytes, transaction size of 500 Bytes, Block generation time is 200 s, and it requires to wait for 10 blocks to confirm any new block. Calculate average block confirmation time and transaction per second (throughput) of this blockchain network?
Scalability
Scalability of blockchain networks is the ability of that platform to support increasing load of transactions, as well as increasing the number of nodes in the network.
Off-chain solutions:
built on top of the main blockchain and handle most of the transactions. (Sidechains, Payment Channels, etc.)