If you are new to hyperledger Fabric, read our previous blogs on hyperledger fabric.
In this blog, let us look how an actual transaction is done in fabric. It would be easy to understand it as a working example. In fabric architecture, every node will have a corresponding ‘Peer’ in the network.
Consider two clients ‘A’ and ‘B’ engaging in a transaction.
Here, ‘A’ trying to send a request to ‘B’, so the client application of ‘A’ will construct a transaction proposal using an available API.
A transaction proposal is nothing but a request to invoke a chaincode function, which is responsible for performing a proposed transaction in a ledger. Every proposal attach a unique signature for that particular transaction before sending the proposal to endorsers. A transaction must satisfy a set of endorsement policies before it is added to the ledger
Now let us see the steps involved in the transaction.
- After constructing transaction proposal in a correct format, client app sends this to all endorsers. Let Peer ‘ A’ and Peer ‘B’ be the endorsers.
- The endorsing peers A and B on receiving the transaction proposal will verify the following:
a. Check whether the transaction proposal is well-formed.
b. Verify that the proposal is not submitted earlier.
c. Check whether the signature attached to the proposal is valid.
d. Check whether the submitter (here Client A) is authenticated to perform the proposed transaction.
- If it follows conditions, then the endorsing peers will invoke the specified functions of chaincode and perform it against the current state of the ledger.
- But the result of this transaction is not updated to the ledger at this stage, instead, it is sent back to the client app of ‘A’ as ‘proposal response’.
- An endorser signature is attached with proposal response. This is to inform that who endorsed that transaction.
- On receiving proposal response, the client app analyzes the following :
a.Check whether the response from all endorser are received
This is accomplished by checking the endorser signatures of each response.
b.Check whether the endorsement policy is fulfilled
c.Check whether the response from all endorsers is same
- If all the conditions are satisfied, then the client app submit the transaction to ordering service to update the ledger.
- The ordering service doesn’t inspect transaction, instead, it simply receives transactions from all channels in the network, orders them and creates blocks of transactions.
- Then the ordering service sends the block to all peers on the channel.
- Each peer appends the block to the Blockchain ledger copy.
- An event is emitted, to notify the client application that the transaction has been immutably appended to the chain