Hello, fellow blockchain enthusiasts! Today we're going to dive into the inner workings of Solana's unique consensus mechanisms - Proof of Stake and Proof of History. I'll explain in simple terms how they enable Solana to be the lightning-fast, censorship-resistant network we know and love. Grab your favorite beverage and let's get started!
What is Proof of Stake?
Proof of Stake (PoS) is a way for blockchain networks to achieve consensus - which means getting nodes to agree on the validity of transactions and the order they occur.
In Proof of Work chains like Bitcoin, nodes compete to solve puzzles. But in PoS, nodes instead prove their stake in the network to participate in voting and add new blocks. The key ideas:
- Nodes are called "validators" instead of miners
- Validators must lock up ("stake") their SOL coins to join consensus
- Their voting power is proportional to the size of their stake
- Following the protocol is financially incentivized by rewards
- Bad behavior is disincentivized by slashing (penalizing) a validator's stake
This aligns the interests of individual validators with the best interests of the overall network. And by making it really expensive to attack Solana, stakeholders help secure the chain.
🍺 Analogy Break 🍺
Proof of Stake is like a co-op pub where to drink (validate) you have to buy a share (stake coins). The more shares you own, the more you've invested in the success of the pub. You'll want it to stay open and serve good beer.
Sure one shareholder could start a fight (attack), but they'd get kicked out and lose their shares. Not worth it! Collectively the shareholders keep things running smoothly.
Why Use Proof of Stake?
There are a few key reasons Solana chose Proof of Stake over Proof of Work:
- Energy efficiency - No computes wasted on "mining" puzzles
- Scalability - Avoid bottleneck from puzzle competition between miners
- Security - Avoid the risk of 51% attack from concentrated miners
- Decentralization - Get broader participation in validation from coin holders
By leveraging PoS, Solana can focus node resources on executing transactions instead of cryptographic puzzles. And that's how it achieves industry-leading speed and scalability!
How are Validators Selected?
On Solana, anyone with at least 1 SOL can stake to join the validator network. But stake doesn't guarantee you'll be selected to actively validate. Here's how the selection process works:
- There are about 1000 active validator spots available
- Spots are assigned proportionally to a validator's total stake
- So if a validator has 5% of the stake, it will get ~5% of the spots
- The Selection algorithm pseudo-randomly picks validators each epoch
- But over time each validator gets spots matching its stake %
This ensures the validator network reflects the preferences of those staking coins. The more SOL staked with a validator, the more often it's selected.
Do All Validators Get Equal Voting Power?
Nope! On Solana, vote weight = stake weight.
So if Validator A has staked 10,000 SOL and Validator B has staked 50 SOL, Validator A has 200x more voting power on consensus.
This aligns financial investment with decision-making ability. Validators have stronger votes based on their skin in the game.
🍺 More Analogy Time! 🍺
Our pub co-op gives shareholders votes on operations based on their shares. If you own 20% of shares, you get a 20% vote. You've invested more in the success of the pub, so you deserve more say in decisions!
Aligning stakes and votes helps prevent Sybil attacks because acquiring majority voting power gets really expensive. A malicious actor can't just spin up 100 nodes to overwhelm consensus. They'd have to buy up a majority of all SOL coins staked - likely billions of dollars worth!
How are Bad Actors Disincentivized?
Validators who don't follow the protocol can get slashed by destroying some of their staked SOL. The specific penalties depend on the violation.
Some slashable offenses:
- Double signing blocks
- Censoring other validators' transactions
- Downtime exceeding a set threshold
- Corrupted hard drives losing blockchain state
Slashing makes attacking Solana very expensive. And since rewards are proportional to stake, it takes a huge financial hit. Getting caught could cost millions!
This motivates validators to highly available nodes with great uptime and security practices. No one wants a 3am call because their validator got slashed!
Why is Fast Block Production So Important?
As a speedy payments network, Solana needs to push out new blocks - and transactions - very quickly. Slow block production would ruin the user experience.
Imagine going to a coffee shop, buying a latte with SOL, but having to wait 10 minutes for your payment to clear! Not gonna cut it 😆 We need transactions confirmed in seconds, requiring sub-second block production.
Most PoS blockchains target 15-30 seconds between blocks. But Solana cranks out new blocks every 400 milliseconds! So how's it able to achieve such fast block production?
Proof of History...
What is Proof of History?
Proof of History (PoH) is the key innovation enabling Solana's speed. It's a clock before consensus, built into the blockchain itself.
See, blockchains need a way to enforce the order of transactions across a decentralized network. And that requires an agreed-upon sense of time between nodes so they know which transactions came first.
But it's hard to synchronize time between computers that don't trust each other! PoH provides a trustless clock that validators can rely on.
🍺 Analogy Break 🍺
Our co-op pub needs to track the order customers buy rounds to settle up tabs at the end of the night. But we don't fully trust the customers or bartenders!
So we build a special wall clock that ticks every time a beer is poured. This gives us an undisputed shared record of the order, even if bartenders lie about who bought rounds first. No one controls the clock, but everyone can trust it.
That's Proof of History!
Here's how it works under the hood...
How Does Proof of History Work?
Proof of History leverages a cool quirk of cryptography - sequencers. These are functions that produce unpredictable outcomes, but where each result builds off previous ones. So if you have result #10, you can verify it came after #9, #8, #7, etc.
For PoH, Solana uses a sequencer with these properties:
- Output is unpredictable but easy to verify
- Easy to compute forward, hard to compute in reverse
- Fast to run on cheap, general hardware
This perfectly describes the SHA-256 hashing algorithm used in Bitcoin mining! The PoH sequencer simply hashes the previous output to generate the next "tick":
Hash(#1) = #2
Hash(#2) = #3
Hash(#3) = #4
Solana validators continuously run this SHA-256 sequencer tracking the passage of time. By passing the latest hash into the next block, validators can verify blocks are sequenced correctly.
Blocks also include proofs - sequences of hashes representing the expected time between blocks. This proves leaders are outputting ticks at the proper rate and not manipulating timestamps!
Why Use an SHA-256 Sequencer?
SHA-256 hashing is a great fit for Solana's Proof of History:
- Unpredictable - Hash outputs are evenly distributed across range
- One-way function - Easy to compute forward, hard to reverse
- Fast & efficient - Optimized to run on consumer GPUs
- Verifiable - Anyone can reproduce hashing steps
Thanks to Bitcoin, ASICs can calculate SHA-256 hashes faster than any other mainstream cryptography. And because it's so widespread, the function is battle-tested and secure.
Leveraging these properties, Proof of History enables incredible coordination between untrusting nodes - the bedrock of Solana's speed!
How Does Proof of History Help Consensus?
First off, the SHA-256 sequencer gives Solana a clock for scheduling block production without networking overhead. Validators can locally calculate who the next leader is and when their slot starts.
This lets Solana organize validators into a predictable leader schedule with slots as short 400ms. Leaders don't need to coordinate off-chain since the on-chain clock keeps everything in sync!
Secondly, Proof of History makes attacks and censorship much harder:
- Leaders can only produce valid blocks during their assigned slots
- Forking the chain requires producing alternative SHA-256 proofs
- But ASICs make manipulating proofs expensive
So Proof of History allows for rapid synchronized block production on Solana while still maintaining censorship resistance and consistency guarantees!
🍺 Last Analogy! 🍺
Solana's SHA-256 clock ensures our pub shareholders stay in sync on orders like a self-regulating watch. Everyone trusts the ticks to sequence events properly.
If someone tries to rewrite history by adding fake timestamps, it requires grinding through hashes faster than all other shareholders combined! Practically impossible without controlling the whole watch factory.
And that's the basics of how Proof of Stake and Proof of History enable Solana to be the high speed blockchain it is today!
Key Takeaways
Here are the core points to remember:
- Proof of Stake incentivizes validators with rewards to secure the network
- Validators stake SOL coins for a chance to vote on consensus
- Their voting power is proportional to stakes, not equal
- Bad behavior results in slashing penalties
- Proof of History sequencers provide a clock before consensus
- SHA-256 hashes make a verifiable timestamp server
- Enables 400ms block production without off-chain coordination
- Manipulating proofs is expensive thanks to ASICs
- Together they allow Solana to be fast, scalable, and secure!
Frequently Asked Questions
Here are answers to some common questions about Solana's unique consensus designs:
What stops a validator from attacking Proof of History sequences?
Recalculating the SHA-256 sequences requires burning electricity on custom ASICs. Any alternative proofs require outpacing all other miners to catch up. This extreme difficulty and real world cost disincentives manipulating consensus rules.
If stakes determine voting power, what stops a whale from controlling everything?
While possible for a single validator to accumulate a very large stake, they likely could never reach 50% total stake to fully control the network. And even with a large plurality, their returns are still best served following the protocol. Other stakeholders would simply deactivate the bad actor.
How often do Proof of Stake epochs change?
Epochs on Solana are 2-3 days, much shorter than the ~14 days of other chains like Cardano. This allows the validator set to rotate more quickly based on changing stakes.
What's the difference between Proof of Stake and Delegated Proof of Stake?
In Delegated PoS (used by EOS), token holders elect delegate nodes to validate for them. But in Solana's direct PoS, anyone with 1+ SOL can stake to be selected to validate without going through delegates.
If there's no mining, where do transaction fees go?
The SOL paid in transaction fees gets burned (destroyed), making the remaining supply more valuable through deflationary pressure. Validators earn returns through block rewards.
Can Proof of History work on any blockchain?
While derived for Solana, Proof of History can technically be implemented on other layer 1 blockchains as a timestamping service for their consensus rules. But it's specifically optimized for PoS block production.
Why doesn't Solana use smaller shards like Ethereum?
Solana's proof of history allows coordinating validator nodes without sharding complexity. And GPUs are so fast there's less need to parallelize capacity across shards.
What stops drained validators from attacking after their stake is gone?
Deprecating validators have their votes deactivated before being fully drained to prevent this scenario. Plus attackers need an ongoing stake for the votes/power necessary to actually threaten consensus.
I hope these explanations and examples help provide intuition for why Solana made its technical design decisions! Let me know if you have any other questions in the comments.