Byzantine Fault Tolerance Consensus Strikes Back Announcements Lab - - PowerPoint PPT Presentation

byzantine fault tolerance
SMART_READER_LITE
LIVE PREVIEW

Byzantine Fault Tolerance Consensus Strikes Back Announcements Lab - - PowerPoint PPT Presentation

Byzantine Fault Tolerance Consensus Strikes Back Announcements Lab 2 Hopefully everyone has started by now, maybe even finished large portions. If not ... you should worry . Please don't change the protobufs. My testing strategy


slide-1
SLIDE 1

Byzantine Fault Tolerance

Consensus Strikes Back

slide-2
SLIDE 2

Announcements

slide-3
SLIDE 3

Lab 2

  • Hopefully everyone has started by now, maybe even finished large portions.
  • If not ... you should worry.
  • Please don't change the protobufs.
  • My testing strategy is going to be to write a few clients and check linearizability.
  • Changing the interface doesn't let me do that.
  • Feel free to change whatever is not the interface.
slide-4
SLIDE 4

BFT

slide-5
SLIDE 5

A Note on Terminology

  • Byzantine Empire?
  • Continuation of the Roman Empire, ~400-1450 AD
  • Commonly used as example of bad bureaucracy, in fighting...
  • Historical records don't entirely agree with this.
slide-6
SLIDE 6

What is the Problem?

1 2 3 4

slide-7
SLIDE 7

What is the Problem?

1 2 3 4

slide-8
SLIDE 8

Concrete Problems

1 2 3 4

AppendEntries(..., [(index=4)]) Success AppendEntries(..., [], leaderCommit=4)

slide-9
SLIDE 9

Concrete Problems

1 2

RequestVote( term=2) RequestVote( term=2) VoteGranted( term=2) VoteGranted( term=2)

slide-10
SLIDE 10

Concrete Problems

slide-11
SLIDE 11

Failure Models

  • Until now we have considered fail-stop processes.
  • When failed: stop sending messages and take no steps.
  • Byzantine faults: when failed do "arbitrary things."
  • These arbitrary things could even be coordinated with other failed nodes.
slide-12
SLIDE 12

However assuming we know participants a priori.

slide-13
SLIDE 13
slide-14
SLIDE 14

On the internet nobody knows what maps to a user, nor to a machine, ...

slide-15
SLIDE 15

Not Considering this Problem

  • Live in a centralized environment.
  • All servers/nodes are launched by some centralized entity.
  • For example Kubernetes or a human with physical access.
  • Several ways to solve the decentralized problem.
  • But largely separable from the discussion at hand.
slide-16
SLIDE 16

Is This Still Useful?

  • Yes...
  • Used by Boeing in the 777 to ensure safety.
  • Used in SpaceX Falcon -- "... to meet requirements for approaching the ISS"
  • Generally useful, but cost prohibitive.
slide-17
SLIDE 17

Failure Models

  • Until now we have considered fail-stop processes.
  • When failed: stop sending messages and take no steps.
  • Byzantine faults: when failed do "arbitrary things."
  • These arbitrary things could even be coordinated with other failed nodes.
slide-18
SLIDE 18

What Can we Do?

slide-19
SLIDE 19

What Do We Care about Addressing

1 2 3 4

State State State State State

slide-20
SLIDE 20

What Do We Care about Addressing

1 2 3 4

State State State State State

Can't really peer into the state of a remote node, cannot do much.

slide-21
SLIDE 21

What Do We Care about Addressing

1 2 3 4 Failed nodes can only interfere by sending messages.

slide-22
SLIDE 22

What Do We Care about Addressing

1 2 3 4 Make sure messages sent by all nodes are "correct" before acting.

slide-23
SLIDE 23

Why challenging? Don't know failed nodes a-priori.

slide-24
SLIDE 24

When are Messages Correct?

  • Every correct node receives the same messages (and acts correctly).
  • Same might not necessarily mean "correct".
  • But always accept any message from a correct participant.
  • Every message is "consistent" with the protocol.
  • Attach some kind of proof that you were supposed to send this message.
slide-25
SLIDE 25

When are Messages Correct?

  • Every correct node receives the same messages (and acts correctly).
  • Every message is "consistent" with the protocol.
slide-26
SLIDE 26

Agreeing on Correct Messages

slide-27
SLIDE 27

Problem we Want to Solve

1 2 3 4

AppendEntries(..., [(index=4)])

slide-28
SLIDE 28

Problem we Want to Solve

1 2 3 4

Success

slide-29
SLIDE 29

Problem we Want to Solve

1 2 3 4

AppendEntries(..., [], leaderCommit = 4)

slide-30
SLIDE 30

Problem we Want to Solve

1 2 3 4

AppendEntries(..., [(index=4)])

slide-31
SLIDE 31

Problem we Want to Solve

1 2 3 4

AppendEntries(..., [], leaderCommit = 4)

slide-32
SLIDE 32

Problem we Want to Solve

  • Cannot observe messages between individuals.
  • Hard to judge whether behavior is correct.
  • New idea: send messages to everyone.
  • Everyone knows where the state machine should be.
slide-33
SLIDE 33

Sending to Everyone

1 2 3 4

0->1: AppendEntries(..., [(index=4)])

slide-34
SLIDE 34

Sending to Everyone

1 2 3 4

Success Success

slide-35
SLIDE 35

Sending to Everyone is Insufficient

1 2 3 4

0->1: AppendEntries(..., [(c0, index=4)]) 0->1: AppendEntries(..., [(c1, index=4)])

slide-36
SLIDE 36

Sending to Everyone is Insufficient

1 2 3 4

Success Success

1 thinks slot 4 is c1 Slot 4 is c0 1 thinks slot 4 is c0

slide-37
SLIDE 37

Sending to Everyone is Not Sufficient

  • Faulty node can send differing messages to "everyone".
  • Run some protocol to detect this problem.
slide-38
SLIDE 38

Sending to Everyone

1 2 3 4

0->1: AppendEntries(..., [(c0, index=4)]) 0->1: AppendEntries(..., [(c1, index=4)])

1 2 3 4

0->1: c0, 4

1 2 3 4

0->1: c1, 4

1 2 3 4

0->1: c0, 4

1 2 3 4

0->1: c1, 4

slide-39
SLIDE 39

Sending to Everyone

1 2 3 4

1 2 3 4

0->1: c0, 4 0->1: c0, 4 0->1: c0, 4 0->1: c0, 4

1 2 3 4

0->1: c1, 4

1 2 3 4

0->1: c0, 4

1 2 3 4

0->1: c1, 4

slide-40
SLIDE 40

Sending to Everyone

1 2 3 4

1 2 3 4

0->1: c0, 4 0->1: c0, 4 0->1: c0, 4 0->1: c0, 4

1 2 3 4

0->1: c1, 4 0->1: c1, 4 0->1: c1, 4 0->1: c1, 4

1 2 3 4

0->1: c0, 4 0->1: c0, 4 0->1: c0, 4 0->1: c0, 4

1 2 3 4

0->1: c1, 4 0->1: c1, 4 0->1: c1, 4 0->1: c1, 4

Choose majority, breaking ties deterministically.

slide-41
SLIDE 41

Sending to Everyone

1 2 3 4 2

1 2 3 4

0->1: c0, 4 0->1: c0, 4 0->1: c0, 4 0->1: c0, 4

1 2 3 4

0->1: c0, 4 ??? ??? ???

1 2 3 4

0->1: c0, 4 0->1: c0, 4 0->1: c0, 4 0->1: c0, 4

1 2 3 4

0->1: c0, 4 0->1: c0, 4 0->1: c0, 4 0->1: c0, 4

Choose majority, breaking ties deterministically.

slide-42
SLIDE 42

Not Possible for 1 failure with 3 participants

1 1 2 2

0->1: x=2 0->1: x=1 0->1: x=1 0->1: x=1

slide-43
SLIDE 43

Not Possible for 1 failure with 3 participants

1 1 2 2

0->1: x=2 0->1: x=1 0->1: x=2 0->1: x=1

slide-44
SLIDE 44

Not Possible for 1 failure with 3 participants

1 1 2 2

0->1: x=2 0->1: x=1 0->1: x=2 0->1: x=1

Cannot distinguish between these two cases. Cannot meet the two requirements state at the beginning.

slide-45
SLIDE 45

Limitations

  • More generally cannot solve for m failures with < 3m+1 participants.
  • Proof by reduction to the case with 3.
slide-46
SLIDE 46

Sending to Everyone

1 2 3 4

1 2 3 4

0->1: c0, 4 0->1: c0, 4 0->1: c0, 4 0->1: c0, 4

1 2 3 4

0->1: c1, 4 0->1: c1, 4 0->1: c1, 4 0->1: c1, 4

1 2 3 4

0->1: c0, 4 0->1: c0, 4 0->1: c0, 4 0->1: c0, 4

1 2 3 4

0->1: c1, 4 0->1: c1, 4 0->1: c1, 4 0->1: c1, 4

  • However, note that doing this once is not sufficient for more than 1 faults.

5 6

0->1: c0, 4 0->1: c1, 4 0->1: c0, 4

1 2 3 4

0->1: c1, 4 0->1: c0, 4 0->1: c1, 4 0->1: c0, 4

1 2 3 4

0->1: c0, 4 0->1: c1, 4 0->1: c1, 4

5 6 5 6 5 6 5 6 5 6 5 6

0->1: c1, 4 0->1: c1, 4 0->1: c1, 4 0->1: c1, 4 0->1: c1, 4 0->1: c0, 4 0->1: c0, 4 0->1: c0, 4 0->1: c0, 4 0->1: c0, 4

slide-47
SLIDE 47

Sending to Everyone

1 2 3 4

1 2 3 4

0->1: c0, 4 0->1: c0, 4 0->1: c0, 4 0->1: c0, 4

1 2 3 4

0->1: c1, 4 ??? ??? ???

1 2 3 4

0->1: c0, 4 0->1: c0, 4 0->1: c0, 4 0->1: c0, 4

1 2 3 4

0->1: c1, 4 0->1: c1, 4 0->1: c1, 4 0->1: c1, 4

  • However, note that doing this once is not sufficient for more than 1 faults.
  • For example, can force any decision in this case.

5 6

0->1: c0, 4 ??? 0->1: c0, 4

1 2 3 4

0->1: c1, 4 0->1: c0, 4 ??? 0->1: c0, 4

1 2 3 4

0->1: c0, 4 0->1: c1, 4 0->1: c1, 4

5 6 5 6 5 6 5 6 5 6 5 6

0->1: c1, 4 0->1: c1, 4 0->1: c1, 4 0->1: c1, 4 0->1: c1, 4 0->1: c0, 4 0->1: c0, 4 0->1: c0, 4 0->1: c0, 4 0->1: c0, 4

2

slide-48
SLIDE 48

Solution: Recursively call again.

slide-49
SLIDE 49

When are Messages Correct?

  • Every correct node receives the same messages (and acts correctly).
  • Every message is "consistent" with the protocol.
slide-50
SLIDE 50

Proving Consistency with the Protocol

slide-51
SLIDE 51

What Does this Even Mean?

1 2 3 4

AppendEntries(..., [(index=4)])

slide-52
SLIDE 52

What Does this Even Mean?

1 2 3 4

Success

slide-53
SLIDE 53

What Does this Even Mean?

1 2 3 4

AppendEntries(..., [], leaderCommit = 4), Proof that a majority have accepted entires until 4.

slide-54
SLIDE 54

Problem

  • How to generate proofs?
  • Many possibilities, but just going to include messages here.
  • How to prevent failed nodes from misrepresenting messages?
slide-55
SLIDE 55

Misrepresenting Messages

1 2 3 4

AppendEntries(..., [], leaderCommit = 4), Success from 0, 1, 2, 3

slide-56
SLIDE 56

Misrepresenting Messages

1 2 3 4

AppendEntries(..., [], leaderCommit = 4), Success from 0, 1, 2, 3

slide-57
SLIDE 57

Warning: Cryptography

slide-58
SLIDE 58

Digests/Hashes

h Arbitrary length input Fixed length output

  • Deterministic: h(x) should always be the same value.
  • Not invertable -- given h(x) cannot find x.
  • Output of h(x) is equivalent to a random function.
  • Infeasible to find collisions.
slide-59
SLIDE 59

Digital Signature

f Input Signature g Input ✔ 𝙔

  • r

Signature g(m, s) = ✔ if and only if f(m) = s.

slide-60
SLIDE 60

Digital Signature

f Input Signature g Input ✔ 𝙔

  • r

Signature g(m, s) = ✔ if and only if f(m) = s. f g g

O w e y

  • u

1 s c

  • p

s

  • f

i c e c r e a m . f ( O w e y

  • u

1 s c

  • p

s

  • f

i c e c r e a m . ) Owe you 10 scoops of ice cream.f(Owe you 10 scoops of ice cream.) O w e y

  • u

s c

  • p

s

  • f

i c e c r e a m . Owe you 10 scoops of ice cream. f(Owe you 10 scoops of ice cream.)

Provides a non-repudiation mechanism.

You owe Grizzly 10 scoops.

slide-61
SLIDE 61

Digital Signature

  • Need an entire family of these functions, not just one.
  • Why?
  • Parametrize with one or more "keys".
  • f(key, message) = signature
  • g(key', message, signature) = ✔ if and only if f(key, message) = signature

f Input Signature g Input ✔ 𝙔

  • r

Signature g(m, s) = ✔ if and only if f(m) = s.

slide-62
SLIDE 62

Digital Signature

  • Need an entire family of these functions, not just one.
  • Parametrize with one or more "keys".
  • f(key private, message) = signature
  • g(key' public, message, signature) = ✔ iff f(key private, message) = signature

f Input Signature g Input ✔ 𝙔

  • r

Signature g(m, s) = ✔ if and only if f(m) = s.

slide-63
SLIDE 63

Proving Message Receipt

1 2 3 4

AppendEntries(..., [], leaderCommit = 4), Sig(pr1, success), Sig(pr2, success), Sig(pr3, success) Pr0 Pr1 Pr2 Pr3 Pr4

slide-64
SLIDE 64

Proving Message Receipt

1 2 3 4

AppendEntries(..., [], leaderCommit = 4), Sig(pr1, success), Sig(pr2, success), Sig(pr3, success) Pr0 Pr1 Pr2 Pr3 Pr4

slide-65
SLIDE 65

Proving Message Receipt

  • Looks simple in principle, but tricky to get right in practice.
  • PBFT takes this basic idea and packages it into an optimized version.
slide-66
SLIDE 66

PBFT

c 1 2 3 req, sigc(req)

slide-67
SLIDE 67

PBFT

c 1 2 3 pre-prep(v, n, d) sig0(pre-prep(v, n, d)) <req , sigc(req)> req, sigc(req)

slide-68
SLIDE 68

PBFT

c 1 2 3 pre-prep(v, n, d) sig0(pre-prep(v, n, d)) <req , sigc(req)> req, sigc(req)

slide-69
SLIDE 69

PBFT

c 1 2 3 req, sigc(req) prep(v, n, d, i) sig1(prep(v, n, d, i))

slide-70
SLIDE 70

PBFT

c 1 2 3 req, sigc(req)

Wait for 2m prepare messages

slide-71
SLIDE 71

PBFT

c 1 2 3 req, sigc(req) commit(v, n, d, i) sig1(commit(v, n, d, i))

slide-72
SLIDE 72

PBFT

c 1 2 3 req, sigc(req)

Wait for 2m commit messages

slide-73
SLIDE 73

PBFT

c 1 2 3 req, sigc(req) resp(r, v, i) sig1(resp)

slide-74
SLIDE 74

Haven't used those signatures yet?

slide-75
SLIDE 75

Where are the Signatures Used?

  • View change: prove that you are not trying to cheat when consolidating logs.
  • Another important bit: in each view leader is decided by view-number.
  • Not by voting as in Raft.
  • Why is this important?
  • Not discussing details today, might return to this next week.
slide-76
SLIDE 76

Quiz