Open In App

What is Sawtooth PBFT in Hyperledger?

The Sawtooth PBFT is a voting-based consensus algorithm with Byzantine fault tolerance (BFT). The article focuses on discussing the Sawtooth PBFT in Hyperledger. The following topics will be discussed here:

  1. What is a Sawtooth PBFT?
  2. What Is PBFT?
  3. What is Primary Node?
  4. Network Overview
  5. How Does PBFT Work?
  6. Pros of Sawtooth PBFT
  7. Cons of Sawtooth PBFT

Let’s start discussing each of these topics in detail.



What is Sawtooth PBFT? 

Sawtooth PBFT (Practical Byzantine Fault Tolerance) is a voting-based consensus algorithm used in the Hyperledger Sawtooth blockchain platform. PBFT is a type of distributed consensus algorithm that allows a network of nodes to reach an agreement on the state of a distributed ledger, without the need for a trusted third party.

PBFT is considered a “Byzantine fault tolerant” algorithm because it is able to tolerate failures or malicious behavior by some nodes in the network without compromising the integrity of the ledger.



Sawtooth PBFT is a variant of the PBFT algorithm that is specifically designed for use with the Hyperledger Sawtooth platform. It incorporates features from the Sawtooth platform, such as the use of cryptographic “leaves” to represent transactions and the ability to support multiple transaction families (i.e., different types of transactions) on the same ledger.

What is PBFT?

PBFT is Practical Byzantine Fault Tolerance a consensus algorithm that is designed to work in practical, asynchronous environments. 

In PBFT as long as a minimum number of nodes are working properly, and connected to the network then the network will make progress and will not allow any node on the network to manipulate the network.

What is a Primary Node?

The nodes on the Sawtooth PBFT network send many messages to reach consensus, commit blocks, and maintain a healthy leader node called a primary node. 

Network Overview

1. Fault Tolerance: In a Practical Byzantine Fault Tolerance (PBFT) network, a series of nodes are ordered from 0 to n-1, where n is the total number of nodes in the network. The PBFT network can only tolerate up to a certain number of “bad” nodes, referred to as the constant f, which is equal to one-third of the total number of nodes in the network. This means that no more than a third of the network (rounded down) can be dishonest or out of order for the algorithm to work properly.

f = (n – 1) / 3 

Here,

n = Total number of nodes in network.
f = Maximum number of faulty nodes.

2. View Changes: This means choosing a new primary node. As the network operates, the nodes move through a series of “views,” where each view represents a period of time in which a given node is the primary leader of the network. In this way, each node takes turns being the primary in a continuous cycle, starting with the first node. 

Example:

In a four-node network,

node 0: primary at view 0
node 1: primary at view 1, and so on. 

When the network reaches view 4, it will “wrap back around” so that node 0 is the primary again.

The PBFT algorithm determines the primary node for each view based on the view number and the ordering of the nodes, using the formula:

p = v mod n

The Sawtooth PBFT changes the primary node at regular intervals or when the secondary nodes determine that the current primary node is faulty.

3. Sequence numbers: In Sawtooth PBFT, the sequence number is equivalent to the block number. For example, a node is on sequence number 5 is equivalent to saying that the node is performing consensus on block 5 in the chain.

4. Information Storage: Each node on the network maintains the following pieces of information:

5. Network Configuration: Sawtooth PBFT configures the network with on-chain settings which list each node in the network, set the view-change interval, and specify items like timeout periods, block publishing frequency, and message log size. 

Message Types 

Below are the different types of Sawtooth PBFT messages:

Message Type Description
PrePrepare This message is sent by the primary node after it has published a new block.
Prepare This message is broadcasted by every node in the Preparing phase.
Commit This message is broadcasted by every node in the Committing phase.
ViewChange This message is sent by any secondary node that suspects that the primary node is faulty.
NewView This message is sent by the node that will be the new primary node to complete a view change.
Seal This message proves that a block was committed after 2f + 1 node agreed to commit it.
SealRequest This message is sent by a node that is requesting a consensus seal for the block that was committed at a given sequence number.

How Does PBFT Work?

The Sawtooth PBFT starts with the Initialization phase and then operates in two modes, Normal mode and View Changing mode.

1. PrePreparing Phase: All nodes begin in prepreparing phase and the purpose of this phase is for the primary node to publish a new block and endorse the block with the preprepare message. 

2. Preparing Phase: In the prepare phase, the secondary nodes broadcast a Prepare message that matches the accepted PrePrepare message. Each node will add its own Prepare message to its log, accept Prepare messages from other nodes and add them to its log. Once the node has 2f +1 Prepare messages that match with the accepted PrePrepare message it has received, then it will move to the committing phase.

3. Committing Phase: In this phase, the primary node is also allowed to broadcast a message. Here, the nodes will broadcast a commit message to all nodes in the network and wait until there are 2f +1 commit messages in their logs and move on to the finishing phase. 

4. Finishing Phase: In this phase, each node will tell its validator to commit the block for which they have matching PrePrepare message, 2f + 1 Prepare message, and 2f + 1 Commit messages. The node will wait for the BlockCommit message from the validator and upon receiving the message the node will increment the sequence number by 1, Update the current chain head to the newly added block, and reset its phase to PrePreparing phase.

 

Log Pruning: When the block is committed, each node compares the size of its log with the maximum log size (–max_log_size) and if the size exceeds then Sawtooth PBFT follows these rules to prune the log:

View Changing mode: View changing is a mechanism that is used in PBFT (Practical Byzantine Fault Tolerance) consensus algorithms to handle situations where the primary node is unable to fulfill its duties. In a PBFT system, the primary node is responsible for receiving client requests, broadcasting them to the other nodes in the network, and executing requests that have been agreed upon by a sufficient number of nodes. However, if the primary node becomes unavailable or unable to fulfill its duties, the other nodes in the network must take action to ensure that the system can continue to operate and reach a consensus. This is where view-changing comes into play. A node starts a view change process if any of the following situations occur:

View changing is a process by which the nodes in the network can select a new primary node to take over the duties of the old primary node. This typically involves a voting process, in which the nodes in the network agree on a new primary node. Once a new primary node has been selected, it can take over the duties of the old primary node and the network can continue to operate normally.

A node will perform the following actions to start a view change:

ViewChanging message are accepted and added to the log if they are for later view than the node’s current view or if the node is in the ViewChanging (v) mode and the view in the message must be greater than or equal to v. 

Once the node has received 2f + 1 ViewChange messages for the new view then it will start view change timeout. This timeout helps to ensure that the new primary node starts the new view in a timely manner.

View change timeout = (DesiredViewNumber  – CurrentViewNumber) * ViewChangeDuration

When the primary node for the new view receives 2f +1 ViewChange messages it will broadcast a NewView message to the network to signify that the new view is valid and it will add 2f + 1 signed ViewChange messages from the other nodes in the NewView message. This will be validated by other nodes on the network.

If a node receives the new primary’s valid NewView message before the view change timeout expires then the node will stop the timeout, update its view, and revert back to normal mode else the node will stop the timeout and initiate the new view change for view v + 1 where v is view the node was attempting to change before. 

Overall, view-changing is a critical mechanism in PBFT systems that ensures that the network can continue to operate and reach consensus, even in the event of a primary node failure.

 

Summary

  1. A client sends a request to the network to perform a specific action, such as transferring funds.
  2. The request is broadcast to all nodes in the network, known as replicas.
  3. Each replica verifies the validity of the request and reaches a consensus on whether to approve or reject it.
  4. Once a consensus is reached, the replicas enter the pre-prepare phase, where they prepare to execute the request.
  5. In the prepare phase, the replicas send messages to each other indicating that they are ready to execute the request.
  6. In the commit phase, the replicas send messages to each other indicating that they have committed to executing the request.
  7. The replicas then execute the request and update their local copies of the ledger to reflect the changes.
  8. Finally, the replicas send messages to each other to confirm that the request has been executed and the ledger has been updated.
  9. The client receives a response from the network indicating the success or failure of the request.

Pros of Sawtooth PBFT

Some of the main advantages of Sawtooth PBFT include:

Overall, Sawtooth PBFT offers a number of benefits over other consensus algorithms, making it a popular choice for distributed ledger systems.

Cons of Sawtooth PBFT

While Sawtooth PBFT (Practical Byzantine Fault Tolerance) offers several benefits over other consensus algorithms, it also has some limitations and drawbacks. Some of the main disadvantages of Sawtooth PBFT include:

Overall, while Sawtooth PBFT offers several advantages over other consensus algorithms, it also has some limitations and drawbacks that must be considered when choosing a consensus algorithm for a distributed ledger system.


Article Tags :