0% found this document useful (0 votes)
17 views

L6 Enterprise Blockchain

Uploaded by

Prateek Verma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

L6 Enterprise Blockchain

Uploaded by

Prateek Verma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 216

Professional Certification Program in

Blockchain
Enterprise Blockchain
Learning Objectives

By the end of this lesson, you will be able to:

Elaborate Enterprise Blockchain and its properties

Identify Hyperledger Sawtooth, Iroha, Indy, Burrow, and


Fabric

List Hyperledger Fabric components, transaction cycle


steps, and network types

Analyze Corda and its network


Enterprise Blockchain
Enterprise Blockchain

Enterprise Blockchain is a permissioned Blockchain that streamlines business processes


extensively, such as the trail of supply chain goods or solving global payments.

Hyperledger Corda
Why Enterprise Blockchain?

Enterprise Blockchain is a permissioned Blockchain which is contrary to Public Blockchain.

Ledger shared across all peers

Anonymity in peers

Features not required by Decentralization


Enterprise Blockchain

Fully transparent

Not scalable
Enterprise Blockchain Features

Enterprise Blockchain has following features:

Accountable

Permissioned Scalable

Pluggable Consensus
Hyperledger
Introduction to Hyperledger

Hyperledger is a global enterprise Blockchain project that provides the architecture, standards,
guidelines, and resources needed to create open source Blockchains and related applications.

Hyperledger
Hyperledger Umbrella Project

Hyperledger Umbrella Project comprises tools, services, and libraries to build Enterprise
Blockchain applications.

Indy

Iroha Burrow

Sawtooth Fabric
Hyperledger Sawtooth
Introduction to Sawtooth

Hyperledger Sawtooth is an open source Blockchain framework to develop enterprise


decentralized applications and networks. This simplifies the process of development and
deployment by isolating the core system from the application domain.
Advantages of Sawtooth

Is easily developed and


Is scalable
deployed

Maintains distributed
Keeps smart contract safe
nature of Blockchain
Sawtooth Features

Parallel Multi
transaction language
support support

Sawtooth

Plug and
Play Seth
Consensus
Sawtooth Architecture

Sawtooth architecture has


five components:
1. Client
2. Rest API
3. Validator
4. Transaction Processor
5. Sawtooth Network
Sawtooth Architecture

Client

● A user or an application that makes the


request to Sawtooth host
● Query the data from ledger
● Make a transaction to write to ledger
● Interact with Sawtooth host through
Rest API call
Sawtooth Architecture

Rest API
● Intermediator between the client and the
validator
● Medium for submitting transactions and
reading blocks
● Performs different operations associated
with Rest methods
Sawtooth Architecture

Validator

Responsible for validating the


incoming transactions and sending
them to the transaction processor
for further processing
Sawtooth Architecture

Transaction Processors

● Compute the business logic that is


equivalent to smart contract

● Constitute multiple transaction


processors in one sawtooth host

● Example: Car ownership change


Sawtooth Architecture

APIs

● Register (): Transaction


processors get registered with
validator

● Apply (Transaction): Dispatch the


transaction details to the
transaction processor from
validator

● Get and Set (Value): Read or


write the latest key-value pair in
State Database
Sawtooth Architecture

Sawtooth Network

● Each host system is a Sawtooth node


● It operates one validator, a
consensus engine, and a set of
transaction processors
Hyperledger Iroha
Hyperledger Iroha

Hyperledger Iroha is a simple Blockchain platform that can be utilized to make trusted, secure,
and fast applications that leverage the power of permission-based Blockchain with Byzantine
fault-tolerant consensus.

Hyperledger Iroha
Hyperledger Iroha Features

Client Application

Easy to Deploy

Smart Contracts

Community

Private Blockchain
Hyperledger Iroha Architecture

API Torii Model Provides gateway to network for


external Client

Assists one node to connect to


Peer network Network Consensus
other nodes

Validates the incoming


transaction and runs that
Business logic Simulator Validator Synchronizer
transaction to update or query
the ledger

Stores the transaction or ledger


Storage Storage Layer
details
Transaction Flow

Step 1

Client initiates the transaction and sends it to the peer through Torii gate

Torii

Client Peer
Transaction
Transaction Flow

Step 2

Peer sends the transaction to the Ordering Service through the Ordering Gate after
performing stateless validation

Torii Ordering Gate

Client Peer Ordering Service


Transaction
Transaction Flow

Step 3

Ordering service collects the transactions and maintains a sequence of them. Transactions
are then put into a block, and they are sent to all peers as Proposals

Ordering Service

Proposals

Peer Peer Peer Peer


Transaction Flow

Step 4
Proposed block reaches the peer, the peer runs the smart contract, and it simulates
the transactions present in that block with the help of a simulator

Proposed Block
Consensus Gate
Peer
Tx1

Tx2
Simulator

Tx3
Transaction Flow

Step 5
All the peers choose a leader based on majority and then the leader confirms the
block to be added to the ledger

Voting
Leader
Peer

Proposed Block
Peer
Tx1

Peer Tx2

Tx3
Hyperledger Indy
Hyperledger Indy

Hyperledger Indy is a distributed ledger used to generate and store decentralized identities,
allowing users to manage and control their digital identities. It stores pointers to identities rather
than private data.

Hyperledger Indy
Importance of Identification in Real World

Recognition of family, employers, and co-


workers

Identification of unknown people


How does identity
work in the real
world? Establishment of a person's level of
access liabilities

Higher bodies, such as governments and


corporations, issue them
Identification on the Internet

Phone Number

Machine-generated user ID
How does identity work
over internet?

Email ID
Identification Attributes

Identification allows the user to monitor the type and amount of personal data posted, which
is an essential feature for users' informational autonomy.

Internet Financial Residential


Identification Identification Identification
Identity Based on Risk

Identity attributes are used in two main categories for transactions.

High Risk
Low Risk
When you open a
When you buy
bank account
something online
online
Identity Correlations

Email id, age,


religion

Email id,
Email id,
family size,
Correlation medical
house
details
details

Email id,
race,
hobby
Decentralized Identifiers

Decentralized Identifiers (DIDs) are the global identifiers generated by the owner and not by
any central authority. They are generated using public and private keys where owner keeps
the private key secret.
Managing DIDs

At a given time, a user can have many DIDs


● For instance, Alice uses different DIDs
for Facebook, Google, Amazon, and
banks.
● Similarly, banks have many customers,
so they need to manage their DIDs.
Wallets and Agents

To manage DIDs, Indy makes use of


agents and wallets
● Agent: Software that helps you to
interact with other DIDs.
● Wallet: It stores DIDs and related
information like public keys.
Hyperledger Burrow
Hyperledger Burrow

Hyperledger Burrow is a permissioned Blockchain node built for a multi-chain universe that
executes smart contracts following the Ethereum specifications. It uses Ethereum Virtual
Machine.
Components of Burrows

Consensus Engine Smart Contract

Application
Gateway
Blockchain Interface
Hyperledger Fabric
Hyperledger Fabric

Hyperledger Fabric is the first distributed ledger platform to support smart contracts written
in general-purpose programming languages rather than domain-specific languages (DSL).
Hyperledger Fabric Architecture
Hyperledger Fabric Features

Performance and
Modularity
Scalability

Pluggable
Smart Contract
Consensus

Privacy and Permissioned


Confidentiality
Advantage of Hyperledger Fabric

● A wide range of industries will benefit from the


Hyperledger fabric project.
● Since the Hyperledger framework is open
source, anybody can use it to boost their
business.
● Since the Hyperledger fabric project is
absolutely modular, you can use as many
Hyperledger functionalities as you like.
Identities in Fabric

Identity is an important feature of permissioned Blockchain. Before connecting to the Hyperledger


Fabric network, each component must be identified.

An X.509 digital certificate is used to represent the identity. The actor specifies and delivers the
certificate when dealing with a fabric network, and the fabric network accepts or rejects it based on
the policy.
Identities in Fabric

• A principal is the combination of identity and its associated


attributes.
• They are similar to user IDs and group IDs, but they are
more flexible because they can include a variety of
identification features.
Fabric CA

Fabric CA is a certificate authority component which can integrate existing registries like LDAP.
MSP leverages fabric CA component.

Helps in Issues ECerts


registration of to the
the identity identity

Helps to revoke
and renew the
certificates
Root and Intermediate CA

Digital certificate are not only issued by Root Certificate Authority but can be issued by
intermediary certificate authority. Root CA authorize intermediate CA to issue certificates.
Certificate Revocation List (CRL)

It is a list of digital certificates that have been revoked by the issuing certificate authority
(CA) prior to their expiration date.
Reasons for Certificates Getting Revoked

It is important to understand that a revoked certificate is not the same as an expired


certificate. It is an active certificate that has been retired.

privilegeWithdrawn unspecified
2 3

Certificatehold 1 4 KeyCompromise

removeFromCRL 7 5 cACompromise

superseded
Membership Service Provider

One of the features of the Enterprise Blockchain is that the user's should not be
anonymous but known.

Contains a list of parties or actors involved in the Blockchain


network

Store identity for each participant


MSP Folder Structure

The MSP Folder Structure is as follows:

Organization

MSP

admincerts: This contains the cert of admin user

cacerts: This contains root CA certificate

tlscerts: Contains certificate to enable secure communication connection

CRL: Contains revoked certificates


MSP Folder Structure

The MSP Folder Structure is as follows:

Organization

Peer1

MSP

admincerts: This contains the cert of admin user

cacerts: This contains root CA certificate

intermediatecerts: Contains intermediate certificates

keystore: Contains private key

tlscerts: Contains certificate to enable secure communication connection

CRL: Contains revoked certificates


MSP Domains

In a blockchain network, MSPs occur in two domains.

• Locally on the user’s node (Local MSP)

• In channel configuration (channel MSP)

The main difference between local and channel MSPs is their scope, not how they work (both turn
identities into roles). At each level of administration, each MSP lists responsibilities and permissions.
Local MSPs and Channel MSPs

Local MSPs Channel MSPs

Channel MSPs define administrative and


Local MSPs are defined for clients and nodes
participatory rights at the channel level.
(peers and buyers).

The system channel MSP includes the MSPs of all


Every node must have a local MSP defined. the organizations that participate in an ordering
service.
How local and channel MSPS coexist on the network

Local MSPs are only defined on the file system of the node or user.

A channel MSP is also installed on every node in the channel’s file system and kept synced via consensus.

Source: https://hyperledger-fabric.readthedocs.io/
Channel

A channel is private communication between two or more participants in a network.

Channel 1

Mark Jay

Channel 3

Sam Steve
Policy

It a set of rules that establish the framework for making decisions and achieving results. These
rules often describe a who and a what, such as an individual’s access or rights to an asset.

One of the features that distinguishes Hyperledger Fabric from other blockchains such as Ethereum
or Bitcoin is its policy system.
Types of Policy

There are two types of policies :

Signature Policies

• It specifies which users must sign for a


policy to be satisfied.

• It defines the policy as a set of


evaluation rules for MSP Principles.

• The syntax supports arbitrary


combination of AND, OR, and NOutOf.
Types of Policy

There are two types of policies :

ImplicitMeta policies

• It is only valid in the context of channel


configuration.

• Policies are Implicit because they are built


implicitly based on the current channel
configuration.

• They are Meta because they are evaluated


against other sub-policies in the configuration
tree rather than specific MSP principles.
Policy hierarchy

A Fabric network’s policies are implemented at many levels. Each policy domain governs a different
aspect of a network’s operation.

System Channel

Consortium Membership and Blockchain structure

Application Channel

Transaction networks and business logic

ACLs and smart contracts

Transactions, data, and events

Source: https://hyperledger-fabric.readthedocs.io/
System Channel Configuration

Every network starts with an ordering system channel. There can only be one ordering system
channel per ordering service, and it must be the first one created.

• The system channel also includes organizations


that are members of the ordering services.

• The system channel also determines which


consortium members are permitted to create
new channels.

• Policies in the ordering system channel


configuration blocks govern the ordering
service’s consensus.
Application Channel Configuration

The ability to add or remove members from an application channel is governed by


the policies in the channel.

An application channel also governs which organizations must approve a chaincode before it is
defined and committed to a channel via the Fabric chaincode lifecycle.
Smart Contract Endorsement Policies

A smart contract within a chaincode package has an endorsement policy that specifies how many
peers from different channel members must execute and validate the transaction.

The endorsement policies define the organizations that must endorse the proposal’s execution.
Access Control List

Not everyone in
Blockchain should be
able to see everything on
Blockchain. One should
Handle permission be able to control who Handle permission
for parties sees what in the at channel level as
involved Blockchain network. well
Access Control List

Blockchain should not expose everything to everyone in the network.

Handle permission
Handle permission
at the channel level
for parties involved
as well

One should be able to control who sees what in the blockchain network.
Peer Introduction

A blockchain network is made up of a collection of peer nodes (or simply peers).

As they host ledgers and smart contracts, peers are critical components of the network.
Peer Introduction

Smart contracts and ledgers are used in networks to encapsulate shared operations
and information.

For these characteristics, a peer is a suitable place to start learning about Fabric networks.
Introduction to Peer Network

The network N in this example is made up of peers P1, P2, and P3, each of whom has their
own instance of the distributed ledger L1.

Fig: https://hyperledger-fabric.readthedocs.io/en/release-2.2/peers/peers.html

To access their copy of the distributed ledger, P1, P2, and P3 use the same chaincode:S1.
Peer Network

Instead of being managed by a single company, blockchain networks are managed


by a group of organizations.

Fig: https://hyperledger-fabric.readthedocs.io/en/release-2.2/peers/peers.html
Peer Types

Peers keep track of the network's status and a copy of the ledger. Peers can be
divided into two types:

Endorsing Peers Committing peers


Endorsers play a role in Prior to assigning transactions
transactions by simulating to the blockchain, committers
and endorsing them. verify endorsements and
confirm transaction results.
Peers’ Roles

There are mainly two types of peers’ roles:

Anchor peers Leader peers

Outside the company, anchor peers


Only the Leader peers receive new
are known. The member organizations
blocks from the Orderer. The Orderer's
anchor peers are encoded in the
workload is reduced as a result of this
genesis block when the network is first
design choice.
built.
Peers Application Client

An application client interacts with the fabric network with the help of peers.

Fabric Network

C1

Application P1

Client
L1
Peers Application Client

An application client interacts with the fabric network with the help of peers.

Fabric Network

C1
C1

P3
P1
Application L1
L1
Client

A1 Channel A2
Ledger Types

The ledger consists of two parts in Hyperledger Fabric:

World state Blockchain


Ledger Types: Blockchain

The Blockchain contains logs of transactions and maintains the history of the transactions.

Car ID - 657
Owner - Fisher

Car ID - 657
Owner - Leena

Car ID - 657
Owner - Rahul

Car ID - 657
Owner - Pankaj

Car ID - 657
Owner - Joy

Car ID - 657
Owner - Mark
Ledger Types: World State

Why is Couch DB preferred over level DB?

• Allows to store data in JSON format rather than

key-value pair

• Provides rich JSON queries against your data

• Supports data indexing


Ledger Types: World State

Why is the world state used?

It is a faster way to It makes Hyperledger It supports both simple

retrieve data from the fabric faster. type and complex type

world state as the current of data storage.

value is often checked

compared to history.
State Database

Car ID - 657
Owner - Fisher

Car ID - 657 Car ID - 657


Owner - Leena Owner - Fisher
● Hyperledger Fabric is faster compared
Car ID - 657
Owner - Rahul
to Public Blockchain due to State
Database.
Car ID - 657
Owner - Pankaj ● State Database is of two types, Level
Database and Couch Database.
Car ID - 657 Level Database
Owner - Joy Couch Database ● World state stores the latest data only.
Car ID - 657
Owner - Mark
World State Database

By re-processing the ledger, the state database can always be rebuilt. When each peer
validates and commits a transaction, it fills up the value.

The state database presently has two options: an integrated Level DB or an external
CouchDB
World State Database

There are two types of World state database:

• Level DB: Contains data in Key-Value pair

{Key= house1, Value=12567}


Example: {Key= house1, Value=12567}

{Key= house1,

Value={owner="mark", • Couch DB: Stores data in JSON

price=12567}} Example: {Key= house1, Value={owner="mark", price=12567}}


Couch DB Queries

Couch DB queries help to interact with the world state. It can be as simple as reading and
writing to a world state or as complex as writing complex queries.

How to read and write JSON data:

• PutState : This helps to write JSON data to Couch DB.

• GetState: This helps to read JSON data from Couch DB.


Couch DB Queries

These are some Couch DB complex queries:

Query syntax

"selector":{"name": "Mark"},

"fields": ["age","address"],

"sort": [{"age": "asc"}],

"limit": 4

}
Couch DB Queries

Simple query syntax: Finding a record with the name Mark:

"selector":{"name": "Mark"}

Simple query syntax: Finding a record with the name Mark

with fields attribute :

"selector":{ name": "Mark"},

"fields": ["age","address"]

}
Couch DB Queries

Simple query syntax: Finding the first 20 records where the year

is after 2010

"selector":{ "year": { "$gt": 2010 }},

"fields": ["name", "age","address"],

"sort": [{"age": "asc"}],

"limit": 20

}
Couch DB Indexing

Indexing helps to make queries more accurate and faster.

Query syntax

Simple Index syntax: Simplex index age-index for

field age

"index":{"fields": ["age"]},

"name": "age-index",

"type": "json"

}
Couch DB Query

Simple query syntax: Finding the first 20 records where the year

is after 2010

"selector":{ "year": { "$gt": 2010 }},

"fields": ["name", "age","address"],

"sort": [{"age": "asc"}],

"limit": 20

}
Read-Write Set

Read-Write set, usually referred to as RW set, is used very heavily in Hyperledger Fabric.

Read Set Write Set

Key, version Key, value

Key, version Key, value

Key, version Key, value

It helps committer nodes to validate the transaction and avoid double spending.
Read-Write Set

How is it created?

When the transaction reaches the endorsing peer, this RW set gets created.

RW
Endorsing Peer

RW
Endorsing Peer

Client RW
Endorsing Peer
Read Set

Read set contains key and version numbers as depicted below:

Read Set
key, version

key, version

key, version

Read Set
Read Set
(key="1234", version="1")
(key="1234", version="1")
(key="4561", version="1")

(key="8769", version="1")
Write Set

Write set contains Key and values as depicted below. This is used to write data to ledger.

Write Set

key, value

key, value

key, value

Write Set Write Set


(key="1234", value="Joe")
(key="1234", value="Joe")
(key="4561", value="Mark")

(key="8769", value="Steve")
Read-Write Set

How does it work and what is the use of it?

Step1: Committing peer uses the received RW and validates the transaction.

Ledger RW
Committing Peer (key="1234", version="1")
(key="1234", value="Lui",
(key="1234", value="Joe")
version="1")
Read-Write Set

Step 2: After validation, version is updated.

(key="1234",value="Lui", version="1")
Committing Peer
Ledger
Read-Write Set

It avoids double spending.

RW 1

(key="1234", version="1")
(key="1234", value="Joe") (key="1234", value="Joe",

Committing Peer version="2")

Ledger

RW2

(key="1234", version="1")

(key="1234", value="Jac")
Ordering Service or Node

The client application sends the transaction (RW set) to the Ordering service.

Endorsing Peer

Endorsing Peer

Endorsing Peer

Ordering Service

Client Transaction to Ordering Service


Ordering Service or Node

Ordering Services perform two operations:

• Maintain the sequence of the transactions

• Generates the block and forms the set of transactions

Fabric Network

Org
Ordering Service or Node

Ordering service can be implemented in three ways:

• Raft (Recommended): Raft is a crash-fault-tolerant (CFT) ordering service based on a Raft protocol

implementation.

• Kafka (deprecated in v2.x): Kafka utilizes a ZooKeeper ensemble for management purposes.

• Solo (deprecated in v2.x): The ordering service's Solo version is only meant for testing, and it

consists of a single order node.


Ordering Service: Raft

A Raft is mainly used for production setup, and it follows a leader-follower model.

O3
Fabric Network
L Org 3
F

O2 01

Org 1
Org 2 F

O4

Org 4
Ordering Service: Raft

A Raft is Crash Fault Tolerant, as two-thirds of the nodes should be active.

O3
Fabric Network

L Org 3

O2

Org 2 F

O4

Org 4
Ordering Service: Raft

Why is Raft preferred over Kafka?

• Kafka has many components, so it is tricky to set up as compared to Raft.

• In Kafka ordering, a cluster is under the control of one organization, but in Raft,

every organization can have its cluster, which makes it more decentralized.

• Kafka support is handled by Apache, not by Hyperledger Fabric.


Raft Concepts

The various concepts of Raft are:

Log Entry: Raft peer runs some commands, and a list of these commands is known as a log. Every

command entry is made to the log.

Consenter set: A leader peer sends the log to other peers for replication and receives replicated logs

back to achieve consensus.

Finite-State Machine (FSM): It is a part of every peer, and it ensures that the sequence of

transactions or logs is the same in all the peers.


Raft Concepts

Quorum: It specifies the minimum number of peers required to approve the transaction

sequence proposal. Example: Out of five peers, three peers need to act and approve.

Leader: It is chosen dynamically and sends the transactions or logs to other peers (followers).

Follower: It receives transaction or logs from the leader and replicates them.
Private Data

Private data helps to accomplish a scenario where certain details need to be shared among
a subgroup of organizations inside one channel instead of showing the information to all the
organizations in that channel.

State

Private data

Ledger
State database
Private Data

Private data is not stored by all the peers in that channel.

P1 P2 P3

State State State

Private data Private data


Private Data Collection

Private data collection consists of two parts: one is the private data, and the other is a hash of
that data.

Private Data Collection

Data hash

private Data
Private Data

Data hash is a peer that is not a member of the subgroup that exchanges private data.

P1 P2 P3

State State State

Data Hash Data Hash Data Hash

Private Data Private Data Private Data


Hyperledger Fabric Transaction
Hyperledger Fabric Transaction

Step 1: Client initiating the transaction

● Network verifies the client's identity using Membership Service Provider


● Network uses an Access Control List to determine if the requester has permission to access
the network

Hyperledger
Client
Network
Hyperledger Fabric Transaction

Step 2: Validate the transaction

Endorsing Peers are notified of the transaction through a proposal

Endorsing Peer

Endorsing Peer
Client

Endorsing Peer
Hyperledger Fabric Transaction

Step 3: Simulating the transaction

Endorsing Peers execute the chaincode and report back to the client program

Endorsing Peer

Client Endorsing Peer

Endorsing Peer
Hyperledger Fabric Transaction

Step 4: Verifying proposal response

The client application receives the response from Endorsing Peers and checks the response
to see if consensus has been achieved

Client

Verify
Hyperledger Fabric Transaction

Step 5: Broadcast transaction to the order

The Ordering Node is notified by the client application that a new transaction is being recorded
on the ledger

Endorsing Peer

Endorsing Peer

Endorsing Peer

Client Ordering Node

Transaction to Ordering Node


Hyperledger Fabric Transaction

Step 6: Order transactions and create block

Ordering Node orders the transactions, generates a block with those transactions, and gives it
back to the Endorsing Peers

Endorsing Peer

Endorsing Peer

Endorsing Peer Ordering Node

Committing Peer

Committing Peer
Hyperledger Fabric Transaction

Step 7: Peers validate each transaction in block

Peers verify each transaction in the block and notify the client as well

Endorsing Peer

Endorsing Peer
Ordering Node
Endorsing Peer

Committing Peer

Committing Peer
Hyperledger Fabric Transaction

Step 8: Committing to Ledger

Committing nodes (and the Endorsing nodes) record the copy of the record in their ledger

Endorsing Peer Chain of blocks


Commits a block
Endorsing Peer

Endorsing Peer

Committing Peer State Database

Committing Peer
Fabric Network
Hyperledger Fabric setup

Hyperledger setup involves the following high-level steps:

Set up
Identify Prerequisites Set up Fabric
Prerequisites
Identify Prerequisites

The following Operating System, Software, and tools are required to run Hyperledger in your
System:

Docker Engine
Docker Compose
Git and Curl

Lib tools

NodeJS
Python
Open JDK
Ubuntu Linux
Set up Hyperledger Fabric Prerequisites

Duration: 10 Min.

Problem Statement:
You are given a task to install Hyperledger Fabric prerequisites.
Assisted Practice: Guidelines

Steps to set up Hyperledger Fabric prerequisites:

1. Installing Curl in the local machine


2. Installing Node.js in the local machine
3. Installing Git in the local machine
4. Installing Python in the local machine
5. Installing Lib tools in the local machine
6. Downloading and installing Docker CE in the local machine
7. Setting up Docker Compose in the local machine
Set up Hyperledger Fabric

Duration: 10 Min.

Problem Statement:
You are given a task to install Hyperledger Fabric.
Assisted Practice: Guidelines

Steps to set up Hyperledger Fabric:

1. Cloning the Hyperledger Fabric repository and installing it


Fabric Network Types
Identify Prerequisites

Test network

The test network is a production network replica which has the same
rules as those of the production.

Enterprise network

The enterprise network is the same as the production network. It has


nodes and links that are spatially interconnected.
Fabric Network Files

crypto-config.yaml

● Fabric Network files account for the majority of


the development, test, and production networks.
configtx.yaml
● These files can be updated as required by the
network administrator.

docker-compose.yaml
Crypto-config.yaml

This file assists the users to generate public and private keys, digital certificates for peers, and
ordered service using the command cryptogen.

Structure Purpose

orderer peers users


Configtx.yaml

This file assists to generate genesis block, which is an appropriate block in Blockchain.

Structure
Purpose

Genesis block

Channel artifacts

Organization Application Profiles


orders capabilities
Docker-compose.yaml

Docker containers are used to run the Hyperledger Fabric network. This file contains information about
each Docker container, such as name, image, port, and volumes.

Structure

Purpose

Create containers

CA Peer and State Start and stop network


containers order database
containers containers
Start and Stop Test Network

Duration: 10 Min.

Problem Statement:
You are given a task to start and stop test network.
Assisted Practice: Guidelines

Steps to start and stop test network:

1. Setting up the standard Hyperledger test network


2. Setting up a test network with CA containers
3. Setting up a test network with CouchDB containers
4. Setting up a test network with all the above parameters
Fabric Explorer
Hyperledger Explorer

Hyperledger Explorer provides the user interface to see the operations of the Hyperledger Fabric
network. This tool allows viewing of the blocks, transactions, and chaincode running on the network.
Explorer Features

The hyperledger explorer features are:

• Rich user interface that shows the details in a


readable format and is developed using ReactJS,
web-sockets, etc
• Easy integration with Hyperledger Fabric
network
Explorer Features

It provides the capability to:

• View different organizations, including their peers


• Get the latest block and its status and set alerts for new blocks
• See transactions metrics in hours and minutes format
• Filter and search the transaction by date and channel
• Search and filter blocks and transactions by date range and channels
Explorer Dashboard Navigation

Hyperledger Explorer provides the given navigation tabs:

Dashboard
Channels
6 1

Chaincodes 5 2 Network

3
4 Blocks
Transactions
Dashboard

Dashboard is the home page of the Hyperledger Explorer and displays a set of panels that
shows the latest activity of the Hyperledger Fabric network.
Network

Hyperledger Fabric Network consists of peers and in this section, user can see all the network peers
and their properties. It allows them to check the peers by channel.
Blocks

Like Bitcoin and Ethereum explorer, Hyperledger Explorer shows a user all the blocks and lists of
transactions in that block. Along with that, it shows different properties of the block.
Transactions

The transaction tab helps to view all the transactions. A user can view maximum 100 transactions per
page, and it allows different filter options as well.
Transaction Details

Transaction details show different properties of transaction along with read and write set.
Chaincode
Chaincode

The chaincode tab lists down all the chaincodes deployed per channel and the number
of transactions for that chaincode.
Channel
Channel

The channel tab shows a list of the channels in the Hyperledger Fabric network.
Explorer Architecture
Explorer Architecture

Hyperledger Explorer consist of


three main layers:

• Presentation Layer
• Backend Layer
• Database Layer
Hyperledger Explorer

Duration: 10 Min.

Problem Statement:
You are given a task to start with hyperledger explorer.
Assisted Practice: Guidelines

Steps to start the Hyperledger explorer:

1. Creating a new directory with the name fabric-explorer in home


2. Downloading necessary files under the fabric-explorer folder
3. Copying Organization folder from test-network to fabric-explorer folder
4. Opening docker-compose.yaml file and replacing volume path
5. Going to the connection-profile folder and editing the test- network.json file
6. Starting the explorer
Node.js
Client Server Architecture

The client-server architecture is shown in the diagram below:

Client 1

Client 2

Client 3
Database
Server
Multi Thread Model

The multi thread model is represented in the image below:

Client 1

Thread A

Client 2 Thread B

Thread C

Client 3
Database
Server
Thread
Limitations of Multi Thread Model

• Every request starts a new thread, which implies


thousands of threads could be active at any given
time.
• As one request can put a shared resource on
wait, additional requests may be unable to finish.
• It is possible that the server will suffocate,
resulting in a deadlock.
Introduction to Node.js

Node.js is a server-side and networking runtime environment that is open-source. It is used to rapidly
construct scalable network applications.

Node.js is a single-threaded programming language that executes code using the Google
JavaScript V8 Engine. It runs on any operating system and is platform agnostic.
Features of Node.js

01 02 03 04

Asynchronous Event driven Very fast Highly scalable


Features of Node.js

Asynchronous

Request
• Node.js is non-blocking, which means it works in
an asynchronous manner.
Response
• Instead of requesting a process first, it accepts
Client Server
Callback additional requests.
• The callback technique is used to send a
synchronized answer to the caller.
Features of Node.js

Event Driven

• Every request is an event, and it comes to


the event queue.
• It is a FIFO queue.
Features of Node.js

Fast and Scalable

• Node.js makes advantage of the Google


Chrome V8 engine, which is extremely fast.
• The event mechanism assists the server in
responding in a non-blocking manner.
Node.js Installation

The given command is used to install Node.js:

sudo apt install nodejs

The given command is used to verify the installation of Node.js :

node -v or node –version


First Example of Node.js

1. Create a new folder using the given command

2. Create a new file


First Example of Node.js

3. Navigate to the project directory

4. Execute the file


Creating a Web Application

1. Import required modules:

var http = require("http");

2. Create a server:

var server = http.createServer(function(request,


response){
console.log('create new server'); });

3. Listen:

server.listen(port, function(){
console.log('server at port 3000;);
});
Creating a Web Application

Import module

Define port

• Create server
• Send HTTP header
• Send HTTP data

Bind server to port 4000


Create Node.js Application

Duration: 10 Min.

Problem Statement:
You have been tasked to create new server that runs on 4000 port using Node.js.
Assisted Practice: Guidelines

Steps to be followed to setup Node.js:

1. Creating a new directory


2. Opening the newly created directory
3. Creating a new file
4. Adding code in the file
5. Running the newly created file
6. Opening the URL to verify if the server is working
Blocking and Non-Blocking I/O

The blocking and non-blocking I/O are illustrated in the image below:
Node Package Manager

Node Package Manager (NPM) helps us with these features:

• Packages and modules for Node.js can


be found in this online repository.

• Install Node.js packages and control


version and dependency management
for Node.js packages with this
command line utility.
Node Package Manager Components

npm --version This command helps us to check npm version.

npm install <module


This is the syntax to install any Node.js module.
name>

npm install <module> -g This syntax is used to install any Node.js module.

This command can be used to create new node


npm init
project.
Package.json File

This is a manifest file that exists in the project's root directory and contains information about
the project.

This file gets created when a user creates new node project using the npm init command.
Package.json File Elements

Mandatory Element

• Name: Unique node project name


• Version: Node.js package version

Optional Element

• Description: Description of the node project


• Dependencies: List of all the dependencies
Purpose of Package.json File

Central place for the project configuration

Maintain list of all the dependencies

Enable npm to start the project

Help npm cli to identify your project


Fabric Node Modules

Node SDK has main two modules:

Fabric-network

This module provides a high-level interface for working with the chain
code that has been deployed. Transactions and queries are examples of
interaction.

Fabric-ca-client

This module manages numerous certification procedures such as user


registrations and enrollments and network re-enrollments.

Note
Fabric-client is depreciated and replaced by fabric-network.
Fabric-network Modules

Fabric-network module main classes:

Gateway

This class allows a user to connect to a fabric network and interact with it.

FileSystemWallet

This class is concerned with network user identities.

X509WalletMixin

This class creates X509 identity within the network.


Fabric-ca Client Modules

Fabric-ca-client module main classes:

Register

This class helps to register new users to the network. This returns secret as
a response when invoked.

Enroll

This class is used to enroll registered users, and the secret that the user
receives after registration is used as input.
Promise

In Node.js, asynchronous calls are handled via Promise.

When an async function is invoked, it


always returns a promise, which can be
in one of two states:

• Resolved
• Rejected
Promise

Promise is shown in the code below:


Async and Await

Promise solves asynchronous code but brings a lot of complexity. With the introduction of async
functions, code look like it is synchronous, but it is asynchronous in nature and non-blocking
behind the scenes.
File System

The file system is a node module that aids in the input and output of files. For this, Node.js
provides a module called fs.

var fs = require("fs")
Express

Express is a web application framework for online and mobile applications that includes
Node.js.

It assists in the development of single, multi, and hybrid web applications. It is built on top
of Node.js and aids in the simplification of its APIs.
Features of Express

Some of the features of Express are:

• Make web development very easy and fast

• Customize and configure easily

• Define routing table for your application based on HTTP methods


and urls

• Helps to create REST API server

• Easy connectivity with different databases like MongoDB, MySql, etc


Express

Express is a minimal and flexible Node.js web application framework that provides a robust set
of features to develop web and mobile applications.

Import express module

Retrieve resources
HTML doc as response

Listening to 5000 port


Create a New App using ExpressJs File Approach

Duration: 15 Min.

Problem Statement:
You have been tasked to create a new app that runs on port 500 using express file approach.
Assisted Practice: Guidelines

Steps to be followed to create a new app using express file approach:

1. Create a new directory and install the express module


2. Create a new file and add the content
3. Execute the created file
Create Web Application Using Expressjs Node Project
Approach

Duration: 15 Min.

Problem Statement:
You have been tasked to create new server that runs on 4000 port using Node.js.
Assisted Practice: Guidelines

Steps to be followed to Create Web Application Using Expressjs Node Project Approach:

1. Create a new directory


2. Set up a new node project and download the module
3 Create a new file and save that
4. Execute the created file
RESTful API

REST stands for representational state transfer.

C R U D
Post Get Put Delete

Create new
resource or Read resource Update Used to remove
update existing data resources resources
resource
R3 Corda
Corda Introduction

Corda is a distributed ledger platform that maintains privacy using smart contracts. It
reduces transaction and record-keeping costs and streamlines business operations.
Corda Features

The key features of Corda are:

High performance and scalability

Known identities Privacy

Permissioned network with no


Global interoperability
mining and cryptocurrency
Corda Key Concepts

The key concepts of Corda are:

1 4 Validity and
Ledger
Uniqueness Consensus

2 States 5 Contracts

3 Transactions 6 Flows
Ledger

In Corda, every node has its ledger where that node stores the transactions. This
implies there is no central ledger.

Nodes Visibility
ALICE 1, 7
BOB 1, 5, 6, 7
CARL 2, 3, 4, 5, 6, 9
ED 3, 4, 8, 9
DEMI 2, 3, 8

Reference: https://docs.corda.net/docs/corda-os/4.6/key-concepts-ledger.html
Bilateral Ledger

● Each node maintains its ledger.


● Nodes in the Corda network may share
data with one another, but ALICE may
have data that is not shared with BOB. As
an example, set 11
● Data from one node can be shared with
other nodes. For example, BOB can share
data with ALICE while also sharing it with
CARL.

Reference: https://docs.corda.net/docs/corda-os/4.6/key-concepts-ledger.html
States

States are immutable digital documents that record the existence, content, and current state of a
contract between two or more parties. They are intended to be shared only with those who have the
approval to see them.

Fact 1

Price Due Paid


Seller Buyer Remaining Price
(Rs.) Date Price
Joe Fact 1 Fisher
June
Joe Fisher 20,000 5000 15,000
2022
States

Historic State
Price Due Paid
Seller Buyer Remaining Price
(Rs.) Date Price
June ● After changing the state, a new
Joe Fisher 20,000 5000 15,000
2022 state defined as the current
state is created.
● The altered state becomes the
historic state.
Current State ● Historic states are not stored on
Price Due Paid the ledger, but they are still
Seller Buyer Remaining Price
(Rs.) Date Price available, ensuring that they are
June never removed.
Joe Fisher 20,000 20,000 0
2022
Transactions

Transactions are generated wherever there is any output for a given input. These transactions
ultimately get stored in the ledger.

TRANSACTION

CASH0 CASH1

BOND1 BOND2
Contracts

CASH
CONTRACT

REFERENCES VALIDATES REFERENCES

CASH0 CASH1 • Contracts are digital agreements


between two or more parties.
• They are used to verify the transaction is
happening per the defined rules.
BOND1 BOND2

REFERENCES VALIDATES REFERENCES

BOND
CONTRACT
Flows

A flow is a method for two or more parties to agree on a simple update ledger and is usually
point-to-point.

Reference: https://docs.corda.net/docs/corda-os/4.6/key-concepts-flows.html
Validity Consensus

Validity consensus is the process of checking that the following conditions hold for every
transaction in the transaction chain that generates the inputs to the proposed transaction:
● The transaction is accepted by the contracts of every input and output state
● The transaction has all the required signatures

Reference: https://docs.corda.net/docs/corda-os/4.6/key-concepts-consensus.html
Uniqueness Consensus

● The criterion of uniqueness consensus is that none of the inputs to a proposed transaction are
being used in another transaction.
● A double spend exists if one or more of the inputs have already been used in another
transaction and the transaction request is deemed invalid.

Reference: https://docs.corda.net/docs/corda-os/4.6/key-concepts-consensus.html
Corda Network
Corda Network

Corda network is a peer-to-peer network where each node runs an instance of Corda.
Communication between nodes inside the network is secured and point-to-point.

Corda Network Setup


Corda Network Services

Corda network has mainly four services:

● Identity Service: This service handles network node identity. It helps add new participants
to the network by verifying their certificate signing requests.

● Network Map Service: This service assists in network mapping where it helps with
message routing and connecting the nodes.

● Notary Service: This service helps with unique consensus.

● Support Service: This helps to resolve inquiries related to the above three nodes.
Corda Pre-Production Network

Corda Pre-Production or User Acceptance Testing is a network that allows developers and
businesses to test their CorDapps in a production-like environment.

Pre-Production testing

Deployment of R3Net

Local testing

CorDapp
development
Quality check
Key Takeaways

Enterprise blockchain is a permissioned blockchain that


streamlines the business processes extensively.

Hyperledger Umbrella Project comprises tools, services, and


libraries to build enterprise blockchain applications.

Hyperledger Fabric is a blockchain platform that supports


general-purpose programming languages.

Corda is a distributed ledger platform that uses smart


contracts to reduce transaction and record-keeping costs.
Knowledge Check
Knowledge
Check
Which Hyperledger project stores digital identities?
1

A. Hyperledger Fabric

B. Hyperledger Iroha

C. Hyperledger Indy

D. Hyperledger Sawtooth
Knowledge
Check
Which Hyperledger project stores digital identities?
1

A. Hyperledger Fabric

B. Hyperledger Iroha

C. Hyperledger Indy

D. Hyperledger Sawtooth

The correct answer is C

Hyperledger Indy is a distributed ledger used to generate and store decentralized digital identities.
Knowledge
Check
Which Hyperledger Fabric network file helps generate the first genesis block?
2

A. crypto-config.yaml

B. configtx.yaml

C. docker-compose.yaml

D. Genesis.yaml
Knowledge
Check
Which Hyperledger Fabric network file helps generate the first genesis block?
2

A. crypto-config.yaml

B. configtx.yaml

C. docker-compose.yaml

D. Genesis.yaml

The correct answer is B

configtx.yaml file helps generate the genesis block and the required channel artifacts.
Knowledge
Check
Which node ensures that transactions are in a particular sequence?
3

A. Ordering node

B. Endorsing node

C. Committing node

D. All nodes
Knowledge
Check
Which node ensures that transactions are in a particular sequence?
3

A. Ordering node

B. Endorsing node

C. Committing node

D. All nodes

The correct answer is A

The sequence of transactions is important in Blockchain and is maintained by the ordering node.
Knowledge
Check
Which app is developed using Corda?
4

A. CordApp

B. Dapp

C. DAO

D. Ndap
Knowledge
Check
Which app is developed using Corda?
4

A. CordApp

B. Dapp

C. DAO

D. Ndap

The correct answer is A

Applications developed using Corda are known as CordApps.


Knowledge
Check
Which consensus type prevents double-spending in Corda?
5

A. Validity consensus

B. Uniqueness consensus

C. Proof of work

D. Proof of stake
Knowledge
Check
Which consensus type prevents double-spending in Corda?
5

A. Validity consensus

B. Uniqueness consensus

C. Proof of work

D. Proof of stake

The correct answer is B

Uniqueness consensus ensures that there is no double-spending in the Corda network.


Transform the Supply Chain

The traditional seafood supply chain industry has illegal, unreported, and
unregulated fishing practices. You are required to bring traceability and
accountability to the supply chain through the power of Hyperledger
Sawtooth technology. Perform the following steps:

1. Visit https://demo.bitwise.io/fish/
2. Click SignUp to create an agent
3. Click Add Fish to add a fish that is to be tracked
4. Enter the details of the fish
5. Once the fish is added to the network, you can account for and track
the supply chain

You might also like