40
Blockchain Hackathon @ Innopolis Blockchain For Developers Alexander Chepurnoy (aka kushti) @chepurnoy IOHK Research

Blockchain For Developers (Talk at Innopolis Blockchain Hackathon 2016)

Embed Size (px)

Citation preview

Page 1: Blockchain For Developers (Talk at Innopolis Blockchain Hackathon 2016)

Blockchain Hackathon @ Innopolis

Blockchain For Developers

Alexander Chepurnoy(aka kushti)

@chepurnoyIOHK Research

Page 2: Blockchain For Developers (Talk at Innopolis Blockchain Hackathon 2016)

Background

● Nxt core developer

● smartcontract.com cofounder (left)

● Scorex since late 2014

● IOHK Research

Page 3: Blockchain For Developers (Talk at Innopolis Blockchain Hackathon 2016)

The talk is about

● How a developer can view a blockchain system

● What are open problems in blockchains

Page 4: Blockchain For Developers (Talk at Innopolis Blockchain Hackathon 2016)

Environment

● P2P network

● No central party

● Probabilistic broadcast

Page 5: Blockchain For Developers (Talk at Innopolis Blockchain Hackathon 2016)

Read Books!

● Cachin et al. „Introduction to Reliable and Secure Distributed Programming“

● Russian: „Введение в надежное и безопасное распределенное программирование“ (Качин и др.)

Page 6: Blockchain For Developers (Talk at Innopolis Blockchain Hackathon 2016)

P2P network

● Each node has own state

● The goal is to have replicated subset of it across the network

● In the presence of Byzantine adversaries!

● (so only honest nodes agree on the state)

● (and only eventually)

Page 7: Blockchain For Developers (Talk at Innopolis Blockchain Hackathon 2016)

A transaction

● Atomic state modifier

● Authenticated

Page 8: Blockchain For Developers (Talk at Innopolis Blockchain Hackathon 2016)

Minimal State

● Can answer the question „whether a transaction is valid and so applicable“

● apply(min_state, tx): (MinimalState | Error)

● apply(apply(min_state, tx), tx) is always Error

● In Bitcoin UTXO set

Page 9: Blockchain For Developers (Talk at Innopolis Blockchain Hackathon 2016)

Minimal State

● Transaction application is deterministic

● There's some initial (genesis) state hardcoded

● By applying the same sequence of transactions to the genesis state, two honest nodes got the same minimal state

● Thus we need for a guarantee every pair of honest nodes is eventually applying the same sequence of transactions!

Page 10: Blockchain For Developers (Talk at Innopolis Blockchain Hackathon 2016)

Blockchain

● Transactions packed into blocks

● Blocks are linked

Page 11: Blockchain For Developers (Talk at Innopolis Blockchain Hackathon 2016)

Blockchain

Page 12: Blockchain For Developers (Talk at Innopolis Blockchain Hackathon 2016)

Block Generator Election

● random party

● sybil-resistant

● efficient(min communication)

solution

● each party has limited queries to random oracle

● random oracle answers „yes“ with adjustable probability

● replace random oracle with a hash function

Page 13: Blockchain For Developers (Talk at Innopolis Blockchain Hackathon 2016)

Bitcoin's Proof-of-Work

● hash(blockheader) < target

● target T = 1 / difficulty

Page 14: Blockchain For Developers (Talk at Innopolis Blockchain Hackathon 2016)

GKL Model

● „The Bitcoin Backbone Protocol:Analysis and Applications“

by Garay / Kiayias / Leonardos

● slides: https://bitcoinschool.gr/slides/session2.pdf

Bitcoin consensus protocol properties:

● Common Prefix

● Chain Quality

● Chain Growth

Page 15: Blockchain For Developers (Talk at Innopolis Blockchain Hackathon 2016)

Common Prefix

no matter the strategy of the adversary, the chains of two honest parties will fork in the last k blocks with probability exponentially decreasing with k

Page 16: Blockchain For Developers (Talk at Innopolis Blockchain Hackathon 2016)

Chain Quality

any sequence of blocks in an honest party’s chain will contain some number of honest blocks with overwhelming probability

Page 17: Blockchain For Developers (Talk at Innopolis Blockchain Hackathon 2016)

Chain Growth

honest party's chain grows with some minimal pace with an overwhelming probability

Page 18: Blockchain For Developers (Talk at Innopolis Blockchain Hackathon 2016)

Bitcoin

● digital cash

● transaction is a set of token transfers

Page 19: Blockchain For Developers (Talk at Innopolis Blockchain Hackathon 2016)

Bitcoin: Transaction

Page 20: Blockchain For Developers (Talk at Innopolis Blockchain Hackathon 2016)

Bitcoin Script

output: OP_DUP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG

input: <sig> <pubKey>

Page 21: Blockchain For Developers (Talk at Innopolis Blockchain Hackathon 2016)

Bitcoin: UTXO set

● unspent outputs set

● enough to validate any transaction

● application is about removing outputs spent and add new ones

Page 22: Blockchain For Developers (Talk at Innopolis Blockchain Hackathon 2016)

Output Abstraction: Box

● minimal state is a set of closed boxes

● transaction opens some boxes and add new ones

● both UTXO and acccount model (Nxt, Ethereum)

Page 23: Blockchain For Developers (Talk at Innopolis Blockchain Hackathon 2016)

Abstract Transaction Authentication

● Box is protected by a proposition (e.g. pubkey)

● To be open with a proof (e.g. a signature)

● check(proposition, proof, message)

Page 24: Blockchain For Developers (Talk at Innopolis Blockchain Hackathon 2016)

Memory Pool

● contains unconfirmed transaction

● inconsistent across a network

Page 25: Blockchain For Developers (Talk at Innopolis Blockchain Hackathon 2016)

Vault (Wallet)

● node-specific information

● e.g. transactions for selected pubkeys

Page 26: Blockchain For Developers (Talk at Innopolis Blockchain Hackathon 2016)

Node view

(MinimalState, Blockchain, MemoryPool, Wallet)

(MinimalState, Blockchain) is eventually the same for all the honest nodes

Page 27: Blockchain For Developers (Talk at Innopolis Blockchain Hackathon 2016)

What app developer should know

● Rollbacks are possible!

● Transaction is always visible before inclusion

● Frontrunning / replay attacks

● Malleability

Page 28: Blockchain For Developers (Talk at Innopolis Blockchain Hackathon 2016)

Incentives and Rationality

● why participants are following a protocol?

● do they do some additional things altruistically?

Page 29: Blockchain For Developers (Talk at Innopolis Blockchain Hackathon 2016)

Modifications

● alternative consensus protocols (Proof-of-Stake etc)

● richer transactional models (NameCoin, Ethereum, ZCash)

● alternative log structures (Bitcoin-NG, GHOST/SPECTRE)

● incentivization of certain activities (Permacoin, Rollerchain)

Page 30: Blockchain For Developers (Talk at Innopolis Blockchain Hackathon 2016)

Bitcoin's Troughput (TPS)

● 7 ??? no

● 2-3 in fact

● 1/600 in worse case

https://www.reddit.com/r/Bitcoin/comments/3cgft7/largest_transaction_ever_mined_999657_kb_consumes/

Page 31: Blockchain For Developers (Talk at Innopolis Blockchain Hackathon 2016)

Better throughput

● Bitcoin-NG

● GHOST/SPECTRE

Page 32: Blockchain For Developers (Talk at Innopolis Blockchain Hackathon 2016)

Blockchain Pruning

Page 33: Blockchain For Developers (Talk at Innopolis Blockchain Hackathon 2016)

Rollerchain

● http://arxiv.org/abs/1603.07926

● „Rollerchain, a Blockchain With Safely Pruneable Full Blocks“

Page 34: Blockchain For Developers (Talk at Innopolis Blockchain Hackathon 2016)

Rollerchain

● Only last n full blocks to be stored collectively

● and n state snapshots

● Each miner stores k state snapshots

Page 35: Blockchain For Developers (Talk at Innopolis Blockchain Hackathon 2016)

Rollerchain

● New node can download a historical snapshot

● Fullblocks not needed for mining could be thrown away

● Blockheaders are to be stored forever, so must be small

Page 36: Blockchain For Developers (Talk at Innopolis Blockchain Hackathon 2016)

PoPoW with sublinear complexity

● „Proofs of Proofs of Work with Sublinear Complexity“

Kiayias et. al. (FC 16)

● chain validity could be validated with only last k headers

● efficient sidechains

● static difficulty only atm

Page 37: Blockchain For Developers (Talk at Innopolis Blockchain Hackathon 2016)

Unload the chain

● Move things off-chain

● Sidechains

● Avoid all the transactions execution(RsCoin)

Page 38: Blockchain For Developers (Talk at Innopolis Blockchain Hackathon 2016)

Offchain

● Lightning Network

● Offchain contracts(SMC/SMP)

Page 39: Blockchain For Developers (Talk at Innopolis Blockchain Hackathon 2016)

Smart Contracts

● Ethereum isn't scalable

● Hawk

● Enigma

Page 40: Blockchain For Developers (Talk at Innopolis Blockchain Hackathon 2016)

Questions?

Twitter: @chepurnoy

Mail: [email protected]