40
Distributed systems: The Byzantine Generals Problem Matej Pavlovič Distributed Programming Laboratory

Distributed systems The Byzantine Generals Problem · Byzantine Generals Problem Commander must send an order to n –1 lieutenants, such that: BG1: All loyal lieutenants obey the

  • Upload
    others

  • View
    7

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Distributed systems The Byzantine Generals Problem · Byzantine Generals Problem Commander must send an order to n –1 lieutenants, such that: BG1: All loyal lieutenants obey the

Distributed systems:

The Byzantine Generals Problem

Matej Pavlovič

Distributed Programming Laboratory

Page 2: Distributed systems The Byzantine Generals Problem · Byzantine Generals Problem Commander must send an order to n –1 lieutenants, such that: BG1: All loyal lieutenants obey the

System model so far

• n processes, message passing

• Process crashes• Algorithms become non-trivial

• Additional assumptions required (P, correct majority…)

• What if processes could lie?

Page 3: Distributed systems The Byzantine Generals Problem · Byzantine Generals Problem Commander must send an order to n –1 lieutenants, such that: BG1: All loyal lieutenants obey the

Leslie Lamport: The Byzantine Generals Problem

Page 4: Distributed systems The Byzantine Generals Problem · Byzantine Generals Problem Commander must send an order to n –1 lieutenants, such that: BG1: All loyal lieutenants obey the
Page 5: Distributed systems The Byzantine Generals Problem · Byzantine Generals Problem Commander must send an order to n –1 lieutenants, such that: BG1: All loyal lieutenants obey the

Retreat

Retreat

Attack

Page 6: Distributed systems The Byzantine Generals Problem · Byzantine Generals Problem Commander must send an order to n –1 lieutenants, such that: BG1: All loyal lieutenants obey the

Retreat

Retreat!

Retreat!

Page 7: Distributed systems The Byzantine Generals Problem · Byzantine Generals Problem Commander must send an order to n –1 lieutenants, such that: BG1: All loyal lieutenants obey the

Attack

Attack!

Attack!

Page 8: Distributed systems The Byzantine Generals Problem · Byzantine Generals Problem Commander must send an order to n –1 lieutenants, such that: BG1: All loyal lieutenants obey the

Retreat

Retreat!

Retreat!

Page 9: Distributed systems The Byzantine Generals Problem · Byzantine Generals Problem Commander must send an order to n –1 lieutenants, such that: BG1: All loyal lieutenants obey the

RetreatAttackRetreat

RetreatAttackRetreat

RetreatAttackRetreat

Page 10: Distributed systems The Byzantine Generals Problem · Byzantine Generals Problem Commander must send an order to n –1 lieutenants, such that: BG1: All loyal lieutenants obey the

RetreatAttackRetreat

RetreatAttackRetreat

RetreatAttackRetreat

Retreat!

Retreat!

Retreat!

Page 11: Distributed systems The Byzantine Generals Problem · Byzantine Generals Problem Commander must send an order to n –1 lieutenants, such that: BG1: All loyal lieutenants obey the

Traitor

Page 12: Distributed systems The Byzantine Generals Problem · Byzantine Generals Problem Commander must send an order to n –1 lieutenants, such that: BG1: All loyal lieutenants obey the

Attack!

Retreat!

Traitor

Page 13: Distributed systems The Byzantine Generals Problem · Byzantine Generals Problem Commander must send an order to n –1 lieutenants, such that: BG1: All loyal lieutenants obey the

AttackAttackRetreat

RetreatAttackRetreat

Traitor

Page 14: Distributed systems The Byzantine Generals Problem · Byzantine Generals Problem Commander must send an order to n –1 lieutenants, such that: BG1: All loyal lieutenants obey the

Traitor

Attack!

Retreat!

Retreat!

AttackAttackRetreat

RetreatAttackRetreat

Page 15: Distributed systems The Byzantine Generals Problem · Byzantine Generals Problem Commander must send an order to n –1 lieutenants, such that: BG1: All loyal lieutenants obey the

Requirements

• All loyal generals choose the same plan (Attack / Retreat)

• A few traitors cannot impose a bad plan on the loyal generals

Page 16: Distributed systems The Byzantine Generals Problem · Byzantine Generals Problem Commander must send an order to n –1 lieutenants, such that: BG1: All loyal lieutenants obey the

Let’s formalize

Page 17: Distributed systems The Byzantine Generals Problem · Byzantine Generals Problem Commander must send an order to n –1 lieutenants, such that: BG1: All loyal lieutenants obey the

v3 = Retreat

v1 = Retreat

v2 = Attack

1

2

3

Page 18: Distributed systems The Byzantine Generals Problem · Byzantine Generals Problem Commander must send an order to n –1 lieutenants, such that: BG1: All loyal lieutenants obey the

Let’s formalize

• n generals

• vi = i-th general’s opinion (value: Attack / Retreat)

• generals only exchange oral messages

… 2 conditions …

Page 19: Distributed systems The Byzantine Generals Problem · Byzantine Generals Problem Commander must send an order to n –1 lieutenants, such that: BG1: All loyal lieutenants obey the

Recall: Requirements

• All loyal generals choose the same plan (Attack / Retreat)

• A few traitors cannot impose a bad plan on the loyal generals

Page 20: Distributed systems The Byzantine Generals Problem · Byzantine Generals Problem Commander must send an order to n –1 lieutenants, such that: BG1: All loyal lieutenants obey the

Let’s formalize

• n generals

• vi = i-th general’s opinion (value: Attack / Retreat)

• generals only exchange oral messages

1) Every loyal general makes his decision based on the same information (d1,…,dn)

Page 21: Distributed systems The Byzantine Generals Problem · Byzantine Generals Problem Commander must send an order to n –1 lieutenants, such that: BG1: All loyal lieutenants obey the

1

2

3

Traitord1: Retreatd2: Attackd3: Retreat

d1: Retreatd2: Attackd3: Retreat

don’t care

Page 22: Distributed systems The Byzantine Generals Problem · Byzantine Generals Problem Commander must send an order to n –1 lieutenants, such that: BG1: All loyal lieutenants obey the

Recall: Requirements

• All loyal generals choose the same plan (Attack / Retreat)

• A few traitors cannot impose a bad plan on the loyal generals

Page 23: Distributed systems The Byzantine Generals Problem · Byzantine Generals Problem Commander must send an order to n –1 lieutenants, such that: BG1: All loyal lieutenants obey the

1

2

3

Traitord1: Attackd2: Attackd3: Attack

d1: Attackd2: Attackd3: Attack

don’t care

Page 24: Distributed systems The Byzantine Generals Problem · Byzantine Generals Problem Commander must send an order to n –1 lieutenants, such that: BG1: All loyal lieutenants obey the

1

2

3

Traitord1: Attackd2: Attackd3: Attack

d1: Attackd2: Attackd3: Attack

don’t care

v3 = Retreat

v2 = Retreat

Page 25: Distributed systems The Byzantine Generals Problem · Byzantine Generals Problem Commander must send an order to n –1 lieutenants, such that: BG1: All loyal lieutenants obey the

Let’s formalize

• n generals

• vi = i-th general’s opinion (value: Attack / Retreat)

• generals only exchange oral messages

1) Every loyal general makes his decision based on the same information (d1,…,dn)

2) If i-th general is loyal, every loyal general must base his decision on di = vi

Page 26: Distributed systems The Byzantine Generals Problem · Byzantine Generals Problem Commander must send an order to n –1 lieutenants, such that: BG1: All loyal lieutenants obey the

Let’s formalize

• n generals

• vi = i-th general’s opinion (value: Attack / Retreat)

• generals only exchange oral messages

1) Every loyal general makes his decision based on the same information (d1,…,dn) Every loyal general uses same value as di

2) If i-th general is loyal, every loyal general must base his decision on di = vi

Page 27: Distributed systems The Byzantine Generals Problem · Byzantine Generals Problem Commander must send an order to n –1 lieutenants, such that: BG1: All loyal lieutenants obey the

Commander and Lieutenants

• Solve once for each general i:• 1 commander (general i)

• n – 1 lieutenants (other generals)

• commander i sends value vi to lieutenants

Page 28: Distributed systems The Byzantine Generals Problem · Byzantine Generals Problem Commander must send an order to n –1 lieutenants, such that: BG1: All loyal lieutenants obey the

Byzantine Generals Problem

Commander must send an order to n – 1 lieutenants, such that:

BG1: All loyal lieutenants obey the same order

BG2: If commander is loyal, then every loyallieutenant obeys commander’s order

In our case, command is “Use ‘Attack’ / ‘Retreat’ as di”

Page 29: Distributed systems The Byzantine Generals Problem · Byzantine Generals Problem Commander must send an order to n –1 lieutenants, such that: BG1: All loyal lieutenants obey the

3 generals, 1 of them traitor

Page 30: Distributed systems The Byzantine Generals Problem · Byzantine Generals Problem Commander must send an order to n –1 lieutenants, such that: BG1: All loyal lieutenants obey the

Commander

Lieutenant 1 Lieutenant 2

“Commander said ‘Retreat!’”

“Attack!”Traitor

“Attack!”

To satisfy BG2, Lieutenant 1 must obey “Attack!”.

Attack!

Page 31: Distributed systems The Byzantine Generals Problem · Byzantine Generals Problem Commander must send an order to n –1 lieutenants, such that: BG1: All loyal lieutenants obey the

Commander

Lieutenant 1 Lieutenant 2

“Commander said ‘Attack!’”

“Retreat!”Traitor

“Retreat!”

To satisfy BG2, Lieutenant 1 must obey “Retreat!”.

Retreat!

Page 32: Distributed systems The Byzantine Generals Problem · Byzantine Generals Problem Commander must send an order to n –1 lieutenants, such that: BG1: All loyal lieutenants obey the

3 generals, 1 of them traitor

To satisfy BG2, a loyal lieutenant must obey the order directly received from the commander.

Page 33: Distributed systems The Byzantine Generals Problem · Byzantine Generals Problem Commander must send an order to n –1 lieutenants, such that: BG1: All loyal lieutenants obey the

Commander

Lieutenant 1 Lieutenant 2

“Commander said ‘Attack!’”

“Attack!”

Traitor

“Retreat!”

BG1 violated!

“Commander said ‘Retreat!’”

Retreat!Attack!

Page 34: Distributed systems The Byzantine Generals Problem · Byzantine Generals Problem Commander must send an order to n –1 lieutenants, such that: BG1: All loyal lieutenants obey the

3 generals, 1 of them traitor

To satisfy BG2, a loyal lieutenant must obey the order directly received from the commander.

If commander is a traitor, BG1 is violated.

No algorithm can satisfy BG1 and BG2 for 3 generals and 1 possible traitor.

Page 35: Distributed systems The Byzantine Generals Problem · Byzantine Generals Problem Commander must send an order to n –1 lieutenants, such that: BG1: All loyal lieutenants obey the

Impossibility result

• No algorithm can solve the “Byzantine Generals Problem” for 3 generals, if one of them can be a traitor.

• Generalization: There is no algorithm for 3f generals, if f or more of them can be traitors.(proof by reduction from 3 generals, 1 traitor)

Page 36: Distributed systems The Byzantine Generals Problem · Byzantine Generals Problem Commander must send an order to n –1 lieutenants, such that: BG1: All loyal lieutenants obey the

3f generals, f of them traitors

• Proof by contradiction:1. Assume a solution for BGP(3f, f) for some f

2. Use it to solve BGP(3,1)

Contradiction with “there is no solution to BGP(3,1)”

Page 37: Distributed systems The Byzantine Generals Problem · Byzantine Generals Problem Commander must send an order to n –1 lieutenants, such that: BG1: All loyal lieutenants obey the

Albanian generalsf Albanian generals

f Albanian generals

f Albanian generals

Some algorithmfor BGP(3f,f)

(exists by assumption)

Page 38: Distributed systems The Byzantine Generals Problem · Byzantine Generals Problem Commander must send an order to n –1 lieutenants, such that: BG1: All loyal lieutenants obey the

Albanian generalsf Albanian generals

f Albanian generals

f Albanian generals

Some algorithmfor BGP(3f,f)

(exists by assumption)simulates

simulates

simulates

Traitor f traitors

Page 39: Distributed systems The Byzantine Generals Problem · Byzantine Generals Problem Commander must send an order to n –1 lieutenants, such that: BG1: All loyal lieutenants obey the

Unsolvability for BGP(3f,f)

If algorithm for BGP(3f,f) existed

Could use it to solve BGP(3,1)

Contradiction to unsolvability of BGP(3,1)

Conclusion: No alg. for BGP(3f,f) exists.

Page 40: Distributed systems The Byzantine Generals Problem · Byzantine Generals Problem Commander must send an order to n –1 lieutenants, such that: BG1: All loyal lieutenants obey the

Conclusion

• If faulty processes can lie (not only crash)• Correct majority is not enough!

• Even two thirds are not enough!

• True for any synchrony assumptions

• What can we do? (next lecture)• Stronger assumption: > 2/3 are correct

• Use signed messages