The Science of the Blockchain Roger Wattenhofer Contents 1 Introduction 1.1 What are Distributed Systems? . . . . . . . . . . . . 1.2 Book Overview . . . . . . . . . . . . . . . . . . . . . 1 1 2 2 Fault-Tolerance & Paxos 5 2.1 Client/Server . . . . . . . . . . . . . . . . . . . . . . 5 2.2 Paxos . . . . . . . . . . . . . . . . . . . . . . . . . . 10 3 Consensus 3.1 Two Friends . . . . . . . . . . . . . . . . . . . . . . . 3.2 Consensus . . . . . . . . . . . . . . . . . . . . . . . . 3.3 Impossibility of Consensus . . . . . . . . . . . . . . . 3.4 Randomized Consensus . . . . . . . . . . . . . . . . 3.5 Shared Coin . . . . . . . . . . . . . . . . . . . . . . . 17 17 18 18 25 29 4 Byzantine Agreement 4.1 Validity . . . . . . . . . . . . . . . . . . . . . . . . . 4.2 How Many Byzantine Nodes? . . . . . . . . . . . . . 4.3 The King Algorithm . . . . . . . . . . . . . . . . . . 4.4 Lower Bound on Number of Rounds . . . . . . . . . 4.5 Asynchronous Byzantine Agreement . . . . . . . . . 33 34 35 38 40 40 5 Authenticated Agreement 45 5.1 Agreement with Authentication . . . . . . . . . . . . 45 5.2 Zyzzyva . . . . . . . . . . . . . . . . . . . . . . . . . 47 6 Quorum Systems 6.1 Load and Work . . . . . . . . . . . . . . . . . . . . . 6.2 Grid Quorum Systems . . . . . . . . . . . . . . . . . 6.3 Fault Tolerance . . . . . . . . . . . . . . . . . . . . . 6.4 Byzantine Quorum Systems . . . . . . . . . . . . . . v 61 62 64 66 70 vi CONTENTS 7 Eventual Consistency & Bitcoin 7.1 Consistency, Availability and Partitions . . . . . . . 7.2 Bitcoin . . . . . . . . . . . . . . . . . . . . . . . . . . 7.3 Smart Contracts . . . . . . . . . . . . . . . . . . . . 7.4 Weak Consistency . . . . . . . . . . . . . . . . . . . 77 78 79 87 91 8 Distributed Storage 95 8.1 Consistent Hashing . . . . . . . . . . . . . . . . . . . 95 8.2 Hypercubic Networks . . . . . . . . . . . . . . . . . . 97 8.3 DHT & Churn . . . . . . . . . . . . . . . . . . . . . 105