hashgraph as code

62
Hashgraph as Code

Upload: calvin-cheng

Post on 21-Jan-2018

543 views

Category:

Technology


0 download

TRANSCRIPT

Hashgraph as Code

Hashgraph as Code by Calvin Cheng

@calvinchengx

www.calvinx.com

Pre-amble

A Short History of Computer Science

There are only 2 hard problems in computer science

A Short History of Computer Science

cache invalidation,

naming things; and

off-by-1 errors

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

A Short History of Distributed Systems

There are only 2 hard problems in distributed systems

A Short History of Distributed Systems

2. Exactly-once delivery

1. Guaranteed order of messages

2. Exactly-once delivery

Solving the Distributed Systems Problem

Allegory

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

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.

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

Blockchain vs Hashgraph Consensusas covered by Mance Harmon / Leemon Baird

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

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

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.

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.

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

Design Overview

• SwirldMain

• SwirldState or SwirldState2

• Platform

• FastCopyable

• Browser and Console for visualisation

Design Overview

Code Organisation (JavaDocs), V17.09.15

Swirlds SDK Demos (Java)

• Eclipse Setup

• IntelliJ Setup

• HelloSwirldDemo

• GameDemo

• HashgraphDemo

• CryptocurrencyDemo

• FilesystemDemo

Setup Gotchas

macOS

• brew install jdk8

Eclipse Setup (Swirlds SDK)

IntelliJ Setup (Swirlds SDK)

IntelliJ Setup (command line)

> java -jar swirlds.jar

IntelliJ Setup (config.txt)

IntelliJ Setup (Swirlds SDK)

IntelliJ Setup (Swirlds clean)

https://github.com/calvinchengx/SwirldsProject

IntelliJ Setup (Swirlds clean)

HelloSwirldDemo

GameDemo

HashgraphDemo

CryptocurrencyDemo

CryptocurrencyDemo

FilesystemDemo

FilesystemDemo

Babble (golang)

• Design Overview (equivalence to Swirlds Java)

• IntelliJ Setup (golang workspace)

• Chat Demo

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

Design Overview

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

Babble (golang) - make test

Babble (golang) - demo app

Babble (golang) - make up

Babble (golang) - make demo

Babble (golang) - hashgraph

Babble (golang) - net

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)

“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

“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.

“AI” and Hashgraph

• Self optimisation

• Self configuration

• Peer-to-peer coordination

• Decentralised “AI”

• Fundamentals for machine economy

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?

Interesting Questions?

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

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?)

Impactful Applications?

Impactful Applications?

Impactful Applications?

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

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)?

Impactful Applications?

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

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

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

Q&A