The old Ethereum was proof of work. Now, the system is proof of stake, where stake is an amount of money they are putting as collateral if they act maliciously. Anybody can stake 32 ETH to become a staker to select blocks, earn rewards and so on. The staking makes sybil (multi-voter) attacks impossible as well. This article is about the nitty-gritty details of how this works - Gasper.
Once a user stakes the 32 ETH to become a validator, they are put into a waiting queue. This is done in order to prevent network congestion on voting and preventing an attacker with sufficient funds from instantaneously making a big impact.
Once a user is in the network and voting, Gasper has slots of 12 seconds and epochs that last 32 slots (6.4 minutes). For every slot, one validator is selected at random to be the block proposer. The proposer constructs the block from the pending transactions in the mempool. The purpose of the epoche is that a validator does not vote on every block. Instead, a committee is made where a validator votes on one block per epoche.
What are validators even validating?
- They validate checkpoint blocks (start of epoche) within previous epoches and the current ones.
- The list of validators on the voting committee.
- The data of the block. In particular, the slot, index, root hash of the block and some other data.
- Signature.
On top of the coordination above, there is other fancy networking occurring to reduce network overhead further. This is about dividing the network into regional subnets which will then communicate with the main network. This is possible by crazy math that combines signatures then broadcasts this to the rest of the network.
When does a block become final? In Bitcoin, this is once 6 blocks have passed. With Ethereum, it is once another block has been verified (justified). A block becomes justified once 2/3 of staked Ether votes in favor of a block. What happens when a fork occurs? The network will always choose the fork with the most backed votes. Theoretically, independent users could fork the chain and bring it back later, only to confuse the users though.
To confirm that the system works as intended, there needs to be incentives and rewards/punishments. A user has two balances: effective and actual balance. The actual balance is the amount deposited for staking, plus rewards and minus value from penalties. The effective balance is derived from the actual balance in some way with a cap of 32 ETH and is what is used for picking validators.
The rewards are given based upon the actions performed. Attesting a block, proposing a new block and participating in a sync committee. The article has numbers for who gets what. However it's proportional to the amount of funds that a user has in the protocol.
For penalties, it depends on what went wrong. For missing an attestation, they lose the amount they would have been rewarded. There are several other benign issues as well. If a validator engages in malicious behavior, then they are slashed; forcing them to leave the network or a large monetary penalty. One of the validators must be a whistleblower in order to do this and receives a reward for doing so.
The penalties depend on how active the network is. For instance, if a single user does perform an action, then the penalty is small. If NONE of the users perform the assigned actions, then the penalty gets larger. The idea is that the inactive users on a stopped blockchain (from inactivity) will be removed fast so that others can validate properly.
Overall, an awesome post on the great merge to Proof of Stake. Many great details showcasing the innerworkings of the blockchain eco-system.