-
Notifications
You must be signed in to change notification settings - Fork 1.7k
EIP-1011: Hybrid Casper FFG / Ethash #7162
Comments
I can take it (edit: busy with Polkadot stuff; can mentor implementation) |
I'm on it to figure out the specs. |
Would be happy to provide any assistance or support. We will try to prioritize improving documentation asap. In the mean time, there's the paper and the python code: http://github.com/karlfloersch/docker-pyeth-dev I recommend starting with the fork choice rule (priority 1: highest justified epoch #, priority 2: max total diff) and the validator logic. |
The paper is pretty good documentation for a start. Initial engineering concerns:
|
does a smart contract keep track of votes and justified checkpoints?
Yes. The Casper contract basically keeps track of everything.
How are light clients meant to track finality?
Probably via a special-purpose protocol, like randomly selecting 50
validator indices and verifying that valid votes for enough of those
validators exist.
Engine needs to get a persistent data store to keep track of any votes
targeting non-finalized checkpoints to avoid violating slashing conditions.
You can simplify this by simply tracking the highest epoch you're used as a
target and the highest epoch you've used as a source; that way there's only
2 variables that you need to figure out how to persist.
…On Mon, Jan 1, 2018 at 3:02 PM, Robert Habermeier ***@***.***> wrote:
The paper is pretty good documentation for a start, but I haven't dug into
how votes are broadcast/accumulated in practice -- does a smart contract
keep track of votes and justified checkpoints? or does a full node have to
track all justified checkpoints internally? How are light clients meant to
track finality?
Engineering concerns:
- BlockChain currently holds the whole fork-choice decision, based
only on total difficulty. Parts of this will need to be deferred to the
Engine.
- Engine needs to get a persistent data store to keep track of any
votes targeting non-finalized checkpoints to avoid violating slashing
conditions. This brings complication due to snapshot restoration replacing
the DB in-place.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#7162 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACIKbqSvvKBFORkhxZwjyaawxj1H2CFgks5tGTnhgaJpZM4QupmR>
.
|
@vbuterin In CasperFFG this will definitely be more difficult and it seems that light clients will have to download lots of state data progressively to follow the fork-choice rule correctly. It would probably be simpler to give light clients a batch of proofs for all finalized dynasty changes (i.e. a warp sync) than to have it try and follow the header chain from genesis. |
As far as implementing the fork-choice rule, I think this will be fairly easy to do (will provide the skeleton for that in an upcoming PR) through the introduction of arbitrary engine metadata being allowed to be stored in the blockchain-db.
The consensus engine gets two new functions:
The fork_choice function always called after the update_metadata function, and never if the prospective block would reorganize past a set reversion limit. Here are some example fork choice implementations: // Ethash
fn total_diff_fork_choice(prospective, current_best, metadata_store) -> H256 {
let new_total_diff = metadata_store.get_total_difficulty(prospective);
let current_best_diff = metadata_store.get_total_difficulty(current_best);
if current_best_diff > new_total_diff {
current_best.hash()
} else {
prospective.hash()
}
}
// a casperFFG fork choice
fn casperFFG_fork_choice(prospective, current_best, metadata_store) -> H256 {
let left_justified_height = get_justified_height(prospective);
let right_justified_height = get_justified_height(current_best);
// Note that there exists at most one justified checkpoint at a height `n`.
// the last justified checkpoint must have been cast as such according to the best block
match left_justified_height.cmp(right_justified_height) {
Ordering::Equal => total_diff_fork_choice_rule(prospective, current_best, metadata_store)
Ordering::Less => current_best.hash(),
Ordering::Greater => prospective.hash(),
}
} The respective update_metadata functions would set the new total difficulty and justified/finalized epochs based on chain or state data. |
@vbuterin when you say "highest justified epoch #", should that be the highest witnessed at any contract-state or only at the contract state of either chain head in the fork choice? |
The "justified epoch #" of a block is the last-justified-epoch in the
contract state in the post-state of that block. So you would look for the
block which returns the highest LJE if you try to call the getter for that
variable using the post-state of the block.
… |
Copy-pasty from Gitter:
|
I would like to help out on this issue. |
Discussed with @ascjones. I'll take over the Casper ABI work and try to see whether we can use the fork choice and metadata framework to make an implementation to connect to the Casper testnet. |
Just fyi, vyper is soon moving to Relevant issue here vyperlang/vyper#566 |
http://eips.ethereum.org/EIPS/eip-1011
The text was updated successfully, but these errors were encountered: