Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cache justified roots in state/rename attestation fields #756

Merged
merged 6 commits into from
Mar 12, 2019

Conversation

djrtwo
Copy link
Contributor

@djrtwo djrtwo commented Mar 11, 2019

addresses #742

Two things:

correct value for genesis justified roots

Right now, we just have ZERO_HASH for the genesis justified roots. This does not actually reflect the value of the root of the block at genesis. The value of the block at the genesis slot is looks like

block = get_empty_block()
genesis_state = get_genesis_state()
block.state_root = hash_tree_root(genesis_state)

Due to the normal chicken-and-egg state/block-root problem, we can't embed the genesis block root in as the initial justified roots when constructing the genesis state. If we want to enforce this, we can do the following in cache_state. This is nice because the value reflects an actual block root but it's not really necessary imo.

if state.justified_root == ZERO_HASH:
    state.justified_root = hash_tree_root(state.latest_block_header)
    state.previous_justified_root = state.justified_root

finalized root

Should we add another field finalized_root for symmetry? It is not needed in the state transition but might be nice to be available in state regardless of the number of slots since finality. (if greater than HISTORICAL_ROOTS_LENGTH you would no longer have it available in state)

@djrtwo djrtwo requested review from JustinDrake and vbuterin March 11, 2019 20:40
@JustinDrake
Copy link
Contributor

Should we add another field finalized_root

Good idea! At the very least we want an EVM2.0 opcode to fetch the finalized root.

djrtwo added a commit to ethereum/research that referenced this pull request Mar 12, 2019
@djrtwo djrtwo changed the title cache current and previous justified root in state cache justified roots in state/rename attestation fields Mar 12, 2019
@djrtwo djrtwo merged commit 9ee7ed0 into dev Mar 12, 2019
@djrtwo djrtwo deleted the store-justified-root branch March 12, 2019 18:35
@hwwhww hwwhww assigned hwwhww and unassigned hwwhww Mar 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants