How does distributed consensus aka blockchain protocol work? DYOR!
What’s consensus? An ability of a distributed network of nodes to achieve correct and equal result(s) under external/internal attacks and failures.
All of us participated in voting, hands rising and counting. Perfect conditions, everyone can see everyone (all-to-all data exhange), no middleman, no cheating. Majority of votes (1/2+1) to make a decision.
Remote voting is different, distributed cryptographic protocol is needed to prevent attacks and tolerate failures.
Simulation controls and settings
Nodes:
- run // run all nodes
- stop // stop all nodes
- add // add new node
- rm // remove node
Links:
- add // add new link
- rm // remove link
Each node: run, rm
Attacks: split, power
Settings: az - auto zoom, gX - views on row
Each node has a number (0) and id (1df3be82..)
Blockhain is a graph (DAG)
Most simple for simulations consensus mechanism is analyzed, rules:
- Genesis block is the same for all nodes.
- Nodes can produce new blocks and broadcast them to the network.
- Nodes can accept new valid blocks from the network (and get all previous blocks if necessary to build a chain).
- Nodes can get blocks from any node.
- Longest chain rule.
Block confirmations are the next blocks (simple rule). The last block is selected on the longest chain rule. Uncertain finality (history can be rewritten).
These rules are for simulation/visualization purposes only, in production systems they are a lot of more complex including proofs (PoX).
Attacks simulations
Red node attack. Red node has the computing power to produce blocks faster than the rest of the network. All history can be rewritten by the red node.
It can be done by sending one-by-one blocks, or an alternative chain can be precomputed and send only the last block.
According to the rules, all other nodes must accept the new chain.
Distributed consensus can be successfully attacked by network manipulations and (51% power attack). Classical cybersecurity attack vectors are here as well (OWASP). Each node must be protected.
Links
https://blog.trailofbits.com/2022/06/21/are-blockchains-decentralized/
https://bitcoin.org/bitcoin.pdf
Also Published Here