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

Epoch processing is too eager #1041

Closed
JustinDrake opened this issue May 3, 2019 · 0 comments
Closed

Epoch processing is too eager #1041

JustinDrake opened this issue May 3, 2019 · 0 comments
Labels
general:bug Something isn't working

Comments

@JustinDrake
Copy link
Collaborator

JustinDrake commented May 3, 2019

The current state transition function structure (as #1018 makes clear) is:

def state_transition(state: BeaconState, block: BeaconBlock) -> BeaconBlock:
    # Process slots (including those with no blocks) since block
    process_slots(state, block.slot)
    # Process block
    process_block(state, block)
    # Return post-state
    return state
def process_slots(state: BeaconState, slot: Slot) -> None:
    assert state.slot < slot
    while state.slot < slot:
        process_slot(state)
        # Process epoch on the last slot of every epoch
        if (state.slot + 1) % SLOTS_PER_EPOCH == 0:
            process_epoch(state)
        state.slot += 1

Notice on the last slot of every epoch, i.e. when (state.slot + 1) % SLOTS_PER_EPOCH == 0, process_epoch is run before process_block. This is bad because the attestations (and other operations such as eth1 votes) in the last block are ignored by process_epoch.

My best guess is that we want something like:

def state_transition(state: BeaconState, block: BeaconBlock) -> BeaconBlock:
    assert state.slot < block.slot
    while state.slot < block.slot:
        process_slot(state)
        if (state.slot + 1) == block.slot:
            process_block(state, block)
        if (state.slot + 1) % SLOTS_PER_EPOCH == 0:
            process_epoch(state)
        state.slot += 1
    return state

Notice that we are actually quite constrained:

  1. process_slot must come first, to "catch up" the skip slots
  2. process_block must come before the final process_epoch as highlighted by this issue

The above two imply that we want process_slot, then process_block, then the final process_epoch.

@JustinDrake JustinDrake added the general:bug Something isn't working label May 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
general:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant