rapidchain: scaling blockchain via full sharding · "evict !nodes from the shard!bounded...

51
RapidChain: Scaling Blockchain via Full Sharding Mahdi Zamani Visa Research Join work with Mahnush Movahedi, Dfinity Mariana Raykova, Yale University Stanford Blockchain Seminar August 2018

Upload: others

Post on 23-Jul-2020

9 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: RapidChain: Scaling Blockchain via Full Sharding · "Evict !nodes from the shard!Bounded Cuckoo rule. Experimental Setup!Prototype implemented in Go!Link latency of 100 ms!Node bandwidth

RapidChain:Scaling Blockchain via Full Sharding

Mahdi ZamaniVisa Research

Join work with Mahnush Movahedi, DfinityMariana Raykova, Yale University

Stanford Blockchain SeminarAugust 2018

Page 2: RapidChain: Scaling Blockchain via Full Sharding · "Evict !nodes from the shard!Bounded Cuckoo rule. Experimental Setup!Prototype implemented in Go!Link latency of 100 ms!Node bandwidth

Agenda

! Part I: Consensus Protocols" Traditional mechanisms" Blockchain consensus

Page 3: RapidChain: Scaling Blockchain via Full Sharding · "Evict !nodes from the shard!Bounded Cuckoo rule. Experimental Setup!Prototype implemented in Go!Link latency of 100 ms!Node bandwidth

Agenda

! Part I: Consensus Protocols" Traditional mechanisms" Blockchain consensus

! Part II: RapidChain[CCS 2018]

" Sharding-based consensus" Protocol overview" Results

Page 4: RapidChain: Scaling Blockchain via Full Sharding · "Evict !nodes from the shard!Bounded Cuckoo rule. Experimental Setup!Prototype implemented in Go!Link latency of 100 ms!Node bandwidth

Part I: Consensus Protocols

Page 5: RapidChain: Scaling Blockchain via Full Sharding · "Evict !nodes from the shard!Bounded Cuckoo rule. Experimental Setup!Prototype implemented in Go!Link latency of 100 ms!Node bandwidth

Consensus Ground Zero

! Store data in a place that is safe and live

! No such a single machine exists

! Replicate data on multiple machines for resiliency

Page 6: RapidChain: Scaling Blockchain via Full Sharding · "Evict !nodes from the shard!Bounded Cuckoo rule. Experimental Setup!Prototype implemented in Go!Link latency of 100 ms!Node bandwidth

The Consensus Problem [PSL80]

! Network of n nodes, t of them are Byzantine

! Leader broadcasts !! Agreement

" All honest nodes output "! Correctness

" If leader is honest, then " # !" Otherwise, " can be anything

Page 7: RapidChain: Scaling Blockchain via Full Sharding · "Evict !nodes from the shard!Bounded Cuckoo rule. Experimental Setup!Prototype implemented in Go!Link latency of 100 ms!Node bandwidth

When is it possible? [PSL80]

! "#$ "#% "

Page 8: RapidChain: Scaling Blockchain via Full Sharding · "Evict !nodes from the shard!Bounded Cuckoo rule. Experimental Setup!Prototype implemented in Go!Link latency of 100 ms!Node bandwidth

When is it possible? [PSL80]

! "#$ "#% "

With PKI

Page 9: RapidChain: Scaling Blockchain via Full Sharding · "Evict !nodes from the shard!Bounded Cuckoo rule. Experimental Setup!Prototype implemented in Go!Link latency of 100 ms!Node bandwidth

When is it possible? [PSL80]

! "#$ "#% "

Without PKI

With PKI

Page 10: RapidChain: Scaling Blockchain via Full Sharding · "Evict !nodes from the shard!Bounded Cuckoo rule. Experimental Setup!Prototype implemented in Go!Link latency of 100 ms!Node bandwidth

When is it possible? [PSL80]

! "#$ "#% "

Without PKI

With PKI

Synchronous

Page 11: RapidChain: Scaling Blockchain via Full Sharding · "Evict !nodes from the shard!Bounded Cuckoo rule. Experimental Setup!Prototype implemented in Go!Link latency of 100 ms!Node bandwidth

When is it possible? [PSL80]

! "#$ "#% "

Without PKI

With PKI

Synchronous

Asynchronous

Page 12: RapidChain: Scaling Blockchain via Full Sharding · "Evict !nodes from the shard!Bounded Cuckoo rule. Experimental Setup!Prototype implemented in Go!Link latency of 100 ms!Node bandwidth

When is it possible? [PSL80]

! "#$ "#% "

Without PKI

With PKI

Synchronous

AsynchronousProbabilistic

Page 13: RapidChain: Scaling Blockchain via Full Sharding · "Evict !nodes from the shard!Bounded Cuckoo rule. Experimental Setup!Prototype implemented in Go!Link latency of 100 ms!Node bandwidth

Blockchain Consensus (since 2008)

! Atomic broadcast [HT93]

" Total Order! An honest node receives !" before !# iff sender sends !" before !#

! Open membership

Transaction 1Transaction 2

$

Page 14: RapidChain: Scaling Blockchain via Full Sharding · "Evict !nodes from the shard!Bounded Cuckoo rule. Experimental Setup!Prototype implemented in Go!Link latency of 100 ms!Node bandwidth

Open Membership Setting

! Sparsely-connected network (e.g., peer-to-peer)

! New nodes can join/leave (churn)

! Sybil rate limited via PoW

Page 15: RapidChain: Scaling Blockchain via Full Sharding · "Evict !nodes from the shard!Bounded Cuckoo rule. Experimental Setup!Prototype implemented in Go!Link latency of 100 ms!Node bandwidth

Leader Election Approaches

! Distributed coin flipping" Generate an unbiased randomness jointly" Byzantine fault tolerance (BFT)" Proof-of-stake (PoS)

! Race-based election" Nodes compete to become the leader" Proof-of-work (PoW)" Proof-of-elapsed-time (PoET)" etc.

Page 16: RapidChain: Scaling Blockchain via Full Sharding · "Evict !nodes from the shard!Bounded Cuckoo rule. Experimental Setup!Prototype implemented in Go!Link latency of 100 ms!Node bandwidth

Pros and Cons of Coin Flipping Approach

! Pros" No forks (instant finality)" Less energy wasted (cf. PoW)

! Cons" Requires identity establishment " Inefficient with node churn (join/leave)" High communication overhead

Page 17: RapidChain: Scaling Blockchain via Full Sharding · "Evict !nodes from the shard!Bounded Cuckoo rule. Experimental Setup!Prototype implemented in Go!Link latency of 100 ms!Node bandwidth

Hybrid Model [PS16]

! Corruptions and churn happen at a limited rate" Handle Sybil only occasionally

! PoW to establish identities; BFT for consensus" No TTP assumption

! Examples" ByzCoin, Hybrid Consensus, Elastico, Algorand, OmniLedger, Dfinity,

RapidChain

Page 18: RapidChain: Scaling Blockchain via Full Sharding · "Evict !nodes from the shard!Bounded Cuckoo rule. Experimental Setup!Prototype implemented in Go!Link latency of 100 ms!Node bandwidth

Bitcoin: Too Much of a Good Thing

! Sacrifices scalability for decentralization

! Permissioned blockchain?" A closed group of servers run the consensus protocol" Membership isn’t the bottleneck

! Full replication scales out in a cluster but not between datacenters/Internet nodes" High round-trip time (~200ms vs <1ms)

Page 19: RapidChain: Scaling Blockchain via Full Sharding · "Evict !nodes from the shard!Bounded Cuckoo rule. Experimental Setup!Prototype implemented in Go!Link latency of 100 ms!Node bandwidth

Full Replication Doesn’t Scale

! Inherently inefficient and unscalable" ! "# communication and computation needed" More nodes, higher message latency" Gossiping a 2 MB message to 90% of 4,000 nodes takes ~50 sec

# participants (")

# bi

ts e

xcha

nged

Page 20: RapidChain: Scaling Blockchain via Full Sharding · "Evict !nodes from the shard!Bounded Cuckoo rule. Experimental Setup!Prototype implemented in Go!Link latency of 100 ms!Node bandwidth

How much redundancy is really needed?

! To tolerate faults and attacks?" Bitcoin and Ethereum create 4,000+ replicas

Page 21: RapidChain: Scaling Blockchain via Full Sharding · "Evict !nodes from the shard!Bounded Cuckoo rule. Experimental Setup!Prototype implemented in Go!Link latency of 100 ms!Node bandwidth

Part II: RapidChain

Page 22: RapidChain: Scaling Blockchain via Full Sharding · "Evict !nodes from the shard!Bounded Cuckoo rule. Experimental Setup!Prototype implemented in Go!Link latency of 100 ms!Node bandwidth

Sharding-Based Consensus

! Elect a set of random committee of nodes

! Each committee runs consensus on behalf of all

! And, maintains a disjoint ledger

! Throughput increases linearly with # nodes

Page 23: RapidChain: Scaling Blockchain via Full Sharding · "Evict !nodes from the shard!Bounded Cuckoo rule. Experimental Setup!Prototype implemented in Go!Link latency of 100 ms!Node bandwidth

Full Sharding

Computation

Communication

Storage

Page 24: RapidChain: Scaling Blockchain via Full Sharding · "Evict !nodes from the shard!Bounded Cuckoo rule. Experimental Setup!Prototype implemented in Go!Link latency of 100 ms!Node bandwidth

Sharding Challenges

! Electing small committees via probabilistic sampling process

! Reconfiguration to avoid Sybil attack

! Cross-shard transactions" Verify transactions located in other committees

! Decentralized bootstrapping*" Establish PKI without initial randomness, CRS, etc.

Page 25: RapidChain: Scaling Blockchain via Full Sharding · "Evict !nodes from the shard!Bounded Cuckoo rule. Experimental Setup!Prototype implemented in Go!Link latency of 100 ms!Node bandwidth

Our Goals/Achievements

! Higher throughput (7300 tx/sec)" Sublinear communication per tx" 6-10x faster fast committee consensus

! Higher resiliency" RapidChain : ! " #$%, previous work [LNZ+16, KJG+18]: ! " #$&

! Provable reconfiguration" Based on Cuckoo rule [AS06]

! Decentralized bootstrappingRapidChain: ' # # , previous work: ( #)

Page 26: RapidChain: Scaling Blockchain via Full Sharding · "Evict !nodes from the shard!Bounded Cuckoo rule. Experimental Setup!Prototype implemented in Go!Link latency of 100 ms!Node bandwidth

Network Model

! ! nodes each with a key pair "#$% &#$! ' committees (a.k.a., shards)! P2P network with gossiping

! Bounded message delay" Known fixed delay, (" Similar to Bitcoin

Page 27: RapidChain: Scaling Blockchain via Full Sharding · "Evict !nodes from the shard!Bounded Cuckoo rule. Experimental Setup!Prototype implemented in Go!Link latency of 100 ms!Node bandwidth

Threat Model

! ! " #$% Byzantine nodes at any moment

! Slowly-adaptive adversary [PS16, KJG+18]

Page 28: RapidChain: Scaling Blockchain via Full Sharding · "Evict !nodes from the shard!Bounded Cuckoo rule. Experimental Setup!Prototype implemented in Go!Link latency of 100 ms!Node bandwidth

Epochs and Iterations

Bootstrap Consensus …

Epoch

Reconfiguration Consensus Reconfiguration

Iteration

Page 29: RapidChain: Scaling Blockchain via Full Sharding · "Evict !nodes from the shard!Bounded Cuckoo rule. Experimental Setup!Prototype implemented in Go!Link latency of 100 ms!Node bandwidth

RapidChain Overview

! Proceed in epochs

! First epoch: Bootstrap a reference committee" Creates epoch randomness" Creates a reconfiguration block in every epoch

! Epoch randomness" Samples sharding committees" New nodes join the system" Re-organize existing committees

Page 30: RapidChain: Scaling Blockchain via Full Sharding · "Evict !nodes from the shard!Bounded Cuckoo rule. Experimental Setup!Prototype implemented in Go!Link latency of 100 ms!Node bandwidth

RapidChain Overview (cont’d)

! Each users sends its tx to some arbitrary node

! tx is routed to the output committee, !"#$! Members of !"#$ create a block

! Cross-shard verification" Verify input transactions of tx" Batch requests based on input committees" Forward them via an inter-committee routing protocol

Page 31: RapidChain: Scaling Blockchain via Full Sharding · "Evict !nodes from the shard!Bounded Cuckoo rule. Experimental Setup!Prototype implemented in Go!Link latency of 100 ms!Node bandwidth

Sharded Consensus

Bootstrap Consensus …

Iteration

Epoch

Reconfiguration Consensus Reconfiguration

Page 32: RapidChain: Scaling Blockchain via Full Sharding · "Evict !nodes from the shard!Bounded Cuckoo rule. Experimental Setup!Prototype implemented in Go!Link latency of 100 ms!Node bandwidth

Committee Size

! How large should the committees be?

! Depends on the intra-committee consensus protocol

! Higher committee resiliency ! Smaller committee

! 4,000 nodes" 16 committees of size 250" 100 committees of size 40

Page 33: RapidChain: Scaling Blockchain via Full Sharding · "Evict !nodes from the shard!Bounded Cuckoo rule. Experimental Setup!Prototype implemented in Go!Link latency of 100 ms!Node bandwidth

Sampling Error

1E-08

1E-07

1E-06

1E-05

1E-04

1E-03

1E-02

1E-01

1E+00

0 20 40 60 80 100 120 140 160 180 200 220 240

Failu

re P

roba

bility

Committee Size

1/3 to 1/2 (RapidChain)1/4 to 1/3 (Previous work)1/5 to 1/3

! Using hypergeometric distribution

Page 34: RapidChain: Scaling Blockchain via Full Sharding · "Evict !nodes from the shard!Bounded Cuckoo rule. Experimental Setup!Prototype implemented in Go!Link latency of 100 ms!Node bandwidth

Consensus in Committees

! Gossiping a 2-MB block in a 250-node committee takes ! "# sec

! Idea: Gossip the block, then agree on the hash of the block

Page 35: RapidChain: Scaling Blockchain via Full Sharding · "Evict !nodes from the shard!Bounded Cuckoo rule. Experimental Setup!Prototype implemented in Go!Link latency of 100 ms!Node bandwidth

Gossiping Large Blocks

! Information dispersal algorithm (IDA) [R89]

" Encode ! into " chunks !#$% $!& using an erasure codingmechanism

" Give each neighbor "'( chunks (( is the node degree)" ! can be reconstructed from any set of ) * + " chunks

! ECC blowup , 2.7x

! New gossip time: 2.6 sec

! Gossip latency reduction , 5.3x

Page 36: RapidChain: Scaling Blockchain via Full Sharding · "Evict !nodes from the shard!Bounded Cuckoo rule. Experimental Setup!Prototype implemented in Go!Link latency of 100 ms!Node bandwidth

Gossiping Merkle Hash

! Compute a Merkle tree over chunks !"#$ #!%

! Send chunks along with Merkle proofs

!" !& !' !(

)*+) !" )*+) !()*+) !& )*+) !'

Page 37: RapidChain: Scaling Blockchain via Full Sharding · "Evict !nodes from the shard!Bounded Cuckoo rule. Experimental Setup!Prototype implemented in Go!Link latency of 100 ms!Node bandwidth

Consensus over Merkle Root

! Synchronous consensus [RNA+17]

" 1/2 resiliency (optimal)" Expected 8 rounds

! Drawbacks" Partitioning attacks" Responsiveness [PS16]

Page 38: RapidChain: Scaling Blockchain via Full Sharding · "Evict !nodes from the shard!Bounded Cuckoo rule. Experimental Setup!Prototype implemented in Go!Link latency of 100 ms!Node bandwidth

Rationale

! Partitioning attacks" PoW-based protocols need bounded-delay channels [PSS17]

! Responsiveness" Large shards already sacrifice responsiveness" Small consensus messages (80 bytes)" Run a pre-scheduled consensus to adjust !

Page 39: RapidChain: Scaling Blockchain via Full Sharding · "Evict !nodes from the shard!Bounded Cuckoo rule. Experimental Setup!Prototype implemented in Go!Link latency of 100 ms!Node bandwidth

Handling Join-Leave Attacks

! Cuckoo rule [AS06]

" Assign the new node to a random shard" Evict ! nodes from the shard

! Bounded Cuckoo rule

Page 40: RapidChain: Scaling Blockchain via Full Sharding · "Evict !nodes from the shard!Bounded Cuckoo rule. Experimental Setup!Prototype implemented in Go!Link latency of 100 ms!Node bandwidth

Handling Join-Leave Attacks

! Cuckoo rule [AS06]

" Assign the new node to a random shard" Evict ! nodes from the shard

! Bounded Cuckoo rule

Page 41: RapidChain: Scaling Blockchain via Full Sharding · "Evict !nodes from the shard!Bounded Cuckoo rule. Experimental Setup!Prototype implemented in Go!Link latency of 100 ms!Node bandwidth

Handling Join-Leave Attacks

! Cuckoo rule [AS06]

" Assign the new node to a random shard" Evict ! nodes from the shard

! Bounded Cuckoo rule

Page 42: RapidChain: Scaling Blockchain via Full Sharding · "Evict !nodes from the shard!Bounded Cuckoo rule. Experimental Setup!Prototype implemented in Go!Link latency of 100 ms!Node bandwidth

Handling Join-Leave Attacks

! Cuckoo rule [AS06]

" Assign the new node to a random shard" Evict ! nodes from the shard

! Bounded Cuckoo rule

Page 43: RapidChain: Scaling Blockchain via Full Sharding · "Evict !nodes from the shard!Bounded Cuckoo rule. Experimental Setup!Prototype implemented in Go!Link latency of 100 ms!Node bandwidth

Experimental Setup

! Prototype implemented in Go

! Link latency of 100 ms

! Node bandwidth of 20 Mbps

! 2 MB blocks (4096 tx/block, 512 B/tx)

! Corruption model" 49% of leaders equivocate in the same iteration" 49% of nodes do not participate in gossips (i.e., remain silent)

Page 44: RapidChain: Scaling Blockchain via Full Sharding · "Evict !nodes from the shard!Bounded Cuckoo rule. Experimental Setup!Prototype implemented in Go!Link latency of 100 ms!Node bandwidth

Synchronous Round Time-Out

275

325

375

425

475

525

100 125 150 175 200 225 250

Late

ncy

(ms)

Committee Size

MaximumAverageMedian

! ! " #$$ ms! Latency of gossiping an 80-byte message in a committee of size

250

Page 45: RapidChain: Scaling Blockchain via Full Sharding · "Evict !nodes from the shard!Bounded Cuckoo rule. Experimental Setup!Prototype implemented in Go!Link latency of 100 ms!Node bandwidth

Throughput vs n

17502744

37264676 5177

61807031 7384

010002000300040005000600070008000

500[145]

1000[175]

1500[190]

2000[200]

2500[225]

3000[225]

3500[230]

4000[250]

Tran

sact

ions

per

Sec

ond

Number of Nodes[Committee Size]

Page 46: RapidChain: Scaling Blockchain via Full Sharding · "Evict !nodes from the shard!Bounded Cuckoo rule. Experimental Setup!Prototype implemented in Go!Link latency of 100 ms!Node bandwidth

Latency vs n

32.2

67.9 69.1 69.8 70.0 70.4 70.6 70.7

8.04

8.498.64 8.72 8.75 8.80 8.83 8.84

7.8

8.1

8.4

8.7

9.0

9.3

9.6

9.9

0

10

20

30

40

50

60

70

80

500 1000 1500 2000 2500 3000 3500 4000

Conf

irmat

ion

Late

ncy

(sec

)

User

-Per

ceiv

ed L

aten

cy (

sec)

Number of Nodes

User-Perceived Latency

Confirmation Latency

Page 47: RapidChain: Scaling Blockchain via Full Sharding · "Evict !nodes from the shard!Bounded Cuckoo rule. Experimental Setup!Prototype implemented in Go!Link latency of 100 ms!Node bandwidth

Impact of Block Size

7384

8.84

0.00

5.00

10.00

15.00

20.00

25.00

30.00

35.00

0100020003000400050006000700080009000

128 256 512 1024 2048 4096 8192

Late

ncy

(sec

)

Tran

sact

ions

per

Sec

ond

Block Size (KB)

Throughput

Latency

Page 48: RapidChain: Scaling Blockchain via Full Sharding · "Evict !nodes from the shard!Bounded Cuckoo rule. Experimental Setup!Prototype implemented in Go!Link latency of 100 ms!Node bandwidth

Where do we stand?

Protocol #Nodes Resiliency TPS Latency Storage Shard Size

Time to Failure

Elastico 1,600 !"# 40 800 sec 1x 100 1 hour

OmniLedger 1,800 !"# 500 14 sec 1/3x 600 230 years

OmniLedger 1,800 !"# 3,500 63 sec 1/3x 600 230 years

RapidChain 1,800 !"$ 4,220 8.5 sec 1/9x 200 1,950 years

RapidChain 4,000 !"$ 7,380 8.7 sec 1/16x 250 4,580 years

Page 49: RapidChain: Scaling Blockchain via Full Sharding · "Evict !nodes from the shard!Bounded Cuckoo rule. Experimental Setup!Prototype implemented in Go!Link latency of 100 ms!Node bandwidth

Where to focus in future?

Protocol Phase Cost Percentage After 7 days

Bootstrapping 5.2%

Shard Reconfiguration 1.5%

Cross-Shard Verification 28.5%

Block Agreement 64.8%

Total 100%

Page 50: RapidChain: Scaling Blockchain via Full Sharding · "Evict !nodes from the shard!Bounded Cuckoo rule. Experimental Setup!Prototype implemented in Go!Link latency of 100 ms!Node bandwidth

Thank you!

We’re hiring Ph.D. candidates for blockchain research!

Page 51: RapidChain: Scaling Blockchain via Full Sharding · "Evict !nodes from the shard!Bounded Cuckoo rule. Experimental Setup!Prototype implemented in Go!Link latency of 100 ms!Node bandwidth

References! [PSL80] Marshall Pease, Robert Shostak, and Leslie Lamport. Reaching agreement in the presence of faults. In JACM, 1980.

! [BT83] Gabriel Bracha and Sam Toueg. Resilient consensus protocols. In PODC, 1983.

! [HT93] Vassos Hadzilacos and Sam Toueg. Distributed systems. Chapter on Fault-tolerant Broadcasts and Related Problems, ACM Press, 1993.

! [PSS17] Rafael Pass, Lior Seeman, and Abhi Shelat. Analysis of the blockchain protocol in asynchronous networks. In Advances in Cryptology – EUROCRYPT 2017, pages 643–673. Springer International Publishing, 2017.

! [R86] Michael O. Rabin. Efficient dispersal of information for security, load balancing, and fault tolerance. In JACM, 1989.

! [KJG+18] Eleftherios Kokoris-Kogias, Philipp Jovanovic, Linus Gasser, Nicolas Gailly, Ewa Syta, and Bryan Ford. OmniLedger: A secure, scale-out, decentralized ledger via sharding. In S&P, 2018.

! [LNZ+16] Loi Luu, Viswesh Narayanan, Chaodong Zheng, Kunal Baweja, Seth Gilbert, and Prateek Saxena. A secure sharding protocol for open blockchains. In CCS, 2016.

! [PS16] Rafael Pass and Elaine Shi. Hybrid consensus: Efficient consensus in the permissionless model. Cryptology ePrintArchive, Report 2016/917, 2016.

! [RNA+17] Ling Ren, Kartik Nayak, Ittai Abraham, and Srinivas Devadas. Practical synchronous byzantine consensus. CoRR , abs/1704.02397, 2017.

! [AS06] Baruch Awerbuch and Christian Scheideler. Towards a scalable and robust DHT. In SPAA, 2006.