280 likes | 443 Views
Blockchains. Lecture 8. State Machine Replication, BFT, and Blockchains. State Machine Replication. Single Server Architecture. State Machine Replication. Single Server Architecture. A single point of failure!. State Machine Replication. State Machine Replication.
E N D
Blockchains Lecture 8
StateMachineReplication SingleServerArchitecture
StateMachineReplication SingleServerArchitecture • Asinglepointoffailure!
StateMachineReplication StateMachineReplication • Interactiveprotocolamongservers • State machine replication gives safetyand liveness.
StateMachineReplication StateMachineReplication(SMR) • Replicas maintain the same state • Replicas start in the same state • Operations are deterministic • Replicas execute operations in the same order(i.e.,totalorder) • Replicassendrepliestoclients • Clientsvoteonreplicareplies
Roughly, Consensus:AllAboutAchieving“TotalOrder” [Lamport, ACM TOPLAS 1984] • Blockchains (modeled as state machine replication) $100 $100 $100
The“TotalOrder”Requirement Client 1: “Deposit $100” $100 $200 Client 1: “Deposit $100” $100 $200 $100
The“TotalOrder”Requirement Chase: “Charge 10%” Client 1: “Deposit $100” $100 $200 $180 Chase: “Charge 10%” Client 1: “Deposit $100” $180 $100 $200 $100
The“TotalOrder”Requirement Chase: “Charge 10%” Client 1: “Deposit $100” $100 $200 $180 Chase: “Charge 10%” Client 1: “Deposit $100” $180 $100 $200 $100
The“TotalOrder”Requirement Chase: “Charge 10%” Client 1: “Deposit $100” $100 $90 $190 Chase: “Charge 10%” Client 1: “Deposit $100” $190 $100 $90 $100
The“TotalOrder”Requirement Chase: “Charge 10%” Client 1: “Deposit $100” $100 $90 $190 Chase: “Charge 10%” Client 1: “Deposit $100” $180 $100 $200 $100
StateMachineReplication Crash Fault-Tolerant SMR • 2f+1replicastotolerateffailures • Example: • Paxos: SMRforcrashfailures • The“most”important backbonearchitecture • Eachmajorservice • BigTable,Chubby,Spanner,Azure,AmazonWebServices,Ceph,IBMSAN,VMwareNSX,… [Lamport, ACMTOCS1998];goingbackto1989
StateMachineReplication Paxos [Lamport. Paxos made simple. ACM SIGACT News2001] [Lamport, ACMTOCS1998];goingbackto1989 “For fundamental contributions to the theory and practice of distributed and concurrent systems, notably the invention of concepts such as causality and logical clocks, safety and liveness, replicated state machines, and sequential consistency.” TuringAward2013
StateMachineReplication ByzantineFault-TolerantSMR(BFTProtocols) • Traditionallyimportant • Powerful: Byzantine/arbitrary failures & attacks • Systems, distributed systems, theory, crypto, security, … • Recentlygainprominence • Realthreatstorealsystems • Blockchains • Mission-criticalsystems (SpaceX) • …
StateMachineReplication ByzantineFault-TolerantSMR(BFTProtocols) • Traditionallyimportant • Powerful: Byzantine/arbitrary failures & attacks • Systems, distributed systems, theory, crypto, security, … • Recentlygainprominence • Realthreatstorealsystems • Blockchains • Mission-criticalsystems (SpaceX) • …
StateMachineReplication PBFT • 3f+1replicastotoleratefByzantinefailures [CastroandLiskov,OSDI1999] “For contributions to practical and theoretical foundations of programming language and system design, especially related to data abstraction, fault tolerance, and distributed computing.” TuringAward2008
Client sends request to all Why not just send to one? Normal Case
Primary sends pre-prepare message to all Records operation in log as pre-prepared Normal Case
Replicas check the pre-prepare and if it is ok: Record operation in log as pre-prepared Send prepare messages to all All to all communication Normal Case
Replicas wait for 2f+1 matching prepares Record operation in log as prepared Send commit message to all Trust the group, not the individuals Normal Case
Replicas wait for 2f+1 matching commits Record operation in log as committed Execute the operation Send result to the client Normal Case
Client waits for f+1 matching replies Normal Case
Request Pre-Prepare Prepare Commit Reply Client Primary Replica 2 Replica 3 Replica 4 BFT
Replicas watch the primary Request a view change send a do-viewchange request to all new primary requires f+1 requests sends new-view with this certificate Rest is similar View Change (Quite Complex!)
Lower latency for writes (4 messages) Replicas respond at prepare Client waits for 2f+1 matching responses Fast reads (one round trip) Client sends to all; they respond immediately Client waits for 2f+1 matching responses Improved Performance
Batching Run protocol every K requests Improvements
Yet with three differences: In blockchains, only append-only operations are allowed; delete, for instance, is disabled. Blockchains operations are batched and written in the database; SMR does not explicitly require this. Blockchains typically allow anyone to deploy programs (“smart contracts”); SMR typically only allows the system designer to write fixed programs. In this sense, blockchains are more general! Blockchains are SMR (e.g., PBFT)