Proof of Stake is used by #Solana and Ethereum 2.0. But what is Proof of Stake, and how does it work? A short thread π
1/ "Proof of stake is a type of consensus mechanism used by blockchain networks to achieve distributed consensus."
In other words, Proof of Stake enables nodes in a blockchain network to agree on the state of the blockchain.
2/ For example, nodes should agree on:
- Which blocks are included in the blockchain
- Which transactions are included in each block
3/ Participants in a Proof of Stake network are called "nodes" or "validators."
Validators are randomly chosen to produce blocks. Only one validator produces blocks at a time.
The rest of the validators validate the blocks being produced.
4/ To become a validator, you must stake some assets. The more you stake, the more often you're chosen as block producer.
For example, to be an Ethereum validator, you must stake at least 32 ETH.
Validators are rewarded for securing the network, and punished for misbehaving.
5/ Most PoS networks let people delegate assets to validators.
Validators earn rewards proportional to the amount they have staked, and distribute some of their rewards to their delegators.
6/ What's the point of requiring validators to stake assets?
Because it promotes good validator behavior π
7/ If validators misbehave, e.g. they validate an invalid block, their stake gets slashed (i.e. some of it gets taken away).
On the other hand, trustworthy validators will attract more delegators, thus increasing their stake and authority in the network.
8/ How secure are Proof of Stake networks?
First, note that PoS networks require at least 2/3 of all nodes in order to reach consensus.
Thus, if more than 1/3 of validators are dishonest, the network will NOT function correctly.
9/ If more than 1/3 of validators are dishonest, the network may be halted (dishonest nodes can refuse to participate).
If at least 2/3 of validators are dishonest, they can collude and manipulate the state of the network (e.g. include fake transactions).
10/ Let's recap:
- PoS is a consensus mechanism
- Validators are randomly chosen to produce blocks. Only one validator produces blocks at a time
- Validators are punished for bad behavior (stake gets slashed)
- If more than 1/3 of validators are dishonest, PoS will not work
Data accounts store data. Program accounts store executable programs.
Each account has an address (usually a public key) and an owner (address of a program account). There are a few more fields every account stores, see π
2/ There are a few important ownership rules:
- Only a data account's owner can modify its data and subtract lamports.
- Anyone is allowed to give lamports to a data account.
- The owner of an account may assign a new owner if the account's data is zeroed out.
2/ Anchor (by @ProjectSerum) is a framework that will make your life much easier.
There are three parts to Anchor:
- A TypeScript library that's similar to web3.js
- Rust crates that make writing Solana programs easier
- A CLI for building/testing, similar to @HardhatHQ
My 7 favorite resources for getting started with web3...
1/ @3blue1brown's video "But how does bitcoin actually work?" explains Bitcoin's blockchain, and is the most understandable introduction to blockchain I've come across.
2/ The @ethereum whitepaper explains what Ethereum is and how it works. I recommend skimming it to get the general idea and revisiting it later.