Casper &
Smart Contract Consensus
1.
Hybrid Casper Overview
Running PoW and PoS at the same time with
Casper The Friendly Finality Gadget
Casper Validator 1,000 foot overview
Casper + PoW
Casper’s rollout will be incremental, and not immediately replace proof of work
Finality
What is finality?
Why doesn’t proof of work have it?
Finality guarantees that history will never be changed.
Why do we want finality?
Fun finality fact:
Real world finality
Before
Miner
User
After
Reverted
chain
User & miner
Head
Head
Checkpointing PoW
How we get finality in PoW by checkpointing with PoS
Hybrid Architecture Overview
Casper’s checkpointing
…98 blocks later ...
…98 blocks later ...
…98 blocks later ...
Validators
Miners
One
Epoch
Some fun attacks
Validators are in charge.
Casper Messages
The two messages required for Casper validators to come to consensus: Prepare & Commit
PREPARE
Casper’s checkpointing
…98 blocks later ...
…98 blocks later ...
…98 blocks later ...
[“PREPARE”, 2, 0xaa…68a41, 1]
0xaa…68a41
0xbe…728cc
0x…..
0x…..
0x…..
0x…..
0x…..
0x…..
PREPARE
Casper’s checkpointing
…98 blocks later ...
…98 blocks later ...
…98 blocks later ...
[“PREPARE”, 3, 0xbe...728cc, 1]
0xaa…68a41
0x…..
0xbe…728cc
0x…..
0x…..
0x…..
0x…..
0x…..
Prepares can reference any previous epoch
COMMIT
Casper’s checkpointing
…98 blocks later ...
…98 blocks later ...
…98 blocks later ...
[“COMMIT”, 2, 0xaa…68a41]
0xaa…68a41
0xbe…728cc
0x…..
0x…..
0x…..
0x…..
0x…..
0x…..
⅔ COMMITs on a single [epoch, HASH] means a checkpoint has been
finalized
Providing Safety with Slashing Conditions
How we punish validators that validate our finality guarantees
Economic Finality means that for finality to be violated, at least ⅓ of the validators funds will be slashed (aka destroyed)
“
Four Slashing Conditions
We will go over each of these individually.
For more information see: https://medium.com/@VitalikButerin/minimal-slashing-conditions-20f0b500fc6c
Prepare REQ
The epoch_source of each prepare must itself have at least ⅔ prepares
NOTE: Each box in this diagram is an EPOCH not a block
⅘ prepares
Valid prepare
Valid prepare
⅓ prepares
Invalid prepare
Invalid prepare
Commit REQ
The HASH of each commit must have received at least ⅔ prepares
NOTE: Each box in this diagram is an EPOCH not a block
⅘ prepares
Valid commit
⅓ prepares
Invalid commit
Prepare Commit Consistency
You must never submit a prepare such that:
prepare_epoch_source < commit_epoch < prepare_epoch
NOTE: Each box in this diagram is an EPOCH not a block
My last commit
My Invalid prepare
epoch source
epoch
No Double Prepare
You must never submit two prepares for the same epoch
NOTE: Each box in this diagram is an EPOCH not a block
My second prepare for epoch X will get me slashed
My first prepare for epoch X is OK
Providing Availability: Negative Interest
How can we punish validators for not finalizing blocks
Overview of Availability concerns
Cases in which we need to penalize
Validator Actions | < ⅔ Prepares | < ⅔ Commits | > ⅔ Commits |
Nothing | The worst | The worst | Bad |
Prepare | Not good | Bad | Not good |
Commit | | | OK |
Prepare & Commit | | Not good | Good |
These
Summary
Validator Rotation
How the validator set can change over time
1,000 foot overview for dynamic validator sets
Putting it together with a fork choice rule
How clients and validators decide which chain is the “the longest”
Fork Choice
Most recent dynasty change
30% commits
35% commits
50% commits
10% commits
5% commits
HEAD
PoW for
subsequent
blocks till
next epoch
Success!
That’s Casper!
So how does this thing work when it’s all
inside a smart contract?
“
2.
Consensus in a Smart Contract
How you can use a smart contract in order to provide consensus
Important Concepts
Smart Contract | Validator |
Economic Incentives | Fork choice |
Historical Data (Consensus Messages) | Transaction sending logic |
How to visualize yourself as a consensus forming contract
In each block, the Casper smart contract can only see its particular history
How to visualize yourself as a consensus forming contract
How to visualize yourself as a consensus forming contract
How to visualize yourself as a consensus forming contract
How to visualize yourself as a consensus forming contract
How to visualize yourself as a consensus forming contract
How to visualize yourself as a validator choosing a fork
Smart contract, how many commits do you have?
30% commits
How to visualize yourself as a validator choosing a fork
Smart contract, how many commits do you have?
30% commits
40% commits
How to visualize yourself as a validator choosing a fork
Smart contract, how many commits do you have?
75%!
I’m finalized!
And so on, and so on...
That’s
Casper
The Friendly
Finality Gadget
This is just the tip of the iceberg when it comes to consensus in smart contracts….
Build your own!
Yay! Fun!
Thanks!
Questions?