flyclient - scaling bitcoin · • less block time-> larger spv client • 40 mb in bitcoin •...

Post on 03-Oct-2020

1 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

FLYCLIENT

Loi Luu, Benedikt Bünz, Mahdi Zamani

SUPER LIGHT CLIENT FOR CRYPTOCURRENCIES 

trans: H( )

prev: H( )

trans: H( )

prev: H( )trans: H( )

prev: H( )

Hash chain of blocks

H( ) H( )

H( ) H( ) H( ) H( )

transaction transaction transaction transaction

Hash tree (Merkle tree) of transactions in each block

Recall: Bitcoin blockchain format

2

trans: H( )

prev: H( )

trans: H( )

prev: H( )trans: H( )

prev: H( )

Hash chain of blocks

H( ) H( )

H( ) H( ) H( ) H( )

transaction transaction transaction transaction

Validity of a blockchain

✅✅✅✅

1. Transactions are valid2. Merkle tree correct

3

mrkl_root: H( )

prev: H( )

mrkl_root: H( )

hash: 0x0000

nonce: 0x7a83

prev: H( )

hash: hash: 0x3485...hash: 0x6a1f...

nonce: 0x0000...nonce: 0x0001...

hash: 0xc9c8...

nonce: 0x0002...

hash: 0x300c...

nonce: 0xffff...

hash:

nonce: 0x0000...

hash: 0xd0c7...

nonce: 0x0001...

hash: 0x0224...hash: 0x0000...

nonce: 0xf77e...

mrkl_root: H( )

prev: H( )

hash: hash: 0x3485...hash: 0x6a1f...

nonce: 0x0000...nonce: 0x0001...

hash: 0xc9c8...

nonce: 0x0002...

hash: 0x300c...

nonce: 0xffff...

hash:

nonce: 0x0000...

hash: 0xd0c7...

nonce: 0x0001...

hash: 0x0224...hash: 0x0000...

nonce: 0xf77e...

≤ 00000000000000001FB893000000000000000000000000000000000000000000

70+ leading zeroes required...

Hash

3. Validity of a block header

4

Two valid blockchains?This is the

blockchain

No this is the blockchain

5

Longest chain rule

❗�

Take the longest chain!Harder to produce.

6

Proof of work conjecture

• Honest mining is a dominant equilibrium strategy • The majority of miners act rational

• Implies that longest chain follows the rules of the network

• Sleeping beauty property: You can always distinguish honest and honest chains after being offline

• Does not (necessarily) hold for proof of stake

• As long as one of the nodes you are connected to is honest you will find the best chain

7

Blockchain size: A growing problem

How am I going to store 150 GB

8

trans: H( )

prev: H( )

trans: H( )

prev: H( )trans: H( )

prev: H( )

H( ) H( )

H( ) H( ) H( ) H( )

transaction transaction transaction transaction

Simple Payment Verifying Client (Satoshi 2008)

Just store the block headers

9

mrkl_root: H( )

prev: H( )

mrkl_root: H( )

hash: 0x0000

nonce: 0x7a83

prev: H( )

hash: hash: 0x3485...hash: 0x6a1f...

nonce: 0x0000...nonce: 0x0001...

hash: 0xc9c8...

nonce: 0x0002...

hash: 0x300c...

nonce: 0xffff...

hash:

nonce: 0x0000...

hash: 0xd0c7...

nonce: 0x0001...

hash: 0x0224...hash: 0x0000...

nonce: 0xf77e...

mrkl_root: H( )

prev: H( )

hash: hash: 0x3485...hash: 0x6a1f...

nonce: 0x0000...nonce: 0x0001...

hash: 0xc9c8...

nonce: 0x0002...

hash: 0x300c...

nonce: 0xffff...

hash:

nonce: 0x0000...

hash: 0xd0c7...

nonce: 0x0001...

hash: 0x0224...hash: 0x0000...

nonce: 0xf77e...

≤ 00000000000000001FB893000000000000000000000000000000000000000000

70+ leading zeroes required...

Hash

Verify block headers

10

Use the longest chain rule

❗�

11

trans: H( )

prev: H( )

trans: H( )

prev: H( )trans: H( )

prev: H( )

H( ) H( )

H( ) H( ) H( ) H( )

transaction transaction transaction transaction

Can’t verify all transactions (but that’s ok)

❓❓❓❓

Assumption:Longest chain is produced honestly

12

trans: H( )

prev: H( )

trans: H( )

prev: H( )trans: H( )

prev: H( )

transaction

Can verify specific transactions (with help)

13

trans: H( )

prev: H( )

trans: H( )

prev: H( )trans: H( )

prev: H( )

H( )

 

transaction

Can verify specific transactions (with help)

 

 

14

15

SPV Properties and Problems• Can determine the longest chain

• Can verify transaction inclusion

• Does not grow with #transactions

• 80 bytes * #blocks (Bitcoin)

• 508 bytes * #blocks (Ethereum)

• Sufficient for sidechains and swaps

• Can’t verify all transactions

• Grows with #blocks

• Less block time-> larger SPV client

• 40 MB in Bitcoin

• 2.2 GB in Ethereum

• Especially bad for multi-chain clients

• SNARK or CS-Proof/CIP/STARK (Micali 91, Ben-Sasson et al. 17)

• Constant size non-interactive proof that chain has length X

• Circuit verifies full blockchain

• Not practical for prover

• SNARKs closer to being practical but trusted setup

Sublinear SPV-Clients: SNARKs

16

• Kyriasis, Miller, Zindros 17• Based on Kiayias, Lamprou, Stouka 16 and Back et al. 14

• Insight: If I want to find x such that H(x) has n 0s then I will find 2 x’ such that H(x’) has n-1 0s, 4 x’’ such that H(x’’) has n-2 0s …

• Best quality proof of work indicates quality of whole chain

• Use a skiplist to point to proofs with less proofs of work

• O(log(n)*log(log(n))) proof size

Sublinear SPV-Clients: NiPoPoWs

17

• High quality blocks do not give extra reward

• But they are important for NiPoPows1

• Bribe honest rational miners to throw away super high quality blocks

• Main chain “looks” worse which makes fooling SPV client easier

• Does not violate NiPoPow’s security proof because honest mining and not rational mining is assumed

• Motivates search for different NiPoPows

NiPoPoW bribery attack

18

Append L2 Append L3

L0 L1

Root 0

L0L2

L1

Root 1

L1L0 L3L2

Root 3

Merkle Mountain Ranges (Todd 16)

Log(n) inclusion proofsLog(n) updatesnth tree commits to kth tree k<nLog(n) difference proofs

Flyclient: A different approach to super-light clients

trans: H( )

prev: H( )

trans: H( )

prev: H( )trans: H( )

prev: H( )

20

Flyclient: A different approach to super-light clients

trans: H( )

root: H( )

trans: H( )

root: H( )trans: H( )

root: H( )

Store just the head

21

Flyclient: A different approach to super-light clients

trans: H( )

root: H( )trans: H( )

root: H( )

Store just the head

Merkle Tree

22

transaction

trans: H( )

root: H( )trans: H( )

root: H( )

Verifying Transaction

H( )

  

 

 

Chain head

23

Flyclient: Two heads?This is the

head

No this is the head

❓ Assumption:At least one

chain is honest

Other one has at most a c fraction

of the mining power

Ex: c=1/3

24

Flyclient Strawman 1

Give me k blocks:

7,13,210…

25

Flyclient Strawman 1: sample constant # of blocks

Sample k blocks + Merkle inclusion proof for each

26

Honest chain

Malicious chain (only 1/3 of the blocks have a PoW)

Head 1

Head 2

Flyclient Strawman 1: sample constant # of blocks

 

27

Honest chain

Malicious chain (only 1/3 of the blocks have a PoW)

Head 1

Head 2

Flyclient Strawman 1: sample constant # of blocks

 

28

Honest chain

Malicious chain (only 1/3 of the blocks have a PoW)

Head 1

Head 2

Flyclient Strawman 1: sample constant # of blocks

 

29

Honest chain

Malicious chain (only 1/3 of the blocks have a PoW)

Head 1

Head 2

Flyclient Strawman 1 problem: Forking

30

Honest chain

Mal

icio

us Fo

rk

Head 1

Head 2

Flyclient idea: Find Fork Point

31

Honest chain

Mal

icio

us Fo

rk

Head 1

Head 2

Knowing this point suffices

︸Sample blocks after fork

Flyclient Strawman 2: Interactive Binary Search

32

Honest chain

Mal

icio

us Fo

rk

Head 1

Head 2

Binary search to find fork point

Log(n) messages

Flyclient Strawman 2: Interactive Binary Search

33

Honest chain

Mal

icio

us Fo

rk

Head 1

Head 2

Binary search to find fork point

Log(n) messages

Works but two provers may not want to interact

Flyclient: Idea bound forking point

34

Honest chainHead 1

Head 2 

Flyclient: Idea bound forking point

35

Honest chainHead 1

Head 2 

 

Flyclient: Idea bound forking point

36

Honest chainHead 1

Head 2Step 3: Repeat

 

Flyclient: Idea bound forking point

37

Honest chainHead 1

Head 2Step 3: Repeat

 

Flyclient: Idea bound forking point

38

Honest chainHead 1

Head 2Step 4: Check final L blocks (to prevent short forks)

Flyclient Analysis

• In each interval check k blocks, k independent of chain length n

• k dependent on attacker strength

• Check log(n) intervalls

• For each block do log(n) merkle inclusion proof

• O(log(n)^2) overall

• For n=1000000->

39

Non Interactive Flyclient

40

Thanks

bbuenz.github.io

BUENZ@CS.STANFORD.EDU

top related