Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions tasks_answers/session5_answer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Ethereum Consensus Mechanisms: Casper LMD-GHOST, Checkpoint Sync, and Consensus Specifications

## Introdution

Ethereum consensus mechanism is the system that ensures all nodes in the network agree on the state of the blockchain. Here’s a closer look at three key parts of how Ethereum’s Proof-of-Stake (PoS) consensus works:

1. **Casper LMD-GHOST**: The fork-choice rule used by Ethereum's consensus layer. It determines which block is the "head" of the chain.
2. **Checkpoint Sync**: A fast Synchronization method allowing new nodes to join the network efficiently.
3. **Consensus Specifications**: Rules governing consensus

## Casper LMD-GHOST

Casper LMD-GHOST (Latest Message Driven Greedy Heaviest Observed SubTree) is the fork-choice rule and finality mechanism used by Ethereum's consensus layer, it determines which block is the "head" of the chain, i.e., the block that validators should build on top of

## How it works:

1. **Validators Vote on Blocks:**
Validators cast votes (called attestations) for the blocks they believe should be part of the canonical chain. Each validator’s vote includes the block they think is the best based on the information they’ve seen

2. **Fork-Choice Decision**
LMD-GHOST (Latest Message Driven – Greediest Heaviest Observed SubTree) uses these attestations to recursively select the next block by choosing the child block with the most total voting weight at each level, starting from the last justified checkpoint.

3. **Finality**
Although LMD-GHOST helps decide which block to build on, it doesn’t provide finality. That’s handled by Casper FFG, which finalizes blocks when 2/3 of validators agree on them through checkpoint voting

## Diagram:

![Fd8ivDeVEAAf3Gr](https://hackmd.io/_uploads/BJAN7azAke.png)

## Checkpoint Sync

Checkpoint synchronization (or state sync) is a mechanism used in blockchain networks to accelerate node synchronization and improve network efficiency. It enables blockchain nodes to quickly join a network by syncing to a specific, verified state (a "checkpoint") rather than downloading and validating the entire blockchain history from the genesis block.

## How it works

- Nodes download a checkpoint, which is a snapshot of the blockchain's state at a specific point in time.
- They then verify the checkpoint's validity against the network's consensus rules
- Once the checkpoint is verified, the node can start processing new blocks and transactions from that point onward.

## Benefits:

1. **Faster initial sync:** Checkpoint sync significantly reduces the time it takes for a new node to join the network.
2. **Reduced storage requirements:** Nodes don't need to store the entire blockchain history, saving storage space.
3. **Faster recovery:** Nodes can recover from failures or outages by syncing from the latest checkpoint, rather than starting from scratch

## Diagram:

![checkpoint](https://hackmd.io/_uploads/r1jOGpGRkg.png)

## Consensus Specification

## Overview

Ethereum’s Consensus Specifications are rules that define how the consensus layer works, including how validators operates, how blocks are proposed, attested, and how finality is reached.

## Components of Ethereum Consensus

1. Validator Roles

- Replace miners in PoS. Responsible for proposing and attesting to blocks.

2. Block Finalization

- **Two-Stage Finality:**

i. Justification: 2/3 of validators attest to a checkpoint.

ii. Finalization: The next checkpoint is justified → prior checkpoint finalizes. Finalized blocks are irreversible

3. Slashing & Penalties

**What Triggers Slashing?**

- **Double Block Proposal:** Signing two different blocks in the same slot.
- **Double Voting:** Attesting to two conflicting blocks in the same epoch.

## References

- Ethereum Consensus Specs (Main Repo):https://github.com/ethereum/consensus-specs

---

## Conclusion

Ethereum’s consensus specifications defines a secure, slashing-enforced, Proof-of-Stake system. It is decentralized, economically and secured.