Blockchain is a peer-to-peer network of nodes, who are engaged in transactions, without any controlling elements. Mobile devices, web apps or even smart IoT devices can be designated nodes, in the network having credentials to initiate and execute transactions.
A shared, Permissioned ledger is a immutable, irreversible and append-only system of records and serves as a single source of facts. The ledger contains the current world state of the network and a chain of transaction invocations.
The membership service provider (MSP) manages identity and Permissioned access for clients and peers, while ensuring privacy of users. It defines the rules in which identities are validated, authenticated and granted permission to the blockchain. It maintains digital identities of users, who are designated to join the network. It offers necessary permissions for users to create transaction. It interfaces with certificate authority that verifies user digital identities. In a consortium network, where multiple organizations are part of blockchain network. The blockchain can incorporate multiple MSPs.
The Smart Contracts (chaincodes) are programs which contain business logic and asset definitions for automating transactions, around assets. Invoking transaction results in changes to the ledger.
The world state reflects the current data about all the assets in the network. This data is stored in a database for efficient access, e.g. CouchDB.
Channels are programmable data privacy mechanisms that allow transaction visibility for defined set of stakeholders of the ecosystem. Each channel is an independent chain of transaction blocks containing transactions only for that particular channel.
Stake holders and Roles
There are few stakeholders/ actors in blockchain system, which have designated roles, to be performed in the blockchain system.
Users are the ones which initiate transactions. Users are applications that act on behalf of a person or device (through smart contracts), to propose transactions on the network.
Each peer maintain copy of ledger, along with the state of the network. There are two types of peers: Endorsing peers and Committing peers. However, there is an overlap between endorsing and committing peers, in that endorsing peers are a special kind of committing peers. All peers commit blocks to the distributed ledger. Endorserssimulate and endorse transactions. Committersverify endorsements and validate transaction results, prior to committing transactions to the blockchain.
Consensus mechanism (Ordering Services) accepts endorsed transactions, orders them into a block and delivers the blocks to the committing peers. In a blockchain system consensus is the process of reaching agreement on the next set of transactions to be added to the ledger.
Services and Processes
It starts with network discovery process. Where in, a user acquires blockchain IP and logs into blockchain network through API. His credentials and identity are validated, by membership service provider, in accordance with user profiles deployed by Certificate Authority (CA). After handshaking with network, the user discovers designated endorsing peers, committing peers and ordering services. The ledger is synchronized with peers, having most recent world state. User then initiates a transaction through web/ mobile app. The transaction can be a standard transaction involving transfer of asset to another user in the network or it can be a part of smart contract, where transaction automatically completes upon triggering the conditions, specified in smart contract.
The transaction is sent to endorsing peers. Endorsing peer then simulates the transaction of user, as if transaction were executed. But without updating the ledger, it adds RW sets with transactions, signs and send back to user. Different endorsement policies can be specified for different smart contracts, at the time of deployment. Endorsement policies can also be channel specific.
The user then submits the endorsed transaction and the RW sets to the consensus mechanism. In this mechanism, consensus happens for all the users, who have submitted endorsed transactions & RW sets. It delivers blocks, containing data of the endorsed transactions & RW sets, to all committing peers. The blocks would have time stamps and they would be added to blockchain in the sequence of block generation time. This platform will have choice of consensus mechanisms, which can be selected and plugged, as per requirement of use cases.
Committing peers are responsible for adding blocks of transactions to the shared ledger and updating the world state. For transactions to get committed to the blockchain, their RW set should match most recent world state. Then only, the committing peer will append the blockchain with this transaction and the world state is updated. In case if RW set doesn’t match the world state, transaction will be still added in block, but it will be marked invalid and they would notify user about the failure of the transaction.
If the transaction fails, that is, if the committing peer finds that the RW set does not match the current world state, the transaction ordered into a block will still be included in that block, but it will be marked as invalid and the world state will not be updated.