Lecture on 29 January 2019
Consensus Algorithms
Nakamoto Consensus
Federated Consensus
Blockchain for Beginners
Elective course from the Faculty of Information Technology, Thai - Nichi Institute of Technology, Bangkok for undergraduate students.
#BlockchainTNI2018
Call Girls In Mahipalpur O9654467111 Escorts Service
Blockchain Technology - Week 11 - Thai-Nichi Institute of Technology
1. Blockchain Technology
Week 11
Unit IV – Consensus Algorithms
Ferdin Joe John Joseph, PhD
Faculty of Information Technology
Thai-Nichi Institute of Technology, Bangkok
Venue: D603
2. Week 11 – Unit IV
Agenda
• Distributed System
• Voting Based Consensus
• Nakamoto Consensus
• Proof of Stake
• Federated Consensus
Faculty of Information Technology, Thai-Nichi Institute of
Technology
2
3. Distributed Systems
• Majority Oprinion
• General Agreement
Faculty of Information Technology, Thai-Nichi Institute of
Technology
3
4. Case: Digital Avionics
• Super dependable computers pioneered by aircraft manufacturers
• 100s of passengers and aircraft costs 100s of million usd
• Altitude, speed and fuel sensors
• Auto Pilot mode
Faculty of Information Technology, Thai-Nichi Institute of
Technology
4
5. Avionics Modules
• Reliability
• Trust without trust
• Solution: Consensus
Faculty of Information Technology, Thai-Nichi Institute of
Technology
5
6. Distributed Systems: Definition
• A set of independent nodes, each representing a “process”
• Message channels for information to move between nodes,
establishing a network
Faculty of Information Technology, Thai-Nichi Institute of
Technology
6
8. Distributed Systems: Properties
• Concurrent components
• No global clock
• Potential failure of individual components
Faculty of Information Technology, Thai-Nichi Institute of
Technology
8
9. Correctness
• Correctness of a distributed system: achieving its intended goal
• To ensure correctness, one uses a consensus algorithm achieving the
following: Validity, Agreement, and Termination
Faculty of Information Technology, Thai-Nichi Institute of
Technology
9
10. Correctness
• To ensure correctness, one uses a consensus algorithm achieving the
following:
• Validity: any value decided upon must be proposed by one of the
processes
• Agreement: all non-faulty processes must agree on the same value
Agreement and Validity are safety properties: Honest nodes will never
decide on trivial, random, or different values
• Termination: all non-faulty nodes eventually decide Termination is a
liveness property: All nodes eventually decide on a value
Faculty of Information Technology, Thai-Nichi Institute of
Technology
10
11. Week 11 – Unit IV
Agenda
• Distributed System
• Voting Based Consensus
• Nakamoto Consensus
• Proof of Stake
• Federated Consensus
Faculty of Information Technology, Thai-Nichi Institute of
Technology
11
12. Paxos
• Paxos is a Greek island
• Also a consensus algorithm
Faculty of Information Technology, Thai-Nichi Institute of
Technology
12
13. Paxon parliament
• Proposer: legislator, advocates a citizen's request, moves protocol
forward
• Acceptor: legislator, voter
• Learner: remembers and carries out result for citizen
• Quorum:
• any majority of Acceptors
• any two Quorums must overlap
Faculty of Information Technology, Thai-Nichi Institute of
Technology
13
14. Relevance
Paxon Parliament Distributed System
Legislator Server
Citizen Client Program
Current Law Database State
Faculty of Information Technology, Thai-Nichi Institute of
Technology
14
15. RAFT Algorithm
Raft is another consensus mechanism designed to be an alternative to
Paxos
• Designed to be more understandable than Paxos
• Leader-based approach
• Easier to implement
• JP Morgan’s Quorum: Raft-based consensus
Faculty of Information Technology, Thai-Nichi Institute of
Technology
15
16. RAFT: Process
• A Raft cluster has one and only one elected leader
• Communicates with client directly
• Responsible for managing log replication on the other servers of the cluster
• Leads until it fails or disconnects, in which case a new leader is elected
Leader Election
• Leader sends “heartbeats” to other nodes saying that it is online
• If other nodes no longer receive “heartbeat,” they start an election cycle (and
internal timer)
• First candidate to timeout becomes new leader
Faculty of Information Technology, Thai-Nichi Institute of
Technology
16
17. RAFT: Process
Log Replication
• Leader accepts client request
• Leader ensures all other nodes have followed that request
Faculty of Information Technology, Thai-Nichi Institute of
Technology
17
18. Week 11 – Unit IV
Agenda
• Distributed System
• Voting Based Consensus
• Nakamoto Consensus
• Proof of Stake
• Federated Consensus
Faculty of Information Technology, Thai-Nichi Institute of
Technology
18
19. Nakamoto Consensus: Proof of Work (PoW)
• Elect leader through some “lottery”
• Leader creates next block
• Others vote implicitly by including block in their chain
Faculty of Information Technology, Thai-Nichi Institute of
Technology
19
20. Nakamoto Consensus
• What resources consumed: Computational Power
Faculty of Information Technology, Thai-Nichi Institute of
Technology
20
21. Nakamoto Consensus: Proof of Stake (PoS)
Overview:
• Validators instead of “miners”
• Locking up “stake”
Resource consumed: Native currency
Faculty of Information Technology, Thai-Nichi Institute of
Technology
21
22. Hybrid Nakamoto Consensus
PoW + PoS hybrid:
• PoW: Miners create blocks (with or without transactions, depending
on implementation); block header contains validator data
• PoS: Validators sign valid blocks
Resources: Both PoW and PoS
Faculty of Information Technology, Thai-Nichi Institute of
Technology
22
23. Proof of Burn
Overview:
• Send coins to irretrievable address
• More coins burned, higher likelihood of election
• Like Proof-of-Stake, but edgier
• Bootstrapping mechanism:
• Tie a coin’s value to some other coin (e.g. Bitcoin) by demonstrating that users
willingly burn Bitcoin to receive this other coin
Resources Consumed: Potentially not native currency
Faculty of Information Technology, Thai-Nichi Institute of
Technology
23
24. Proof of Space
Overview:
• Use disk space to solve challenge
• Nowadays used for file storage
• Variations on implementations: Let users receive coins after voting on
blocks (Also known as Proof-of-Capacity)
• Resource consumed: Storage space
Faculty of Information Technology, Thai-Nichi Institute of
Technology
24
25. Proof of Elapsed Time
Overview:
• Spend time instead of mining power
• Resource Consumed: Time
Faculty of Information Technology, Thai-Nichi Institute of
Technology
25
26. Proof of Authority
Overview:
• Permissioned, non-production
• Used in Kovan and Rinkeby Ethereum testnets
• Resource Consumed: Identity (Reputation)
Faculty of Information Technology, Thai-Nichi Institute of
Technology
26
27. Week 11 – Unit IV
Agenda
• Distributed System
• Voting Based Consensus
• Nakamoto Consensus
• Proof of Stake
• Federated Consensus
Faculty of Information Technology, Thai-Nichi Institute of
Technology
27
29. Chain Based PoS
Algorithm for Chain-based PoS:
1. Randomly choose a validator based on the proportional stake
invested from the group of already existing validators.
2. The chosen validator creates a block which points to some
previously created block.
3. The chosen validator gets the block reward and the
transaction fees
Faculty of Information Technology, Thai-Nichi Institute of
Technology
29
30. Byzantine Fault Tolerant PoS
Algorithm for Byzantine Fault Tolerant PoS:
1. Randomly choose a validator based on the proportional stake
invested from the group of already existing validators.
2. The chosen validator proposes a block
3. All the other validators vote yes if they think it is a valid block
4. If ⅔ or more voting power votes yes, the block is included in the
blockchain. Otherwise a new proposer is chosen and we go back to Step 1.
5. The chosen validator gets the block reward and the transaction
fees
Faculty of Information Technology, Thai-Nichi Institute of
Technology
30
32. Week 11 – Unit IV
Agenda
• Distributed System
• Voting Based Consensus
• Nakamoto Consensus
• Proof of Stake
• Federated Consensus
Faculty of Information Technology, Thai-Nichi Institute of
Technology
32
33. Byzantine Agreement
• In a distributed system, a quorum is a set of nodes sufficient to
reach agreement.
Faculty of Information Technology, Thai-Nichi Institute of
Technology
33
36. Case: Lunch time consensus
Faculty of Information Technology, Thai-Nichi Institute of
Technology
36
A B C
Wanna get
37. Case: Lunch time consensus
Faculty of Information Technology, Thai-Nichi Institute of
Technology
37
A B C
We prefer
Burger. Its $1
today!
38. Case: Lunch time consensus
Faculty of Information Technology, Thai-Nichi Institute of
Technology
38
A B C
Then I will opt
for burger too.
39. Case: Lunch time consensus
Faculty of Information Technology, Thai-Nichi Institute of
Technology
39
A B C
Can I Join too?
D
40. Case: Lunch time consensus
Faculty of Information Technology, Thai-Nichi Institute of
Technology
40
A B C
But I don’t
Trust A.
D
41. Case: Lunch time consensus
Faculty of Information Technology, Thai-Nichi Institute of
Technology
41
A B C
Don’t Worry!
We can form a
quorem slice.
D
42. Case: Lunch time consensus
Faculty of Information Technology, Thai-Nichi Institute of
Technology
42
A B C D
43. Case: Lunch time consensus
Faculty of Information Technology, Thai-Nichi Institute of
Technology
43
A B C
Can I join too?
DE
44. Case: Lunch time consensus
Faculty of Information Technology, Thai-Nichi Institute of
Technology
44
A B C
But I trust A
and B only.
DE
45. Case: Lunch time consensus
Faculty of Information Technology, Thai-Nichi Institute of
Technology
45
A B C
Sure. We can
for a quorem.
DE
46. Case: Lunch time consensus
Faculty of Information Technology, Thai-Nichi Institute of
Technology
46
A B C DE
47. Next Week
• Distributed Ledger Management
• Government Policies and Ethics in Blockchain usage
Faculty of Information Technology, Thai-Nichi Institute of
Technology
47