Introduction to Blockchain and Hyperledger

Preview:

Citation preview

@benji_fuentes @niteshpthakrar#Devoxx #Hyperledger

Introduction to Blockchainand Hyperledger

Benjamin FuentesNitesh Thakrar

IBM

@benji_fuentes @niteshpthakrar#Devoxx #Hyperledger

https://ibm.box.com/v/devoxxUSFor Part 1:Bluemix account: https://console.ng.bluemix.net/registrationDocker: https://docs.docker.com/engine/installation/#platform-support-matrixDocker compose: https://docs.docker.com/compose/installPostman: https://www.getpostman.com

For Part 2 & 3:Java JDK 8: http://www.oracle.com/technetwork/java/javase/downloads/index-jsp-138363.htmlEclipse: https://www.eclipse.org/downloadsEclipse Maven plugin: (you can use the one embedded on Eclipse)Eclipse Gradle plugin: (depending on the version, it can be already included or https://projects.eclipse.org/projects/tools.buildship)

#Devoxx #Hyperledger @benji_fuentes @niteshpthakrar

Agenda• First part (1H)

Introduction to Blockchain and Hyperledger (30min)Use Blockchain As a Service on Bluemix Cloud and start a network locally (30min)

• Pause (15min)

• Second part (45min)Create a smart contract (in Java or Go)

• Pause (15min)

• Third part (45min)Develop the client side (HTTP API or JAVA/HFC SDK)

#Devoxx #Hyperledger @benji_fuentes @niteshpthakrar

Blockchain• Introduction

• Hyperledger

• Blockchain as a Service(on Bluemix Cloud)

#Devoxx #Hyperledger @benji_fuentes @niteshpthakrar

Blockchain - IntroductionA blockchain is a distributed database, introduced by Bitcoin (2008) on Satoshi Nakamoto’swhite paper, that maintains a continuously-growing list of data records that each refer to previous items on this list and is thus hardened against tampering and revision

Distributed systems answer to a problem called Byzantine Generals’ Problem described by Leslie Lamport (1982)

As today, blockchains can be used to write distributed applications named “smart contract” or “chaincode”

Mesopotamianledger

Byzantine Generals’ Problem

#Devoxx #Hyperledger @benji_fuentes @niteshpthakrar

Blockchain - HyperledgerHyperledger (or Hyperledger project) is a cross-industry collaborative effort to create blockchain-based open standard for distributed ledgers for globally conducted business transactions under the Linux Foundation

The project aims to create an open-standard, public, decentralised public ledger based on blockchain technology to advance worldwide business transaction processing in terms of cost-effectiveness, speed and traceability

More than 100 members

Fabric

Sawtooth Lake

#Devoxx #Hyperledger @benji_fuentes @niteshpthakrar

Blockchain -Blockchain as a Service (on Bluemix Cloud)

IBM is the only provider that gives you access to a permissioned Blockchain as a Service on its catalog of services

#Devoxx #Hyperledger @benji_fuentes @niteshpthakrar

Fabric V0.6• Actors

• Components

• Interactions

• Architecture

#Devoxx #Hyperledger @benji_fuentes @niteshpthakrar

Fabric - ActorsThe business user, operating in a business network. This role interacts with the Blockchain using an application. They are not aware of the Blockchain.

The overall authority in a business network. Specifically, regulators may require broad access to the ledger’s contents.

The developer of applications and smart contracts that interact with the Blockchain and are used by Blockchain users.

Defines, creates, manages and monitors the Blockchain network. Each business in the network has a Blockchain Network operator.

Manages the different types of certificates required to run a permissioned Blockchain.

An existing computer system which may be used by the Blockchain to augment processing. This system may also need to initiate requests into the Blockchain.

An existing data system which may provide data to influence the behavior of smart contracts.

BlockchainUser

BlockchainDeveloper

Certificate Authority

BlockchainRegulator

Traditional Processing Platform

Traditional Data

Sources

BlockchainNetworkOperator

U

R

D

O

ü

#Devoxx #Hyperledger @benji_fuentes @niteshpthakrar

Fabric - Components

Membership

Smart Contract

Systems Management

Events

ConsensusNetwork

Wallet

Ledger Contains the current World State of the ledger and a Blockchain of transaction invocations

f(abc); Encapsulates business network transactions into logic code. Transaction invocations result in gets and sets of ledger state

E T

A collection of network data and processing peers forming a Blockchain network. Responsible for maintaining a consistently replicated ledger

Manages identity and transaction certificates, as well as other aspects of permissioned access

Creates notifications of significant operations on the Blockchain (e.g. a new block), as well as notifications related to smart contracts. Does not include event distribution.

Provides the ability to create, change and monitor Blockchain components

Securely manages a user’s security credentials

i

Responsible for integrating Blockchain bi-directionally with external systems. Not part of Blockchain, but used with it.

SystemsIntegration

#Devoxx #Hyperledger @benji_fuentes @niteshpthakrar

Fabric - InteractionsProtocols :

• SDK : use gRPC to communicate with a blockchain peer or Certificate Authority. Maintain the user’s key wallet

• HTTP API : use HTTP (will be deprecated in V1.0)

Functional interaction methods:

• DEPLOY* : to deploy a chaincode

• QUERY : to retrieve data from World State

• INVOKE* : to call a chaincode method creating a transaction

membership

keys

ConsensusLedgerEvents

Chaincodestate

peer

SDK

ECA, TCA, TLS-CA

API

Blockchain network

(* Creates a block on the chain)

#Devoxx #Hyperledger @benji_fuentes @niteshpthakrar

Fabric - Architecture1.Blockchain developer codes

Application and Smart Contract

2.He deploys the app on a server and smart contract on a peerusing DEPLOY

3.A registered user interacts withthe app sending order(INVOKE) or retrievinginformation (QUERY)throught the smart contract

4.Smart contract can emit an event susbcribed by the app World/Ledger

State

BlockchainGenesis Block

Blockchain developer

Smart Contrac

t

Invokes/querieson a smart contract

DevelopsApplication

DSDK HTTP

txn txn txn txn txn

Block n

PEER

develops, then deploys

emits

PutState/GetState

U

Blockchain developer

Interacts

#Devoxx #Hyperledger @benji_fuentes @niteshpthakrar

Think distributed and deterministic !!! Get resources from external systems

peer

Blockchain network

peer

peer

Ext system

Put resources to external systems

peer

Blockchain network

peer

peer

Ext system

t1 t3t2 1 call 1 call

1 call

#Devoxx #Hyperledger @benji_fuentes @niteshpthakrar

Next coming on V1.0 (March 2017?)• Endorsement/consensus model

• Plugging external identity server

• Plugging external State DB

• Historical queries

• HTTP API deprecated, use SDK

• Chaincode upgrades

#Devoxx #Hyperledger @benji_fuentes @niteshpthakrar

Fabric V1.0 - Endorsement/Consensus model

Peer role has been split :

• Committer peer : commits transactions, maintains ledger and state

• Endorsing peer: receives a transaction proposal for endorsement, responds granting or denying endorsement

• Ordering peer: approves the inclusion of transaction blocks into the ledger and communicates with peer and endorsing peer nodes

Also a peer can now communicate via private channels inside the network to strenghten privacy

Different configuration options for the ordering service include:– SOLO

• Single node for development– Kafka / Zookeeper

• 1:n nodes providing Crash Fault Tolerance

• Odd number of nodes recommended

– SBFT (future)• 1:n nodes providing Byzantine

Fault Tolerance

Ordering-Service

OO

O OE C

Peer types

oror

#Devoxx #Hyperledger @benji_fuentes @niteshpthakrar

Fabric V1.0 - Identity serverNew Identity server (COP)

• make as pluggable as possible

• make it decentralized

• default implementation : CloudFlare'sPKI/TLS toolkit

• can be configured to read from an LDAP server

• Developed in GO

• CLI commands for server and client

#Devoxx #Hyperledger @benji_fuentes @niteshpthakrar

Fabric V1.0 - External World State DB• Key/value database (LevelDB)

• Document JSON database (CouchDB)

• SQL data stores (future?)• requires schema definition

• difficult to change schema CouchDB

ChaincodeAPIs

LevelDB

Worldstate

#Devoxx #Hyperledger @benji_fuentes @niteshpthakrar

Fabric V1.0 - Historical queriesSimple use case :

• Show history of values for an asset X

Rich queries :

• Show value of an asset at a certain point in time

• Show all assets having same field value through history (example : owned by a specific owner)

tt-1t-2

#Devoxx #Hyperledger @benji_fuentes @niteshpthakrar

Fabric V1.0 - HTTP deprecated, use SDK

•Do not use HTTP API anymore

•Use SDK over gRPC :• Java

•NodeJs

•Python

#Devoxx #Hyperledger @benji_fuentes @niteshpthakrar

Fabric V1.0 - Chaincode upgrades• New command UPGRADE to use

instead of redeploying another chaincode

• Chaincode will contain version number…

Smart Contrac

t

txn txn txn txn

Smart Contrac

t

ApplicationSDK HTTP

UPGRADE

Version N+1Version N

World/Ledger State

#Devoxx #Hyperledger @benji_fuentes @niteshpthakrar

Thank you !

Recommended