VVictor
VVictor

Reputation: 269

What is the difference between consensus and endorsement in Hyperledger Fabric?

An endorsement is the process where endorsing peers execute a transaction and agree on the result. How is it different from the consensus in Fabric?

Upvotes: 3

Views: 1986

Answers (1)

Trinayan
Trinayan

Reputation: 867

One key difference between Hyperledger Fabric and many other blockchain platforms is the lifecycle of a transaction.

In other platforms, the lifecycle of a transaction is usually Order-execute in which:

Order: transactions are added to the ledger in some order and disseminated to all peers.

Execute: transactions are sequentially executed (e.g. using smart contract code) on all peers.

While in Hyperledger Fabric, the lifecycle of a transaction is different as it is a Execute-order-validate model:

Execute: Transactions are executed (using chaincode) in any order, possibly even in parallel.

Order: When enough peers agree on the results of a transaction, it’s added to the ledger and disseminated to all peers. This step is where the transactions are first given an ordering — until transactions are added to the ledger.

Validate: Each peer validates and applies the ledger’s transactions in sequence. Now that the transactions have an ordering, the peers can check whether a later transaction was invalidated by an earlier transaction. For example, this prevents one item from being sold two times (called double-spending).

Endorsement in Hyperledger Fabric basically allows users to define policies around the execution of chaincode. These endorsement policies define which peers need to agree on the results of a transaction before it can be added to the ledger.

Now let's see how endorsement works:

Fabric starts with a transaction proposal. It’s a bundle of information used to trigger a specific chaincode. The transaction proposal is sent to some peers for endorsement. An endorsing peer executes the chaincode, which (if it succeeds) yields an actual transaction for the ledger. The endorsing peer then signs the transaction and returns it to the proposer. This is the Execute step in execute-order-validate.

Once the creator of the proposal receives enough signatures to satisfy the endorsement policy, it can submit the transaction (and the signatures) to be added to the ledger. This is the Order step.

Consensus or Validation is the last step in which all the peers verify if there are any changes in the world state in between this whole transaction process and then validates only those transactions that are valid and marks other transactions as invalid.

Upvotes: 4

Related Questions