Consensus & Agreement in Distributed Systems: Byzantine Generals & Algorithms, Study notes of Computer Science

A series of lecture notes from computer science 328: distributed systems, focusing on consensus and agreement in distributed systems. The notes cover the concepts of consensus, requirements for consensus, consensus algorithms, and interactive consistency. The document also includes examples and proofs of correctness for these concepts.

Typology: Study notes

Pre 2010

Uploaded on 03/16/2009

koofers-user-dc1
koofers-user-dc1 🇺🇸

10 documents

1 / 15

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
2006, M. T. Harandi Lecture 10- 1
Computer Science 328
Distributed Systems
Lecture 10
Coordination & Agreement:
Consensus
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

Partial preview of the text

Download Consensus & Agreement in Distributed Systems: Byzantine Generals & Algorithms and more Study notes Computer Science in PDF only on Docsity!

Computer Science 328

Distributed Systems

Lecture 10

Coordination & Agreement:

Consensus

Consensus

 Consensus: N Processes agree on a value.

e.g. synchronized action (go / abort)

 Consensus may have to be reached in the presence of

failure.

 (^) Process failure – process crash (fail stop failure), arbitrary failure.  (^) Communication failure – lost or corrupted messages.

 In a consensus algorithm:

 (^) All Pi start in an “undecided” state.  (^) Each Pi proposes a value vi from a set D and communicates it to some or all other processes.  (^) A consensus is reached if all non failed processes agree on the same value, d.  (^) Each non failed Pi sets its decision variable to d and changes its state to “decided.”

For a system with at most f processes crashing, the algorithm proceeds in f+1 rounds (with timeout), using basic multicast.  Valuesri: the set of proposed values known to Pi at the beginning of round r. Initially Values^0 i = {} ; Values^1 i = {vi} for round = 1 to f+1 do multicast ( Values riValuesr 1i ) Values r+1iValuesri for each Vj received Values r+1i = Values r+1i ∪ Vj end end di = minimum( Values f+2i )

Consensus in a Synchronous System

Proof of Correctness

  • (^) Proof by contradiction.
  • (^) Assume that two processes differ in their final set of values.
  • Assume that^ pi possesses a value^ v^ that^ pj does not possess.  A third process, pk , sent v to pi , and crashed before sending v to pj.  Any process sending v in the previous round must have crashed; otherwise, both pk and pj should have received v.  Proceeding in this way, we infer at least one crash in each of the preceding rounds.  But we have assumed at most f crashes can occur and there are f+1 rounds  contradiction.

Example: Consensus & Interactive Consistency

P

P2 P

P Crashed

ConsensusAlg.

V 1 = go

V 2 = go V 3 = go

V 4 = abort

d 1go

d 2go d 3 ←^ go

P

P2 P

P Crashed

ConsensusAlg.

V 1 = 5

V 2 = 7 V 3 = 2

V 4 =

d 1(5,7,2, -)

Consensus

d 2(5,7,2, -) d^3 ←^ (5,7,2, -)

Interactive Consistency

Two waring armies, Red army is larger but divided  (^) Red army can win by synchronized attack, if not coordinated they’ll lose  (^) Timing is critical. They cannot wait for long (supplies run out, get weaker)  (^) R1 sends a message to R2 with “time of attack”  (^) R1 not sure R2 received it  (^) R2 may get concerned R1 is not sure  (^) R2 may send ACK, but that may get lost  (^) the message from R1 may be intercepted by B

No solution if the comm. medium is unreliable

Agreement in light of failure: The 2 Army problem

R1 R B

Byzantine Generals in Synchronous Systems

  • (^) Now a fault process may send any message with any value at any time; or it may omit to send any message.
  • (^) In the case of arbitrary failure, no solution exists if N<=3f.

p 1 (Commander)

p 2 p 3

1:v 1:v 2:1:v 3:1:u

p 1 (Commander)

p 2 p 3

1:w 1:x 2:1:w 3:1:x Faulty processes are shown shaded If a solution exists, process p2 is bound to decide on value v when the commander is correct, by the integrity condition. If we accept that no algorithm can possibly distinguish between the two scenarios, p2 must also choose the value sent by the commander in the right scenario.

Solution with One Faulty Process

• To solve the Byzantine generals problem in a

synchronous system, we require. N>=3f+

• for f = 1, a simple 2 round algorithm works

  • (^) In the first round, the commander sends a value to each of the lieutenants.
  • (^) In the second round, each of the lieutenants sends the value it received to its peers.
  • (^) The correct lieutenants need only apply a simple majority function on the set of values received.
  • (^) As N f 1 >= 2f , the majority function will ignore any faulty value.

Solution for no commander case

• The N generals need to update each other with their

values (e.g. troop strength)

• for f < N/3, a 2 round algorithm works

  • (^) In the first round, each general sends its value to all other generals
  • (^) In the second round, each of the generals sends a vector of values it has received to others.
  • (^) Once all vectors are received each node will compare and choose majority value for each vector element.

Example: Byzantine Generals

P1 P

P3 P

1

1

1

3

3

3

4

4

4

x

y

z

Step 1

P1 P

P3 P

1,x,3,

x,w,t,s

1,x,3,4 z,mp,x^ y,x,w,p 1,x,3,

1,y,3,

1,z,3,

1,z,3,4 1,z,3,4^ 1,y,3,

1,y,3,

Step 2

Step 3 2: <x,w,t,s> 1:<1,x,3,4> P1 3:<1,z,3,4> P2 3: <1,z,3,4> 4: <1,y,3,4> 4: <1,y,3,4> 1:<1,x,3,4> 1:<1,x,3,4> P3 2: <x,w,t,s> P4 2: <x,w,t,s> 4: <1,y,3,4> 3: <1,z,3,4>

Step 4

P1 <1,?,3,4> P2 <1,?,3,4>

P3 <1,?,3,4> P4 <1,?,3,4>