hyperledger fabric

blockchain framework implementation hosted by the Linux Foundation
a “blockchain platform for the enterprise”.
open source and modular - allowing different modules to be used, plug and play style.
this enables a wide variety of enterprise requirements.
designed to provide speed and scalability
lacking in public chains due to proof of work requirement (essentially nonce mining)
ideal for building a permissioned, private blockchain business network.
private means not publicly open for everyone to run a peer or transact on the network.
permissioned means enterprises can implement access control as per their own requirements.
the permission issuer issues or revokes permissions for all participants and infrastructure components of the network.
this permission or access control in Fabric is based on X509 PKI infrastructure
which means there is a trusted certificate authority that issues certificates to all participants.
smart contracts hold logic that defines who can change what on the ledger.
and participants write transactions on the ledger by invoking smart contracts.
image.png

network concepts

multiple organizations can form a network.
in order for other organizations to validate transactions by each other,
they need to be set up by having trusted root certificate authorities pre-configured on them
in something called an MSP (Membership Service Provider).
each organization can have its own membership services provider
which will issue and revoke identities for users and peers of that organization.
this membership service provider can be a certificate authority hierarchy or a single root certificate authority.

channels

each peer can join one or more channels.
if there are some special transactions that need to be shared only by org1 and org2
and they don’t want any peer from org3 to read it, both the organizations can join a separate channel
and be present on the main channel as well.
this provides privacy that does not exist in public blockchains.
internally a separate ledger is maintained on each peer for each channel that it is on.

ledger

a ledger is essentially two things:
timestamped transactions organized in blocks and stored.
a State Database (an instance of Apache CouchDB) which is the computed outcome of all transactions executed in order.
each peer maintains a ledger.
the current state is pre-calculated and stored on each peer.
it helps make querying the blockchain faster, as the state is pre-calculated.
the state database contains the final state of the ledger after applying all transactions recorded in blockchain (like cache).
the peers communicate with each other to ensure their final state is the same at all times using the gossip protocol.

chaincode

business rules coded to store data onto the ledger
logic on what, how, when, and by whom things can be written on ledger.
the chaincode can make sure an account holder has enough balance
before he transfers an amount to another account, for example
gives developers an easier programming model to work with.
developers writing chaincode do not need to write transactions directly on blockchain,
but rather, write to state in state database (the required transactions are generated under the hood)

ordering service

distributed (solo in dev mode) service
responsible for organizing endorsed transactions into sequenced blocks and distributing to all peers.
service is run on multiple nodes.
typically each org will have at least one node of ordering service
to ensure they are a part of the end to end transaction processing.

transaction processing

high-level steps being carried out when a transaction needs to be applied to the ledger
Client App prepares transaction signed by the user.
Client App connects to endorsing peers (as per endorsement policy)
to collected signed endorsements on the transaction output.
peers simulate transaction and return a signed endorsement.
Client App submits endorsed transaction to ordering service, which puts it into a valid block and distributes to all peers.
image.png

development components

basic end-to-end development flow
configure dev network
image.png
write and deploychaincodeon dev network
image.png
write application code that can invoke chaincode transactions on dev network.
image.png
image.png

deploying network

typically network architect and network operator will deploy a network
which will be distributed on multiple machines that are connected.
for development purposes we can launch a simple network on our local machine to test code on it.
deploy basic network on local machine
write chaincode.
deploy chaincode on basic network
write application code that invokes chaincode deployed.

docker

Hyperledger Fabric forms a distributed network and in order to run on a single machine,
we use docker containers to run individual distributed components.
each component runs in a separate container instance and connects to other containers to form a network.
a docker container image is a lightweight, standalone, executable package of software
it includes everything needed to run an application: code, runtime, system tools, system libraries and settings.
for development purposes we will run a small network on our machine in docker containers.
this network configuration is called basic-network and is provided in the official hyperledger fabric-samples repo

components of a basic network

peer

peer container → runs the peer node
couch db container → stores the state database of peer node

orderer

orderer container → solo orderer node to keep dev environment simple.
in a real-world network the ordering service is distributed with multiple nodes communicating with each other.

certificate authority

fabric-ca container → root certificate authority for issuing membership certificates to all nodes and users.
since we will use single CA, our network is comprised of a single org called “example dot com”.

tooling

fabric-cli container → this container has some cli tools that help us interact with network nodes to deploy chaincode etc.
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.