mirror of
https://github.com/status-im/eth2.0-specs.git
synced 2025-02-26 09:15:17 +00:00
must be correct target to get correct head
This commit is contained in:
parent
ad01c85ff6
commit
b029c75d88
@ -374,7 +374,7 @@ def process_attestation(state: BeaconState, attestation: Attestation) -> None:
|
|||||||
|
|
||||||
# Participation flags
|
# Participation flags
|
||||||
participation_flags = []
|
participation_flags = []
|
||||||
if is_matching_head and state.slot <= data.slot + MIN_ATTESTATION_INCLUSION_DELAY:
|
if is_matching_head and is_matching_target and state.slot <= data.slot + MIN_ATTESTATION_INCLUSION_DELAY:
|
||||||
participation_flags.append(TIMELY_HEAD_FLAG)
|
participation_flags.append(TIMELY_HEAD_FLAG)
|
||||||
if is_matching_source and state.slot <= data.slot + integer_squareroot(SLOTS_PER_EPOCH):
|
if is_matching_source and state.slot <= data.slot + integer_squareroot(SLOTS_PER_EPOCH):
|
||||||
participation_flags.append(TIMELY_SOURCE_FLAG)
|
participation_flags.append(TIMELY_SOURCE_FLAG)
|
||||||
|
@ -517,11 +517,18 @@ def run_test_full_random(spec, state, rng=Random(8020)):
|
|||||||
pending_attestation.inclusion_delay = rng.randint(1, spec.SLOTS_PER_EPOCH)
|
pending_attestation.inclusion_delay = rng.randint(1, spec.SLOTS_PER_EPOCH)
|
||||||
else:
|
else:
|
||||||
for index in range(len(state.validators)):
|
for index in range(len(state.validators)):
|
||||||
# ~1/3 have bad target
|
# ~1/3 have bad head or bad target or not timely enough
|
||||||
state.previous_epoch_participation[index][spec.TIMELY_TARGET_FLAG] = rng.randint(0, 2) != 0
|
is_timely_correct_head = rng.randint(0, 2) != 0
|
||||||
# ~1/3 have bad head
|
state.previous_epoch_participation[index][spec.TIMELY_HEAD_FLAG] = is_timely_correct_head
|
||||||
state.previous_epoch_participation[index][spec.TIMELY_HEAD_FLAG] = rng.randint(0, 2) != 0
|
if is_timely_correct_head:
|
||||||
# ~50% participation
|
# If timely head, then must be timely target
|
||||||
state.previous_epoch_participation[index][spec.TIMELY_SOURCE_FLAG] = rng.choice([True, False])
|
state.previous_epoch_participation[index][spec.TIMELY_TARGET_FLAG] = True
|
||||||
|
# If timely head, then must be timely source
|
||||||
|
state.previous_epoch_participation[index][spec.TIMELY_SOURCE_FLAG] = True
|
||||||
|
else:
|
||||||
|
# ~50% of remaining have bad target or not timely enough
|
||||||
|
state.previous_epoch_participation[index][spec.TIMELY_TARGET_FLAG] = rng.choice([True, False])
|
||||||
|
# ~50% of remaining have bad source or not timely enough
|
||||||
|
state.previous_epoch_participation[index][spec.TIMELY_SOURCE_FLAG] = rng.choice([True, False])
|
||||||
|
|
||||||
yield from run_deltas(spec, state)
|
yield from run_deltas(spec, state)
|
||||||
|
@ -29,6 +29,12 @@ def test_full_random_2(spec, state):
|
|||||||
yield from rewards_helpers.run_test_full_random(spec, state, rng=Random(3030))
|
yield from rewards_helpers.run_test_full_random(spec, state, rng=Random(3030))
|
||||||
|
|
||||||
|
|
||||||
|
@with_all_phases
|
||||||
|
@spec_state_test
|
||||||
|
def test_full_random_3(spec, state):
|
||||||
|
yield from rewards_helpers.run_test_full_random(spec, state, rng=Random(4040))
|
||||||
|
|
||||||
|
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@with_custom_state(balances_fn=low_balances, threshold_fn=lambda spec: spec.EJECTION_BALANCE)
|
@with_custom_state(balances_fn=low_balances, threshold_fn=lambda spec: spec.EJECTION_BALANCE)
|
||||||
@spec_test
|
@spec_test
|
||||||
|
Loading…
x
Reference in New Issue
Block a user