Distributed Computing On Topics of: Leader election + Byzantine algorithms)
-
Upload
osama-askoura -
Category
Technology
-
view
155 -
download
0
Transcript of Distributed Computing On Topics of: Leader election + Byzantine algorithms)
![Page 1: Distributed Computing On Topics of: Leader election + Byzantine algorithms)](https://reader031.fdocuments.us/reader031/viewer/2022022203/587909131a28ab6f658b559f/html5/thumbnails/1.jpg)
Distributed Computing On Topics of: Leader election + Byzantine algorithms)
SLIDES BY OSAMA ASKOURA
EECS 6117
Distributed Computing Set 2
![Page 2: Distributed Computing On Topics of: Leader election + Byzantine algorithms)](https://reader031.fdocuments.us/reader031/viewer/2022022203/587909131a28ab6f658b559f/html5/thumbnails/2.jpg)
Leader Election in rings
![Page 3: Distributed Computing On Topics of: Leader election + Byzantine algorithms)](https://reader031.fdocuments.us/reader031/viewer/2022022203/587909131a28ab6f658b559f/html5/thumbnails/3.jpg)
Slide
2
We define leader election:
By the end of algorithm’s execution, only one
node identifies as “leader”
All other nodes identify as “follower”
Leader Election in anonymous rings is
impossible.
Leader Election in
Model
Ring Topology
Synchronous
Non Anonymous Processes
Anonymous ring Non-Anonymous ring
#1
#3 #9
#7 #5
#2
#3
#4
![Page 4: Distributed Computing On Topics of: Leader election + Byzantine algorithms)](https://reader031.fdocuments.us/reader031/viewer/2022022203/587909131a28ab6f658b559f/html5/thumbnails/4.jpg)
Leader Election in non-anonymous rings
![Page 5: Distributed Computing On Topics of: Leader election + Byzantine algorithms)](https://reader031.fdocuments.us/reader031/viewer/2022022203/587909131a28ab6f658b559f/html5/thumbnails/5.jpg)
Slide
2
Leader election algorithm 1:
• send id CCW;
• Forward msgs until you receive own id back;
• If ( my id was smallest seen before own id
comes back )
• Then I’m “leader”
• Else
• Not leader “follower”
Total # messages = n2
Model
Ring Topology
Synchronous
Non Anonymous Processes
Non-Anonymous ring
#1
#3 #9
#7 #5
#2
#3
#4
![Page 6: Distributed Computing On Topics of: Leader election + Byzantine algorithms)](https://reader031.fdocuments.us/reader031/viewer/2022022203/587909131a28ab6f658b559f/html5/thumbnails/6.jpg)
Slide
2
Leader election algorithm 2:
• Candidate = true;
• loop
• send id CCW and CW (bi-directional)
• If received id < own id
• Candidate = false
• Exit loop (“follower”)
• If got own id back
• I’m “leader”
• Exit loop
Total # messages = 2n log(n)
Model
Ring Topology
Synchronous
Non Anonymous Processes
Bi-directional msgs
Non-Anonymous ring
#1
#3 #9
#7 #5
#2
#8
#4
![Page 7: Distributed Computing On Topics of: Leader election + Byzantine algorithms)](https://reader031.fdocuments.us/reader031/viewer/2022022203/587909131a28ab6f658b559f/html5/thumbnails/7.jpg)
Leader election algorithm 2:
Proof that total # messages = 2n log(n):
• Every cycle each node sends 2 msgs 2n messages
• Every cycle you eliminate half log(n) cycles
• Total = 2n log(n)
Model
Ring Topology
Synchronous
Non Anonymous Processes
Bi-directional msgs
Non-Anonymous ring
#1
#3 #9
#7 #5
#2
#8
#4
#1
#3 #9
#7 #5
#2
#8
#4
#1
#9
#7 #5
#2
#8
#3
#4
#1
#9
#7 #5
#2
#8
#3
#4
#1
#9
#7 #5
#2
#8
#3
#4
![Page 8: Distributed Computing On Topics of: Leader election + Byzantine algorithms)](https://reader031.fdocuments.us/reader031/viewer/2022022203/587909131a28ab6f658b559f/html5/thumbnails/8.jpg)
Slide
2
Leader election algorithm 3:
• Wait until CLOCK = n * id
• Declare yourself leader
• Send everybody telling you are leader
Total # messages = n
But what if id’s are very large numbers or IP addresses?
• Time complexity grows big
• Cannot compare IP to CLOCK Model
Ring Topology
Synchronous
Non Anonymous Processes
#1
#3 #9
#7 #5
#2
#8
#4
![Page 9: Distributed Computing On Topics of: Leader election + Byzantine algorithms)](https://reader031.fdocuments.us/reader031/viewer/2022022203/587909131a28ab6f658b559f/html5/thumbnails/9.jpg)
Slide
2
CLAIM:
Every Leader Election algorithm in this model uses Ω( n log(n) )
messages
PROOF (Contradiction):
Suppose, exists algorithm that uses < n log(n) messages
Let A be that L.E algorithm
Transform A into A’ so that in A’ every process outputs minimum
id’s
So, A’ is
1. Elect leader;
2. Leader sends message around round to find smallest id
3. Leader sends smallest id to all
Model
Ring Topology
Synchronous
Non Anonymous Processes
#1
#3 #9
#7 #5
#2
#8
#4
![Page 10: Distributed Computing On Topics of: Leader election + Byzantine algorithms)](https://reader031.fdocuments.us/reader031/viewer/2022022203/587909131a28ab6f658b559f/html5/thumbnails/10.jpg)
Slide
2
If A uses A(n) messages, then A’ uses A(n) + 2n messages
We will show that A(n) + 2n ≥ c. n log(n)
i.e. A(n) ≥ c. log(n)
Base n = 1: at least 0 messages
m(n) :
m(1) = 0
m(n) = 2 m(n) + 𝒏
𝟐
Two rings proof Model
Ring Topology
Synchronous
Non Anonymous Processes
#1
#3 #9
#7 #5
#2
#8
#4
![Page 11: Distributed Computing On Topics of: Leader election + Byzantine algorithms)](https://reader031.fdocuments.us/reader031/viewer/2022022203/587909131a28ab6f658b559f/html5/thumbnails/11.jpg)
Byzantine Agreement
in complete graphs
![Page 12: Distributed Computing On Topics of: Leader election + Byzantine algorithms)](https://reader031.fdocuments.us/reader031/viewer/2022022203/587909131a28ab6f658b559f/html5/thumbnails/12.jpg)
We look at the problem where a group of processes or nodes
need to agree on an output. In Byzantine agreements, some
nodes are allowed to be malicious. i.e. stay alive but not
follow their algorithm.
This problem arises in distributed systems with sensors
that can be faulty; such as airplane systems
Byzantine
Process
Correct
Processes
![Page 13: Distributed Computing On Topics of: Leader election + Byzantine algorithms)](https://reader031.fdocuments.us/reader031/viewer/2022022203/587909131a28ab6f658b559f/html5/thumbnails/13.jpg)
Agreement Property
All outputs of correct processes are same
Validity Property
If all inputs are “v”, then all outputs of correct processes are “v”
Byzantine
Process
Correct
Processes
![Page 14: Distributed Computing On Topics of: Leader election + Byzantine algorithms)](https://reader031.fdocuments.us/reader031/viewer/2022022203/587909131a28ab6f658b559f/html5/thumbnails/14.jpg)
Examples for Agreement with n=2 #failures = 0
Solution: each process send their input to each other; output
AND of the inputs (ensures both output same value)
Model
Non Anonymous Processes ( Proc IDs)
Message Passing System
Complete Network
Synchronous
No cryptography (used in reality to
avoid byzantine/malicious nodes)
![Page 15: Distributed Computing On Topics of: Leader election + Byzantine algorithms)](https://reader031.fdocuments.us/reader031/viewer/2022022203/587909131a28ab6f658b559f/html5/thumbnails/15.jpg)
Examples for Agreement with n=2 #failures = 1 (up to 1 failure: we don’t know if any will fail)
Solution Attempt:
output whatever your input is; No communication in between.
- This satisfies validity property (if all input was v; all output is v)
- But doesn’t satisfy agreement property. How?:
So if n=2 & f =1, it’s impossible to solve
Model
Non Anonymous Processes ( Proc IDs)
Message Passing System
Complete Network
Synchronous
No cryptography (used in reality to
avoid byzantine/malicious nodes)
v1
v1
v1
v1
1
1
0
0
![Page 16: Distributed Computing On Topics of: Leader election + Byzantine algorithms)](https://reader031.fdocuments.us/reader031/viewer/2022022203/587909131a28ab6f658b559f/html5/thumbnails/16.jpg)
Examples for Agreement with n=3 #failures = 1 (up to 1 failure: we don’t know if any will fail)
Solution Attempt:
Round 1: send to your neighbors your input
Round 2: ask other nodes what others sent them?
Problem: Bad guy can send inconsistent answers to bias their
decisions and violate agreement or validity property.
n = 3 and f = 1 is impossible
Model
Non Anonymous Processes ( Proc IDs)
Message Passing System
Complete Network
Synchronous
No cryptography (used in reality to
avoid byzantine/malicious nodes)
1 1
0 1
0 0
0
1 Byzantine:
sends
inconsistent
values to each
0 1
0 1
0 1
0
1 Byzantine:
sends
inconsistent
values to each
Round 1 Round 2
![Page 17: Distributed Computing On Topics of: Leader election + Byzantine algorithms)](https://reader031.fdocuments.us/reader031/viewer/2022022203/587909131a28ab6f658b559f/html5/thumbnails/17.jpg)
Byzantine Agreement in n = 4, f =1 is possible.
Byzantine Agreement is possible if n > 3f
Proving impossibility for n ≤ 3f
Claim: it’s impossible for n ≤ 3f
Proof (by contradiction):
assume it’s possible for n ≤ 3f i.e. exists algorithm A, that
solve it, then we can show that n=3, f=1 is solvable by A
![Page 18: Distributed Computing On Topics of: Leader election + Byzantine algorithms)](https://reader031.fdocuments.us/reader031/viewer/2022022203/587909131a28ab6f658b559f/html5/thumbnails/18.jpg)
If there is an algorithm for n=3, f=1 take it and run it on 6
nodes as follows:
Then processes a & b can’t tell difference if P3’ and P3
send you same as
P3’
P3
a
b
![Page 19: Distributed Computing On Topics of: Leader election + Byzantine algorithms)](https://reader031.fdocuments.us/reader031/viewer/2022022203/587909131a28ab6f658b559f/html5/thumbnails/19.jpg)
Algorithm for Byzantine Agreement if n > 4f: for i=1 to f+1
round 1: send preference to everyone
round 2: if i=my_id then
send majority value received in prev round
Lemma 1: if all correct processes have same preference v at
start of phase P, they have preference v at end of phase P.
Proof: In round 1, all correct processes send v (≥ n-f v’s sent)
n-f > f + 𝑛
2 ≡
𝑛
2 > 2f ≡ n > 4f
Therefore, satisfying validity property follows from Lemma 1
![Page 20: Distributed Computing On Topics of: Leader election + Byzantine algorithms)](https://reader031.fdocuments.us/reader031/viewer/2022022203/587909131a28ab6f658b559f/html5/thumbnails/20.jpg)
Algorithm for Byzantine Agreement if n > 4f:
Lemma 2: if process i is correct, then all correct processes have
same preference at end of phase P.
Proof: Any 2 correct proc that update to leader’s value choose
same preference (since leader is correct)
Any 2 that chooses value because they get > f+ 𝑛
2 copies must
choose same value. (since > 𝑛
2 copies caused from correct
processes + cannot be each of 2 different values )
![Page 21: Distributed Computing On Topics of: Leader election + Byzantine algorithms)](https://reader031.fdocuments.us/reader031/viewer/2022022203/587909131a28ab6f658b559f/html5/thumbnails/21.jpg)
Proof (continued): if any proc gets > f + 𝑛
2 copies of v then:
• > 𝑛
2 v’s came from correct processes
• Leader gets > 𝑛
2 copies of v
• Leader sends v
• all correct processes choose v
Thus satisfying agreement property follows from Lemma 2
Since we proved that our algorithm satisfies validity and
agreement, we prove that our algorithm is correct.
![Page 22: Distributed Computing On Topics of: Leader election + Byzantine algorithms)](https://reader031.fdocuments.us/reader031/viewer/2022022203/587909131a28ab6f658b559f/html5/thumbnails/22.jpg)
Byzantine Agreement
in incomplete graphs
![Page 23: Distributed Computing On Topics of: Leader election + Byzantine algorithms)](https://reader031.fdocuments.us/reader031/viewer/2022022203/587909131a28ab6f658b559f/html5/thumbnails/23.jpg)
Byzantine agreement works in complete graphs (model
below) if n > 3f
But for incomplete graphs, an extra condition holds.
Why?
Model
Non Anonymous Processes ( Proc IDs)
Message Passing System
Complete Network
Synchronous
No cryptography (used in reality to
avoid byzantine/malicious nodes)
A
C
B
D
Nodes B or C can fail, but NOT both
If this happens, the agreement is not
solvable.
![Page 24: Distributed Computing On Topics of: Leader election + Byzantine algorithms)](https://reader031.fdocuments.us/reader031/viewer/2022022203/587909131a28ab6f658b559f/html5/thumbnails/24.jpg)
Byzantine agreement works in complete graphs (model
below) if n > 3f
But for incomplete graphs, an extra condition holds.
Why?
Model
Non Anonymous Processes ( Proc IDs)
Message Passing System
Complete Network
Synchronous
No cryptography (used in reality to
avoid byzantine/malicious nodes)
A
C
B
D
Nodes B or C can fail, but NOT both (so n > 3f)
BUT
If this happens, the agreement
is not solvable: as A and D can only
communicate reliably one non-byzantine
process. However, the byzantine process
can reach all other 3.
![Page 25: Distributed Computing On Topics of: Leader election + Byzantine algorithms)](https://reader031.fdocuments.us/reader031/viewer/2022022203/587909131a28ab6f658b559f/html5/thumbnails/25.jpg)
Generality:
Byzantine Agreement is solvable in any arbitrary graph
if and only if:
n > 3f AND connectivity > 2f
![Page 26: Distributed Computing On Topics of: Leader election + Byzantine algorithms)](https://reader031.fdocuments.us/reader031/viewer/2022022203/587909131a28ab6f658b559f/html5/thumbnails/26.jpg)
When we say model A is as strong as model B, we need to
prove any of:
1. All executions in A are also executions in B
2. Problems solvable in B are subset of problems
solvable in A • i.e. any problem the can be solved in B; can also be solved in A.
(Corollary: If a problem is impossible in A; it’s also impossible in B)
3. Show that A simulates B ( ᴟ transformation that
converts any algorithm for B into algorithm for A) • Strong simulates weak
B
executions
A
executions
![Page 27: Distributed Computing On Topics of: Leader election + Byzantine algorithms)](https://reader031.fdocuments.us/reader031/viewer/2022022203/587909131a28ab6f658b559f/html5/thumbnails/27.jpg)
Slide
18
EECS 6117 notes FW15-16, Instructor: Eric Ruppert
Hagit Attiya and Jennifer Welch. Distributed Computing: Fundamentals, Simulations and Advanced
Topics, 2nd edition. Wiley, 2004.
Nancy A. Lynch. Distributed Algorithms. Morgan Kaufmann, 1996.
References