concept ledger in category hyperledger

appears as: ledger, ledger, ledgers, ledgers, The ledger
Programming Hyperledger Fabric: Creating Permissioned Blockchains

This is an excerpt from Manning's book Programming Hyperledger Fabric: Creating Permissioned Blockchains.

Append-only means data once written cannot be erased. It is immutable. Once Alice sends money to Bob, and the transaction is recorded onto the ledger, it cannot be undone. It stays there permanently. Note that the transaction cannot be undone but its effect can be undone by performing the reverse transaction i.e., Bob sending money back to Alice. That is okay. But records cannot be deleted. That is what we mean by append-only.

In this section we explain how Fabric works with a worked out example. The basic idea behind Fabric is this: a bunch of companies come together to transact business and document transactions in a ledger or database. Each company has their own ledger but will enter a record into it only when its signed-off by all the stakeholders defined in an endorsement policy. This ensures everyone always remains on the same page. That is all there is to Fabric. Really.

Let’s see how a Fabric blockchain can be used by a group of banks to facilitate monetary transactions. The first step is for the banks to come together to form a consortium. The banks will be known as peers or peer organizations of the consortium. Each bank will spin up one or more peer nodes (i.e., machines or computers) which will store their respective copy of the ledger (or blockchain if you will). Each bank will also have their users which are the bank’s customers. The peer nodes will be running application code to process requests coming in from users and generating transactions in response to those requests. Recall we use the term transaction to mean the record that gets written to the ledger. Fabric refers to the application code as chaincode although with version 1.4 it has given in and started to also refer to it as smart contract which is a term that has caught on and popularized by Ethereum originally. The chaincode will be developed jointly by all the banks and all peer nodes will run exact same copy of the chaincode. 15

The transaction will be committed to the ledger when all checks have passed.19 During the commit phase, the smart contract is not executed again. It doesn’t have to. The peer nodes already know what would happen if the smart contract were to be executed. That is nothing but the writeset. Using induction it follows that once we start off with identical ledgers, they will continue to remain in sync. There will be no fights between the banks. Fabric allows for a configurable endorsement policy ranging from all participants must sign-off - this is most strict and will provide maximum security against a hacked ledger on some peer node - to at least one participant must sign (strongly discouraged). A middle ground is that a majority of the participants should sign-off. Using the strictest form of the endorsement policy will run into scalability issues as more and more participants join the network. This propose, collect votes, commit flow is illustrated in Figure 1. 3 and is very much how proposals are accepted or rejected in a board meeting if you have been to one. One important difference is that in case of human actors, people don’t run the same code inside their heads i.e., they can react differently to the same proposal but in case of Fabric all peer nodes run identical code and have to respond the same way to the same input.

CH01 F05 Jain

Figure 1. 3. Lifecycle of a Fabric transaction or equivalently the peer chaincode invoke command. Step 1, user submits a proposal using a client app. Step 2, proposal is evaluated by each of the peer nodes independently. Step 3, peer nodes send back endorsed responses to the client together with readwrite sets. Step 4, client application packages endorsements into a transaction, digitally signs it and submits it to the orderer. Step 5, orderer is a pubsub service that performs an atomic broadcast and establishes an unambiguous order on transactions. Step 6, peer nodes can poll the orderer for new blocks or get notified via an event; they dequeue new blocks, validate transactions and commit them to their copy of the blockchain. Step 7, client application can register with a peer node to be notified when its transaction is committed to the ledger. Figure adapted from medium.com/coinmonks/demystifying-hyperledger-fabric-1-3-fabric-architecture-a2fdb587f6cb