Merge pull request #1384 from ethereum/length-check-fix

Remove bug bitlist length checks in process_attestation
This commit is contained in:
dankrad 2019-08-28 13:44:44 +01:00 committed by GitHub
commit 5f1cdc4acc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 9 deletions

View File

@ -1615,11 +1615,6 @@ def process_attestation(state: BeaconState, attestation: Attestation) -> None:
proposer_index=get_beacon_proposer_index(state), proposer_index=get_beacon_proposer_index(state),
) )
# Check bitlist lengths
committee_size = get_committee_count(state, attestation.data.target.epoch)
assert len(attestation.aggregation_bits) == committee_size
assert len(attestation.custody_bits) == committee_size
if data.target.epoch == get_current_epoch(state): if data.target.epoch == get_current_epoch(state):
assert data.source == state.current_justified_checkpoint assert data.source == state.current_justified_checkpoint
parent_crosslink = state.current_crosslinks[data.crosslink.shard] parent_crosslink = state.current_crosslinks[data.crosslink.shard]

View File

@ -10,7 +10,7 @@ from .utils import vector_test, with_meta_tags
def with_state(fn): def with_state(fn):
def entry(*args, **kw): def entry(*args, **kw):
try: try:
kw['state'] = create_genesis_state(spec=kw['spec'], num_validators=spec_phase0.SLOTS_PER_EPOCH * 8) kw['state'] = create_genesis_state(spec=kw['spec'], num_validators=spec_phase0.SLOTS_PER_EPOCH * 10)
except KeyError: except KeyError:
raise TypeError('Spec decorator must come within state decorator to inject spec into state.') raise TypeError('Spec decorator must come within state decorator to inject spec into state.')
return fn(*args, **kw) return fn(*args, **kw)

View File

@ -212,13 +212,16 @@ def test_max_reveal_lateness_1(spec, state):
challenge = get_valid_bit_challenge(spec, state, attestation) challenge = get_valid_bit_challenge(spec, state, attestation)
responder_index = challenge.responder_index responder_index = challenge.responder_index
target_epoch = attestation.data.target.epoch
state.validators[responder_index].max_reveal_lateness = 3 state.validators[responder_index].max_reveal_lateness = 3
for i in range(spec.get_randao_epoch_for_custody_period( latest_reveal_epoch = spec.get_randao_epoch_for_custody_period(
spec.get_custody_period_for_validator(state, responder_index), spec.get_custody_period_for_validator(state, responder_index, target_epoch),
responder_index responder_index
) + 2 * spec.EPOCHS_PER_CUSTODY_PERIOD + state.validators[responder_index].max_reveal_lateness - 2): ) + 2 * spec.EPOCHS_PER_CUSTODY_PERIOD + state.validators[responder_index].max_reveal_lateness
while spec.get_current_epoch(state) < latest_reveal_epoch - 2:
next_epoch(spec, state) next_epoch(spec, state)
apply_empty_block(spec, state) apply_empty_block(spec, state)