Sei sulla pagina 1di 18

Byzantine

and King Algorithm

Bar-Ilan
Shmuel Goldklang
2007

Consensus with Byzantine


In consensus problem we strive to
have a consensus in the system.
The Byzantine nodes, sends different
input to different nodes.
So each node get different input.
Each node will run the same
algorithm.
Different input + same algorithm =
different result.

Example
Selecting the minimum value.
1,8,-9,-65,-278

1,8,-9,-65,268
1

1,8,-9,-65,-268
-9

-65

1,8,-9,-65
1,8,-9,-65,278
268

Example
Selecting the minimum value.

-278

-65

-65

-65

Reminder
What are the three requirements
that a consensus algorithm must
have?
Termination
Agreement
Validity

Solution
Give a solution to the Byzantine
problem.
System has N nodes + F Byzantine
nodes.
Hint: limit the ratio of F:N
Hint: use pigeonhole principle.

Kings solution
The system will have F+1 King
nodes.
There will be F+1 rounds.
Each round for each king.
Each round has 2 steps

Kings solution
Step 1:
Each node sends this value to the rest of
the nodes.
Each node selects the majority value.
Step 2:
Only the king sends this value to the rest
of the nodes.
If the majority is higher then (N/2)+F
select the major value.
Else select the King value.

Algorithm
Initially pref[i] = v
And pref[j] = v, for any j != i
1: round 2k 1 ; 1 <=k <= f+1:
2:
send <pref[i]> to all processors
3:
receive <Vj> from Pj and assign to pref[j]
4:
let maj be the majority value of PREF, or V
5:
let mult be the multiplicity of maj
6: round 2k ; 1 <= k < f +1
7:
if i = k then send <maj> to all processors
8:
receive <king-maj> from Pk, or v
9:
if mult > (n/2 +f) then
10:
pref[i] := maj
11:
else
12:
pref[i] := king-maj
13: if k = f + 1 then y := pref[j]

Example
1

Example round 1.1


1

1(4)

1(4)

1(4)

1(3)

1(4)

2(4)

1(5)

0(4)

1(4)

Example round 1.1


1

1(4)

1(4)

1(4)

1(3)

1(4)

2(4)

1(5)

0(4)

1(4)

Example round 2.1


1

1(5)

2(4)

1(5)

1(4)

1(5)

1(6)

1(5)

1(5)

1(5)

Example round 2.1


1

1(5)

2(4)

1(5)

1(4)

1(5)

1(6)

1(5)

1(5)

1(5)

Example round 3.1


1

1(4)

2(5)

0(1)

2(4)

2(4)

1(5)

1(4)

2(4)

1(4)

Example round 3.1


1

1(4)

2(5)

0(1)

2(4)

2(4)

1(5)

1(4)

2(4)

1(4)

Example round 3.2


1

Question
In order to gain majority, we need the
majority will be higher the N/2+ F.
What is the F:N ratio that is require for
the King algorithm.
Major > N/2 + F
N F > N/2 + F
2N 2F > N + 2F
N > 4F

Potrebbero piacerti anche