def test_inactivity_scores_full_participation_leaking(spec, state): randomize_inactivity_scores(spec, state, rng=Random(5252)) assert len(set(state.inactivity_scores)) > 1 # Only set full participation for previous epoch to remain in leak set_full_participation_previous_epoch(spec, state) previous_inactivity_scores = state.inactivity_scores.copy() yield 'pre', state # Block transition to next epoch block = build_empty_block(spec, state, slot=state.slot + spec.SLOTS_PER_EPOCH) signed_block = state_transition_and_sign_block(spec, state, block) assert spec.is_in_inactivity_leak(state) yield 'blocks', [signed_block] yield 'post', state # Full particiaption during a leak so all scores should decrease by 1 for pre, post in zip(previous_inactivity_scores, state.inactivity_scores): assert post == pre - 1
def test_random_high_inactivity_scores(spec, state): randomize_inactivity_scores(spec, state, minimum=500000, maximum=5000000, rng=Random(9998)) yield from rewards_helpers.run_test_full_random(spec, state, rng=Random(9998))
def test_half_zero_half_random_inactivity_scores(spec, state): randomize_inactivity_scores(spec, state, rng=Random(10101)) half_val_point = len(state.validators) // 2 state.inactivity_scores = [ 0 ] * half_val_point + state.inactivity_scores[half_val_point:] yield from rewards_helpers.run_test_full_random(spec, state, rng=Random(10101))
def randomize_state_altair(spec, state, stats, exit_fraction=0.1, slash_fraction=0.1): scenario_state = randomize_state(spec, state, stats, exit_fraction=exit_fraction, slash_fraction=slash_fraction) randomize_inactivity_scores(spec, state) return scenario_state
def test_inactivity_scores_leaking(spec, state): assert spec.is_in_inactivity_leak(state) randomize_inactivity_scores(spec, state, rng=Random(5252)) assert len(set(state.inactivity_scores)) > 1 previous_inactivity_scores = state.inactivity_scores.copy() yield 'pre', state # Block transition to next epoch block = build_empty_block(spec, state, slot=state.slot + spec.SLOTS_PER_EPOCH) signed_block = state_transition_and_sign_block(spec, state, block) yield 'blocks', [signed_block] yield 'post', state # No participation during a leak so all scores should increase for pre, post in zip(previous_inactivity_scores, state.inactivity_scores): assert post == pre + spec.config.INACTIVITY_SCORE_BIAS
def test_random_inactivity_scores_full_participation(spec, state): next_epoch_via_block(spec, state) set_full_participation(spec, state) randomize_inactivity_scores(spec, state, rng=Random(33333)) yield from run_process_inactivity_updates(spec, state)
def test_random_inactivity_scores_leaking_0(spec, state): randomize_inactivity_scores(spec, state, rng=Random(9999)) yield from rewards_helpers.run_test_full_random(spec, state, rng=Random(9999))
def test_full_random_misc_balances(spec, state): randomize_inactivity_scores(spec, state, rng=Random(33333)) yield from rewards_helpers.run_test_full_random(spec, state)
def test_random_inactivity_scores_low_balances_1(spec, state): randomize_inactivity_scores(spec, state, rng=Random(22222)) yield from rewards_helpers.run_test_full_random(spec, state)