Hyperledger consensus consensus process
The process of consensus-building in Hyperlydger consists of the following two separate processes:
- Ordering of transactions (trade sort)
- Validating transactions (transaction verification)
Logically separating this two process ensures that Hyperledger can apply any consensus module.
The first step in building consensus is to receive transactions from the client side and then order the trades by the ordering service. Ordering service can be implemented in a variety of ways, in the development testing phase can be used to centralized sorting services, but also for different networks to adopt distributed protocols.
In order to achieve the privacy of the transaction, the sorting layer should not see the specific contents of the transaction (the transaction content is not visible), the contents of the transaction can be encrypted or hashed.
The transaction is passed through the interface to the sort service, and then the sorting service sorts the transactions according to the consensus algorithm and configuration policy. To improve efficiency, the sequencing service packs multiple transactions into one block and then outputs, ordering services that need to guarantee the order of intra-block transactions.
In order to verify the correctness of the transaction, the establishment of consensus relies on the intelligent contract layer, and the intelligent contract layer defines the business logic to confirm how the transaction is valid. The smart contract layer confirms that each transaction is valid according to a specific strategy and agreement. The invalid trade fair was rejected and removed from the block.
Potential checksum failures are divided into the following two types: syntax error, logic error.
Syntax errors include the following types, such as invalid input, unverified signatures, duplicate transactions, and so on, which should be discarded.
The second type of error is more complex and requires a specific strategy to feel how to handle it. For example, a trading experience is a multiple payment. We need to record whether this type of transaction has been validated as a policy requirement.
The consensus layer communicates with the client or other nodes through the communication layer.
Consensus properties
Consensus must follow the following two attributes: Security (Safety) and activity (liveness).
- Security refers to ensuring that each node has the same input sequence and produces the same output on each node. When a node receives a set of transactions, the state changes on each node should be the same. The algorithm needs to be implemented on a node where transactions are processed atomically, that is, only one transaction can be processed at a time.
- Active, each node in the network must receive a transaction for each commit, unless the node is faulty.
The consensus in Hyperledger frameworks
Because the demand for the business district block chain is diverse, a different consensus mechanism is needed. Hyperledger works on a variety of different consensus mechanisms and is modular.
The above table compares the consensus algorithms used in Hyperledger.
The consensus in Hyperledger Fabric
The consensus-building process in fabric is broken down into the following three steps:
- Endorsement, network-participatory endorse a deal
- Ordering, receive endorse transactions, sort them, and pack them into blocks
- Validation, receive a sorted block, verify the correctness of the trading results, including checking the endorsement strategy, two payments and other issues.
The three phases of fabric consensus support are configurable, enabling users to implement their own endorsement, ordering, and validation processes. In addition, the ordering service also supports the configuration of the consensus algorithm based on Byzantine fault tolerance. The ordering Service API consists of two basic actions: broadcast, transmission.
- Broadcast: The client invokes the interface to broadcast any message, and when a request is sent to a service, the BFT part is also called the request.
- The Deliver:ordering service invokes the interface used to send messages with a specific message sequence value and Prehash worth. Or, this is an output event that is used from a sort service. Deliver () is sometimes referred to as notify () in a broadcast-subscription system and is called a commit () in the BFT system.
Multiple sequencing components are under development, including BFT Smart, simplified Byzantine Fault tolerance (SBFT), Honey Badger of BFT, and more. In Fabric v1, Apache Kafka is provided as an out-of-package reference implementation. Users decide which component to use based on the usage scenario and the fault tolerance model.
The consensus in Hyperledger Indy
The consensus in Hyperledger Indy was based on redundant Byzantine Fault tolerance (RBFT), RBFT was developed by Plenum Byzantine Fault tolerance (Plenum), RBFT can be imagined as a parallel implementation of several plenum instances.
Ordered request messages sent to master by a single entity are used to update ledger, but the performance of master (throughput, latency, and so on) is periodically compared to the average of other entities. If master performance is found to be low, view changes occur and different instances are assigned to the role of master.
Like PBFT, RBFT requires at least \ (3f+1\) nodes to process \ (f\) error nodes. Shows a network of 4 nodes that can handle 1 error nodes. Each of these nodes can run a primary (leader) instance.
Figure 4 shows a RBFT structure view that the client sends a request to the node in the network. It is not necessary to send a message to all nodes, because sending \ (f+1\) is sufficient. After the node receives the client's request, it propagates the message so that the other nodes know the request message. Each primary node creates a proposal (Pre-prepare) after it receives the request, and then sends it to all other nodes. If the other node receives the pre-prepare of the master node, a PREPARE message is returned. Once the node receives the Pre-prepare message and \ (2f\) prepare message, the node has enough information to receive proposal and send a commit message. Once a node receives a \ (2f+1\) commit message, the batch request can be sorted and added to the ledger.
Hyperledger Indy uses RNFT to handle ordering and validation, enabling a simple ledger to be sorted and validated simultaneously. This is different from many other blockchain networks, and many just use the BFT protocol to ordering. These networks will leave the validation until the request is sorted.
RBFT uses state to describe the ledger, and all valid, received requests can change the state of the ledger. Ledger status is a combination of variables and their values that are stored in the database. The structure of the Merkle Patricia Tree is encrypted and stored in the database (Merkle Patricia Tree is implemented in Ethereum). Hyperledger Indy Stores Decentralized identifers (DIDs) as a state in which the state includes the authentication key and other things. The replication and status changes in the in-Memory ledger transactions are updated during the proposal process, and the primary node updates the state after the proposal is issued, and the non-master node updates the status when the acknowledgement proposal is received. When proposal gets sort verification, the status change of the ledger is confirmed. If, for some reason, the proposal fails, the state changes that occur in particular will be restored.
The consensus in Hyperledger Iroha
The BFT algorithm called Sumeragi is introduced in Hyperledger Iroha, which can be fault-tolerant \ (f\) error nodes, which are presented in the following paper.
Bchain:byzantine Replication with high throughput and Embedded reconfiguration
In B-chain, we consider the concept of global order when validating transactions, and divide the nodes into a and B groups, where a contains \ (2f+1\) nodes, and Group B contains the remaining nodes. Under normal circumstances, it is necessary to confirm that a transaction requires only \ (2f+1\) node signature, so this is the only node that we use \ (2f+1\) in the transaction confirmation. The remaining nodes are used only when the error is confirmed, and the second (2f+1\) node is called the agent trailer. The transaction verification process under normal conditions is as follows:
The client will first commit the transaction to the dominant node, which verifies the transaction and puts it in the queue, and signs the transaction. After that, the node will trade the other \ (2f+1\) authentication nodes of the optical waveguide.
The order of processing nodes is determined by the server reputation system known as Hijiri, and the Hijiri is based on the following three factors to calculate server reliability.
- The time that each server is registered in the Member management system
- Number of transactions processed successfully
- Whether an error has occurred
To detect errors, each server sets a timer when it signs and broadcasts a transaction to the agent's tail node (2f+1 node). If a response is not received within the timer time or an error occurs, the server continues to broadcast the transaction on the next node of the next tail node. The process is as shown.
When a validation node is received and traded, the following steps are done:
-
- Verify that the signature is valid
-
- Verify that the trading content is valid
-
- Temporarily add transactions to the ledger, which includes the update of the global state of the Merkel root
-
- Sign up for the updated Merkel root and the hash of the transaction content
-
- Broadcasting
-
- When synchronization occurs between nodes, the valid portions of the Merkel tree are shared with root.
The consensus in Hyperledger sawtooth
Hyperledger Sawtooth promotes a consensus mechanism that uses both lottery-based and voting-based algorithms. By default, Sawtooth uses a lottery-based algorithm, called poet. In order to achieve a more effective distributed consensus, a good lottery-based algorithm needs to have the following characteristics:
- Fairness, each node should participate in the poll based on the same probability of fairness
- Input, the outcome of the election should be derived from the potential input value
- Validity, there should be a way to build a file that all nodes can verify the results are valid
In the current Hyperledger sawtooth implementation, a tee (Trusted execution Environment) system is built, which guarantees the security and randomness of the electoral process, without the need for power consumption or special hardware to speed up the workload proof algorithm.
Every poet validator requests a random time to wait from a trusted function before claiming leadership. The validator with the shortest wait time to a particular transaction block is implicitly elected the leader. The function "Createtimer" creates a timer for a transaction blocks that's guaranteed to has been created by the TEE. The "Checktimer" function verifes that the timer is created by the TEE and, if it had expired, creates an attestation tha T can is used to verify that validator do, in fact, wait the allotted time before claiming the leadership role.
The poet leader election algorithm meets the criteria for a good lottery algorithm. It randomly distributes leadership election across the entire population of validators with a distribution so is similar To what's provided by and other lottery algorithms. The probability of election is proportional to the resources contributed, where resources was general purpose processors W ITH a TEE. An attestation of execution provides information for verifying the certifcate is created within the TEE and that the Validator waited the allotted time. Further, the low cost of participation increases the likelihood, the population of validators would be large, increasin G The robustness of the consensus algorithm.
The consensus mechanism in Hyperledger