PR feedback from @hwwhww
This commit is contained in:
parent
d26cfd2e59
commit
b2dfb6cebe
|
@ -61,19 +61,19 @@ def run_attestation_component_deltas(spec, state, component_delta_fn, matching_a
|
||||||
assert penalties[index] == 0
|
assert penalties[index] == 0
|
||||||
|
|
||||||
|
|
||||||
def test_empty(spec, state, runner):
|
def run_test_empty(spec, state, runner):
|
||||||
# Do not add any attestations to state
|
# Do not add any attestations to state
|
||||||
|
|
||||||
yield from runner(spec, state)
|
yield from runner(spec, state)
|
||||||
|
|
||||||
|
|
||||||
def test_full_all_correct(spec, state, runner):
|
def run_test_full_all_correct(spec, state, runner):
|
||||||
prepare_state_with_full_attestations(spec, state)
|
prepare_state_with_full_attestations(spec, state)
|
||||||
|
|
||||||
yield from runner(spec, state)
|
yield from runner(spec, state)
|
||||||
|
|
||||||
|
|
||||||
def test_full_but_partial_participation(spec, state, runner, rng=Random(5522)):
|
def run_test_full_but_partial_participation(spec, state, runner, rng=Random(5522)):
|
||||||
prepare_state_with_full_attestations(spec, state)
|
prepare_state_with_full_attestations(spec, state)
|
||||||
|
|
||||||
for a in state.previous_epoch_attestations:
|
for a in state.previous_epoch_attestations:
|
||||||
|
@ -82,7 +82,7 @@ def test_full_but_partial_participation(spec, state, runner, rng=Random(5522)):
|
||||||
yield from runner(spec, state)
|
yield from runner(spec, state)
|
||||||
|
|
||||||
|
|
||||||
def test_partial(spec, state, fraction_filled, runner):
|
def run_test_partial(spec, state, fraction_filled, runner):
|
||||||
prepare_state_with_full_attestations(spec, state)
|
prepare_state_with_full_attestations(spec, state)
|
||||||
|
|
||||||
# Remove portion of attestations
|
# Remove portion of attestations
|
||||||
|
@ -92,11 +92,11 @@ def test_partial(spec, state, fraction_filled, runner):
|
||||||
yield from runner(spec, state)
|
yield from runner(spec, state)
|
||||||
|
|
||||||
|
|
||||||
def test_half_full(spec, state, runner):
|
def run_test_half_full(spec, state, runner):
|
||||||
yield from test_partial(spec, state, 0.5, runner)
|
yield from run_test_partial(spec, state, 0.5, runner)
|
||||||
|
|
||||||
|
|
||||||
def test_one_attestation_one_correct(spec, state, runner):
|
def run_test_one_attestation_one_correct(spec, state, runner):
|
||||||
prepare_state_with_full_attestations(spec, state)
|
prepare_state_with_full_attestations(spec, state)
|
||||||
|
|
||||||
# Remove all attestations except for the first one
|
# Remove all attestations except for the first one
|
||||||
|
@ -105,7 +105,7 @@ def test_one_attestation_one_correct(spec, state, runner):
|
||||||
yield from runner(spec, state)
|
yield from runner(spec, state)
|
||||||
|
|
||||||
|
|
||||||
def test_with_slashed_validators(spec, state, runner):
|
def run_test_with_slashed_validators(spec, state, runner):
|
||||||
prepare_state_with_full_attestations(spec, state)
|
prepare_state_with_full_attestations(spec, state)
|
||||||
|
|
||||||
# Slash half of validators
|
# Slash half of validators
|
||||||
|
@ -115,19 +115,19 @@ def test_with_slashed_validators(spec, state, runner):
|
||||||
yield from runner(spec, state)
|
yield from runner(spec, state)
|
||||||
|
|
||||||
|
|
||||||
def test_some_very_low_effective_balances_that_attested(spec, state, runner):
|
def run_test_some_very_low_effective_balances_that_attested(spec, state, runner):
|
||||||
state.balances
|
state.balances
|
||||||
prepare_state_with_full_attestations(spec, state)
|
prepare_state_with_full_attestations(spec, state)
|
||||||
|
|
||||||
# Set some balances to be very low (including 0)
|
# Set some balances to be very low (including 0)
|
||||||
assert len(state.validators) >= 5:
|
assert len(state.validators) >= 5
|
||||||
for i, index in enumerate(5):
|
for i, index in enumerate(range(5)):
|
||||||
state.validators[index].effective_balance = i
|
state.validators[index].effective_balance = i
|
||||||
|
|
||||||
yield from runner(spec, state)
|
yield from runner(spec, state)
|
||||||
|
|
||||||
|
|
||||||
def test_some_very_low_effective_balances_that_did_not_attest(spec, state, runner):
|
def run_test_some_very_low_effective_balances_that_did_not_attest(spec, state, runner):
|
||||||
prepare_state_with_full_attestations(spec, state)
|
prepare_state_with_full_attestations(spec, state)
|
||||||
|
|
||||||
# Remove attestation
|
# Remove attestation
|
||||||
|
@ -141,7 +141,7 @@ def test_some_very_low_effective_balances_that_did_not_attest(spec, state, runne
|
||||||
yield from runner(spec, state)
|
yield from runner(spec, state)
|
||||||
|
|
||||||
|
|
||||||
def test_full_fraction_incorrect(spec, state, correct_target, correct_head, fraction_incorrect, runner):
|
def run_test_full_fraction_incorrect(spec, state, correct_target, correct_head, fraction_incorrect, runner):
|
||||||
prepare_state_with_full_attestations(spec, state)
|
prepare_state_with_full_attestations(spec, state)
|
||||||
|
|
||||||
# Make fraction_incorrect of pending attestations have bad target/head as specified
|
# Make fraction_incorrect of pending attestations have bad target/head as specified
|
||||||
|
@ -155,14 +155,14 @@ def test_full_fraction_incorrect(spec, state, correct_target, correct_head, frac
|
||||||
yield from runner(spec, state)
|
yield from runner(spec, state)
|
||||||
|
|
||||||
|
|
||||||
def test_full_random(spec, state, runner, rng=Random(8020)):
|
def run_test_full_random(spec, state, runner, rng=Random(8020)):
|
||||||
prepare_state_with_full_attestations(spec, state)
|
prepare_state_with_full_attestations(spec, state)
|
||||||
|
|
||||||
for pending_attestation in state.previous_epoch_attestations:
|
for pending_attestation in state.previous_epoch_attestations:
|
||||||
# 1/3 have bad target
|
# ~1/3 have bad target
|
||||||
if rng.randint(0, 2) == 0:
|
if rng.randint(0, 2) == 0:
|
||||||
pending_attestation.data.target.root = b'\x55' * 32
|
pending_attestation.data.target.root = b'\x55' * 32
|
||||||
# 1/3 have bad head
|
# ~1/3 have bad head
|
||||||
if rng.randint(0, 2) == 0:
|
if rng.randint(0, 2) == 0:
|
||||||
pending_attestation.data.beacon_block_root = b'\x66' * 32
|
pending_attestation.data.beacon_block_root = b'\x66' * 32
|
||||||
# ~50% participation
|
# ~50% participation
|
||||||
|
|
|
@ -22,49 +22,49 @@ def run_get_head_deltas(spec, state):
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_empty(spec, state):
|
def test_empty(spec, state):
|
||||||
yield from rewards_helpers.test_empty(spec, state, run_get_head_deltas)
|
yield from rewards_helpers.run_test_empty(spec, state, run_get_head_deltas)
|
||||||
|
|
||||||
|
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_full_all_correct(spec, state):
|
def test_full_all_correct(spec, state):
|
||||||
yield from rewards_helpers.test_full_all_correct(spec, state, run_get_head_deltas)
|
yield from rewards_helpers.run_test_full_all_correct(spec, state, run_get_head_deltas)
|
||||||
|
|
||||||
|
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_half_full(spec, state):
|
def test_half_full(spec, state):
|
||||||
yield from rewards_helpers.test_half_full(spec, state, run_get_head_deltas)
|
yield from rewards_helpers.run_test_half_full(spec, state, run_get_head_deltas)
|
||||||
|
|
||||||
|
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_full_but_partial_participation(spec, state):
|
def test_full_but_partial_participation(spec, state):
|
||||||
yield from rewards_helpers.test_full_but_partial_participation(spec, state, run_get_head_deltas)
|
yield from rewards_helpers.run_test_full_but_partial_participation(spec, state, run_get_head_deltas)
|
||||||
|
|
||||||
|
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_one_attestation_one_correct(spec, state):
|
def test_one_attestation_one_correct(spec, state):
|
||||||
yield from rewards_helpers.test_one_attestation_one_correct(spec, state, run_get_head_deltas)
|
yield from rewards_helpers.run_test_one_attestation_one_correct(spec, state, run_get_head_deltas)
|
||||||
|
|
||||||
|
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_with_slashed_validators(spec, state):
|
def test_with_slashed_validators(spec, state):
|
||||||
yield from rewards_helpers.test_with_slashed_validators(spec, state, run_get_head_deltas)
|
yield from rewards_helpers.run_test_with_slashed_validators(spec, state, run_get_head_deltas)
|
||||||
|
|
||||||
|
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_some_very_low_effective_balances_that_attested(spec, state):
|
def test_some_very_low_effective_balances_that_attested(spec, state):
|
||||||
yield from rewards_helpers.test_some_very_low_effective_balances_that_attested(spec, state, run_get_head_deltas)
|
yield from rewards_helpers.run_test_some_very_low_effective_balances_that_attested(spec, state, run_get_head_deltas)
|
||||||
|
|
||||||
|
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_some_very_low_effective_balances_that_did_not_attest(spec, state):
|
def test_some_very_low_effective_balances_that_did_not_attest(spec, state):
|
||||||
yield from rewards_helpers.test_some_very_low_effective_balances_that_did_not_attest(
|
yield from rewards_helpers.run_test_some_very_low_effective_balances_that_did_not_attest(
|
||||||
spec,
|
spec,
|
||||||
state,
|
state,
|
||||||
run_get_head_deltas,
|
run_get_head_deltas,
|
||||||
|
@ -74,7 +74,7 @@ def test_some_very_low_effective_balances_that_did_not_attest(spec, state):
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_full_half_correct_target_incorrect_head(spec, state):
|
def test_full_half_correct_target_incorrect_head(spec, state):
|
||||||
yield from rewards_helpers.test_full_fraction_incorrect(
|
yield from rewards_helpers.run_test_full_fraction_incorrect(
|
||||||
spec, state,
|
spec, state,
|
||||||
correct_target=True,
|
correct_target=True,
|
||||||
correct_head=False,
|
correct_head=False,
|
||||||
|
@ -86,7 +86,7 @@ def test_full_half_correct_target_incorrect_head(spec, state):
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_full_correct_target_incorrect_head(spec, state):
|
def test_full_correct_target_incorrect_head(spec, state):
|
||||||
yield from rewards_helpers.test_full_fraction_incorrect(
|
yield from rewards_helpers.run_test_full_fraction_incorrect(
|
||||||
spec, state,
|
spec, state,
|
||||||
correct_target=True,
|
correct_target=True,
|
||||||
correct_head=False,
|
correct_head=False,
|
||||||
|
@ -98,7 +98,7 @@ def test_full_correct_target_incorrect_head(spec, state):
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_full_half_incorrect_target_incorrect_head(spec, state):
|
def test_full_half_incorrect_target_incorrect_head(spec, state):
|
||||||
yield from rewards_helpers.test_full_fraction_incorrect(
|
yield from rewards_helpers.run_test_full_fraction_incorrect(
|
||||||
spec, state,
|
spec, state,
|
||||||
correct_target=False,
|
correct_target=False,
|
||||||
correct_head=False,
|
correct_head=False,
|
||||||
|
@ -110,7 +110,7 @@ def test_full_half_incorrect_target_incorrect_head(spec, state):
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_full_half_incorrect_target_correct_head(spec, state):
|
def test_full_half_incorrect_target_correct_head(spec, state):
|
||||||
yield from rewards_helpers.test_full_fraction_incorrect(
|
yield from rewards_helpers.run_test_full_fraction_incorrect(
|
||||||
spec, state,
|
spec, state,
|
||||||
correct_target=False,
|
correct_target=False,
|
||||||
correct_head=True,
|
correct_head=True,
|
||||||
|
@ -122,4 +122,4 @@ def test_full_half_incorrect_target_correct_head(spec, state):
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_full_random(spec, state):
|
def test_full_random(spec, state):
|
||||||
yield from rewards_helpers.test_full_random(spec, state, run_get_head_deltas)
|
yield from rewards_helpers.run_test_full_random(spec, state, run_get_head_deltas)
|
||||||
|
|
|
@ -60,85 +60,85 @@ def transition_state_to_leak(spec, state, epochs=None):
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_empty_no_leak(spec, state):
|
def test_empty_no_leak(spec, state):
|
||||||
yield from rewards_helpers.test_empty(spec, state, run_get_inactivity_penalty_deltas)
|
yield from rewards_helpers.run_test_empty(spec, state, run_get_inactivity_penalty_deltas)
|
||||||
|
|
||||||
|
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_empty_leak(spec, state):
|
def test_empty_leak(spec, state):
|
||||||
transition_state_to_leak(spec, state)
|
transition_state_to_leak(spec, state)
|
||||||
yield from rewards_helpers.test_empty(spec, state, run_get_inactivity_penalty_deltas)
|
yield from rewards_helpers.run_test_empty(spec, state, run_get_inactivity_penalty_deltas)
|
||||||
|
|
||||||
|
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_full_no_leak(spec, state):
|
def test_full_no_leak(spec, state):
|
||||||
yield from rewards_helpers.test_full_all_correct(spec, state, run_get_inactivity_penalty_deltas)
|
yield from rewards_helpers.run_test_full_all_correct(spec, state, run_get_inactivity_penalty_deltas)
|
||||||
|
|
||||||
|
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_full_leak(spec, state):
|
def test_full_leak(spec, state):
|
||||||
transition_state_to_leak(spec, state)
|
transition_state_to_leak(spec, state)
|
||||||
yield from rewards_helpers.test_full_all_correct(spec, state, run_get_inactivity_penalty_deltas)
|
yield from rewards_helpers.run_test_full_all_correct(spec, state, run_get_inactivity_penalty_deltas)
|
||||||
|
|
||||||
|
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_half_full_no_leak(spec, state):
|
def test_half_full_no_leak(spec, state):
|
||||||
yield from rewards_helpers.test_half_full(spec, state, run_get_inactivity_penalty_deltas)
|
yield from rewards_helpers.run_test_half_full(spec, state, run_get_inactivity_penalty_deltas)
|
||||||
|
|
||||||
|
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_half_full_leak(spec, state):
|
def test_half_full_leak(spec, state):
|
||||||
transition_state_to_leak(spec, state)
|
transition_state_to_leak(spec, state)
|
||||||
yield from rewards_helpers.test_half_full(spec, state, run_get_inactivity_penalty_deltas)
|
yield from rewards_helpers.run_test_half_full(spec, state, run_get_inactivity_penalty_deltas)
|
||||||
|
|
||||||
|
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_quarter_full_no_leak(spec, state):
|
def test_quarter_full_no_leak(spec, state):
|
||||||
yield from rewards_helpers.test_partial(spec, state, 0.25, run_get_inactivity_penalty_deltas)
|
yield from rewards_helpers.run_test_partial(spec, state, 0.25, run_get_inactivity_penalty_deltas)
|
||||||
|
|
||||||
|
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_quarter_full_leak(spec, state):
|
def test_quarter_full_leak(spec, state):
|
||||||
transition_state_to_leak(spec, state)
|
transition_state_to_leak(spec, state)
|
||||||
yield from rewards_helpers.test_partial(spec, state, 0.25, run_get_inactivity_penalty_deltas)
|
yield from rewards_helpers.run_test_partial(spec, state, 0.25, run_get_inactivity_penalty_deltas)
|
||||||
|
|
||||||
|
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_full_but_partial_participation_no_leak(spec, state):
|
def test_full_but_partial_participation_no_leak(spec, state):
|
||||||
yield from rewards_helpers.test_full_but_partial_participation(spec, state, run_get_inactivity_penalty_deltas)
|
yield from rewards_helpers.run_test_full_but_partial_participation(spec, state, run_get_inactivity_penalty_deltas)
|
||||||
|
|
||||||
|
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_full_but_partial_participation_leak(spec, state):
|
def test_full_but_partial_participation_leak(spec, state):
|
||||||
transition_state_to_leak(spec, state)
|
transition_state_to_leak(spec, state)
|
||||||
yield from rewards_helpers.test_full_but_partial_participation(spec, state, run_get_inactivity_penalty_deltas)
|
yield from rewards_helpers.run_test_full_but_partial_participation(spec, state, run_get_inactivity_penalty_deltas)
|
||||||
|
|
||||||
|
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_with_slashed_validators_no_leak(spec, state):
|
def test_with_slashed_validators_no_leak(spec, state):
|
||||||
yield from rewards_helpers.test_with_slashed_validators(spec, state, run_get_inactivity_penalty_deltas)
|
yield from rewards_helpers.run_test_with_slashed_validators(spec, state, run_get_inactivity_penalty_deltas)
|
||||||
|
|
||||||
|
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_with_slashed_validators_leak(spec, state):
|
def test_with_slashed_validators_leak(spec, state):
|
||||||
transition_state_to_leak(spec, state)
|
transition_state_to_leak(spec, state)
|
||||||
yield from rewards_helpers.test_with_slashed_validators(spec, state, run_get_inactivity_penalty_deltas)
|
yield from rewards_helpers.run_test_with_slashed_validators(spec, state, run_get_inactivity_penalty_deltas)
|
||||||
|
|
||||||
|
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_some_very_low_effective_balances_that_attested_no_leak(spec, state):
|
def test_some_very_low_effective_balances_that_attested_no_leak(spec, state):
|
||||||
yield from rewards_helpers.test_some_very_low_effective_balances_that_attested(
|
yield from rewards_helpers.run_test_some_very_low_effective_balances_that_attested(
|
||||||
spec,
|
spec,
|
||||||
state,
|
state,
|
||||||
run_get_inactivity_penalty_deltas,
|
run_get_inactivity_penalty_deltas,
|
||||||
|
@ -149,7 +149,7 @@ def test_some_very_low_effective_balances_that_attested_no_leak(spec, state):
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_some_very_low_effective_balances_that_attested_leak(spec, state):
|
def test_some_very_low_effective_balances_that_attested_leak(spec, state):
|
||||||
transition_state_to_leak(spec, state)
|
transition_state_to_leak(spec, state)
|
||||||
yield from rewards_helpers.test_some_very_low_effective_balances_that_attested(
|
yield from rewards_helpers.run_test_some_very_low_effective_balances_that_attested(
|
||||||
spec,
|
spec,
|
||||||
state,
|
state,
|
||||||
run_get_inactivity_penalty_deltas,
|
run_get_inactivity_penalty_deltas,
|
||||||
|
@ -159,7 +159,7 @@ def test_some_very_low_effective_balances_that_attested_leak(spec, state):
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_some_very_low_effective_balances_that_did_not_attest_no_leak(spec, state):
|
def test_some_very_low_effective_balances_that_did_not_attest_no_leak(spec, state):
|
||||||
yield from rewards_helpers.test_some_very_low_effective_balances_that_did_not_attest(
|
yield from rewards_helpers.run_test_some_very_low_effective_balances_that_did_not_attest(
|
||||||
spec,
|
spec,
|
||||||
state,
|
state,
|
||||||
run_get_inactivity_penalty_deltas,
|
run_get_inactivity_penalty_deltas,
|
||||||
|
@ -170,7 +170,7 @@ def test_some_very_low_effective_balances_that_did_not_attest_no_leak(spec, stat
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_some_very_low_effective_balances_that_did_not_attest_leak(spec, state):
|
def test_some_very_low_effective_balances_that_did_not_attest_leak(spec, state):
|
||||||
transition_state_to_leak(spec, state)
|
transition_state_to_leak(spec, state)
|
||||||
yield from rewards_helpers.test_some_very_low_effective_balances_that_did_not_attest(
|
yield from rewards_helpers.run_test_some_very_low_effective_balances_that_did_not_attest(
|
||||||
spec,
|
spec,
|
||||||
state,
|
state,
|
||||||
run_get_inactivity_penalty_deltas,
|
run_get_inactivity_penalty_deltas,
|
||||||
|
@ -180,25 +180,25 @@ def test_some_very_low_effective_balances_that_did_not_attest_leak(spec, state):
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_full_random_no_leak(spec, state):
|
def test_full_random_no_leak(spec, state):
|
||||||
yield from rewards_helpers.test_full_random(spec, state, run_get_inactivity_penalty_deltas)
|
yield from rewards_helpers.run_test_full_random(spec, state, run_get_inactivity_penalty_deltas)
|
||||||
|
|
||||||
|
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_full_random_leak(spec, state):
|
def test_full_random_leak(spec, state):
|
||||||
transition_state_to_leak(spec, state)
|
transition_state_to_leak(spec, state)
|
||||||
yield from rewards_helpers.test_full_random(spec, state, run_get_inactivity_penalty_deltas)
|
yield from rewards_helpers.run_test_full_random(spec, state, run_get_inactivity_penalty_deltas)
|
||||||
|
|
||||||
|
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_full_random_five_epoch_leak(spec, state):
|
def test_full_random_five_epoch_leak(spec, state):
|
||||||
transition_state_to_leak(spec, state, epochs=5)
|
transition_state_to_leak(spec, state, epochs=5)
|
||||||
yield from rewards_helpers.test_full_random(spec, state, run_get_inactivity_penalty_deltas)
|
yield from rewards_helpers.run_test_full_random(spec, state, run_get_inactivity_penalty_deltas)
|
||||||
|
|
||||||
|
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_full_random_ten_epoch_leak(spec, state):
|
def test_full_random_ten_epoch_leak(spec, state):
|
||||||
transition_state_to_leak(spec, state, epochs=10)
|
transition_state_to_leak(spec, state, epochs=10)
|
||||||
yield from rewards_helpers.test_full_random(spec, state, run_get_inactivity_penalty_deltas)
|
yield from rewards_helpers.run_test_full_random(spec, state, run_get_inactivity_penalty_deltas)
|
||||||
|
|
|
@ -64,43 +64,43 @@ def run_get_inclusion_delay_deltas(spec, state):
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_empty(spec, state):
|
def test_empty(spec, state):
|
||||||
yield from rewards_helpers.test_empty(spec, state, run_get_inclusion_delay_deltas)
|
yield from rewards_helpers.run_test_empty(spec, state, run_get_inclusion_delay_deltas)
|
||||||
|
|
||||||
|
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_full(spec, state):
|
def test_full(spec, state):
|
||||||
yield from rewards_helpers.test_full_all_correct(spec, state, run_get_inclusion_delay_deltas)
|
yield from rewards_helpers.run_test_full_all_correct(spec, state, run_get_inclusion_delay_deltas)
|
||||||
|
|
||||||
|
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_half_full(spec, state):
|
def test_half_full(spec, state):
|
||||||
yield from rewards_helpers.test_half_full(spec, state, run_get_inclusion_delay_deltas)
|
yield from rewards_helpers.run_test_half_full(spec, state, run_get_inclusion_delay_deltas)
|
||||||
|
|
||||||
|
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_quarter_full(spec, state):
|
def test_quarter_full(spec, state):
|
||||||
yield from rewards_helpers.test_partial(spec, state, 0.25, run_get_inclusion_delay_deltas)
|
yield from rewards_helpers.run_test_partial(spec, state, 0.25, run_get_inclusion_delay_deltas)
|
||||||
|
|
||||||
|
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_full_but_partial_participation(spec, state):
|
def test_full_but_partial_participation(spec, state):
|
||||||
yield from rewards_helpers.test_full_but_partial_participation(spec, state, run_get_inclusion_delay_deltas)
|
yield from rewards_helpers.run_test_full_but_partial_participation(spec, state, run_get_inclusion_delay_deltas)
|
||||||
|
|
||||||
|
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_with_slashed_validators(spec, state):
|
def test_with_slashed_validators(spec, state):
|
||||||
yield from rewards_helpers.test_with_slashed_validators(spec, state, run_get_inclusion_delay_deltas)
|
yield from rewards_helpers.run_test_with_slashed_validators(spec, state, run_get_inclusion_delay_deltas)
|
||||||
|
|
||||||
|
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_some_very_low_effective_balances_that_attested(spec, state):
|
def test_some_very_low_effective_balances_that_attested(spec, state):
|
||||||
yield from rewards_helpers.test_some_very_low_effective_balances_that_attested(
|
yield from rewards_helpers.run_test_some_very_low_effective_balances_that_attested(
|
||||||
spec,
|
spec,
|
||||||
state,
|
state,
|
||||||
run_get_inclusion_delay_deltas
|
run_get_inclusion_delay_deltas
|
||||||
|
@ -110,7 +110,7 @@ def test_some_very_low_effective_balances_that_attested(spec, state):
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_full_random(spec, state):
|
def test_full_random(spec, state):
|
||||||
yield from rewards_helpers.test_full_random(spec, state, run_get_inclusion_delay_deltas)
|
yield from rewards_helpers.run_test_full_random(spec, state, run_get_inclusion_delay_deltas)
|
||||||
|
|
||||||
|
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
|
@ -179,7 +179,8 @@ def test_duplicate_attestations_at_later_slots(spec, state):
|
||||||
max_slot = max([a.data.slot + a.inclusion_delay for a in state.previous_epoch_attestations])
|
max_slot = max([a.data.slot + a.inclusion_delay for a in state.previous_epoch_attestations])
|
||||||
later_attestations = []
|
later_attestations = []
|
||||||
for a in state.previous_epoch_attestations:
|
for a in state.previous_epoch_attestations:
|
||||||
# Do not create later duplicate if goes into next epoch
|
# Only have proposers for previous epoch so do not create later
|
||||||
|
# duplicate if slot exceeds the max slot in previous_epoch_attestations
|
||||||
if a.data.slot + a.inclusion_delay >= max_slot:
|
if a.data.slot + a.inclusion_delay >= max_slot:
|
||||||
continue
|
continue
|
||||||
later_a = a.copy()
|
later_a = a.copy()
|
||||||
|
|
|
@ -22,49 +22,53 @@ def run_get_source_deltas(spec, state):
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_empty(spec, state):
|
def test_empty(spec, state):
|
||||||
yield from rewards_helpers.test_empty(spec, state, run_get_source_deltas)
|
yield from rewards_helpers.run_test_empty(spec, state, run_get_source_deltas)
|
||||||
|
|
||||||
|
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_full_all_correct(spec, state):
|
def test_full_all_correct(spec, state):
|
||||||
yield from rewards_helpers.test_full_all_correct(spec, state, run_get_source_deltas)
|
yield from rewards_helpers.run_test_full_all_correct(spec, state, run_get_source_deltas)
|
||||||
|
|
||||||
|
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_half_full(spec, state):
|
def test_half_full(spec, state):
|
||||||
yield from rewards_helpers.test_half_full(spec, state, run_get_source_deltas)
|
yield from rewards_helpers.run_test_half_full(spec, state, run_get_source_deltas)
|
||||||
|
|
||||||
|
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_full_but_partial_participation(spec, state):
|
def test_full_but_partial_participation(spec, state):
|
||||||
yield from rewards_helpers.test_full_but_partial_participation(spec, state, run_get_source_deltas)
|
yield from rewards_helpers.run_test_full_but_partial_participation(spec, state, run_get_source_deltas)
|
||||||
|
|
||||||
|
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_one_attestation_one_correct(spec, state):
|
def test_one_attestation_one_correct(spec, state):
|
||||||
yield from rewards_helpers.test_one_attestation_one_correct(spec, state, run_get_source_deltas)
|
yield from rewards_helpers.run_test_one_attestation_one_correct(spec, state, run_get_source_deltas)
|
||||||
|
|
||||||
|
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_with_slashed_validators(spec, state):
|
def test_with_slashed_validators(spec, state):
|
||||||
yield from rewards_helpers.test_with_slashed_validators(spec, state, run_get_source_deltas)
|
yield from rewards_helpers.run_test_with_slashed_validators(spec, state, run_get_source_deltas)
|
||||||
|
|
||||||
|
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_some_very_low_effective_balances_that_attested(spec, state):
|
def test_some_very_low_effective_balances_that_attested(spec, state):
|
||||||
yield from rewards_helpers.test_some_very_low_effective_balances_that_attested(spec, state, run_get_source_deltas)
|
yield from rewards_helpers.run_test_some_very_low_effective_balances_that_attested(
|
||||||
|
spec,
|
||||||
|
state,
|
||||||
|
run_get_source_deltas
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_some_very_low_effective_balances_that_did_not_attest(spec, state):
|
def test_some_very_low_effective_balances_that_did_not_attest(spec, state):
|
||||||
yield from rewards_helpers.test_some_very_low_effective_balances_that_did_not_attest(
|
yield from rewards_helpers.run_test_some_very_low_effective_balances_that_did_not_attest(
|
||||||
spec,
|
spec,
|
||||||
state,
|
state,
|
||||||
run_get_source_deltas,
|
run_get_source_deltas,
|
||||||
|
@ -81,7 +85,7 @@ def test_some_very_low_effective_balances_that_did_not_attest(spec, state):
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_full_half_correct_target_incorrect_head(spec, state):
|
def test_full_half_correct_target_incorrect_head(spec, state):
|
||||||
yield from rewards_helpers.test_full_fraction_incorrect(
|
yield from rewards_helpers.run_test_full_fraction_incorrect(
|
||||||
spec, state,
|
spec, state,
|
||||||
correct_target=True,
|
correct_target=True,
|
||||||
correct_head=False,
|
correct_head=False,
|
||||||
|
@ -93,7 +97,7 @@ def test_full_half_correct_target_incorrect_head(spec, state):
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_full_correct_target_incorrect_head(spec, state):
|
def test_full_correct_target_incorrect_head(spec, state):
|
||||||
yield from rewards_helpers.test_full_fraction_incorrect(
|
yield from rewards_helpers.run_test_full_fraction_incorrect(
|
||||||
spec, state,
|
spec, state,
|
||||||
correct_target=True,
|
correct_target=True,
|
||||||
correct_head=False,
|
correct_head=False,
|
||||||
|
@ -105,7 +109,7 @@ def test_full_correct_target_incorrect_head(spec, state):
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_full_half_incorrect_target_incorrect_head(spec, state):
|
def test_full_half_incorrect_target_incorrect_head(spec, state):
|
||||||
yield from rewards_helpers.test_full_fraction_incorrect(
|
yield from rewards_helpers.run_test_full_fraction_incorrect(
|
||||||
spec, state,
|
spec, state,
|
||||||
correct_target=False,
|
correct_target=False,
|
||||||
correct_head=False,
|
correct_head=False,
|
||||||
|
@ -117,7 +121,7 @@ def test_full_half_incorrect_target_incorrect_head(spec, state):
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_full_half_incorrect_target_correct_head(spec, state):
|
def test_full_half_incorrect_target_correct_head(spec, state):
|
||||||
yield from rewards_helpers.test_full_fraction_incorrect(
|
yield from rewards_helpers.run_test_full_fraction_incorrect(
|
||||||
spec, state,
|
spec, state,
|
||||||
correct_target=False,
|
correct_target=False,
|
||||||
correct_head=True,
|
correct_head=True,
|
||||||
|
@ -129,4 +133,4 @@ def test_full_half_incorrect_target_correct_head(spec, state):
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_full_random(spec, state):
|
def test_full_random(spec, state):
|
||||||
yield from rewards_helpers.test_full_random(spec, state, run_get_source_deltas)
|
yield from rewards_helpers.run_test_full_random(spec, state, run_get_source_deltas)
|
||||||
|
|
|
@ -22,49 +22,53 @@ def run_get_target_deltas(spec, state):
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_empty(spec, state):
|
def test_empty(spec, state):
|
||||||
yield from rewards_helpers.test_empty(spec, state, run_get_target_deltas)
|
yield from rewards_helpers.run_test_empty(spec, state, run_get_target_deltas)
|
||||||
|
|
||||||
|
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_full_all_correct(spec, state):
|
def test_full_all_correct(spec, state):
|
||||||
yield from rewards_helpers.test_full_all_correct(spec, state, run_get_target_deltas)
|
yield from rewards_helpers.run_test_full_all_correct(spec, state, run_get_target_deltas)
|
||||||
|
|
||||||
|
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_half_full(spec, state):
|
def test_half_full(spec, state):
|
||||||
yield from rewards_helpers.test_half_full(spec, state, run_get_target_deltas)
|
yield from rewards_helpers.run_test_half_full(spec, state, run_get_target_deltas)
|
||||||
|
|
||||||
|
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_full_but_partial_participation(spec, state):
|
def test_full_but_partial_participation(spec, state):
|
||||||
yield from rewards_helpers.test_full_but_partial_participation(spec, state, run_get_target_deltas)
|
yield from rewards_helpers.run_test_full_but_partial_participation(spec, state, run_get_target_deltas)
|
||||||
|
|
||||||
|
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_one_attestation_one_correct(spec, state):
|
def test_one_attestation_one_correct(spec, state):
|
||||||
yield from rewards_helpers.test_one_attestation_one_correct(spec, state, run_get_target_deltas)
|
yield from rewards_helpers.run_test_one_attestation_one_correct(spec, state, run_get_target_deltas)
|
||||||
|
|
||||||
|
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_with_slashed_validators(spec, state):
|
def test_with_slashed_validators(spec, state):
|
||||||
yield from rewards_helpers.test_with_slashed_validators(spec, state, run_get_target_deltas)
|
yield from rewards_helpers.run_test_with_slashed_validators(spec, state, run_get_target_deltas)
|
||||||
|
|
||||||
|
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_some_very_low_effective_balances_that_attested(spec, state):
|
def test_some_very_low_effective_balances_that_attested(spec, state):
|
||||||
yield from rewards_helpers.test_some_very_low_effective_balances_that_attested(spec, state, run_get_target_deltas)
|
yield from rewards_helpers.run_test_some_very_low_effective_balances_that_attested(
|
||||||
|
spec,
|
||||||
|
state,
|
||||||
|
run_get_target_deltas
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_some_very_low_effective_balances_that_did_not_attest(spec, state):
|
def test_some_very_low_effective_balances_that_did_not_attest(spec, state):
|
||||||
yield from rewards_helpers.test_some_very_low_effective_balances_that_did_not_attest(
|
yield from rewards_helpers.run_test_some_very_low_effective_balances_that_did_not_attest(
|
||||||
spec,
|
spec,
|
||||||
state,
|
state,
|
||||||
run_get_target_deltas,
|
run_get_target_deltas,
|
||||||
|
@ -74,7 +78,7 @@ def test_some_very_low_effective_balances_that_did_not_attest(spec, state):
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_full_half_correct_target_incorrect_head(spec, state):
|
def test_full_half_correct_target_incorrect_head(spec, state):
|
||||||
yield from rewards_helpers.test_full_fraction_incorrect(
|
yield from rewards_helpers.run_test_full_fraction_incorrect(
|
||||||
spec, state,
|
spec, state,
|
||||||
correct_target=True,
|
correct_target=True,
|
||||||
correct_head=False,
|
correct_head=False,
|
||||||
|
@ -86,7 +90,7 @@ def test_full_half_correct_target_incorrect_head(spec, state):
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_full_correct_target_incorrect_head(spec, state):
|
def test_full_correct_target_incorrect_head(spec, state):
|
||||||
yield from rewards_helpers.test_full_fraction_incorrect(
|
yield from rewards_helpers.run_test_full_fraction_incorrect(
|
||||||
spec, state,
|
spec, state,
|
||||||
correct_target=True,
|
correct_target=True,
|
||||||
correct_head=False,
|
correct_head=False,
|
||||||
|
@ -98,7 +102,7 @@ def test_full_correct_target_incorrect_head(spec, state):
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_full_half_incorrect_target_incorrect_head(spec, state):
|
def test_full_half_incorrect_target_incorrect_head(spec, state):
|
||||||
yield from rewards_helpers.test_full_fraction_incorrect(
|
yield from rewards_helpers.run_test_full_fraction_incorrect(
|
||||||
spec, state,
|
spec, state,
|
||||||
correct_target=False,
|
correct_target=False,
|
||||||
correct_head=False,
|
correct_head=False,
|
||||||
|
@ -110,7 +114,7 @@ def test_full_half_incorrect_target_incorrect_head(spec, state):
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_full_half_incorrect_target_correct_head(spec, state):
|
def test_full_half_incorrect_target_correct_head(spec, state):
|
||||||
yield from rewards_helpers.test_full_fraction_incorrect(
|
yield from rewards_helpers.run_test_full_fraction_incorrect(
|
||||||
spec, state,
|
spec, state,
|
||||||
correct_target=False,
|
correct_target=False,
|
||||||
correct_head=True,
|
correct_head=True,
|
||||||
|
@ -122,4 +126,4 @@ def test_full_half_incorrect_target_correct_head(spec, state):
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_full_random(spec, state):
|
def test_full_random(spec, state):
|
||||||
yield from rewards_helpers.test_full_random(spec, state, run_get_target_deltas)
|
yield from rewards_helpers.run_test_full_random(spec, state, run_get_target_deltas)
|
||||||
|
|
Loading…
Reference in New Issue