simplifying analytical reporting for blockchain applications · -joining blockchain data with other...

35
IBM Db2 / © 2018 IBM Corporation Simplifying Analytical Reporting for Blockchain Applications Vinayak Agrawal Developer Advocate for Analytics [email protected] @dapper_hack_er

Upload: others

Post on 20-May-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Simplifying Analytical Reporting for Blockchain Applications · -Joining Blockchain data with other enterprise data set (Hadoop, Hive, Spark, external RDBMs) for complex use cases

IBM Db2 / © 2018 IBM Corporation

Simplifying Analytical Reporting for Blockchain Applications — Vinayak Agrawal Developer Advocate for Analytics [email protected] @dapper_hack_er

Page 2: Simplifying Analytical Reporting for Blockchain Applications · -Joining Blockchain data with other enterprise data set (Hadoop, Hive, Spark, external RDBMs) for complex use cases

Who are we?

2

Developer Advocates for Analytics We build code patterns for various analytics use-cases based on customer requests.

Page 3: Simplifying Analytical Reporting for Blockchain Applications · -Joining Blockchain data with other enterprise data set (Hadoop, Hive, Spark, external RDBMs) for complex use cases

What were we trying to do?

• Build a sample insurance application for an insurance company.

Our Blockchain application has 4 peers:

1.Shop – A storefront that sells expensive sporting goods. Also sells insurance on them.

2.Insurance Organization – Partners with shop and offers insurance

3.Police – Cerifies claims filed by customers.

4.Repair Shop – Administers repair requests.

3

Page 4: Simplifying Analytical Reporting for Blockchain Applications · -Joining Blockchain data with other enterprise data set (Hadoop, Hive, Spark, external RDBMs) for complex use cases

Problem: Blockchain becomes a transaction repository. So how to find insights about the business running on it?

4

1. How many Insurance Policy were sold?

2. How were they sold over a period of time?

3. What were the products mostly bought with insurance?

1. How much revenue did the insurance company make?

2. Which insurance policy bought the maximum revenue?

1. How many insurance claims were filed?

2. For which product the maximum claims were filed?

3. How much $$ was paid out in claims?

1. How many claims were filed which couldn’t be verified by the policy?

2. Which customer filed fraud claims?

Page 5: Simplifying Analytical Reporting for Blockchain Applications · -Joining Blockchain data with other enterprise data set (Hadoop, Hive, Spark, external RDBMs) for complex use cases

Options we Tried with Hyperledger Fabric Blockchain (1)

5

1. Fabric SDK

Our Observations:

1. Learn Go

2. Learning Curve

3. Limited Functions

4. No Analytical functions

Lets Code!!

Page 6: Simplifying Analytical Reporting for Blockchain Applications · -Joining Blockchain data with other enterprise data set (Hadoop, Hive, Spark, external RDBMs) for complex use cases

6

Options we Tried with Hyperledger Fabric Blockchain (2)

2. Peer chaincode Cli

This is what it looks like

Page 7: Simplifying Analytical Reporting for Blockchain Applications · -Joining Blockchain data with other enterprise data set (Hadoop, Hive, Spark, external RDBMs) for complex use cases

Our Concerns with Custom Approach

7

Skill gap

Learning Curve

Custom Code Maintainability

Security

Access Control

Page 8: Simplifying Analytical Reporting for Blockchain Applications · -Joining Blockchain data with other enterprise data set (Hadoop, Hive, Spark, external RDBMs) for complex use cases

For our Customer, we needed Ease to Use, Rich Analytical Functions, Stability/Scalability and Security

8

Easy to Use – Python, SQL

Bridging the Skill Gap

Analytical Intelligence

Rich Analytical Functions

Page 9: Simplifying Analytical Reporting for Blockchain Applications · -Joining Blockchain data with other enterprise data set (Hadoop, Hive, Spark, external RDBMs) for complex use cases

We needed Ease to Use, Rich Analytical Functions, Stability/Scalability and Security

9

Stability and Scalability

Performance and Concurrency

Security like a data management solution for access control

Page 10: Simplifying Analytical Reporting for Blockchain Applications · -Joining Blockchain data with other enterprise data set (Hadoop, Hive, Spark, external RDBMs) for complex use cases

We found solution to all those problems with IBM Db2. So we developed something new in Db2.

1

0

Page 11: Simplifying Analytical Reporting for Blockchain Applications · -Joining Blockchain data with other enterprise data set (Hadoop, Hive, Spark, external RDBMs) for complex use cases

Solution Simplified View

1

1

1. A Db2 federation wrapper that provides:

– Connectivity to Blockchain Transactions via Hyperledger Rest API

– Rewriting SQL queries into equivalent Hyperledger API calls to query data.

2. Using Zeppelin (can use any JDBC supported tool) as end user tool to connect to Db2.

3. Query Blockchain via Zeppelin using SQL.

Honors the security measures in place at Blockchain level and Db2 level for end users.

End User

User Interface

JDBC connection

Federation

Hyperledger Fabric

1 2

3

4

How does the solution work?

Page 12: Simplifying Analytical Reporting for Blockchain Applications · -Joining Blockchain data with other enterprise data set (Hadoop, Hive, Spark, external RDBMs) for complex use cases

• The Fabric ledger is maintained by each peer and includes the blockchain and world-state

• A separate ledger is maintained for each channel the peer joins

• Transaction read/write sets are written to the blockchain

• Channel configurations are also written to the blockchain

• The worldstate can be either LevelDB (default) or CouchDB

• LevelDB is a simple key/value store • CouchDB is a document store that allows

complex queries • The smart contact Contract decides what is

written to the worldstate

Overview of Hyperledger Fabric Data Model (Txs & World-State)

How does the solution work?

Page 13: Simplifying Analytical Reporting for Blockchain Applications · -Joining Blockchain data with other enterprise data set (Hadoop, Hive, Spark, external RDBMs) for complex use cases

Difference between Transaction and World State

1

3

# Transaction Initiator Receiver Amount

1 Create a/c Cash Matt £1000

2 Create a/c Cash Dave £2000

3 Transfer Matt Dave £100

4 Create a/c Cash Ant £500

5 Transfer Ant Matt £50

6 Transfer Ant Dave £200

7 Transfer Dave Matt £100

8 Transfer Dave Ant £50

9 Transfer Matt Ant £50

Transactions

• What’s Dave’s balance?

• Does Matt have funds to clear a £1000 transaction? (Assuming no overdraft)

Matt.balance = £1000

Dave.balance = £2150

Ant.balance = £350

World State • It is clearly not feasible to reparse the entire transaction

log to complete a new transaction • Blockchains often include an associated database (world

state) – e.g. Hyperledger Fabric • Transactions become a set of creates, reads, updates

and deletes of records in this data store

Our Focus from Analytics Perspective

How does the solution work?

Page 14: Simplifying Analytical Reporting for Blockchain Applications · -Joining Blockchain data with other enterprise data set (Hadoop, Hive, Spark, external RDBMs) for complex use cases

Architecture

1

4

IBM Db2 Big SQL

How does the solution work?

Fabric

SDK

Wrapper

Page 15: Simplifying Analytical Reporting for Blockchain Applications · -Joining Blockchain data with other enterprise data set (Hadoop, Hive, Spark, external RDBMs) for complex use cases

Runtime Flow

1

5

How does the solution work?

Fabric

SDK

Wrapper

Page 16: Simplifying Analytical Reporting for Blockchain Applications · -Joining Blockchain data with other enterprise data set (Hadoop, Hive, Spark, external RDBMs) for complex use cases

End use Experience (Peer chaincode vs Db2)

1

6

Page 17: Simplifying Analytical Reporting for Blockchain Applications · -Joining Blockchain data with other enterprise data set (Hadoop, Hive, Spark, external RDBMs) for complex use cases

Our Vision

• Easy and Secured: (Addressing the Skill Gap)

-In place querying, reporting & analytics of Blockchain data using the rich SQL language support provided without compromising the Blockchain security model.

• Data Virtualization: (Fits into Analytics Infrastructure)

-Joining Blockchain data with other enterprise data set (Hadoop, Hive, Spark, external RDBMs) for complex use cases without additional work

-Immediate support for all Db2 based products through Federation

17

Blockchain Traditional Database

Reporting Tools

Connect to Blockchain just like any other database

Data Access Layer

Data Repositories

Page 18: Simplifying Analytical Reporting for Blockchain Applications · -Joining Blockchain data with other enterprise data set (Hadoop, Hive, Spark, external RDBMs) for complex use cases

What is the current status and how you can try it?

Currently this enhancement is coming out in IBM Db2 11.5 (June 27th ).

You can try it out by downloading/cloud IBM Db2 11.5 Free Version at (clickable):

Db2 Docker Image

Db2 on IBM Cloud

Db2 on AWS

Db2 Desktop Edition

1

8

Page 19: Simplifying Analytical Reporting for Blockchain Applications · -Joining Blockchain data with other enterprise data set (Hadoop, Hive, Spark, external RDBMs) for complex use cases

Resources

[Video] Blockchain Analytics with Db2 - https://youtu.be/3tPBdIr0lA4

For Demo, Details and latest updates,

Follow Db2 on Twitter: @IBM_Db2luw

Follow me on Twitter: @dapper_hack_er

1

9

Page 20: Simplifying Analytical Reporting for Blockchain Applications · -Joining Blockchain data with other enterprise data set (Hadoop, Hive, Spark, external RDBMs) for complex use cases

Thank you

20 IBM Db2 Augmented Data Explorer/ © 2018 IBM Corporation

Vinayak Agrawal

Developer Advocate

[email protected]

+1-412-660-7784

Page 21: Simplifying Analytical Reporting for Blockchain Applications · -Joining Blockchain data with other enterprise data set (Hadoop, Hive, Spark, external RDBMs) for complex use cases

21 IBM Db2 / © 2018 IBM Corporation

Page 22: Simplifying Analytical Reporting for Blockchain Applications · -Joining Blockchain data with other enterprise data set (Hadoop, Hive, Spark, external RDBMs) for complex use cases

Demo – Screenshots available in Appendix

22

Page 23: Simplifying Analytical Reporting for Blockchain Applications · -Joining Blockchain data with other enterprise data set (Hadoop, Hive, Spark, external RDBMs) for complex use cases

Demo – Insurance Business Network

We will be using a insurance application for this demo which has 4 participants (peers) in the business network. 1.Shop - A business front that sells cell phones, bicycles and ski. They also sell the insurance for the respective products.

2.Insurance Organization - The organization that is the insurance provider of policies and is also responsible for managing and processing claims.

3.Police - Police works in the network to provide validity on a insurance claim regarding theft of the asset.

4.Repair Shop - If a claim is filed to be repaired then repair shop gets request from insurance agency and completes the repair. The customer only interacts with the shop to buy an asset and insurance organization to file claims if needed.

Page 24: Simplifying Analytical Reporting for Blockchain Applications · -Joining Blockchain data with other enterprise data set (Hadoop, Hive, Spark, external RDBMs) for complex use cases

Demo – Insurance Business Network

24

Page 25: Simplifying Analytical Reporting for Blockchain Applications · -Joining Blockchain data with other enterprise data set (Hadoop, Hive, Spark, external RDBMs) for complex use cases

Create the Blockchain Wrapper in Db2

25

Page 26: Simplifying Analytical Reporting for Blockchain Applications · -Joining Blockchain data with other enterprise data set (Hadoop, Hive, Spark, external RDBMs) for complex use cases

Creating Username Mapping, Nickname and Querying

26

Page 27: Simplifying Analytical Reporting for Blockchain Applications · -Joining Blockchain data with other enterprise data set (Hadoop, Hive, Spark, external RDBMs) for complex use cases

27

Sample Questions for Insurance Peer

Page 28: Simplifying Analytical Reporting for Blockchain Applications · -Joining Blockchain data with other enterprise data set (Hadoop, Hive, Spark, external RDBMs) for complex use cases

28

Insurance Peer Exploring Data

Page 29: Simplifying Analytical Reporting for Blockchain Applications · -Joining Blockchain data with other enterprise data set (Hadoop, Hive, Spark, external RDBMs) for complex use cases

29

Insurance Peer identifying interesting columns

Page 30: Simplifying Analytical Reporting for Blockchain Applications · -Joining Blockchain data with other enterprise data set (Hadoop, Hive, Spark, external RDBMs) for complex use cases

30

Performing Analytical Queries

Page 31: Simplifying Analytical Reporting for Blockchain Applications · -Joining Blockchain data with other enterprise data set (Hadoop, Hive, Spark, external RDBMs) for complex use cases

31

Performing Analytical Query (II)

Page 32: Simplifying Analytical Reporting for Blockchain Applications · -Joining Blockchain data with other enterprise data set (Hadoop, Hive, Spark, external RDBMs) for complex use cases

32

Performing Analytical Query (III)

Page 33: Simplifying Analytical Reporting for Blockchain Applications · -Joining Blockchain data with other enterprise data set (Hadoop, Hive, Spark, external RDBMs) for complex use cases

33

Performing COMPLEX Analytical Query (IV)

Page 34: Simplifying Analytical Reporting for Blockchain Applications · -Joining Blockchain data with other enterprise data set (Hadoop, Hive, Spark, external RDBMs) for complex use cases

34

Performing Complex Analytical Query (V)

Page 35: Simplifying Analytical Reporting for Blockchain Applications · -Joining Blockchain data with other enterprise data set (Hadoop, Hive, Spark, external RDBMs) for complex use cases

35 IBM Db2 / © 2018 IBM Corporation