# <center><i class="fa fa-edit"></i> 2.2 Distributed Consensus </center> ###### tags: `Blockchain` The following notes are taken from [Coursera](https://www.coursera.org/learn/cryptocurrency/home/week/2) --- Traditional motivation: reliability in distributed systems - Distributed key-value store: enables various applications (i.e. DNS, public key directory, stock trades, etc) - Good for **Altcoins**: systems built on Bitcoin-like principles to achieve slightly diff goals ### Definition Suppose there are `n` nodes 1. Protocol terminates and all *correct* nodes decide on same value 2. Value must been proposed by some correct node Bitcoin is **peer-to-peer system** - When Alice wants to pay Bob, she *broadcasts the transaction to ALL Bitcoin nodes* ![](https://i.imgur.com/Bj2WLpZ.png) - Bob's computer not pictured - Does not have to listen on the network for node to be his. Can choose to if he wants ### How consensus COULD work in Bitcoin At any given time: - All nodes have a sequence of *blocks of transactions* they have reached consensus on - Each node has a set of outstanding transactions it's heard about Cons - Why Consensus is Hard - Nodes might 1. Crash 2. Be malicious - Network is imperfect 1. Not all pairs of nodes connected 2. Faults in network 3. Latency -> no notion of global time Impossibilities - Byzantine General's Problem: inconsistency - Fischer-Lynch-Paterson (deterministic nodes): consensus impossible with a single faulty node Well Known Protocols - Paxos: never produces inconsistent results, but can (rarely) get stuck :::warning 1. Say more about the model than the problem 2. Developed for distributed systems ::: :::success THUS consensus in Bitcoin works better in practice than in theroy BUT theory is important to help predict *unforeseen attacks* ::: ### Bitcoin Does Things Differently 1. Introduces incentives - possible only because it is currency 2. Embraces randomness - Does away with notion of specific end-point - Consensus happens over long time scales (~ 1 hr) ### Summary - Protection against invalid transactions is cryptographic but enforced by consensus - Protection against double-spend is purely by consensus - You are never 100% sure a transaction you are intered in is on the consensus branch, but exponential probability is pretty good