Fix/ignore mainnet preset cases

This commit is contained in:
Hsiao-Wei Wang 2021-10-15 11:57:10 +08:00
parent 52235a9e40
commit a4e5d50660
No known key found for this signature in database
GPG Key ID: 1111A8A81778319E
3 changed files with 19 additions and 6 deletions

View File

@ -1,5 +1,9 @@
import random import random
from eth2spec.test.context import fork_transition_test from eth2spec.test.context import (
MINIMAL,
fork_transition_test,
with_presets,
)
from eth2spec.test.helpers.constants import PHASE0, ALTAIR from eth2spec.test.helpers.constants import PHASE0, ALTAIR
from eth2spec.test.helpers.fork_transition import ( from eth2spec.test.helpers.fork_transition import (
do_altair_fork, do_altair_fork,
@ -17,6 +21,7 @@ from eth2spec.test.helpers.random import (
# #
@fork_transition_test(PHASE0, ALTAIR, fork_epoch=2) @fork_transition_test(PHASE0, ALTAIR, fork_epoch=2)
@with_presets([MINIMAL], reason="only test with non-full committee")
def test_transition_with_one_fourth_exiting_validators_exit_post_fork(state, def test_transition_with_one_fourth_exiting_validators_exit_post_fork(state,
fork_epoch, fork_epoch,
spec, spec,

View File

@ -1,6 +1,8 @@
import random import random
from eth2spec.test.context import ( from eth2spec.test.context import (
MINIMAL,
fork_transition_test, fork_transition_test,
with_presets,
) )
from eth2spec.test.helpers.constants import PHASE0, ALTAIR from eth2spec.test.helpers.constants import PHASE0, ALTAIR
from eth2spec.test.helpers.fork_transition import ( from eth2spec.test.helpers.fork_transition import (
@ -14,6 +16,7 @@ from eth2spec.test.helpers.random import (
@fork_transition_test(PHASE0, ALTAIR, fork_epoch=1) @fork_transition_test(PHASE0, ALTAIR, fork_epoch=1)
@with_presets([MINIMAL], reason="only test with non-full committee")
def test_transition_with_one_fourth_slashed_active_validators_pre_fork(state, def test_transition_with_one_fourth_slashed_active_validators_pre_fork(state,
fork_epoch, fork_epoch,
spec, spec,

View File

@ -198,18 +198,21 @@ def run_transition_with_operation(state,
is_right_before_fork = operation_at_slot == fork_epoch * spec.SLOTS_PER_EPOCH - 1 is_right_before_fork = operation_at_slot == fork_epoch * spec.SLOTS_PER_EPOCH - 1
assert is_at_fork or is_right_before_fork assert is_at_fork or is_right_before_fork
blocks = []
if is_at_fork: if is_at_fork:
transition_until_fork(spec, state, fork_epoch) transition_until_fork(spec, state, fork_epoch)
elif is_right_before_fork:
if is_right_before_fork:
_transition_until_fork_minus_one(spec, state, fork_epoch) _transition_until_fork_minus_one(spec, state, fork_epoch)
# prepare operation # prepare operation
selected_validator_index = None selected_validator_index = None
if operation_type == OperetionType.PROPOSER_SLASHING: if operation_type == OperetionType.PROPOSER_SLASHING:
proposer_slashing = get_valid_proposer_slashing(spec, state, signed_1=True, signed_2=True) # avoid slashing the next proposer
future_state = state.copy()
next_slot(spec, future_state)
proposer_index = spec.get_beacon_proposer_index(future_state)
selected_validator_index = (proposer_index + 1) % len(state.validators)
proposer_slashing = get_valid_proposer_slashing(
spec, state, slashed_index=selected_validator_index, signed_1=True, signed_2=True)
operation_dict = {'proposer_slashings': [proposer_slashing]} operation_dict = {'proposer_slashings': [proposer_slashing]}
elif operation_type == OperetionType.ATTESTER_SLASHING: elif operation_type == OperetionType.ATTESTER_SLASHING:
attester_slashing = get_valid_attester_slashing(spec, state, signed_1=True, signed_2=True) attester_slashing = get_valid_attester_slashing(spec, state, signed_1=True, signed_2=True)
@ -225,6 +228,8 @@ def run_transition_with_operation(state,
signed_exits = prepare_signed_exits(spec, state, [selected_validator_index]) signed_exits = prepare_signed_exits(spec, state, [selected_validator_index])
operation_dict = {'voluntary_exits': signed_exits} operation_dict = {'voluntary_exits': signed_exits}
blocks = []
if is_right_before_fork: if is_right_before_fork:
# add a block with operation. # add a block with operation.
block = build_empty_block_for_next_slot(spec, state) block = build_empty_block_for_next_slot(spec, state)