freecoding.school100% FREE · NO SIGNUP
Proof PeaksISSUE #29 of 38

casper ffg · the finality gadget

ZeekaVSThe Collision
Zeeka saysCasper FFG layers finality on any fork choice: validators vote on checkpoints, a 2/3 supermajority justifies one, and two consecutive justifications finalize.

Casper FFG (Friendly Finality Gadget) does not pick the chain head — it decides which blocks are final. Validators sign votes pointing from a source checkpoint to a target checkpoint. When 2/3 of staked weight votes for a target, it becomes JUSTIFIED. When the chain has two consecutive justified pairs, the source of the second pair becomes FINALIZED — irreversible unless 1/3 of stake commits provable byzantine behavior and gets slashed.

Eth runs FFG on top of LMD-GHOST. The demo simulates five epochs of validator votes; epochs that clear the 2/3 threshold get justified, and any justified epoch whose successor is also justified is marked finalized. Slashing rules (no double-vote, no surround-vote) keep the votes honest at the cost of the validator's stake.

Power-ups you unlock

The Collision attacks — common mistakes

Boss battleSimulate validator votes across five epochs and identify which ones get justified and which finalized.

Example code

<!doctype html><html><head><meta charset="utf-8"></head>
<body style="background:#06040d;color:#e6e0ff;font-family:monospace;padding:20px"><pre id="o"></pre>
<script>
// Casper FFG: epoch justified at ≥ 2/3 stake; finalized when itself + next are both justified.
const epochVotes = [70, 80, 60, 90, 75];          // % stake voting per epoch
const justified  = epochVotes.map(v => v >= 67);
const finalized  = justified.map((j,i) => j && i+1 < justified.length && justified[i+1]);
const rows = epochVotes.map((v,i) => 'epoch ' + (i+1) + ': votes ' + String(v).padStart(2) + '% → '
  + (justified[i] ? 'JUSTIFIED' : 'unjustified').padEnd(11) + (finalized[i] ? ' → FINALIZED' : ''));
document.getElementById('o').textContent = [
  'stake threshold: 2/3 = 67%',
  ...rows,
  'finalization needs consecutive justified epochs — epoch 2 not finalized because epoch 3 fell short'
].join('\n');
</script></body></html>
▶ Open the interactive comic issue
‹ The Ghost Protocol · Heaviest SubtreeGasper · Lmd-Ghost + Ffg ›