Kaizen: Building a Performant Blockchain System Verified for - - PowerPoint PPT Presentation

kaizen building a performant blockchain system verified
SMART_READER_LITE
LIVE PREVIEW

Kaizen: Building a Performant Blockchain System Verified for - - PowerPoint PPT Presentation

Kaizen: Building a Performant Blockchain System Verified for Consensus and Integrity Faria Kalim , Karl Palmskog , Jayasi Mehar , Adithya Murali , P. Madhusudan and Indranil Gupta University of Illinois at


slide-1
SLIDE 1

Kaizen: Building a Performant Blockchain System Verified for Consensus and Integrity

Faria Kalim†, Karl Palmskog∗, Jayasi Mehar‡, Adithya Murali†,

  • P. Madhusudan† and Indranil Gupta†

†University of Illinois at Urbana-Champaign ∗KTH; work done while at UT Austin and UIUC ‡Facebook; work done while at UIUC

1 / 21

slide-2
SLIDE 2

Blockchains and Cryptocurrencies

distributed ledger dissemination transactions+state consensus Nakamoto Algorand Ouroboros Bitcoin Ethereum

2 / 21

slide-3
SLIDE 3

Consensus Protocol Challenges

Distributed protocols need to handle: communication delays (asynchrony) node crashes, corruption message drops, duplication, forging Protocol implementation challenges: conformance to protocol specification node-local performance absence of bugs compromising safety

3 / 21

slide-4
SLIDE 4

Consensus System Formal Verification

Project Paper Protocol Tool LOC Disel POPL ’18 2-phase commit Coq 5k+ Verdi Raft CPP ’16 Raft Coq 50k+ Velisarios ESOP ’18 PBFT Coq 50k+ Ironfleet SOSP ’15 Paxos Dafny 20k+ Toychain CPP ’18 proof-of-X Coq 10k+

4 / 21

slide-5
SLIDE 5

Interactive vs. Mostly-Automated Verification

Coq proof assistant

  • much training required

+ explicit proofs + many libraries

  • purely functional (extraction to OCaml/Haskell)

Dafny verification environment + less training required

  • implicit proofs
  • few libraries

+ functional & imperative (C# code generation)

5 / 21

slide-6
SLIDE 6

Our Contributions

novel combination of Coq & Dafny to build performant and verified blockchain system, Kaizen methodology based on continuous refinement

adapted & instantiated Coq model translated Coq code (not proofs) to Dafny imperative code refined C# code and linked to network shim

performed evaluation measuring minting and consensus time

6 / 21

slide-7
SLIDE 7

Methodology Overview∗

PHASE 1 PHASE 2 PHASE 3 PHASE 4 PHASE 5 PHASE 6 PHASE 7 STAGE I STAGE II STAGE III Abstract protocol design & verification in Coq Translation of abstract protocol to Dafny contracts Refinement to imperative code in Dafny Implementing application specific functions in C# Translation to executable code on a distributed network Refinement in Coq Refinement in Dafny for performance Coq experts Dafny experts Dafny experts and systems engineers Systems engineers

∗system is fully verified until Stage III

7 / 21

slide-8
SLIDE 8

Stage I: Modeling and Verification Using Coq

1 encode system in higher-order functional language (Gallina) 2 prove specification interactively using powerful tactics 3 check soundness of every low-level step user logic engine type checker Coq tactics subgoals proof term

8 / 21

slide-9
SLIDE 9

Toychain Examples

Record Block := mkB { prevBlockHash : Hash; txs : seq Transaction; proof : VProof }. Record State := mkS { id: Address; peers: seq Address; forest: map Hash Block; txpool: seq Transaction }. Definition valid_chain_block (bc:seq Block) (b:Block):= VAF (proof b) bc (txs b) && all [pred t | txValid t bc] (txs b).

9 / 21

slide-10
SLIDE 10

Toychain Results and Extensions

Toychain proves that in quiescent state, all nodes know the same (canonical) chain we added support for coinbase transactions we added checking of proof-of-work validity of chains we changed Toychain nodes to avoid unncessary messages All changes are proof-preserving and now merged into Toychain.

10 / 21

slide-11
SLIDE 11

Stage II: Refinement and Verification Using Dafny

1 encode programs and their contracts in imperative language 2 try to prove automatically that contracts are fulfilled 3 add more annotations if necessary user Dafny Boogie Z3 ? Dfy program IVL program VCs

11 / 21

slide-12
SLIDE 12

Dafny Examples

datatype Block = Block(prevBlockHash: Hash, txs: seq<Transaction>, proof: VProof) datatype State = Node(id: Address, peers: seq<Address>, forest: map<Hash,Block>, txpool: seq<Transaction>) class StateImpl { var id : Address; var peers : . . .; var forest : . . .; var txpool : . . .; ghost var st: State; predicate Valid() { . . .} method ProcMsgImpl(from: Address, msg: Message, ts: Timestamp) returns (pt: seq<Packet>) requires Valid(); ensures Valid(); ensures st =procMsg(old(st), from, msg, ts).0; ensures pt =procMsg(old(st), from, msg, ts).1; { . . .} }

12 / 21

slide-13
SLIDE 13

Stage III: Refinements in C#

block and proof-of-work generation define and inject miner rewards store pre-computed chains add network shim based on UDP

13 / 21

slide-14
SLIDE 14

Implementation Architecture

Shim Layer Bitcoin Functions Blockchain Functions Verified Implementation

Message Queue

Shim Layer Bitcoin Functions Blockchain Functions Verified Implementation

Message Queue

Network Peer Network Peer

14 / 21

slide-15
SLIDE 15

Evaluation Setup

metrics: block minting time and consensus time use 30-node cluster of 2.4GHz processors w/ 64GB RAM baseline: performance of stock Bitcoin implementation workload: traces of arrival times of 50 transactions from realistic dataset

15 / 21

slide-16
SLIDE 16

Evaluation: Block Minting Time

100 500 1000 Initial Number of Blocks 0.0 0.2 0.4 0.6 0.8 Time to Mint Block (Seconds) Bitcoin: 30 Nodes KznCoin: 10 Nodes KznCoin: 20 Nodes KznCoin: 30 Nodes

16 / 21

slide-17
SLIDE 17

Evaluation: Consensus Time

100 500 1000 Initial Number of Blocks 1 2 Time to Consensus (Seconds) Bitcoin KznCoin

17 / 21

slide-18
SLIDE 18

Evaluation: Scalability

10 20 30 Cluster Size 2 4 6 8 10 Time to Consensus (Seconds) Bitcoin - 50 KznCoin - 50 Bitcoin - 250 KznCoin - 250

18 / 21

slide-19
SLIDE 19

Components and Effort

Component Lines of Code Coq refinement ≈ 1k Dafny refinement ≈ 5k C# refinement ≈ 1k C# network shim ≈ 4k Development effort ≈ 6 person months across four people

19 / 21

slide-20
SLIDE 20

Lessons Learned and Future Work

holistic expertise necessary in Coq/Dafny/systems for Kaizen “easy” change can require large changes at earlier stages local node computation took most effort to optimize (rather than network messaging) future Coq proofs of Toychain Byzantine tolerance transferrable to Kaizen (see WIP by Gopinathan and Sergey, CoqPL ’19)

20 / 21

slide-21
SLIDE 21

Conclusion

system development methodology combines interactive and mostly-automated verification, Coq & Dafny verified executable blockchain system Kaizen evaluation gives encouraging results on performance More information: GitHub: https://github.com/palmskog/kaizen contact me: Karl Palmskog palmskog@kth.se

21 / 21