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

Parent root reconstruction + granular state roots + body/header segregation #649

Closed
wants to merge 53 commits into from

Conversation

JustinDrake
Copy link
Collaborator

@JustinDrake JustinDrake commented Feb 18, 2019

This PR introduces three significant changes:

  1. Parent root reconstruction: Instead of relying on a parent root "oracle" in the state transition function, the state transition function now only has two argument: (current) state and (latest) block.
  2. Granular state roots: To be more friendly to clients we expose granular state roots at every slot independently of block production. Having the state roots at every epoch boundary is especially helpful.
  3. Body/header segregation: This follows the discussion here, and allows us to remove Proposal and related things.

(Draft—don't merge yet. Thanks to @vbuterin for pushing to remove the `Proposal` object and for @djrtwo for taking down past proposals.)

Main feature: The state transition function now only depends on the current `BeaconState` and the latest `BeaconBlock`. (As opposed to also requiring `previous_block_root` to populate `latest_block_roots`.)

**Cleanups**

* Removed `Proposal`, `BeaconBlockBody`, `BEACON_CHAIN_SHARD_NUMBER`.
* More consistent signature verification handling of beacon blocks (now done via a `BeaconBlockMetadata` object which also avoids the duplication of `signature` and `slot` across multiple objects).
* Be explicit about per-block `block_root` checks.
* Reworked the section on the genesis block and state for clarity.
* Misc fixes along the way (e.g. missing `transfers=[]` in the genesis block).

Todo: Is `genesis_eth1_data` defined properly?
@JustinDrake JustinDrake changed the title Self sufficient BeaconState Standalone BeaconState Feb 19, 2019
specs/core/0_beacon-chain.md Outdated Show resolved Hide resolved
specs/core/0_beacon-chain.md Outdated Show resolved Hide resolved
specs/core/0_beacon-chain.md Outdated Show resolved Hide resolved
specs/core/0_beacon-chain.md Show resolved Hide resolved
Copy link
Contributor

@djrtwo djrtwo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm finding the slot processing section difficult to understand/debug. Made a few comments/questions to start.

also, once we get this phase 0 doc locked down, I'll clean up the validator doc before mergning

specs/core/0_beacon-chain.md Outdated Show resolved Hide resolved
specs/core/0_beacon-chain.md Outdated Show resolved Hide resolved
specs/core/0_beacon-chain.md Outdated Show resolved Hide resolved
specs/core/0_beacon-chain.md Outdated Show resolved Hide resolved
specs/core/0_beacon-chain.md Outdated Show resolved Hide resolved
specs/core/0_beacon-chain.md Outdated Show resolved Hide resolved
specs/core/0_beacon-chain.md Show resolved Hide resolved
Copy link
Contributor

@djrtwo djrtwo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No quite sold yet 😬
comments/questions below

specs/core/0_beacon-chain.md Outdated Show resolved Hide resolved
Copy link
Contributor

@hwwhww hwwhww left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for that I didn’t follow this PR these days! High-level quick recap:

Before this PR:

  • On genesis:
    • Use Eth1 chain logs to generate genesis state.
    • Use genesis_state to generate genesis_block.
  • Start from (genesis_block, genesis_state).
  • If slot 1 is not skipped:
    • state_transition_function(genesis_state, block_1, previous_block_root) -> state_1
  • If slot 1 is skipped:
    • per_slot_transition(genesis_state, previous_block_root) -> state_1

After this PR:

  • On genesis:
    • Use empty block + Eth1 chain logs to generate genesis_state.
    • Use genesis_state to generate genesis_block.
  • Start from S: (genesis_block, genesis_state).
    • state.latest_block_header is the empty block header, and will track the last block header.
  • If slot 1 is not skipped:
    • state_transition_function(genesis_state, block_1) -> state_1
  • If slot 1 is skipped:
    • per_slot_transition(genesis_state) -> state_1

We gain:

  1. Parent root reconstruction
  2. Granular state roots
  3. Body/header segregation

And, extra costs

  • Two more fields in BeaconState:
    • latest_block_header: BeaconBlockHeader
    • historical_batchings: ['bytes32'], where historical_batchings is an unlimited size list contains 8192 slots/per log.

Is that correct? Is there any other extra cost that we should consider?

specs/core/0_beacon-chain.md Outdated Show resolved Hide resolved
Co-Authored-By: JustinDrake <drakefjustin@gmail.com>
@JustinDrake
Copy link
Collaborator Author

Is that correct?

Yes! :)

@mslipper mslipper mentioned this pull request Feb 26, 2019
Copy link
Contributor

@djrtwo djrtwo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some brief comments/questions. Close to merge time

specs/core/0_beacon-chain.md Show resolved Hide resolved
specs/core/0_beacon-chain.md Outdated Show resolved Hide resolved
specs/core/0_beacon-chain.md Outdated Show resolved Hide resolved
specs/core/0_beacon-chain.md Outdated Show resolved Hide resolved
specs/core/0_beacon-chain.md Show resolved Hide resolved
specs/core/0_beacon-chain.md Outdated Show resolved Hide resolved
specs/core/0_beacon-chain.md Outdated Show resolved Hide resolved
@JustinDrake
Copy link
Collaborator Author

    for index in range(LATEST_ACTIVE_INDEX_ROOTS_LENGTH):
        state.latest_active_index_roots[index] = genesis_active_index_root

@djrtwo Can we just do latest_active_index_roots[0] = genesis_active_index_root?

vbuterin added a commit that referenced this pull request Mar 3, 2019
@djrtwo
Copy link
Contributor

djrtwo commented Mar 4, 2019

close in favor of #711

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