Top Banner
Hashgraph as Code
62

Hashgraph as Code

Jan 21, 2018

Download

Technology

Calvin Cheng
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Hashgraph as Code

Hashgraph as Code

Page 2: Hashgraph as Code

Hashgraph as Code by Calvin Cheng

@calvinchengx

www.calvinx.com

Page 3: Hashgraph as Code

Pre-amble

Page 4: Hashgraph as Code

A Short History of Computer Science

There are only 2 hard problems in computer science

Page 5: Hashgraph as Code

A Short History of Computer Science

cache invalidation,

naming things; and

off-by-1 errors

Page 6: Hashgraph as Code

Why Distributed Systems?

1. Foundation: for cloud computing

2. Scale: large data set

3. Live site: being fault tolerant when machines fail

4. Latency: no one likes to wait

5. Intelligence: insights from data to make good decisions

Page 7: Hashgraph as Code

A Short History of Distributed Systems

There are only 2 hard problems in distributed systems

Page 8: Hashgraph as Code

A Short History of Distributed Systems

2. Exactly-once delivery

1. Guaranteed order of messages

2. Exactly-once delivery

Page 9: Hashgraph as Code

Solving the Distributed Systems Problem

Page 10: Hashgraph as Code

Allegory

Byzantine General Belisariusref: https://medium.com/network-economics/bitcoin-the-byzantine-generals-problem-245a41f93157

Page 11: Hashgraph as Code

Allegory

Imagine that several divisions of the Byzantine army are camped outside an enemy city, each division commanded by its own general. The generals can communicate with one another only by messenger. After observing the enemy, they must decide upon a common plan of action. However, some of the generals may be traitors, trying to prevent the loyal generals from reaching agreement. The generals must decide on when to attack the city, but they need a strong majority of their army to attack at the same time. The generals must have an algorithm to guarantee that (a) all loyal generals decide upon the same plan of action, and (b) a small number of traitors cannot cause the loyal generals to adopt a bad plan. The loyal generals will all do what the algorithm says they should, but the traitors may do anything they wish. The algorithm must guarantee condition (a) regardless of what the traitors do. The loyal generals should not only reach agreement, but should agree upon a reasonable plan.

Page 12: Hashgraph as Code

Consensus

1. Leader-based Systems: PBFT, Paxos, RAFT (databases: Google’s Spanner, Apache Cassandra etc)

2. Proof-of-Work: bitcoin, ethereum

3. Proof-of-Stake (economy-based): Iota, Casper, Tezos, EOS

4. Voting-based systems: none, because no one likes to wait

5. Virtual voting: hashgraph, ABFT as a new and mathematically provable approach?

as covered by Mance Harmon / Leemon Baird

Page 13: Hashgraph as Code

Blockchain vs Hashgraph Consensusas covered by Mance Harmon / Leemon Baird

Page 14: Hashgraph as Code

Blockchain vs Hashgraph Consensus1. Data Storage:

Blockchain data is stored in blocks (all transactions made in a given period of time)Hashgraph data is stored in events

2. Data Structure:Blockchain - consensus on who has right to add blockHashgraph - recorded as a graph of connections

3. Protocol:Blockchain - mining (PoW) or PoSHashgraph - virtual voting

Page 15: Hashgraph as Code

Virtual Votingas covered by Mance Harmon / Leemon Baird and Paul Madsen

ref: https://medium.com/hashgraph/i-want-your-vote-oh-wait-i-already-know-it-e1faa50b31ad

Page 16: Hashgraph as Code

Virtual Voting

1. Hashgraph is divided in roundsEvery time one event can connect >2/3 of the first events of current round by more paths than 2/3 of the population.(We say one node strongly sees another node)

2. Do we agree on data contained in the first row of events?First few nodes of new round will vote to say if they will agree on the data contained in the first row of events of the preceding round. To do so, they just need to verify that they are connected to these nodes.

Page 17: Hashgraph as Code

Virtual Voting

3. Last stage is to collect the 3rd round node answersUsing 4th round nodes, strongly see the 3rd round node. If one of the 4th round node succeed in collecting a super majority (more than 2/3 of the population) of positive votes upon the data in the 2nd round, then the consensus is found.

Page 18: Hashgraph as Code

Hashgraph as Code

• Design Overview (developer docs in diagrams)

• Swirlds SDK Demos (Java)

• Babble (golang implementation with batteries)

• [Optional] Experiments

• REST and websocket w/Swirlds SDK

• JavaFX desktop app

Page 19: Hashgraph as Code

Design Overview

• SwirldMain

• SwirldState or SwirldState2

• Platform

• FastCopyable

• Browser and Console for visualisation

Page 20: Hashgraph as Code

Design Overview

Page 21: Hashgraph as Code

Code Organisation (JavaDocs), V17.09.15

Page 22: Hashgraph as Code

Swirlds SDK Demos (Java)

• Eclipse Setup

• IntelliJ Setup

• HelloSwirldDemo

• GameDemo

• HashgraphDemo

• CryptocurrencyDemo

• FilesystemDemo

Page 23: Hashgraph as Code

Setup Gotchas

macOS

• brew install jdk8

Page 24: Hashgraph as Code

Eclipse Setup (Swirlds SDK)

Page 25: Hashgraph as Code

IntelliJ Setup (Swirlds SDK)

Page 26: Hashgraph as Code

IntelliJ Setup (command line)

> java -jar swirlds.jar

Page 27: Hashgraph as Code

IntelliJ Setup (config.txt)

Page 28: Hashgraph as Code

IntelliJ Setup (Swirlds SDK)

Page 29: Hashgraph as Code

IntelliJ Setup (Swirlds clean)

https://github.com/calvinchengx/SwirldsProject

Page 30: Hashgraph as Code

IntelliJ Setup (Swirlds clean)

Page 31: Hashgraph as Code

HelloSwirldDemo

Page 32: Hashgraph as Code

GameDemo

Page 33: Hashgraph as Code

HashgraphDemo

Page 34: Hashgraph as Code

CryptocurrencyDemo

Page 35: Hashgraph as Code

CryptocurrencyDemo

Page 36: Hashgraph as Code

FilesystemDemo

Page 37: Hashgraph as Code

FilesystemDemo

Page 38: Hashgraph as Code

Babble (golang)

• Design Overview (equivalence to Swirlds Java)

• IntelliJ Setup (golang workspace)

• Chat Demo

Page 39: Hashgraph as Code

Babble (golang)

Caveats:

• This is an unofficial implementation

• There are no guarantees that the hashgraph ABFT is properly or fully implemented

• You WILL need a license from Swirlds (the patent holder) if you want to use this open source project on your projects

Page 40: Hashgraph as Code

Design Overview

Page 41: Hashgraph as Code

Design Overview

• De-coupled architecture to facilitate language agnostic implementation

• babble/main.go as example implementation

• uses docker to run a example test net and simple chat demo

• Hashicorp’s terraform for deployment on AWS

Page 42: Hashgraph as Code

Babble (golang) - make test

Page 43: Hashgraph as Code

Babble (golang) - demo app

Page 44: Hashgraph as Code

Babble (golang) - make up

Page 45: Hashgraph as Code

Babble (golang) - make demo

Page 46: Hashgraph as Code

Babble (golang) - hashgraph

Page 47: Hashgraph as Code

Babble (golang) - net

Page 48: Hashgraph as Code

Implications

• General purpose Hashgraph(like Ethereum is a general purpose blockchain)

• Specific purpose Hashgraph

• missing gap in autonomous AI systems

• consortium solutions (super API system)

Page 49: Hashgraph as Code

“AI” and Hashgraph

David Allen Cohen ref: https://medium.com/hashgraph/ai-3-0-why-hashgraph-and-how-it-will-

revolutionize-blockchain-and-ai-86a6ef715c9f

Page 50: Hashgraph as Code

“AI” and Hashgraph

While traditional blockchains such as that which underlies Bitcoin have gained popularity, many have major scalability issues due to external mining and its impact on transaction costs and in particular, unsustainable energy costs expended in the transaction settlement process.

Even so, there is a new category of what is called blockchain-free cryptocurrencies that are designed for different domains that attempt to remedy these scalability issues which use different forms of a Directed Acyclic Graph (DAG) such as DAGCoin, IOTA for IoT applications, ByteBall, and others that are emerging. While these may have found suitable use cases, in evaluating these technologies, I determined that none would meet all of my requirements (scalability, speed, footprint, fault tolerance, cybersecurity, AI integration, communications, etc for initial use in permissioned networks.

Page 51: Hashgraph as Code

“AI” and Hashgraph

• Self optimisation

• Self configuration

• Peer-to-peer coordination

• Decentralised “AI”

• Fundamentals for machine economy

Page 52: Hashgraph as Code

Fun Tech Projects?

• Gateway Server: REST API, websocket to Swirlds

• Desktop App: JavaFX to Swirlds SDK

• Gateway Server: REST API, websocket to Babble (golang)

• Hashgraph on RaspberryPi (Raspbian)?

• Hashgraph on Mobile?

• Hashgraph in Android?

• Swift port for iOS?

Page 53: Hashgraph as Code

Interesting Questions?

• How would quantum computing, quantum cryptography impact blockchain, hashgraph and various distributed ledger technology?

Page 54: Hashgraph as Code

Impactful Applications?

• Decentralised Deep Learning (e.g. anonymised medical data for disease diagnosis/prediction)

• Peer-to-peer coordination (e.g. autonomous vehicle fleet, drones, energy systems)

• Service transformation (e.g. cross jurisdiction, cross agency systems for governments, municipalities and cities)

• Financial services (e.g. remittance services, decentralised stock exchange?)

Page 55: Hashgraph as Code

Impactful Applications?

Page 56: Hashgraph as Code

Impactful Applications?

Page 57: Hashgraph as Code

Impactful Applications?

ref: https://smartnet.niua.org/sites/default/files/resources/rb162799_mnd_uss_bk4_seaports_final.pdf

Page 58: Hashgraph as Code

Impactful Applications?

• containerisation technology for ports can be thought of as a ‘standardised’ physical goods / supply chain system

• like app stores can be thought of as a ‘standardised’ distribution channel on mobile devices

• like docker can be thought of as a ‘standardised’ application deployment methodology

• SO, can distributed ledger technology be thought of as a ‘standardised’ data sharing methodology between members in the shared world (consortium)?

Page 59: Hashgraph as Code

Impactful Applications?

• And of course, not forgetting - are CryptoKitties impactful too?

Page 60: Hashgraph as Code

Advertisement

• Deep Tech Nexus (“AI”, cybersecurity, crypto etc)

• Invests in Deep Tech startups

• Invests in Med Tech startups

• Market Opportunities for portfolio companies

• Talent Spotting for portfolio companies

ref: http://www.straitstimes.com/business/companies-markets/sginnovate-to-invest-in-20-deep-tech-startups

Page 61: Hashgraph as Code

Advertisement

Are you a startup founder or a scientist/engineer?

https://sginnovate.com/join-our-community

Apprenticeship program: pairing top tech students to deep tech startups

https://sginnovate.com/apprenticeship

Opportunities in our portfolio companies?

http://bit.ly/sgitalent

Page 62: Hashgraph as Code

Q&A