You are on page 1of 40

Hyperledger & Smart Contracts

Manoj S P
Open Source Solution's Specialist
manojs@sg.ibm.com
Agenda for Discussion ..

¾ Hyperledger – Introduction, Architecture and Ecosystem


¾ Blockchain Internals
¾ Smart Contracts & Containers

1
The Buzz ..Every one are talking about them
At the heart of decentralized systems such as Bitcoin is a revolutionary
platform – the “blockchain”

In Bitcoin, the central functions are distributed to all the


Traditional banks are built on participants in the system:
private, centralized systems:
Every user has access to their own copy of the transaction
ledger in a long ledger called the BLOCK CHAIN

Account owners

Bank balances

Transaction records

New
Transactions

CRYPTOGRAPHY is used to verify transactions and keep


There is one central ledger for information private
accounts, identities, and New currency is issued to users as a REWARD for doing
transactions. the computation “work” involved in verifying transactions.
Introducing Hyperledger

A collaborative effort created to advance blockchain technology


by identifying and addressing important features for a cross-
industry open standard for distributed ledgers that can
transform the way business transactions are conducted globally.
Hyperledger Project Members

[1] At 17th December 2015


Open source participation is important to the IBM Strategy

2016
62k+ IBMers contributing to 150+ Open Orgs

Founder & Platinum


Sponsor
IBM is a top-3
contributor in the past 4
releases
IBM has 450+
Founder & Platinum developers & 20 core
Sponsor reviewers
A Dramatic Commitment to Open Technology ! IBM has the largest Cloud
Foundry deployment
IBM has 10 dedicated core
IBM a founding contributors
member of the newly
Leading dev of nightly
established
builds for x86, Power &
foundation
Mainframe systems
2.1b npm downloads
#2 in Commits in 2015
in the past month
behind Docker
Donation of
IBM SystemML machine
IBM pledged 3,500 devs to
5 IBMers contributing to IBM is a founding member Spark across 12 labs
500+ organizations participating
Education for 1m + data
Linux & Apache Projects Provides customer-led guidance to scientists & engineers on
cloud standards-defining orgs Spark.

1999
Open Source in the Enterprise

https://www.blackducksoftware.com/future-of-open-source
Open Explained
• OPEN is enticing:
– Done correctly: reduce cost base prevent vendor lock in, Open
leverage large community Standards

– Done incorrectly: expensive / difficult to maintain


critical systems, impossible to control, legal liabilities Open Source Open Data
Community
• OPEN is often miss-understood – e.g. open source software Innovation
confused with open standards; open source = free!
Open
• IBM leader in Open since late 1990s – Linux, Eclipse, Open Governance

Cloud. Open Source embedded in our Software.


• Intelligent balance (Open – Commercial) essential, system
engineering led, based on total cost of ownership
underpinned by Open Standards
Join the movement

As with Java, Linux, Open Stack, Node and Spark, industry can advance Hyperledger (open
blockchain) technology and focus it on the requirements of industrial use cases by working
together through an open source foundation

What? How?
• Enterprise grade specification • Community led
– Functional & non-functional • Open Governance
• Help build open source fabric • Promote use and support
• Licensing (Apache / OSS) • Advisory board
Hyperledger Fabric

Hyperledger Interface is REST APIs

Managing Secured and lightweight


identity, privacy, way to sandbox the
confidentiality and “Smart Contract”
auditability execution on the
validating nodes.
PKI-based
infrastructure to SDK with support for
enable a Go, Java and Node.js
permissioned
Blockchain
Manage the distributed ledger through a
peer-to-peer protocol, built on HTTP/2.
Pluggable consensus algorithm.
Default consensus based on PBFT/Sieve
Hyperledger Overview: System Context
Roles & Participants Membership & Network Entities

<uses > <to access>


Solution Provider Network Proprietor Membership Service

<is-a>
End User <is-a> Register Issue E-Cert
Users Certificates T-Cert
Chain Transactor Chain Validator
Manage
Chain Network User Certs.
Validating
Construct Node
<node in>
Transactions
Initiate Query Validate
Transactions Transactions Transactions
Forward
Transactions
V
Audit
Transactions <node in>
Non-Validating Maintain
Node Ledger Chain Network
Execute <types of>
Consensus &
Industry Network
<is-a> Update
Regional Network
Network Auditor Chain Auditor Ledger
g
Application Network
Hyperledger Membership Services Note: Deployment Transaction: Transactions that deploy
chaincode to a chain
Invocation Transaction: Transactions that invoke a function on
chaincode
Hyperledger Security Overview

Audit Support Permissioned Blockchain: PKI-based Certificates

Privacy-
preserving
Authentication Transaction Crypto
Confidentiality Secured

Identity & Role Management: Transaction Privacy: TLS Certificates for


Two Level (E-Cert, T-Certs) Anonymity + Un-linkability System-System Messaging
Hyperledger REST APIs

Example:

Number of Blocks in the Blockchain


Hyperledger Protocol
Open Blockchain peer-to-peer communication is Message passed between nodes encapsulated by
built on gRPC that allows bi-directional stream OpenChainMessage proto structure.
messaging

OpenChainMessage

gRPC
V Discovery Transaction Synchronization Consensus
V
Discover Deploy, Catch up Initiated when
peers in the Invoke and with other chain Tx is
network Query peers received

Nodes

OBC data structures, messages, and services are Message payloads are opaque byte arrays containing either
described using proto3. the Transaction object or Response.

Protocol Buffers serialize data structures for data Transaction is always associated with a chaincode spec that
transfer between peers. defines the chaincode and the execution environment.
Hyperledger Chaincode implements Smart Contract
Chaincode is application code deployed as a transaction to be distributed in the network, managed by validating nodes, and
implemented as Docker containers. Chaincode implemented in Go language.

Deploying Chaincode Chaincode State World State


• PUT_STATE
Deploy • GET_STATE
Transaction V • DEL_STATE
• RANGE-QUERY_STATE Chaincode
<launch> States
Chaincode
Chaincode
<gRPC Link> V
Invoke
Query

• Register with Validating Node using • Each Chaincode can define its own • World state refers to collection of
ChainCodeID persistent state variables (key-value) states of all deployed chaincode

• Call Invoke on Chaincode Interface to • Chaincode can update the state • Organized as a bucket-tree to enable
initialize based on Invoke Tx efficient crypto-hash
Hyperledger Ledger

Message Block{

<Hash>

Linked List of Blocks

}
Message BlockTransactions{
List of Tx World State Hash
}
Hash of the Block based on FIPS 202
Hyperledger Pluggable Consensus Framework

Consensus Framework Practical Byzantine Fault Tolerance (PBFT)

Interfaces all If there are f failures then need 3f+1


consensus plugins replicas in an asynchronous network to
need to implement
ensure data integrity
consensus

Identifies consensus
plugin used by SIEVE
validating peers
controller
Extends PBFT to handle non-deterministic
Enables consensus
transactions by leveraging Execute-Verify
plugin to interact with (EVE) replication mechanism.
OBC stack (e.g.
message handling)
helper
Hyperledger Fabric – Sample Application Architecture

Blockchain
application
Monitoring
Dashboards
Control, Search
Blockchain Blockchain
Application Fabric

Certificate
Blockchain Authority
Application
Chaincode Transactions
Non
Validator
REST Smart
Validators
Contrac
(Consensus)
t
Hyperledger
API

Blockchain
Application
Smart Contracts & Containers
LinuxONE Blockchain : Leveraging Open Source
OpenShift Cloud Foundry Juju BlueMix
Platform Connectors
as-a-Service For RedHat For SUSE, Ubuntu For Ubuntu IBM

Infrastructure Container Management


as-a-Service OpenStack
•OpenStack as Base
Technology Kubernetes Mesos
•Leverage Chef Patterns Docker
Nova Neutron Cinder )
(IBM SW & Open Source
SW in Chef Supermarket)

Enterprise Linux Distribution


Virtual
Infrastructure
z/VM KVM for IBM z

Physical Storage
Infrastructure

Switches

Each Distro (SUSE, RedHat, Ubuntu) will have its own flavor of a cloud stack
What are Docker basic functions?
Describes steps to build Build Store Run
container automatically
from source
Dockerfile for
Application

Docker Engine Build M Docker

Container A
Container N
Image N

Container B
Source Code Get N Run N
(Build) Image
Repository Repository …

Push new
Image to
Repository
Docker Engine

Host OS
Client
z Systems Server

22
High Level View of the Infrastructure

App Layer

Code execution environment,


blockchain datastructure
(synchronized through Hyperledger
consensus), and membership
service
System of Record
Virtual Images
Highly Secure
Private Cloud
IBM Systems
High Level Solution Components

Application

Middleware

Open Blockchain Peer node

Docker 1.11

SLES/Ubuntu/Redhat System of Record

Hypervisor Layer – z/VM

z Systems Hardware
Hyperledger Solutions Architecture…

Protocol REST
Programming

Database

Software Requirements Container

Linux Distribution Linux

LPAR KVM HSBN z/VM


Virtualization Technology Virtualization

IBM Systems
High level Infrastructure View
Use of Containers in Blockchain

• Chain codes run in Docker containers


– Isolated from one another
– Isolated from the peer control code
• Entire peer instance
– Can run in a Docker container
– Run in a VM
• Packaging, signing, install, execute as an
appliance
Hyperledger Chaincode container

9 We can build blockchain chain code as Docker images that hold your
business logic and automation code.

9 Docker containers can be created from those Docker images to run your
chain codes.

9 Consortium can share those chain code docker images via private registry
Hyperledger Chaincode implements Smart Contract
Chaincode is application code deployed as a transaction to be distributed in the network, managed by validating nodes, and implemented as
Docker containers. Chaincode implemented in Go language.

Deploying Chaincode Chaincode State World State

Deploy • PUT_STATE
V • GET_STATE
Transaction
• DEL_STATE Chaincode
• RANGE-QUERY_STATE States
<launch> Chaincode
<gRPC Link> V
Chaincode
Invoke
Query

• Register with Validating Node using • Each Chaincode can define its own • World state refers to collection of states
ChainCodeID persistent state variables (key-value) of all deployed chaincode

• Call Invoke on Chaincode Interface to • Chaincode can update the state based on • Organized as a bucket-tree to enable
initialize Invoke Tx efficient crypto-hash
Hyperledger Chaincode implements Smart Contract – SWIFT MT700

Deploying Chaincode/Smart contract : Chaincode Images Stored on Master Application


Peer: Invokes Event
Example : Create SWIFT MT700 table
Chaincode developed in go lang and Example : Create SWIFT MT700 table
packaged as a Docker image. Chaincode developed in go lang and
packaged as a Docker image.

Container N
Container N
Docker Engine

z/VM or zKVM or zACI


Build Store
Why Blockchain Dockerization on z Systems
Docker is available to use on z Systems platforms
– Same code and open source model as used in the industry today
– Exact Same Usability and Experience as on other platforms for developers
– Growing ecosystem of dockerized applications for z Systems and increasing community
engagement

Docker is Better on z Systems


– Greater System Capacity to run Typical Cloud Native Docker Workloads
– More containers per system lowers cost of operations for service providers
– With its Huge IO Bandwidth, z Systems excels at data oriented workloads running in
containers

z Systems Platform are built for workload consolidation – Docker enables it


High Security Business Network (HSBN) On LinuxONE
HSBN Architecture – Overview

High Security Business Network

Secure Service
Container

High-Security
Plan User

Other User

Hyperledger

Public Internet Bluemix


High Security Business Network Architecture – High Level

Logical Partition Isolation High Security Business Network


The high security business network is deployed as
an appliance into a Secure Service Container, which
provides the base infrastructure for hosting
blockchain services. The appliance combines
operating systems, Docker, middleware, and
Secure Service Container
software components that work autonomously to
Network#2 Network#3 provide core services and infrastructure with
Network#1 optimized security.

LinuxONE platform

Overview: https://console.ng.bluemix.net/docs/services/blockchain/etn_ssc.html
HSBN on LinuxONE : Reference Architecture

High Security Business Network

Bluemix SoftLayer Ubuntu Ubuntu

Security Layer 1

Chaincode 0
Chaincode 1

Chaincode j
Internet

Security Layer 2

Security Layer 3
Internet

Internet
Proxy Proxy
Peer 0 . . . Peer 3
Load
Balance
r
48 GB RAM
48 GB 48 GB
Memor Memor Secure Service Container
y y

High- Hipersockets PR/SM


Security
Plan Network Cards Crypto Cards
User
High Secure Blockchain Container Network

Secure Service Container ensures…

No system admin access, ever


• Once the appliance image is built,
OS access (ssh) is not possible
• Only Remote APIs available
• Memory access disabled
• Encrypted disk
• Debug data (dumps) encrypted

How the Secure Service Container boot sequence works…


Boot sequence
1. Firmware bootloader is loaded in memory
2. Firmware loads the software bootloader from disk
i. Check integrity of software bootloader
ii.Decrypt software bootloader
3. Software bootloader activate encrypted disks
i. Key stored in software bootloader (encrypted)
36
ii.Encryption/decryption done on the flight when accessing
appliance code and data
High Security Business Network (HSBN) – Hyperledger Container

Security Performance Compliance Simplicity

• Protection against misuse of privileged user • Hardware accelerators: • Highly auditable operating • Open-source Hyperledger
credentials: Blockchain operating environments and data Crypto optimization environment: Hardware code along with a single,
are protected by secured service containers against supports an environment and firmware audit logs integrated stack.
access and abuse by root users, system administrator that moves hashing and provide information about
credentials and other privileged user access. These symmetric encryption to any critical actions done to
Blockchain instances are locked so they must deployed to accelerators and optimizes system such as replacing
system models configured to our high security settings. digital signatures to reduce hardware or changing
• Malware protection: Blockchain data and software is drain on CPU performance. configurations. This allows
protected from malware being installed. such changes to be audited,
• Protection of peers from one another: Blockchain peers including verification of
are able to run in protected, isolated environments to unauthorized actions.
prevent deliberate or unintentional leakage of information
from one party's environment to another.
• Key safety: Identity, communications, and data privacy
are safeguarded by having all keys in a secure services
container. For our general-availability release, enrollment
key security will be further enhanced by implementing
“secure key” using our tamper-resistant crypto-card.
Additional security and privacy benefits

Benefit Value How

Prevent Edward Protection against misuse of Our differentiation is that IBM Secure Service Containers prevent system admins with
Snowden-type attack privileged user credentials access to the hardware from disabling the restrictions as it is possible on other
environments:
• No access to the data store
• No ability to modify any of the code in the container
• All data leaving the container is encrypted

HOW: We do this by encrypting all data on the disk; only the machine hardware has the
keys—there are no keys accessible to privileged users. Only authorized APIs are available
(not the underlying software). For example on other systems, system admins can disable
SELinux on the Redhat Enterprise Linux, then get full access to the system.

Data Privacy Participants in a business network Because each peer in the network has a copy of all data from all parties, we do not want
can’t see each other’s private data the owner of each peer to be able to look at the data stored in the peer. The container
prevents the machine owner from peeking /viewing the raw data. The only thing a peer
owner can do is start or stop a peer.

HOW: All peer data and code is encrypted all the time. The peer owner does not have the
keys.
Thank You

Manoj S P
Open Source Solution's Specialist
manojs@sg.ibm.com

You might also like