â LESSON 3: MINING, CONSENSUS & DISTRIBUTED SYSTEMS â
>> Connecting to blockchain network...
Remember from Lesson 1: blockchain is distributed - everyone has a copy. But how does everyone agree on what's true when there's no central authority?
Imagine 10 friends trying to decide where to eat dinner:
Solution: Majority wins! Ramen gets 4 votes, so everyone goes there. This is consensus - the group agrees on one decision.
In Blockchain: Thousands of computers "vote" on which transactions are valid and should be added to the chain!
â Single Point of Failure:
â Distributed Consensus: No single point of failure, no one can cheat alone!
If a blockchain has 1000 nodes, how many need to agree for consensus?
Answer: It depends on the consensus mechanism!
The key: Majority must agree, so attackers would need to control 51%+ of the network!
Mining is the process of adding new blocks to the blockchain. But here's the twist - it's designed to be HARD!
The Mining Challenge:
Find a special number (called a "nonce") that when added to the block and hashed, produces a hash starting with a certain number of zeros.
Think of mining like a lottery where:
Bitcoin: Miners try ~500 trillion hashes per second globally! It's like buying 500 trillion lottery tickets every second!
Let's simulate mining a block. We'll try to find a hash that starts with "000":
Block Data:
Difficulty (number of leading zeros):
Hash attempts will appear here...
Security Through Difficulty!
To change history, attacker must re-mine all blocks faster than rest of network - nearly impossible!
Different blockchains use different methods to achieve consensus. Let's compare the major ones:
Used by: Bitcoin, Dogecoin
How it works: Miners compete to solve complex math puzzles. First to solve gets to add block and earns reward.
â Very secure
â Battle-tested (15+ years)
â Truly decentralized
â Energy intensive
â Slow transactions
â Expensive hardware needed
Used by: Ethereum 2.0, Cardano
How it works: Validators "stake" their crypto as collateral. Network randomly selects validators to create blocks. Bad behavior = lose stake.
â Energy efficient (99% less than PoW)
â Faster transactions
â Lower barrier to entry
â "Rich get richer" concern
â Less battle-tested
â Requires minimum stake
Used by: EOS, TRON
How it works: Token holders vote for delegates (witnesses) who validate blocks. Like electing representatives in democracy.
â Very fast transactions
â Scalable
â Democratic voting
â More centralized (fewer validators)
â Voter apathy issues
â Potential for cartels
Used by: Hyperledger, Zilliqa
How it works: Nodes communicate and vote on validity. Can tolerate up to 1/3 malicious nodes.
â Fast finality (instant confirmation)
â Low energy use
â No forking
â Requires known validators
â Doesn't scale well
â More centralized
Let's simulate different consensus mechanisms:
There's no "perfect" consensus mechanism! Each has tradeoffs between:
If someone controls more than 50% of the network's computing power (or stake), they can:
Let's see what it takes to attack different networks:
Select Network Size:
How do networks protect against 51% attacks?
Yes, but only on smaller networks!
Lesson: Network size and hash power matter! Smaller chains are more vulnerable.
When you make a blockchain transaction, it doesn't become "final" immediately. Here's what happens:
Transaction broadcast to network but not yet in a block. Can still be reversed!
Included in latest block. Relatively safe but could still be reversed if block gets orphaned.
3 more blocks built on top. Much safer - would need to re-mine 3 blocks to reverse.
Bitcoin standard. Considered final - reversing would cost millions!
Watch how blocks get confirmed:
Click "Add New Block" to start...
Status: No blocks yet
Different blockchains have different confirmation requirements:
For everyday purchases: 1-3 confirmations is usually enough
For large amounts (like buying a house): Wait for 6+ confirmations
More confirmations = more security, but longer wait time!
Question 1: What is the main purpose of mining in Proof of Work?
Question 2: What makes a 51% attack difficult on Bitcoin?
Question 3: Proof of Stake is more energy efficient than Proof of Work because:
Question 4: How many confirmations does Bitcoin typically need?
Question 5: Consensus mechanisms are needed to:
You've mastered Lesson 3: Consensus Mechanisms & Mining!
You understand how distributed networks reach agreement!