Validate that the attestation bitlist size matches the committee size #1693
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Description
When creating an indexed attestation we need to ensure that the aggregation bits are the same size as the committee. There are four places this can occur:
BeaconState
contains invalidPendingAttestation
waiting processing at the end of the epoch. This will never occur "naturally" but could occur if an invalid start state is provided.An explicit precondition check has been added in
get_attesting_indices
so that it's now impossible to create an indexed attestation if the bitlist size is incorrect. All of the above cases now will reject the attestation.The gossip attestation validator also performs an explicit check so it can return a standard INVALID result instead of throwing an
IllegalStateException
. Fork choice now catchesInvalidArgumentException
when creating the indexed attestation instead ofIndexOutOfBoundsException
(which is what was thrown if the bitlist was too short). The other cases already expect and handle the precondition check exception.Fixed Issue(s)
fixes #1685
covers at least part of #1686