Proof of Work Vs. Proof of Stake | PoW vs. PoS | Explained
Ethereum Proof of Work.
Consensus (Key Concept): the fault-tolerant mechanism used to agree on account balances and the order of transactions.
The current consensus mechanism used by the Ethereum blockchain is proof of work.
Let's see the key concepts and pros/cons.
Table of Contents:
- Intro
- What is PoW?
- PoW and Mining
- The work in PoW
- PoW and security
- 51% Rule
- PoW Finality
- PoW Energy Usage
- PoW Pros
- PoW Cons
Intro
Ethereum uses a consensus protocol called Proof-of-work (PoW).
This allows the nodes of the Ethereum network to:
- agree on the state of the recorded info in the blockchain
- prevents some economic attacks.
In the future, it will be replaced with Proof-of-Stack.
What is PoW?
PoW allows the network to come to a consensus, or agree on account balances and the order of transactions.
This:
- prevents users from double-spending
- makes the chain hard to manipulate.
PoW & Mining
PoW: an algorithm that sets difficulty/rules for the work miners do.
Mining: the act of adding valid blocks to the chain.
The chain's length helps to:
- follow the correct chain.
- understand the state.
More work done > the chain is longer > more state's certain
PoW & Work
Miners make a race of trial & error to find the block's nonce.
A dataset is repeatedly put. You can get it by downloading & running the full chain.
The hash target is easy to verify, hard to compute.
If a transaction is different, the hash is different => FRAUD.
PoW & Security
Goal: extend the chain and have a single source of truth.
Miners are incentivized to work on the main chain
Users always choose the longest chain.
It's super hard to:
- create new blocks that erase transactions
- create fake blocks
- maintain another chain
The 51% Rule
A malicious miner would need to solve the block nonce faster than everyone else.
To create malicious valid blocks, you need 51%+ network mining power to beat everyone else.
This would need a lot of computing power!
The energy spent could be higher than the gain!
PoW Economics
PoW is responsible for:
- issuing new currency in the system
- incentivizing miners.
Miners who create a block get rewarded with 2 ETH and all the block's transaction fees.
Uncle blocks: valid blocks created nearly at the same time. A miner gets 1.75 ETH for it.
Finality
A transaction has finality when it's part of a block that can't change.
Two valid blocks can get mined at the same time, creating a temp fork.
Eventually, one of the chains will become the accepted chain after a subsequent block has been added, making it longer.
Finality is the time to wait before considering a transaction irreversible.
Recommended time: 6 blocks or 1 minute.
After 6 blocks, you can say that the transaction was successful.
This timing doesn't include the transaction wait times picked up by a miner.
PoW Energy Usage
PoW requires a lot of energy to keep the network safe.
For Ethereum, it's currently ~73.2 TWh annually (the amount of a mid-size European country)
This could change with the switch to Proof of Stake.
PoW Pros
neutral: No ETH is needed to start and block rewards allow you to go from 0ETH to a positive balance.
consensus mechanism tried and tested that worked for many years.
pow it's relatively easy to implement compared to proof of stack.
PoW Cons
uses up so much energy: bad for the environment.
big investment to start mining.
mining pools could dominate the game, leading to centralization & security risks.
Proof of Stake.
After the proof of work explained, the proof of stake explanation is a must.
This is the new consensus that will be used by Ethereum.
Many concepts will require a dedicated content in the future.
Table of Contents:
- What is Proof of Stake (PoS)
- POS & Validators
- Attesting
- Sharded Chains
- Beacon chain
- How validation will work?
- Committee
- Epoch
- Crosslink
- Finality
- Security
- PoS Pros
- PoS Cons
What is Proof of Stake (PoS)?
Users stake their ETH to become VALIDATORS.
Validators responsibilities:
- ordering transactions
- creating new blocks
Improvements:
more energy efficiency
reduced HW requirements
more centralization immunity
more nodes
shard chains
PoS & Validators
PoS activates validators upon receipt of enough stake (32 ETH).
Validators are randomly chosen to create blocks
They are responsible for checking & confirming blocks they don't create.
Users' stakes are used to incentivize good validator behavior.
Attesting
This validation is known as ATTESTING ("this block looks good to me").
Validators:
- don't use much computational power
- create and validate blocks
- get rewards for proposing new blocks & for attesting
You attest to malicious blocks => you lose the stake.
Sharded Chains
They are new separate blockchains.
They will need validators to process transactions & create blocks.
They will have a shared understanding of the state.
They will be managed by the beacon chain.
Beacon chain
The beacon chain will coordinate the sharded chains
The beacon chain will:
- receive state info from shards
- sync network state
- manage validators
How validation will work?
When you will submit a transaction on a shard, a validator will be responsible for adding your transaction to a shard block.
Validators will be chosen by the beacon chain to propose new blocks.
Committee
The attestation (not the transaction) is recorded in the beacon chain.
Committee:
- 128+ validators are required to attest to each shard block.
- has a time frame ("Slot") in which to propose and validate a shard block.
Epoch
Only one valid block is created per slot.
There are 32 slots in an "epoch."
After each epoch, the committee is disbanded and reformed.
This helps keep shards safe from bad actors.
Crosslink
A crosslink confirms:
- the inclusion of the block
- the transaction in the beacon chain.
The crosslink is created once a new shard block proposal has enough attestations.
Once there's a crosslink, the validator gets the reward.
Finality
It's when a transaction is part of a block that can't change.
The block is finalized If 2/3 of the validators agree.
Validators lose their stake if they try and revert this later on (51% attack).
Security
51% attack still exists but it's even riskier: you need 51% of the staked ETH.
This is a lot of money, and it would cause ETH's value to drop.
The beacon chain will prevent bad behavior.
Validators will be responsible for flagging incidents.
PoS Pros
easier to run a node. If you don't have enough ETH, you can join staking pools.
more decentralization.
increased participation
more nodes don't mean increased % returns
more throughput: Shard chains allows to create of multiple blocks at the same time
PoS Cons
Can tend toward centralization
POS is still in its infancy
Less battle-tested, compared to proof-of-work
May not be as secure as proof of work
I hope this was helpful!
Thank you for reading!
If you're interested in following along, feel free to subscribe my Newsletter 👆
Delivering interesting content every single week on Web3, Crypto, NFTs and DeFi. It's FREE, Takes less than 5-minutes to read, and you are guaranteed to learn something. Let's front-run the opportunity!
Let’s bust some more in next article.
If you want more, be sure to
FOLLOW ME
credit: Francesco Ciulla
Comments
Post a Comment