
Consensus: When a new transaction is broadcasted to the network, nodes can decide if
they want to include it as a copy in their ledger or to ignore it. If the majority of the actors
decides on a single defined state, the consensus is achieved.
How can we reach a consensus through computers? Through a consensus algorithm: a
process used to achieve agreement on a single data value among distributed processes or
systems.
Distributed consensus protocol: it must terminate with all honest nodes in agreement on the
value, which must have been generated by an honest node.
All the nodes in the P2P network have a ledger consisting of a sequence of blocks, each
containing a list of transactions, that they’ve reached consensus on. This leads to a single
and global ledger.
+ Some nodes might have not been informed
How exactly do nodes come to consensus on a block? At regular intervals, every node
proposes its own outstanding transaction pool to be the next block. Then the nodes execute
some consensus protocol. If it succeeds, a valid block will be selected as the output.
Issues: consensus is a hard problem (nodes can crash and can be malicious); the network is
imperfect; latency is a real problem.
à Fault tolerance: the goal is to achieve overall system reliability in the presence of a number
of faulty processes.
Unsolvable problems:
The 2 generals’ problem à no guarantee that the message has reached the other;
The byzantine generals’ problem à possibility of traitors;
Byzantine fault tolerance à as long as the traitors don’t exceed the 1/3 of the generals.
Proof-of-Work (PoW): the leader is the responsible for transmitting the block to the
network so that the other peers can verify it. To be elected as a leader and choose the next
block, the network has to solve a mathematical puzzle. The first to solve the problem is
probably the one with more computing power à leader à gets a reward (incentive).
à An attack to the whole network would cost a lot: energy, computational power, hardware,
potential missed rewards.
Proof of Work in Bitcoin: each block is mined every 10 mins and, since computational power
constantly increases, mining difficulty increases with time and is adjusted every 2016 blocks
(the difficulty can even go down if the supply of computational power decreases). Miners are
rewarded 6.25 Bitcoins for mining each block. For a safe transaction, it can take up to 1 hour.
Proof-of-Stake (PoS): a given amount of currency that a given wallet is willing to lock up and
freeze for a certain amount of time; in return, you get a chance of mining the next block
proportional to the stake you froze.
Issue: nothing-at-stake à nodes are not disincentivized in mining forked chains.
Some hybrid consensus algorithms PoS-PoW have been developed.