Press ESC to close

Understanding Consensus Mechanism in Quorums: Raft vs. IBFT

What happens when you’re signing a contract in real life? Generally, it would help if you had validation from various authorities. Now, switch this scene to another story, a digital world where computers carry out all your transactions. Yeah, you guessed it right, we’re talking about Blockchain technology. In Blockchain, securing agreements between these virtual participants (Consensus) is most important. We have already discussed the Consensus mechanism in Quorum and how it works in our previous web blogs. Quorum is designed specifically for enterprise blockchain to offer reliable solutions. Consensus mechanism in Quorum acts as verification standards to maintain order and trust in the Blockchain network. In this web blog, we will learn about two types of Consensus algorithms. These algorithms are the pillars of the Quorum network: Raft and IBFT.

Raft and IBFT fight for authority in Quorum’s consensus arena. Both of them use their capabilities to strengthen security and transactions within the network. So, join the Blockchainist as we discuss the Inner workings of these mechanisms.

  • Explore their differences 
  • Please find out how they support the security of Quorum’s distributed ledger.
  • Byzantine Generals Problem

Okay, think of a group of generals (some loyal, some not so much) trying to regulate an attack on a town. You cannot trust the communication in this scenario. They are unreliable. You can’t fully trust generals who might lie or send false messages. This is the foundation of the Byzantine General’s Problem (BGP). It’s a game theory problem, a thought experiment that forms the basis for Byzantine Fault Tolerance algorithms. E.g., Istanbul Byzantine Fault Tolerance. IBFT is a powerful tool for consensus even when there are malicious nodes.

Raft Consensus Algorithm

Diego Ongaro and John Ousterhout developed the Raft protocol. It’s a leader-based Consensus mechanism  designed to explore consensus. Unlike other algorithms, where nodes participate equally,  Raft is a solo leader. It singularly manages communication to ensure data consistency and push the data forward.

1. Election Time at Raft

Raft does not have an appointed leader, it’s a role chosen by nodes. When a leader steps down or faces some issues, a new leader is selected by triggering an election. Here is a breakdown of how it works:

A. Candidate Selection

Any follower node can initiate an election by transitioning to the candidate state. A candidate broadcasts a “VoteRequest” message to all other nodes to garner support.

B. Term Lengths

Elections occur within designated terms, preventing endless loops and providing stability. Each “VoteRequest” includes the candidate’s current term number. Nodes only grant their vote to a candidate with the highest term number, ensuring consistency across the network.

C. Heartbeat Message 

The leader plays a crucial role by constantly sending “AppendEntries” messages to followers, containing the leader’s current term and the last committed log entry. These heartbeats replicate data and serve as a health check, indicating the leader’s liveness and preventing unnecessary elections.

2. Log Replication

  • Once the leader shows up, it takes the center seat and replicate the transaction logs. Here is how Raft maintains consistency :
  • Only the server elected as a leader can interact with the client. The leader receives new transactions, gathers them in the local log, and broadcasts the “AppendEntries” message.
  • The follower applies the terms and consistency by verifying them. This ensures that all the nodes maintain identical transaction sequences.
  • Once most followers accept the receipt, the leader forwards them to its local log and informs other nodes about it. This committed state is now final and unalterable.

3. Safety Measures

Raft Prioritizes data integrity and consistency above all else. Several mechanisms ensure the data safety;

i.) Leader Election Ensures Liveness

The election process guarantees that even with leader failures, a new leader will eventually arise. It prevents the network from stalling.

ii.) Term-Based Voting

Term numbers prevent inconsistencies only vote for candidates with the highest number, ensuring all agreements on the leader and the current state of the log.

iii.) Major Commitment

The leader only commits entries after receiving acknowledgment from most followers. This prevents any single node from manipulating the transaction log.

iv.) Appendentries With Previous Log Information

“AppendEntries” messages include the previous log entry’s hash. This ensures followers can detect inconsistencies and reject attempts to insert invalid transactions.

4. Performance Advantages: Speed and Scalability

Raft‘s performance shines, making it ideal for smaller to medium-sized permissioned blockchain networks. Here’s why:

a. Leader-Based Communication

Instead of complex multi-party communication, Raft leverages the leader to broadcast messages and synchronize the network efficiently.

b. Lightweight Heartbeats

Heartbeat messages are small and contain essential information, reducing network overhead compared to more extensive data exchange protocols.

c. Fast Leader Election

The election process is relatively quick, minimizing downtime and ensuring the network can resume normal operations swiftly.

5. Real-World Applications: Raft in Action

Raft‘s efficiency and focus on safety make it a compelling choice for permissioned blockchains where speed and reliable data management are crucial. Here are some real-world applications:

  • Supply Chain Management

 Tracking the movement and ownership of goods across a complex supply chain can benefit from Raft’s efficient consensus and data integrity features.

  • Financial Transactions

Permissioned blockchains utilizing Raft can facilitate faster and more secure financial transactions than traditional methods.

  • Voting Systems

Ensuring the integrity and immutability of votes within a secure voting system aligns perfectly with Raft‘s safety mechanisms.

You need a deep understanding of Raft’s leader-based approach to evaluate the suitability of your Blockchain projects.

IBFT (Inter Bank Funds Transfers)

IBFT follows the idea of transferring funds instantly from one account to another. Unlike Raft, which follows a leader-based approach, IBFT follows a more democratic structure. It was created to handle Byzantine faults. That means it can work even when some nodes are not working correctly. That is why IBFT is a good fit for permissioned Blockchains where security &data integrity are essential.

Reaching Byzantine Agreement

IBFT achieves consensus through a multi-phase dance involving all participating nodes. Here’s a breakdown of the key steps:

Pre-prepare Phase: A node proposing a transaction initiates the process by broadcasting a “pre-prepare” message containing the proposed transaction and its current view number (a counter to track progress).

Prepare Phase: Upon receiving a valid “pre-prepare” message, honest nodes enter the prepare phase. They verify the message’s authenticity and broadcast “prepare” messages to all other nodes, indicating their tentative agreement.

Commit Phase: Once a node receives “prepare” messages from most other nodes for the same transaction and view number, it enters the commit phase. Here, nodes broadcast “commit” messages, signifying their final agreement on the transaction’s inclusion in the Blockchain.

Safety Over Speed

Although IBFT excels in security, it comes at a price. Communication can be slow due to its complex multi-phase nature compared to Raft. IBFT prioritizes safety to ensure data integrity even in the presence of faulty nodes. However, this translates to enhanced latency and potentially lower throughput.

Scalability for secure, smaller networks 

This multi-phase concept ensures that all honest nodes approve the transaction order, even if some nodes hinder the process. Byzantine fault tolerance makes a move by needing plenty of honest nodes to participate in each step. I prevent a small number of malicious nodes from swaying the outcome.

Due to its complex communication flow, IBFT works less efficiently than Raft. The number of messages exchanged during each phase grows as the network size increases. Before making your final decision about which Consensus mechanism to use, deeply understand the Byzantine genre Problem. While IBFT might not seem like the fastest horse in the race, it is reliable.

Choosing The Right Consensus Mechanism in Quorum: Raft Vs. IBFT 

FeatureRaftIBFT
Core PrincipleLeader based communicationByzantine Fault Tolerance (BFT)
Fault ToleranceTolerates node crashes and temporary failuresTolerates Byzantine faults (malicious nodes)
PerformanceFaster, lower latencySlower, higher latency
ScalabilityMore scalable for larger networksLess scalable for very large networks
Ideal Use CasesPermissioned blockchains with moderate sizePermissioned blockchains with high security needs (smaller size)

A Side-by-Side Comparison: Create a table comparing key aspects of Raft and IBFT, including their core principles, fault tolerance, performance, and ideal use cases.

Decision-Making Factors: Guide readers on choosing the appropriate Consensus mechanism in Quorum (Raft or IBFT) based on their specific network requirements (e.g., size, security needs, performance demands).

We thought of making this journey of learning about Blockchain technology more fun. So here are two terms or words of the day for you to remember from this topic.

  • Leader Election: The process by which a Consensus mechanism in Quorum selects a leader node among participants in a distributed system
  • Transaction log: A Transaction Log is a chronological record of all transactions that have occurred within a system or network

Wrapping Up!

The world of Consensus mechanism is continuously evolving. Several emerging protocols, like PBFT (Practical Byzantine Fault Tolerance), balance security and performance. These protocols offer new options for Quorum users in the future.

Quiz For the Readers

Q.1. What does BFT stand for in the context of Consensus mechanism in Quorums?

   A) Blockchain Fault Tolerance

   B) Byzantine Fault Tolerance

   C) Bitcoin Fault Tolerance

   D) Balanced Fault Tolerance

Q.2. What is the primary function of leader election in a Consensus mechanism in Quorum?

 A) Electing a president for the network

  B) Selecting the node with the highest computational power

  C) Choosing a node responsible for coordinating consensus decisions

  D) Assigning roles to different nodes in the Blockchain

3. Which of the following best describes a Transaction Log in blockchain technology?

   A) A log of network errors

   B) A record of all network participants

   C) A record of all transactions in chronological order

   D) A log of cryptographic keys used in the network

Answers

1. B) Byzantine Fault Tolerance

2. C) Choosing a node responsible for coordinating consensus decisions

3. C) A record of all transactions in chronological order

If you want to learn more about Blockchain technology and cryptocurrencies, check out our Blog section. Stay tuned for more such content!