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

Clarify "per-epoch processing" #946

Closed
dankrad opened this issue Apr 16, 2019 · 4 comments
Closed

Clarify "per-epoch processing" #946

dankrad opened this issue Apr 16, 2019 · 4 comments
Labels
general:discussion general:presentation Presentation (as opposed to content)

Comments

@dankrad
Copy link
Contributor

dankrad commented Apr 16, 2019

When reading through the spec, I noticed that during epoch processing, the "current epoch" actually refers to the previous epoch, whereas in the block processing, the "current slot" corresponds to the slot of the given block.

To make this less confusing, I suggest renaming it to "end of epoch processing"?

@JustinDrake JustinDrake added the general:presentation Presentation (as opposed to content) label Apr 17, 2019
@JustinDrake
Copy link
Collaborator

JustinDrake commented Apr 18, 2019

We have

def get_current_epoch(state: BeaconState) -> Epoch:
    return state.slot // SLOTS_PER_EPOCH

and (see state_transition.py)

def state_transition_to(state: BeaconState, up_to: Slot) -> BeaconState:
    while state.slot < up_to:
        spec.cache_state(state)
        if (state.slot + 1) % spec.SLOTS_PER_EPOCH == 0:
            process_epoch_transition(state)
        spec.advance_slot(state)

In other words, process_epoch_transition happens at transition_slot(k) = SLOTS_PER_EPOCH * k + SLOTS_PER_EPOCH - 1 for k = 0, 1, 2, ..., where get_current_epoch(transition_slot(k)) == k.

This does seem to contradict this sentence in the spec:

The per-epoch transitions, which happens at the start of the first slot of every epoch."

@djrtwo: Should it say "The per-epoch transitions, which happens at the start of the last slot of every epoch."?

@dankrad
Copy link
Contributor Author

dankrad commented Apr 19, 2019

@djrtwo: Should it say "The per-epoch transitions, which happens at the start of the last slot of every epoch."?

I think it should actually be

  • after the last slot of every epoch
  • before the first slot of every epoch

(I prefer the first variant and suggest, to make it clearer, to call them "end of epoch" transition, because the epoch number at the time of the transition is the old epoch rather than the new one)

@djrtwo
Copy link
Contributor

djrtwo commented May 7, 2019

The per-epoch transitions, which happens at the start of the first slot of every epoch."

At the start of the state transition of the first slot of every epoch.

yes, the slot isn't incremented yet at that point in the state transition but it is certainly during the state transition of the 1st slot of the epoch.

That said, the debate really seems to be in #1043 😂

@JustinDrake
Copy link
Collaborator

Closing in favour of #1043

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
general:discussion general:presentation Presentation (as opposed to content)
Projects
None yet
Development

No branches or pull requests

3 participants