In the last issue, we discussed how cryptography helps secure the Blockchain with regards to the Cryptographic linkage of blocks. Think of a block as a page in a book (ledger), in which a page is Cryptographically linked to it's previous and next pages.
In this issue, we will discuss, from a high level, how the different nodes on the Blockchain agree on the state of the Blockchain without the need for a central authority.
Let's get started, shall we?
All nodes in the Blockchain hold a copy of the Blockchain state (data on the Blockchain) and quite often, this state has to be updated. Conventionally, in systems like traditional banking, a central authority (the bank) can update its ledger easily because there is only one copy of it. This is pretty fast and efficient but the trade off is security and censorship.
There is a single point of failure, attacking the ledger can spell doom for the bank, and the bank literally holds control over everyone's funds and can freeze them whenever they want. This is not the kind of world we'd want to live in, but unfortunately here we are. Imagine keeping "your" money in someone's control, does it really make it yours?
On the Blockchain, this is solved by decentralization - distributing the ledger among all the nodes on the network, but how do the nodes know when to update their respective ledgers and how do they know that the data to be added is valid and not malicious (e.g. in cases of double spending).
That's where consensus algorithms come in. Consensus Algorithms are ways in which the nodes on the Blockchain agree on the state of the Blockchain without the need of a central authority. Two major applications of consensus algorithms are Proof of Work (PoW) which is used by the Bitcoin network and Proof of Stake (PoS) which is used by the Ethereum network.
In PoW, nodes are called miners and for a block to be added to the Blockchain, a miner picks up a transaction from the mempool (remember this?), it validates the transaction by doing computational work (for example it hashes the transaction data and computes a number that satisfies the hash, this is just a reference, it is quite more nuanced than this).
The first miner to validate the block gets the block reward (which is a small amount of tokens paid by the sender of transactions). Ever heard of gas fess? Yeah, that's it. The miner broadcasts the mined block to the network and the remaining miners can now validate it, if valid they can add it to their copy of the Blockchain and the block becomes a permanent part of the Blockchain.
In PoS, it quite different, validators (the nodes, just like miners in PoW), stake an amount of tokens, say ETH. The higher your stake, the higher the likelihood of getting selected as the validator of the block, just like saying "Hey, here are some tokens, allow me validate this block". Rather than doing computational work, tokens serve as proof that the block has been validated and it can be broadcast and added to the Blockchain. Validators also get part of the gas fees as rewards.
This is a pretty high level explanation, if you want to get into the guts of consensus algorithms, there are a ton of resources online. This article is to just give an insight and a broad overview, weldone on making it this far.
Now that we have touched consensus algorithms, what possible attacks could be possible on the Blockchain and how are they effectively prevented?
Catch you in the next issue!
Top comments (0)