Summary

This presentation details the Ethereum consensus mechanisms, focusing on Proof-of-Work (PoW) and Proof-of-Stake (PoS). It also discusses transaction fees and the evolution of rewards, along with different stages of the transition from PoW to PoS.

Full Transcript

UZH Blockchain &DLT Research Group Blockchain Center Ethereum Consensus Blockchain and Crypto-Economics: Session 4.1 Sina Rafati Blockchain & Distributed Ledger Technologies UZH Blockchain Center Blockchain and Crypto-Economics HS23 | 03.10.23 UZH Blockchain Center Blockchain &DLT Research...

UZH Blockchain &DLT Research Group Blockchain Center Ethereum Consensus Blockchain and Crypto-Economics: Session 4.1 Sina Rafati Blockchain & Distributed Ledger Technologies UZH Blockchain Center Blockchain and Crypto-Economics HS23 | 03.10.23 UZH Blockchain Center Blockchain &DLT Research Group Lecture Objectives 1. Learning the Ethereum consensus mechanisms 1. Proof-of-Work (PoW) 2. Proof-of-Stake (PoS) 3. The incentives for the move from PoW to PoS 4. Actors exist in these consensus mechanisms 2. How is the rewarding mechanism changed over time 2 UZH Blockchain Center Blockchain &DLT Research Group 1. Introduction to Ethereum PoW • • • PoW protocol Ommer (uncle) Blocks Supply and Rewards 3 UZH Blockchain Center Blockchain &DLT Research Group Ethereum’s Proof-of-Work Algorithm • Ethereum employed a different PoW algorithm from Bitcoin, called Ethash. • EThash was memory hard, meaning it resisted miners' use of ASICs (differently from Bitcoin) due to an increased memory requirement. • EThash ASICs were eventually developed, but GPU mining was still viable until PoW switched off. 4 UZH Blockchain Center Blockchain &DLT Research Group Ethash in a nutshell • Ethash was dependent on the generation and analysis of a large dataset, known as a Directed Acyclic Graph (DAG) • The DAG had an initial size of about 1 GB (later reached ~4 GB) and continued to grow slowly and linearly, being updated once every 30,000 blocks (roughly 125 hours). 5 UZH Blockchain Center Blockchain &DLT Research Group Mining included grabbing random slices of the dataset and hashing them together. Verification was done with low memory by using the cache to regenerate the specific pieces of the dataset 6 UZH Blockchain Center Blockchain &DLT Research Group Transaction Finality in Ethreum • A transaction has "finality" on Ethereum when it is part of a block, which is part of the chain, that cannot change. • Finality refers to the time users should wait before considering a transaction inclusion on the chain • Rule of thumb: 6 blocks = 1 min • This timing does not include waiting for a transaction to be picked up by a miner. 7 UZH Blockchain Center Blockchain &DLT Research Group Average mining difficulty of Ethereum Over time, mining difficulty was increased, until September 2022, when Ethereum moved from PoW to PoS. Average Mining Difficulty of Ethereum PoW 8 UZH Blockchain Center Blockchain &DLT Research Group Ethereum PoW’s hash rate Ethereum's “hash rate” indicates the PoW mining effort on the mining network, which is way less than the Bitcoin network, even when handling more transactions. Ethereum PoW’s Daily Hash Rate vs Bitcoin Ethereum and Bitcoin Daily Users and Transactions 9 UZH Blockchain Center Blockchain &DLT Research Group Hash rate and mining difficulty correlation Hash rate and mining difficulty are proportionally corelated Average Mining Difficulty and Hash rate correlation of Ethereum PoW 10 UZH Blockchain Center Blockchain &DLT Research Group Ommer (Uncle) Blocks t0 … 1. The competing block (in green) is left out at t1; it becomes an ommer block. It is now stale, albeit still valid for the t1 next iteration … 2. The stale block (green diamond) is included by a newer block at t2. t2 … Partial block reward received for stale block mined 11 UZH Blockchain Center Blockchain &DLT Research Group Why did Ethereum let ommer blocks happen? 12 UZH Blockchain Center Blockchain &DLT Research Group Ethereum Uncle Count and Reward Ethereum PoW protected the chain health by rewarding the Ommer blocks’ miners with 1.75 Eth. Ethereum daily Ommer block count https://etherscan.io/chart/uncles 13 UZH Blockchain Center Blockchain &DLT Research Group Effect of Ommer Blocks on Ethereum PoW 1. To allow for creating more ommer blocks as a by-product of shorter block times and speeding up the network. 2. To decrease the centralisation of incentives for large mining pools. 3. To increase the network's security by supplementing the work on the main blockchain by allowing the work done on ommer blocks to be included. 14 UZH Blockchain Center Blockchain &DLT Research Group Economic incentives of Ethereum PoW miners i. Block mining reward ii. Transaction Fees à tips iii. Ommer block mining reward iv. Ommer block inclusion reward 15 UZH Blockchain Center Blockchain &DLT Research Group Before EIP-1559 (Aug 5, 2021: London) Transaction fee calculation: users bid a random amount of money to pay for each transaction. When the network became busy, this system caused gas fees to become high and unpredictable. 16 UZH Blockchain Center Blockchain &DLT Research Group EIP-1559 (Aug 5, 2021: London) After the London upgrade: gas fees have two components – a base fee and a tip. The base fee was a standard charge that all users paid. It was calculated by the network based on network traffic. The tip is an optional extra payment that users can pay to speed up their transactions. EIP-1559 also requires that the network burn all Ether tokens used to pay base fees. This procedure will reduce the total supply of Ether tokens, making Ether more scarce and, therefore, more valuable. 17 UZH Blockchain Center Blockchain &DLT Research Group Block Creation Reward Changes • Frontier Upgrade – September 2015: • set reward to 5 ETH/block • Byzantium Upgrade – October 2017: • set reward to 3 ETH/block • Constantinople Upgrade – February 2019: • Set reward to 2 ETH • London Upgrade – August 2021: • Part of every transaction fee will be burned (removed from supply) Ethereum Supply and Block Creation Reward Changes 18 UZH Blockchain Center Blockchain &DLT Research Group Daily Burnt Ether Burning Ether is employed to reduce mining rewards, and hence increasing the public participation of weaker miners Number of daily burnt Ether over time https://etherscan.io/chart/dailyethburnt 19 UZH Blockchain Center Blockchain &DLT Research Group Ethereum PoW daily block creation reward Ethereum PoW block creation reward has been reduced to 0 over time. Ethereum block creation reward changes 20 UZH Blockchain Center Blockchain &DLT Research Group 2. Upgrade to PoS 1. 2. 3. 4. 5. Ethereum PoW to PoS Upgrade Phases 1. The Bomb Beacon Chain The roles of validators LMD-GHOST and fork choice Casper-FFG and finality 21 UZH Blockchain Center Blockchain &DLT Research Group Proof of Stake (PoS) is a category of consensus algorithms for public blockchains where the likelihood a validator will be selected to create a block depends on its economic stake in the network 22 UZH Blockchain Center Blockchain &DLT Research Group The original vision of Vitalik Buterin was to use Proof-of-Stake (PoS) consensus, which took years to come to realisation “Significant advantages of PoS include security, reduced risk of centralisation, and energy efficiency.” 23 UZH Blockchain Center Blockchain &DLT Research Group The 3 Phases of Ethereum PoW to PoS upgrade Phase 1 Phase 0 • Beacon chain: December 2020 • • • Serenity upgrade: December 1, 2020 Introduction of the Beacon Chain and the Proof-of-Stake Protocol The Beacon Chain ran separate and parallel to the Eth PoW chain • The Merge: September 2022 • • • • Paris upgrade: September 15, • 2022 PoS consensus switch, • through difficulty bomb Merge of Beacon chain and Execution layer 99.5% reduction in Ethereum energy consumption Phase 2 • Stake withdrawal: April 2023 Shangai/Cappella: April 12, 2023 Enable Stake withdrawal 24 UZH Blockchain Center Blockchain &DLT Research Group Beacon Chain • The original Ethereum PoS blockchain is called the Beacon Chain: • In 2020, it started to work in parallel with the Ethereum PoW • It is the consensus layer of the Ethereum P2P network that handles block gossip and consensus logic: block and attestation handling, running the fork choice algorithm, and managing rewards and penalties. • It does not process transactions or handle smart contract interactions 25 UZH Blockchain &DLT Research Group Blockchain Center From PoW to PoS Merge • The Beacon chain was not originally processing Mainnet transactions. Instead, it was reaching a consensus on its own state by agreeing on active validators and their account balances. Merge PoS PoW Beacon Chain Beacon Chain The same beacon chain is used in the PoS network 26 UZH Blockchain Center Blockchain &DLT Research Group The merge • After ~22 months of running the Beacon chain, the PoW and the Beacon chain merged in September 2022. To stop the PoW mining, the difficulty bomb was used: • • the difficulty of mining a new block increased, such that it became impossible, and no new blocks could be mined. • originally included in the network in September 2015. To support the eventual transition from PoW towards PoS PoW 27 UZH Blockchain Center Blockchain &DLT Research Group Gasper is the PoS mechanism of Ethereum, defining how validators get rewarded and punished, decides which blocks to accept and reject, and which fork of the blockchain to build on 28 UZH Blockchain Center Blockchain &DLT Research Group Gasper Ethereum PoS Algorithm: Gasper LMD-GHOST Fork choice algorithm CASPER FFG Finality algorithm The combination of Casper the Friendly Finality Gadget (CasperFFG) and the LMD-GHOST fork choice algorithm is called Gasper 29 UZH Blockchain &DLT Research Group Blockchain Center Ethereum PoS nodes • An Ethereum PoS node is composed of two clients: an execution client, and a consensus client. • Ethereum validators are the only nodes containing all these two clients’ components. Ethereum Validator Ethereum node JSON RPC requests Execution client Consensus client (Beacon node) Consensus layer validator Structure of an Ethereum PoS validator node 30 UZH Blockchain &DLT Research Group Blockchain Center Comparing Ethereum Clients Tasks Execution Client Tasks Consensus Client Tasks Consensus Client of a Validator Tasks transaction handling (submit transactions and deploy smart contracts) receiving blocks from peers block gossiping transaction gossip running a fork choice algorithm handling consensus logic supporting the EVM Staying in sync with the blockchain by only keeping the head of the chain Accrues rewards/penalties (Can be slashed) updating state trie Gossips blocks and attestations over its p2p network Requires 32 ETH to be staked offering a user interface to Ethereum Manages the Beacon state (contains consensus and execution info) Makes attestations 31 UZH Blockchain Center Blockchain &DLT Research Group In summary, the execution client is: a user gateway to Ethereum, and a home to the Ethereum Virtual Machine, Ethereum's state, and transaction pool 32 UZH Blockchain &DLT Research Group Blockchain Center The main participants of Ethereum PoS: Validators and Attestators (Stakers) Attestation Committee members Block proposers 33 UZH Blockchain &DLT Research Group Blockchain Center The 4 main steps of Ethereum PoS: Block proposal Block attestation Block justification Block finality 34 UZH Blockchain Center Blockchain &DLT Research Group Ethereum PoS Validators • A validator must deposit some stake as collateral. To initialize, 32 Ether (ETH) must be deposited. • One can activate a multitude of validators to add more stake. • Validators activate validator software, which stores data, processes transactions, and adds new blocks to the blockchain. • Validators are incentivised by receiving ETH-denominated rewards for correct behaviour. 35 UZH Blockchain &DLT Research Group Blockchain Center Ethereum PoS time units: Epochs & Slots Ethereum PoS works on two-time scales: epochs and slots Time is split into 12s slots, an epoch is 32 slots (6.4 minutes) Epoch .............................. 0m00s 1m00s Epoch composition, source: https://ethos.dev/beacon-chain/ Slots 6m00s 6m24s 36 UZH Blockchain Center Blockchain &DLT Research Group Ethereum PoS has a deterministic inter-block time of 12 seconds 37 UZH Blockchain Center Blockchain &DLT Research Group Ethereum PoS Roles For each slot, validators have two possible roles to execute: • Block Proposer: build and propose one block for the slot. • There’s no limit to how many times a validator is a block proposer • Attestation Committee (AC) member: AC is a group of 128 validators who vote on the validity of the proposed blocks. These votes are called attestations. • Each validator can attest only once per epoch. 38 UZH Blockchain &DLT Research Group Blockchain Center Ethereum PoS validator assignment Validators are assigned a role in each slot at the previous epoch by a pseudo-random distributed algorithm called RANDAO Slot 31 Slot 1 Proposer Committee A (128 validators) Committee X (128 validators) Proposer RANDAO a b c https://ethos.dev/beacon-chain/ d e f g h i j k l m n o p 39 UZH Blockchain Center Blockchain &DLT Research Group Block Proposer Specifications • Only one for each slot • Builds the slot’s block • Gossips it to other validators known as its peers • That slot’s validators should accept only the block built by the official block proposer 40 UZH Blockchain Center Blockchain &DLT Research Group Attestation Committee • Each slot is randomly assigned a committee of at least 128 validators • When validators receive the proposed block, they determine the validity of the block being proposed. • If the validators did not receive the block from the expected proposer 4 seconds in the slot, they will start attesting for the previous head of the chain. 41 UZH Blockchain Center Blockchain &DLT Research Group An attestation is a validator’s vote, weighted by the validator’s balance. Attestations are broadcast by validators in addition to blocks. 42 UZH Blockchain Center Blockchain &DLT Research Group But how do validators decide which block to attest to? 43 UZH Blockchain Center Blockchain &DLT Research Group LMD GHOST fork choice algorithm • Validators locally determine what they consider to be the main chain • Every time a validator receives a block, it should determine whether it is part of the main chain or not. • To do so, they follow a fork choice rule, a mechanism that returns the head of the chain, given their local view of the block tree and received attestations. • PoS Ethereum fork choice rule is called “Latest Message Driven Greediest Heaviest Observed SubTree” (LMD GHOST). 44 UZH Blockchain &DLT Research Group Blockchain Center LMD GHOST example 1 1 1 Bgenesis For all the leaves, define the weight as the number of directed attestations 1 3 45 UZH Blockchain &DLT Research Group Blockchain Center LMD GHOST example 1 2 1 Bgenesis 5 Define the weight of the other blocks as the sum over the weights of the descendants 1 1 1 3 46 UZH Blockchain &DLT Research Group Blockchain Center LMD GHOST example 1 7 Bgenesis 7 2 5 Repeat until the weight of all the blocks in the blockchain is assigned 2 1 1 1 1 3 47 UZH Blockchain &DLT Research Group Blockchain Center LMD GHOST example 1 7 Bgenesis 7 2 5 2 1 1 1 1 3 Define the Main Chain following the largest weight block starting from the genesis 48 UZH Blockchain Center Blockchain &DLT Research Group Under LMD GHOST, when there is a fork, the chain follows the heaviest subtree. 49 UZH Blockchain &DLT Research Group Blockchain Center Finality: checkpoints • A checkpoint, or Epoch Boundary Block (EBB), is a block in the first slot of an epoch. • If there is no such block, then the checkpoint is the preceding most recent block. Epoch 0 1 Bgenesis 2 Epoch 3 Epoch 1 ... 31 32 33 34 Block 32 is EBB (65,2) ... 63 64 65 Block 64 is EBB (65,1) Buterin, Vitalik, et al. "Combining GHOST and casper." arXiv preprint arXiv:2003.03052 (2020). 50 UZH Blockchain Center Blockchain &DLT Research Group Casper FFG vote: A validator votes for the checkpoint in its current and previous epoch, called target and source, respectively. 51 UZH Blockchain Center Blockchain &DLT Research Group Justification & Finalisation • When an epoch ends, if its checkpoint has garnered a ⅔ supermajority of attestations, the checkpoint is justified. • If a checkpoint B is justified and the checkpoint in the immediate next epoch becomes justified, then B becomes finalised. 52 UZH Blockchain Center Blockchain &DLT Research Group PoS ETH 6-blocks rule equivalent • Finality is a property of every block indicating that block cannot be reverted • In ETH PoS, checkpoints are used to indicate the finality of the blocks in an epoch. • Typically, a checkpoint is finalized in two epochs, 12.8 minutes. 53 UZH Blockchain &DLT Research Group Blockchain Center PoS ETH 6-blocks rule equivalent (example) Assuming a user transaction is in a block in the middle of an • epoch. • It takes half an epoch until the next checkpoint, suggesting transaction finality of 2.5 epochs: 16 minutes. • Optimally, more than ⅔ of attestations will have been included by the 22nd slot of an epoch. • Thus, transaction finality is an average of 14 minutes (16+32+22 slots). Bgenesis 1 2 Epoch 0 ... 31 32 33 34 Epoch 1 ... 63 64 65 Epoch 3 UZH Blockchain Center Blockchain &DLT Research Group 4. Ethereum PoS Economics 1. Rewards 2. Penalties and Slashing 3. Supply 55 UZH Blockchain Center Blockchain &DLT Research Group Rewards • Validators receive a reward in ETH which is added to their stake • The reward amount is: • weighted by all the duties (block proposing, attesting, participating in sync committees) they perform, • Directly proportional to the stake they have, • Inversely proportional to the number of validators on the network. 56 UZH Blockchain Center Blockchain &DLT Research Group Penalties and Slashing Validators miss out on ETH rewards and will be fined if they : i. fail to participate when called upon, or if they behave dishonestly: ii. proposing multiple blocks in a single slot (equivocating) iii. submitting contradictory attestations 58 UZH Blockchain Center Blockchain &DLT Research Group Validators police each other and are rewarded for reporting other validators that make conflicting votes or propose multiple blocks. 59 UZH Blockchain Center Blockchain &DLT Research Group PoS Ethereum Supply Because of the base fee burning and the reduction of ETH rewards, Ethereum supply is not inflationary anymore Ethereum supply 61 UZH Blockchain Center Blockchain &DLT Research Group References • Buterin, Vitalik, et al. "Combining GHOST and casper." arXiv preprint arXiv:2003.03052 (2020). • Beacon Chain explanation • Online Book on Ethereum Upgrade • Ethereum PoS rewards deep explanation • "Proof of Stake FAQ” from Vitalik Buterin 62 UZH Blockchain Center Blockchain &DLT Research Group Questions? 63 UZH Blockchain Center Dr. Sina Rafati Blockchain & Distributed Ledger Technologies UZH Blockchain Center [email protected] https://www.blockchain-group.io https://www.blockchain.uzh.ch @uzh_blockchain Blockchain &DLT Research Group

Use Quizgecko on...
Browser
Browser