Ethereum Proof-of-Stake Consensus Interview Questions
Ethereum Proof-of-Stake consensus algorithm interview questions covering Casper FFG and LMD GHOST.
Q1: How does Ethereum consensus work (Proof-of-Stake)?
Answer:
Ethereum 2.0 uses Proof-of-Stake consensus (Casper FFG + LMD GHOST).
Sequence Diagram:
Overall Flow Diagram:
Individual Node Decision Diagram:
Ethereum PoS Components:
1. Beacon Chain:
- Coordinates validators
- Manages validator set
- Handles finality
2. Validator Duties:
- Proposing: Create blocks (selected randomly)
- Attesting: Vote on blocks (every epoch)
- Sync Committee: Light client support
3. Slot and Epoch:
- Slot: 12 seconds (one block)
- Epoch: 32 slots (~6.4 minutes)
- Finality: ~2 epochs (~13 minutes)
4. Fork Choice (LMD GHOST):
- Latest Message Driven Greedy Heaviest Observed Subtree
- Follows chain with most attestations
- Resolves forks
5. Finality (Casper FFG):
- Finalized blocks cannot be reverted
- Requires
2/3+validator stake - Checkpoint every epoch
Key Properties:
- Security: Economic security (stake at risk)
- Energy: 99.9% less energy than PoW
- Finality: Checkpoint finality
- Scalability: Sharding support
Example:
1class EthereumValidator:
2 def __init__(self, validator_index, balance):
3 self.validator_index = validator_index
4 self.balance = balance # In ETH
5 self.activation_epoch = None
6 self.exit_epoch = None
7
8 def propose_block(self, slot, parent_block):
9 # Selected as proposer
10 if self.is_proposer(slot):
11 block = {
12 'slot': slot,
13 'parent_root': parent_block.hash,
14 'state_root': self.get_state_root(),
15 'body': self.get_transactions(),
16 'signature': self.sign_block()
17 }
18 return block
19 return None
20
21 def attest(self, slot, block_root):
22 # Attest to block
23 attestation = {
24 'slot': slot,
25 'index': self.validator_index,
26 'beacon_block_root': block_root,
27 'source': self.get_source_checkpoint(),
28 'target': self.get_target_checkpoint(),
29 'signature': self.sign_attestation()
30 }
31 return attestation
32
33 def get_rewards(self, epoch):
34 # Calculate rewards based on participation
35 base_reward = self.calculate_base_reward()
36 if self.attested_correctly(epoch):
37 return base_reward
38 else:
39 # Penalty for missing attestations
40 return -base_reward
Slashing Conditions:
- Double Voting: Two different attestations in same epoch
- Surround Voting: Attestation surrounds another
- Proposer Violations: Invalid block proposals
Use Cases:
- Ethereum 2.0
- High-security PoS systems
Related Snippets
- Bitcoin (Nakamoto) Consensus Interview Questions
Bitcoin consensus algorithm interview questions covering Proof-of-Work (PoW) and … - Byzantine Fault Tolerance (BFT) Consensus Interview Questions
Byzantine Fault Tolerance (BFT) consensus algorithm interview questions covering … - Cardano Interview Questions - Easy
Easy-level Cardano interview questions covering blockchain basics, Plutus, and … - Cardano Interview Questions - Hard
Hard-level Cardano interview questions covering advanced optimization and formal … - Cardano Interview Questions - Medium
Medium-level Cardano interview questions covering advanced Plutus development … - Consensus Algorithms Comparison Interview Questions
Consensus algorithm comparison and general implementation interview questions. … - Cosmos Chain Operations Interview Questions - Easy
Easy-level Cosmos chain operation interview questions covering chain operations, … - Cosmos Chain Operations Interview Questions - Hard
Hard-level Cosmos chain operation questions covering advanced algorithms, … - Cosmos Chain Operations Interview Questions - Medium
Medium-level Cosmos chain operation questions covering advanced chain … - Cosmos SDK Interview Questions - Easy
Easy-level Cosmos SDK interview questions covering chain code, SDK basics, and … - Cosmos SDK Interview Questions - Hard
Hard-level Cosmos SDK interview questions covering advanced SDK internals, … - Cosmos SDK Interview Questions - Medium
Medium-level Cosmos SDK interview questions covering advanced module … - Ouroboros (Cardano) Consensus Interview Questions
Ouroboros consensus algorithm interview questions covering Cardano's … - Paxos Consensus Interview Questions
Paxos consensus algorithm interview questions covering the classic distributed … - Polkadot (NPoS) Consensus Interview Questions
Polkadot consensus algorithm interview questions covering Nominated … - Polkadot Interview Questions - Easy
Easy-level Polkadot interview questions covering blockchain basics, Substrate, … - Polkadot Interview Questions - Hard
Hard-level Polkadot interview questions covering advanced optimization and … - Polkadot Interview Questions - Medium
Medium-level Polkadot interview questions covering advanced Substrate … - Solana Interview Questions - Easy
Easy-level Solana interview questions covering blockchain basics, programs, and … - Solana Interview Questions - Hard
Hard-level Solana interview questions covering advanced optimization, security, … - Solana Interview Questions - Medium
Medium-level Solana interview questions covering advanced program development, … - Solana Proof of History Consensus Interview Questions
Solana consensus algorithm interview questions covering Proof of History (PoH) … - Tendermint Consensus Interview Questions
Tendermint consensus algorithm interview questions covering the Byzantine Fault … - Web3 Interview Questions - Easy
Easy-level Web3 interview questions covering blockchain fundamentals, Ethereum, … - Web3 Interview Questions - Hard
Hard-level Web3 interview questions covering MEV, zero-knowledge proofs, … - Web3 Interview Questions - Medium
Medium-level Web3 interview questions covering DeFi, advanced Solidity, …