-
Notifications
You must be signed in to change notification settings - Fork 997
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
off-by-one validating justified_epoch for attestations #618
Comments
related commit: f943361 |
It would be much cleaner to make this epoch based and arguably should have been done in the epoch rework
If the attestation is included in the epoch during the slot it was for, then it uses |
This is clean because we don't actually transition into the next upon until the end of the state transition. so when processing the block, the current epoch check is valid |
I'm not sure I follow here
|
Ok, I replayed this with a bit more detail this time:
Now, let's teleport back to when the attestation is created:
thus, when creating the attestation, the epoch processing is already done while the condition fails to capture this and uses the previous epoch instead... does this make sense? my original description looks a bit off here in terms of where exactly the off-by-one happens the proposed fix, to compare using epoch seems to run into the same |
I see now. thank you The problem here is that an attester is attesting to the post state of the block. Which when that block is at the end of the epoch includes the epoch transition. You're right, your proposal is the simplest way to clean it up. Moving the epoch transition to the start of the 0th slot of an epoch cleans this issue up as well, but has some rippling effects in other places. Going to mull it over a bit |
3d5aa35
Currently, spec has this rule for validating attestations:
Epoch transitions happen at
(state.slot + 1) % EPOCH_LENGTH == 0
. This means that whenattestation.data.slot % EPOCH_LENGTH == 0
, the epoch state update will not yet have happened butget_epoch_start_slot
will already return a slot from the new epoch, and this check will fail due to an off-by-one.. it can be fixed by an extra + 1:It should be noted however that this feels like a workaround - the deeper issue here is that
get_current_epoch
returns the new epoch one slot earlier than thejustified_epoch
update happens, so we have a situation where according to one function, we are in a new epoch, butstate
has not yet been updated to include the changes that pertain to that epoch.The text was updated successfully, but these errors were encountered: