|
|
@ -31,7 +31,7 @@ from eth2spec.test.context import (
|
|
|
|
@spec_state_test
|
|
|
|
@spec_state_test
|
|
|
|
@always_bls
|
|
|
|
@always_bls
|
|
|
|
def test_invalid_signature_bad_domain(spec, state):
|
|
|
|
def test_invalid_signature_bad_domain(spec, state):
|
|
|
|
committee_indices = compute_committee_indices(spec, state)
|
|
|
|
committee_indices = compute_committee_indices(state)
|
|
|
|
|
|
|
|
|
|
|
|
block = build_empty_block_for_next_slot(spec, state)
|
|
|
|
block = build_empty_block_for_next_slot(spec, state)
|
|
|
|
block.body.sync_aggregate = spec.SyncAggregate(
|
|
|
|
block.body.sync_aggregate = spec.SyncAggregate(
|
|
|
@ -52,7 +52,7 @@ def test_invalid_signature_bad_domain(spec, state):
|
|
|
|
@spec_state_test
|
|
|
|
@spec_state_test
|
|
|
|
@always_bls
|
|
|
|
@always_bls
|
|
|
|
def test_invalid_signature_missing_participant(spec, state):
|
|
|
|
def test_invalid_signature_missing_participant(spec, state):
|
|
|
|
committee_indices = compute_committee_indices(spec, state)
|
|
|
|
committee_indices = compute_committee_indices(state)
|
|
|
|
rng = random.Random(2020)
|
|
|
|
rng = random.Random(2020)
|
|
|
|
random_participant = rng.choice(committee_indices)
|
|
|
|
random_participant = rng.choice(committee_indices)
|
|
|
|
|
|
|
|
|
|
|
@ -116,7 +116,7 @@ def test_invalid_signature_infinite_signature_with_single_participant(spec, stat
|
|
|
|
@spec_state_test
|
|
|
|
@spec_state_test
|
|
|
|
@always_bls
|
|
|
|
@always_bls
|
|
|
|
def test_invalid_signature_extra_participant(spec, state):
|
|
|
|
def test_invalid_signature_extra_participant(spec, state):
|
|
|
|
committee_indices = compute_committee_indices(spec, state)
|
|
|
|
committee_indices = compute_committee_indices(state)
|
|
|
|
rng = random.Random(3030)
|
|
|
|
rng = random.Random(3030)
|
|
|
|
random_participant = rng.choice(committee_indices)
|
|
|
|
random_participant = rng.choice(committee_indices)
|
|
|
|
|
|
|
|
|
|
|
@ -140,7 +140,7 @@ def test_invalid_signature_extra_participant(spec, state):
|
|
|
|
@with_presets([MINIMAL], reason="to create nonduplicate committee")
|
|
|
|
@with_presets([MINIMAL], reason="to create nonduplicate committee")
|
|
|
|
@spec_state_test
|
|
|
|
@spec_state_test
|
|
|
|
def test_sync_committee_rewards_nonduplicate_committee(spec, state):
|
|
|
|
def test_sync_committee_rewards_nonduplicate_committee(spec, state):
|
|
|
|
committee_indices = compute_committee_indices(spec, state)
|
|
|
|
committee_indices = compute_committee_indices(state)
|
|
|
|
committee_size = len(committee_indices)
|
|
|
|
committee_size = len(committee_indices)
|
|
|
|
committee_bits = [True] * committee_size
|
|
|
|
committee_bits = [True] * committee_size
|
|
|
|
active_validator_count = len(spec.get_active_validator_indices(state, spec.get_current_epoch(state)))
|
|
|
|
active_validator_count = len(spec.get_active_validator_indices(state, spec.get_current_epoch(state)))
|
|
|
@ -156,7 +156,7 @@ def test_sync_committee_rewards_nonduplicate_committee(spec, state):
|
|
|
|
@with_presets([MAINNET], reason="to create duplicate committee")
|
|
|
|
@with_presets([MAINNET], reason="to create duplicate committee")
|
|
|
|
@spec_state_test
|
|
|
|
@spec_state_test
|
|
|
|
def test_sync_committee_rewards_duplicate_committee_no_participation(spec, state):
|
|
|
|
def test_sync_committee_rewards_duplicate_committee_no_participation(spec, state):
|
|
|
|
committee_indices = compute_committee_indices(spec, state)
|
|
|
|
committee_indices = compute_committee_indices(state)
|
|
|
|
committee_size = len(committee_indices)
|
|
|
|
committee_size = len(committee_indices)
|
|
|
|
committee_bits = [False] * committee_size
|
|
|
|
committee_bits = [False] * committee_size
|
|
|
|
active_validator_count = len(spec.get_active_validator_indices(state, spec.get_current_epoch(state)))
|
|
|
|
active_validator_count = len(spec.get_active_validator_indices(state, spec.get_current_epoch(state)))
|
|
|
@ -172,7 +172,7 @@ def test_sync_committee_rewards_duplicate_committee_no_participation(spec, state
|
|
|
|
@with_presets([MAINNET], reason="to create duplicate committee")
|
|
|
|
@with_presets([MAINNET], reason="to create duplicate committee")
|
|
|
|
@spec_state_test
|
|
|
|
@spec_state_test
|
|
|
|
def test_sync_committee_rewards_duplicate_committee_half_participation(spec, state):
|
|
|
|
def test_sync_committee_rewards_duplicate_committee_half_participation(spec, state):
|
|
|
|
committee_indices = compute_committee_indices(spec, state)
|
|
|
|
committee_indices = compute_committee_indices(state)
|
|
|
|
committee_size = len(committee_indices)
|
|
|
|
committee_size = len(committee_indices)
|
|
|
|
committee_bits = [True] * (committee_size // 2) + [False] * (committee_size // 2)
|
|
|
|
committee_bits = [True] * (committee_size // 2) + [False] * (committee_size // 2)
|
|
|
|
assert len(committee_bits) == committee_size
|
|
|
|
assert len(committee_bits) == committee_size
|
|
|
@ -189,7 +189,7 @@ def test_sync_committee_rewards_duplicate_committee_half_participation(spec, sta
|
|
|
|
@with_presets([MAINNET], reason="to create duplicate committee")
|
|
|
|
@with_presets([MAINNET], reason="to create duplicate committee")
|
|
|
|
@spec_state_test
|
|
|
|
@spec_state_test
|
|
|
|
def test_sync_committee_rewards_duplicate_committee_full_participation(spec, state):
|
|
|
|
def test_sync_committee_rewards_duplicate_committee_full_participation(spec, state):
|
|
|
|
committee_indices = compute_committee_indices(spec, state)
|
|
|
|
committee_indices = compute_committee_indices(state)
|
|
|
|
committee_size = len(committee_indices)
|
|
|
|
committee_size = len(committee_indices)
|
|
|
|
committee_bits = [True] * committee_size
|
|
|
|
committee_bits = [True] * committee_size
|
|
|
|
active_validator_count = len(spec.get_active_validator_indices(state, spec.get_current_epoch(state)))
|
|
|
|
active_validator_count = len(spec.get_active_validator_indices(state, spec.get_current_epoch(state)))
|
|
|
@ -205,7 +205,7 @@ def test_sync_committee_rewards_duplicate_committee_full_participation(spec, sta
|
|
|
|
@spec_state_test
|
|
|
|
@spec_state_test
|
|
|
|
@always_bls
|
|
|
|
@always_bls
|
|
|
|
def test_sync_committee_rewards_not_full_participants(spec, state):
|
|
|
|
def test_sync_committee_rewards_not_full_participants(spec, state):
|
|
|
|
committee_indices = compute_committee_indices(spec, state)
|
|
|
|
committee_indices = compute_committee_indices(state)
|
|
|
|
rng = random.Random(1010)
|
|
|
|
rng = random.Random(1010)
|
|
|
|
committee_bits = [rng.choice([True, False]) for _ in committee_indices]
|
|
|
|
committee_bits = [rng.choice([True, False]) for _ in committee_indices]
|
|
|
|
|
|
|
|
|
|
|
@ -216,7 +216,7 @@ def test_sync_committee_rewards_not_full_participants(spec, state):
|
|
|
|
@spec_state_test
|
|
|
|
@spec_state_test
|
|
|
|
@always_bls
|
|
|
|
@always_bls
|
|
|
|
def test_sync_committee_rewards_empty_participants(spec, state):
|
|
|
|
def test_sync_committee_rewards_empty_participants(spec, state):
|
|
|
|
committee_indices = compute_committee_indices(spec, state)
|
|
|
|
committee_indices = compute_committee_indices(state)
|
|
|
|
committee_bits = [False for _ in committee_indices]
|
|
|
|
committee_bits = [False for _ in committee_indices]
|
|
|
|
|
|
|
|
|
|
|
|
yield from run_successful_sync_committee_test(spec, state, committee_indices, committee_bits)
|
|
|
|
yield from run_successful_sync_committee_test(spec, state, committee_indices, committee_bits)
|
|
|
@ -226,7 +226,7 @@ def test_sync_committee_rewards_empty_participants(spec, state):
|
|
|
|
@spec_state_test
|
|
|
|
@spec_state_test
|
|
|
|
@always_bls
|
|
|
|
@always_bls
|
|
|
|
def test_invalid_signature_past_block(spec, state):
|
|
|
|
def test_invalid_signature_past_block(spec, state):
|
|
|
|
committee_indices = compute_committee_indices(spec, state)
|
|
|
|
committee_indices = compute_committee_indices(state)
|
|
|
|
|
|
|
|
|
|
|
|
for _ in range(2):
|
|
|
|
for _ in range(2):
|
|
|
|
# NOTE: need to transition twice to move beyond the degenerate case at genesis
|
|
|
|
# NOTE: need to transition twice to move beyond the degenerate case at genesis
|
|
|
@ -280,7 +280,7 @@ def test_invalid_signature_previous_committee(spec, state):
|
|
|
|
# Use the previous sync committee to produce the signature.
|
|
|
|
# Use the previous sync committee to produce the signature.
|
|
|
|
# Ensure that the pubkey sets are different.
|
|
|
|
# Ensure that the pubkey sets are different.
|
|
|
|
assert set(old_sync_committee.pubkeys) != set(state.current_sync_committee.pubkeys)
|
|
|
|
assert set(old_sync_committee.pubkeys) != set(state.current_sync_committee.pubkeys)
|
|
|
|
committee_indices = compute_committee_indices(spec, state, old_sync_committee)
|
|
|
|
committee_indices = compute_committee_indices(state, old_sync_committee)
|
|
|
|
|
|
|
|
|
|
|
|
block = build_empty_block_for_next_slot(spec, state)
|
|
|
|
block = build_empty_block_for_next_slot(spec, state)
|
|
|
|
block.body.sync_aggregate = spec.SyncAggregate(
|
|
|
|
block.body.sync_aggregate = spec.SyncAggregate(
|
|
|
@ -322,7 +322,7 @@ def test_valid_signature_future_committee(spec, state):
|
|
|
|
assert sync_committee != old_current_sync_committee
|
|
|
|
assert sync_committee != old_current_sync_committee
|
|
|
|
assert sync_committee != old_next_sync_committee
|
|
|
|
assert sync_committee != old_next_sync_committee
|
|
|
|
|
|
|
|
|
|
|
|
committee_indices = compute_committee_indices(spec, state, sync_committee)
|
|
|
|
committee_indices = compute_committee_indices(state, sync_committee)
|
|
|
|
|
|
|
|
|
|
|
|
block = build_empty_block_for_next_slot(spec, state)
|
|
|
|
block = build_empty_block_for_next_slot(spec, state)
|
|
|
|
block.body.sync_aggregate = spec.SyncAggregate(
|
|
|
|
block.body.sync_aggregate = spec.SyncAggregate(
|
|
|
@ -344,7 +344,7 @@ def test_valid_signature_future_committee(spec, state):
|
|
|
|
@always_bls
|
|
|
|
@always_bls
|
|
|
|
@with_presets([MINIMAL], reason="prefer short search to find matching proposer")
|
|
|
|
@with_presets([MINIMAL], reason="prefer short search to find matching proposer")
|
|
|
|
def test_proposer_in_committee_without_participation(spec, state):
|
|
|
|
def test_proposer_in_committee_without_participation(spec, state):
|
|
|
|
committee_indices = compute_committee_indices(spec, state, state.current_sync_committee)
|
|
|
|
committee_indices = compute_committee_indices(state, state.current_sync_committee)
|
|
|
|
|
|
|
|
|
|
|
|
# NOTE: seem to reliably be getting a matching proposer in the first epoch w/ ``MINIMAL`` preset.
|
|
|
|
# NOTE: seem to reliably be getting a matching proposer in the first epoch w/ ``MINIMAL`` preset.
|
|
|
|
for _ in range(spec.SLOTS_PER_EPOCH):
|
|
|
|
for _ in range(spec.SLOTS_PER_EPOCH):
|
|
|
@ -385,7 +385,7 @@ def test_proposer_in_committee_without_participation(spec, state):
|
|
|
|
@always_bls
|
|
|
|
@always_bls
|
|
|
|
@with_presets([MINIMAL], reason="prefer short search to find matching proposer")
|
|
|
|
@with_presets([MINIMAL], reason="prefer short search to find matching proposer")
|
|
|
|
def test_proposer_in_committee_with_participation(spec, state):
|
|
|
|
def test_proposer_in_committee_with_participation(spec, state):
|
|
|
|
committee_indices = compute_committee_indices(spec, state, state.current_sync_committee)
|
|
|
|
committee_indices = compute_committee_indices(state, state.current_sync_committee)
|
|
|
|
participation = [True for _ in committee_indices]
|
|
|
|
participation = [True for _ in committee_indices]
|
|
|
|
|
|
|
|
|
|
|
|
# NOTE: seem to reliably be getting a matching proposer in the first epoch w/ ``MINIMAL`` preset.
|
|
|
|
# NOTE: seem to reliably be getting a matching proposer in the first epoch w/ ``MINIMAL`` preset.
|
|
|
@ -451,7 +451,7 @@ def test_sync_committee_with_participating_exited_member(spec, state):
|
|
|
|
for _ in range(3):
|
|
|
|
for _ in range(3):
|
|
|
|
next_epoch_via_block(spec, state)
|
|
|
|
next_epoch_via_block(spec, state)
|
|
|
|
|
|
|
|
|
|
|
|
committee_indices = compute_committee_indices(spec, state)
|
|
|
|
committee_indices = compute_committee_indices(state)
|
|
|
|
rng = random.Random(1010)
|
|
|
|
rng = random.Random(1010)
|
|
|
|
|
|
|
|
|
|
|
|
exited_index = _exit_validator_from_committee_and_transition_state(
|
|
|
|
exited_index = _exit_validator_from_committee_and_transition_state(
|
|
|
@ -490,7 +490,7 @@ def test_sync_committee_with_nonparticipating_exited_member(spec, state):
|
|
|
|
for _ in range(3):
|
|
|
|
for _ in range(3):
|
|
|
|
next_epoch_via_block(spec, state)
|
|
|
|
next_epoch_via_block(spec, state)
|
|
|
|
|
|
|
|
|
|
|
|
committee_indices = compute_committee_indices(spec, state)
|
|
|
|
committee_indices = compute_committee_indices(state)
|
|
|
|
rng = random.Random(1010)
|
|
|
|
rng = random.Random(1010)
|
|
|
|
|
|
|
|
|
|
|
|
exited_index = _exit_validator_from_committee_and_transition_state(
|
|
|
|
exited_index = _exit_validator_from_committee_and_transition_state(
|
|
|
@ -533,7 +533,7 @@ def test_sync_committee_with_participating_withdrawable_member(spec, state):
|
|
|
|
for _ in range(3):
|
|
|
|
for _ in range(3):
|
|
|
|
next_epoch_via_block(spec, state)
|
|
|
|
next_epoch_via_block(spec, state)
|
|
|
|
|
|
|
|
|
|
|
|
committee_indices = compute_committee_indices(spec, state)
|
|
|
|
committee_indices = compute_committee_indices(state)
|
|
|
|
rng = random.Random(1010)
|
|
|
|
rng = random.Random(1010)
|
|
|
|
|
|
|
|
|
|
|
|
exited_index = _exit_validator_from_committee_and_transition_state(
|
|
|
|
exited_index = _exit_validator_from_committee_and_transition_state(
|
|
|
@ -572,7 +572,7 @@ def test_sync_committee_with_nonparticipating_withdrawable_member(spec, state):
|
|
|
|
for _ in range(3):
|
|
|
|
for _ in range(3):
|
|
|
|
next_epoch_via_block(spec, state)
|
|
|
|
next_epoch_via_block(spec, state)
|
|
|
|
|
|
|
|
|
|
|
|
committee_indices = compute_committee_indices(spec, state)
|
|
|
|
committee_indices = compute_committee_indices(state)
|
|
|
|
rng = random.Random(1010)
|
|
|
|
rng = random.Random(1010)
|
|
|
|
|
|
|
|
|
|
|
|
exited_index = _exit_validator_from_committee_and_transition_state(
|
|
|
|
exited_index = _exit_validator_from_committee_and_transition_state(
|
|
|
|