Merge branch 'testgenphase1' into reveal_deadlines_setting
This commit is contained in:
commit
dc888178be
|
@ -2,6 +2,7 @@
|
||||||
# Note: the intention of this file (for now) is to illustrate what a mainnet configuration could look like.
|
# Note: the intention of this file (for now) is to illustrate what a mainnet configuration could look like.
|
||||||
# Some of these constants may still change before the launch of Phase 0.
|
# Some of these constants may still change before the launch of Phase 0.
|
||||||
|
|
||||||
|
CONFIG_NAME: "mainnet"
|
||||||
|
|
||||||
# Misc
|
# Misc
|
||||||
# ---------------------------------------------------------------
|
# ---------------------------------------------------------------
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
# Mainnet preset - phase 1
|
# Mainnet preset - phase 1
|
||||||
|
|
||||||
|
CONFIG_NAME: "mainnet"
|
||||||
|
|
||||||
# phase1-fork
|
# phase1-fork
|
||||||
# ---------------------------------------------------------------
|
# ---------------------------------------------------------------
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
# Minimal preset
|
# Minimal preset
|
||||||
|
|
||||||
|
CONFIG_NAME: "minimal"
|
||||||
|
|
||||||
# Misc
|
# Misc
|
||||||
# ---------------------------------------------------------------
|
# ---------------------------------------------------------------
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
# Minimal preset - phase 1
|
# Minimal preset - phase 1
|
||||||
|
|
||||||
|
CONFIG_NAME: "minimal"
|
||||||
|
|
||||||
# phase1-fork
|
# phase1-fork
|
||||||
# ---------------------------------------------------------------
|
# ---------------------------------------------------------------
|
||||||
|
|
4
setup.py
4
setup.py
|
@ -119,6 +119,8 @@ from eth2spec.utils import bls
|
||||||
from eth2spec.utils.hash_function import hash
|
from eth2spec.utils.hash_function import hash
|
||||||
|
|
||||||
SSZObject = TypeVar('SSZObject', bound=View)
|
SSZObject = TypeVar('SSZObject', bound=View)
|
||||||
|
|
||||||
|
CONFIG_NAME = 'mainnet'
|
||||||
'''
|
'''
|
||||||
PHASE1_IMPORTS = '''from eth2spec.phase0 import spec as phase0
|
PHASE1_IMPORTS = '''from eth2spec.phase0 import spec as phase0
|
||||||
from eth2spec.config.config_util import apply_constants_config
|
from eth2spec.config.config_util import apply_constants_config
|
||||||
|
@ -150,6 +152,8 @@ reload(phase0)
|
||||||
SSZVariableName = str
|
SSZVariableName = str
|
||||||
GeneralizedIndex = NewType('GeneralizedIndex', int)
|
GeneralizedIndex = NewType('GeneralizedIndex', int)
|
||||||
SSZObject = TypeVar('SSZObject', bound=View)
|
SSZObject = TypeVar('SSZObject', bound=View)
|
||||||
|
|
||||||
|
CONFIG_NAME = 'mainnet'
|
||||||
'''
|
'''
|
||||||
SUNDRY_CONSTANTS_FUNCTIONS = '''
|
SUNDRY_CONSTANTS_FUNCTIONS = '''
|
||||||
def ceillog2(x: uint64) -> int:
|
def ceillog2(x: uint64) -> int:
|
||||||
|
|
|
@ -10,6 +10,13 @@ from ruamel.yaml import (
|
||||||
|
|
||||||
from gen_base.gen_typing import TestProvider
|
from gen_base.gen_typing import TestProvider
|
||||||
|
|
||||||
|
from eth2spec.test import context
|
||||||
|
from eth2spec.test.exceptions import SkippedTest
|
||||||
|
|
||||||
|
|
||||||
|
# Flag that the runner does NOT run test via pytest
|
||||||
|
context.is_pytest = False
|
||||||
|
|
||||||
|
|
||||||
def validate_output_dir(path_str):
|
def validate_output_dir(path_str):
|
||||||
path = Path(path_str)
|
path = Path(path_str)
|
||||||
|
@ -136,19 +143,19 @@ def run_generator(generator_name, test_providers: Iterable[TestProvider]):
|
||||||
written_part = False
|
written_part = False
|
||||||
meta = dict()
|
meta = dict()
|
||||||
|
|
||||||
output = test_case.case_fn()
|
try:
|
||||||
# If the output is `None`, that means the testcase doesn't support this fork or this config.
|
for (name, out_kind, data) in test_case.case_fn():
|
||||||
if output is None:
|
written_part = True
|
||||||
|
if out_kind == "meta":
|
||||||
|
meta[name] = data
|
||||||
|
if out_kind == "data":
|
||||||
|
output_part("data", name, dump_yaml_fn(data, name, file_mode, yaml))
|
||||||
|
if out_kind == "ssz":
|
||||||
|
output_part("ssz", name, dump_ssz_fn(data, name, file_mode))
|
||||||
|
except SkippedTest as e:
|
||||||
|
print(e)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
for (name, out_kind, data) in output:
|
|
||||||
written_part = True
|
|
||||||
if out_kind == "meta":
|
|
||||||
meta[name] = data
|
|
||||||
if out_kind == "data":
|
|
||||||
output_part("data", name, dump_yaml_fn(data, name, file_mode, yaml))
|
|
||||||
if out_kind == "ssz":
|
|
||||||
output_part("ssz", name, dump_ssz_fn(data, name, file_mode))
|
|
||||||
# Once all meta data is collected (if any), write it to a meta data file.
|
# Once all meta data is collected (if any), write it to a meta data file.
|
||||||
if len(meta) != 0:
|
if len(meta) != 0:
|
||||||
written_part = True
|
written_part = True
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
ruamel.yaml==0.16.5
|
ruamel.yaml==0.16.5
|
||||||
eth-utils==1.6.0
|
eth-utils==1.6.0
|
||||||
|
pytest>=4.4
|
||||||
|
|
|
@ -5,6 +5,7 @@ setup(
|
||||||
packages=['gen_base', 'gen_from_tests'],
|
packages=['gen_base', 'gen_from_tests'],
|
||||||
install_requires=[
|
install_requires=[
|
||||||
"ruamel.yaml==0.16.5",
|
"ruamel.yaml==0.16.5",
|
||||||
"eth-utils==1.6.0"
|
"eth-utils==1.6.0",
|
||||||
|
"pytest>=4.4",
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
|
@ -54,6 +54,8 @@ def load_config_file(configs_dir: str, presets_name: str) -> Dict[str, Any]:
|
||||||
out[k] = [int(item) if item.isdigit() else item for item in v]
|
out[k] = [int(item) if item.isdigit() else item for item in v]
|
||||||
elif isinstance(v, str) and v.startswith("0x"):
|
elif isinstance(v, str) and v.startswith("0x"):
|
||||||
out[k] = bytes.fromhex(v[2:])
|
out[k] = bytes.fromhex(v[2:])
|
||||||
|
elif k == "CONFIG_NAME":
|
||||||
|
out[k] = str(v)
|
||||||
else:
|
else:
|
||||||
out[k] = int(v)
|
out[k] = int(v)
|
||||||
return out
|
return out
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
|
import pytest
|
||||||
|
|
||||||
from eth2spec.phase0 import spec as spec_phase0
|
from eth2spec.phase0 import spec as spec_phase0
|
||||||
from eth2spec.phase1 import spec as spec_phase1
|
from eth2spec.phase1 import spec as spec_phase1
|
||||||
from eth2spec.utils import bls
|
from eth2spec.utils import bls
|
||||||
|
|
||||||
|
from .exceptions import SkippedTest
|
||||||
from .helpers.genesis import create_genesis_state
|
from .helpers.genesis import create_genesis_state
|
||||||
|
|
||||||
from .utils import vector_test, with_meta_tags
|
from .utils import vector_test, with_meta_tags
|
||||||
|
|
||||||
from random import Random
|
from random import Random
|
||||||
|
@ -22,11 +24,16 @@ def reload_specs():
|
||||||
# Some of the Spec module functionality is exposed here to deal with phase-specific changes.
|
# Some of the Spec module functionality is exposed here to deal with phase-specific changes.
|
||||||
|
|
||||||
SpecForkName = NewType("SpecForkName", str)
|
SpecForkName = NewType("SpecForkName", str)
|
||||||
|
ConfigName = NewType("ConfigName", str)
|
||||||
|
|
||||||
PHASE0 = SpecForkName('phase0')
|
PHASE0 = SpecForkName('phase0')
|
||||||
PHASE1 = SpecForkName('phase1')
|
PHASE1 = SpecForkName('phase1')
|
||||||
ALL_PHASES = (PHASE0, PHASE1)
|
ALL_PHASES = (PHASE0, PHASE1)
|
||||||
|
|
||||||
|
MAINNET = ConfigName('mainnet')
|
||||||
|
MINIMAL = ConfigName('minimal')
|
||||||
|
|
||||||
|
|
||||||
# TODO: currently phases are defined as python modules.
|
# TODO: currently phases are defined as python modules.
|
||||||
# It would be better if they would be more well-defined interfaces for stronger typing.
|
# It would be better if they would be more well-defined interfaces for stronger typing.
|
||||||
|
|
||||||
|
@ -175,6 +182,17 @@ def single_phase(fn):
|
||||||
DEFAULT_BLS_ACTIVE = True
|
DEFAULT_BLS_ACTIVE = True
|
||||||
|
|
||||||
|
|
||||||
|
is_pytest = True
|
||||||
|
|
||||||
|
|
||||||
|
def dump_skipping_message(reason: str) -> None:
|
||||||
|
message = f"[Skipped test] {reason}"
|
||||||
|
if is_pytest:
|
||||||
|
pytest.skip(message)
|
||||||
|
else:
|
||||||
|
raise SkippedTest(message)
|
||||||
|
|
||||||
|
|
||||||
def spec_test(fn):
|
def spec_test(fn):
|
||||||
# Bls switch must be wrapped by vector_test,
|
# Bls switch must be wrapped by vector_test,
|
||||||
# to fully go through the yielded bls switch data, before setting back the BLS setting.
|
# to fully go through the yielded bls switch data, before setting back the BLS setting.
|
||||||
|
@ -275,7 +293,8 @@ def with_phases(phases, other_phases=None):
|
||||||
if 'phase' in kw:
|
if 'phase' in kw:
|
||||||
phase = kw.pop('phase')
|
phase = kw.pop('phase')
|
||||||
if phase not in phases:
|
if phase not in phases:
|
||||||
return
|
dump_skipping_message(f"doesn't support this fork: {phase}")
|
||||||
|
return None
|
||||||
run_phases = [phase]
|
run_phases = [phase]
|
||||||
|
|
||||||
available_phases = set(run_phases)
|
available_phases = set(run_phases)
|
||||||
|
@ -308,3 +327,30 @@ def disable_process_reveal_deadlines(fn):
|
||||||
spec.process_reveal_deadlines = lambda state: None
|
spec.process_reveal_deadlines = lambda state: None
|
||||||
return fn(*args, spec=spec, **kw)
|
return fn(*args, spec=spec, **kw)
|
||||||
return with_meta_tags({'reveal_deadlines_setting': 1})(entry)
|
return with_meta_tags({'reveal_deadlines_setting': 1})(entry)
|
||||||
|
|
||||||
|
|
||||||
|
def with_configs(configs):
|
||||||
|
def decorator(fn):
|
||||||
|
def wrapper(*args, spec: Spec, **kw):
|
||||||
|
available_configs = set(configs)
|
||||||
|
if spec.CONFIG_NAME not in available_configs:
|
||||||
|
dump_skipping_message(f"doesn't support this config: {spec.CONFIG_NAME}")
|
||||||
|
return None
|
||||||
|
|
||||||
|
return fn(*args, spec=spec, **kw)
|
||||||
|
return wrapper
|
||||||
|
return decorator
|
||||||
|
|
||||||
|
|
||||||
|
def only_full_crosslink(fn):
|
||||||
|
def is_full_crosslink(spec, state):
|
||||||
|
epoch = spec.compute_epoch_at_slot(state.slot)
|
||||||
|
return spec.get_committee_count_per_slot(state, epoch) >= spec.get_active_shard_count(state)
|
||||||
|
|
||||||
|
def wrapper(*args, spec: Spec, state: Any, **kw):
|
||||||
|
# TODO: update condition to "phase1+" if we have phase2
|
||||||
|
if spec.fork == PHASE1 and not is_full_crosslink(spec, state):
|
||||||
|
dump_skipping_message("only for full crosslink")
|
||||||
|
return None
|
||||||
|
return fn(*args, spec=spec, state=state, **kw)
|
||||||
|
return wrapper
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
class SkippedTest(Exception):
|
||||||
|
...
|
|
@ -179,15 +179,6 @@ def get_sample_shard_transition(spec, start_slot, block_lengths):
|
||||||
return shard_transition
|
return shard_transition
|
||||||
|
|
||||||
|
|
||||||
def get_custody_secret(spec, state, validator_index, epoch=None):
|
|
||||||
period = spec.get_custody_period_for_validator(validator_index, epoch if epoch is not None
|
|
||||||
else spec.get_current_epoch(state))
|
|
||||||
epoch_to_sign = spec.get_randao_epoch_for_custody_period(period, validator_index)
|
|
||||||
domain = spec.get_domain(state, spec.DOMAIN_RANDAO, epoch_to_sign)
|
|
||||||
signing_root = spec.compute_signing_root(spec.Epoch(epoch_to_sign), domain)
|
|
||||||
return bls.Sign(privkeys[validator_index], signing_root)
|
|
||||||
|
|
||||||
|
|
||||||
def get_custody_slashable_test_vector(spec, custody_secret, length, slashable=True):
|
def get_custody_slashable_test_vector(spec, custody_secret, length, slashable=True):
|
||||||
test_vector = get_custody_test_vector(length)
|
test_vector = get_custody_test_vector(length)
|
||||||
offset = 0
|
offset = 0
|
||||||
|
|
|
@ -35,8 +35,3 @@ def get_shard_transition_of_committee(spec, state, committee_index, shard_blocks
|
||||||
shard = spec.compute_shard_from_committee_index(state, committee_index, state.slot)
|
shard = spec.compute_shard_from_committee_index(state, committee_index, state.slot)
|
||||||
shard_transition = spec.get_shard_transition(state, shard, shard_blocks=shard_blocks)
|
shard_transition = spec.get_shard_transition(state, shard, shard_blocks=shard_blocks)
|
||||||
return shard_transition
|
return shard_transition
|
||||||
|
|
||||||
|
|
||||||
def is_full_crosslink(spec, state):
|
|
||||||
epoch = spec.compute_epoch_at_slot(state.slot)
|
|
||||||
return spec.get_committee_count_per_slot(state, epoch) >= spec.get_active_shard_count(state)
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ from eth2spec.test.helpers.shard_transitions import get_shard_transition_of_comm
|
||||||
|
|
||||||
from eth2spec.test.context import (
|
from eth2spec.test.context import (
|
||||||
PHASE0, PHASE1,
|
PHASE0, PHASE1,
|
||||||
spec_state_test, with_all_phases, expect_assertion_error, always_bls, with_phases,
|
spec_state_test, with_all_phases, expect_assertion_error, always_bls, with_phases, dump_skipping_message,
|
||||||
disable_process_reveal_deadlines,
|
disable_process_reveal_deadlines,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -292,10 +292,9 @@ def test_empty_epoch_transition(spec, state):
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_empty_epoch_transition_not_finalizing(spec, state):
|
def test_empty_epoch_transition_not_finalizing(spec, state):
|
||||||
# Don't run for non-minimal configs, it takes very long, and the effect
|
|
||||||
# of calling finalization/justification is just the same as with the minimal configuration.
|
|
||||||
if spec.SLOTS_PER_EPOCH > 8:
|
if spec.SLOTS_PER_EPOCH > 8:
|
||||||
return
|
return dump_skipping_message("Skip mainnet config for saving time."
|
||||||
|
" Minimal config suffice to cover the target-of-test.")
|
||||||
|
|
||||||
# copy for later balance lookups.
|
# copy for later balance lookups.
|
||||||
pre_balances = list(state.balances)
|
pre_balances = list(state.balances)
|
||||||
|
@ -481,9 +480,8 @@ def test_attester_slashing(spec, state):
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_duplicate_attester_slashing(spec, state):
|
def test_duplicate_attester_slashing(spec, state):
|
||||||
# Skip test if config cannot handle multiple AttesterSlashings per block
|
|
||||||
if spec.MAX_ATTESTER_SLASHINGS < 2:
|
if spec.MAX_ATTESTER_SLASHINGS < 2:
|
||||||
return
|
return dump_skipping_message("Skip test if config cannot handle multiple AttesterSlashings per block")
|
||||||
|
|
||||||
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)
|
||||||
attester_slashings = [attester_slashing, attester_slashing.copy()]
|
attester_slashings = [attester_slashing, attester_slashing.copy()]
|
||||||
|
@ -510,9 +508,8 @@ def test_duplicate_attester_slashing(spec, state):
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_multiple_attester_slashings_no_overlap(spec, state):
|
def test_multiple_attester_slashings_no_overlap(spec, state):
|
||||||
# Skip test if config cannot handle multiple AttesterSlashings per block
|
|
||||||
if spec.MAX_ATTESTER_SLASHINGS < 2:
|
if spec.MAX_ATTESTER_SLASHINGS < 2:
|
||||||
return
|
return dump_skipping_message("Skip test if config cannot handle multiple AttesterSlashings per block")
|
||||||
|
|
||||||
# copy for later balance lookups.
|
# copy for later balance lookups.
|
||||||
pre_state = state.copy()
|
pre_state = state.copy()
|
||||||
|
@ -551,9 +548,8 @@ def test_multiple_attester_slashings_no_overlap(spec, state):
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_multiple_attester_slashings_partial_overlap(spec, state):
|
def test_multiple_attester_slashings_partial_overlap(spec, state):
|
||||||
# Skip test if config cannot handle multiple AttesterSlashings per block
|
|
||||||
if spec.MAX_ATTESTER_SLASHINGS < 2:
|
if spec.MAX_ATTESTER_SLASHINGS < 2:
|
||||||
return
|
return dump_skipping_message("Skip test if config cannot handle multiple AttesterSlashings per block")
|
||||||
|
|
||||||
# copy for later balance lookups.
|
# copy for later balance lookups.
|
||||||
pre_state = state.copy()
|
pre_state = state.copy()
|
||||||
|
@ -891,9 +887,9 @@ def test_historical_batch(spec, state):
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_eth1_data_votes_consensus(spec, state):
|
def test_eth1_data_votes_consensus(spec, state):
|
||||||
# Don't run when it will take very, very long to simulate. Minimal configuration suffices.
|
|
||||||
if spec.EPOCHS_PER_ETH1_VOTING_PERIOD > 2:
|
if spec.EPOCHS_PER_ETH1_VOTING_PERIOD > 2:
|
||||||
return
|
return dump_skipping_message("Skip test if config with longer `EPOCHS_PER_ETH1_VOTING_PERIOD` for saving time."
|
||||||
|
" Minimal config suffice to cover the target-of-test.")
|
||||||
|
|
||||||
voting_period_slots = spec.EPOCHS_PER_ETH1_VOTING_PERIOD * spec.SLOTS_PER_EPOCH
|
voting_period_slots = spec.EPOCHS_PER_ETH1_VOTING_PERIOD * spec.SLOTS_PER_EPOCH
|
||||||
|
|
||||||
|
@ -935,9 +931,9 @@ def test_eth1_data_votes_consensus(spec, state):
|
||||||
@with_all_phases
|
@with_all_phases
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_eth1_data_votes_no_consensus(spec, state):
|
def test_eth1_data_votes_no_consensus(spec, state):
|
||||||
# Don't run when it will take very, very long to simulate. Minimal configuration suffices.
|
|
||||||
if spec.EPOCHS_PER_ETH1_VOTING_PERIOD > 2:
|
if spec.EPOCHS_PER_ETH1_VOTING_PERIOD > 2:
|
||||||
return
|
return dump_skipping_message("Skip test if config with longer `EPOCHS_PER_ETH1_VOTING_PERIOD` for saving time."
|
||||||
|
" Minimal config suffice to cover the target-of-test.")
|
||||||
|
|
||||||
voting_period_slots = spec.EPOCHS_PER_ETH1_VOTING_PERIOD * spec.SLOTS_PER_EPOCH
|
voting_period_slots = spec.EPOCHS_PER_ETH1_VOTING_PERIOD * spec.SLOTS_PER_EPOCH
|
||||||
|
|
||||||
|
|
|
@ -9,10 +9,10 @@ from eth2spec.test.helpers.attestations import (
|
||||||
from eth2spec.test.helpers.state import transition_to, transition_to_valid_shard_slot
|
from eth2spec.test.helpers.state import transition_to, transition_to_valid_shard_slot
|
||||||
from eth2spec.test.context import (
|
from eth2spec.test.context import (
|
||||||
PHASE0,
|
PHASE0,
|
||||||
with_all_phases_except,
|
|
||||||
spec_state_test,
|
|
||||||
expect_assertion_error,
|
expect_assertion_error,
|
||||||
disable_process_reveal_deadlines,
|
disable_process_reveal_deadlines,
|
||||||
|
spec_state_test,
|
||||||
|
with_all_phases_except,
|
||||||
)
|
)
|
||||||
from eth2spec.test.phase0.block_processing.test_process_attestation import run_attestation_processing
|
from eth2spec.test.phase0.block_processing.test_process_attestation import run_attestation_processing
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
from eth2spec.test.helpers.custody import (
|
from eth2spec.test.helpers.custody import (
|
||||||
get_valid_custody_slashing,
|
get_valid_custody_slashing,
|
||||||
get_custody_secret,
|
|
||||||
get_custody_slashable_shard_transition,
|
get_custody_slashable_shard_transition,
|
||||||
)
|
)
|
||||||
from eth2spec.test.helpers.attestations import (
|
from eth2spec.test.helpers.attestations import (
|
||||||
get_valid_on_time_attestation,
|
get_valid_on_time_attestation,
|
||||||
)
|
)
|
||||||
|
from eth2spec.test.helpers.keys import privkeys
|
||||||
from eth2spec.utils.ssz.ssz_typing import ByteList
|
from eth2spec.utils.ssz.ssz_typing import ByteList
|
||||||
from eth2spec.test.helpers.state import get_balance, transition_to
|
from eth2spec.test.helpers.state import get_balance, transition_to
|
||||||
from eth2spec.test.context import (
|
from eth2spec.test.context import (
|
||||||
|
@ -78,7 +78,12 @@ def run_standard_custody_slashing_test(spec,
|
||||||
if block_lengths is None:
|
if block_lengths is None:
|
||||||
block_lengths = [2**15 // 3] * len(offset_slots)
|
block_lengths = [2**15 // 3] * len(offset_slots)
|
||||||
|
|
||||||
custody_secret = get_custody_secret(spec, state, validator_index)
|
custody_secret = spec.get_custody_secret(
|
||||||
|
state,
|
||||||
|
validator_index,
|
||||||
|
privkeys[validator_index],
|
||||||
|
spec.get_current_epoch(state),
|
||||||
|
)
|
||||||
shard_transition, slashable_test_vector = get_custody_slashable_shard_transition(
|
shard_transition, slashable_test_vector = get_custody_slashable_shard_transition(
|
||||||
spec,
|
spec,
|
||||||
state.slot,
|
state.slot,
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
from eth2spec.test.context import (
|
from eth2spec.test.context import (
|
||||||
PHASE0,
|
PHASE0,
|
||||||
with_all_phases_except,
|
with_all_phases_except,
|
||||||
|
only_full_crosslink,
|
||||||
spec_state_test,
|
spec_state_test,
|
||||||
)
|
)
|
||||||
from eth2spec.test.helpers.attestations import (
|
from eth2spec.test.helpers.attestations import (
|
||||||
|
@ -10,7 +11,6 @@ from eth2spec.test.helpers.attestations import (
|
||||||
)
|
)
|
||||||
from eth2spec.test.helpers.shard_transitions import (
|
from eth2spec.test.helpers.shard_transitions import (
|
||||||
run_shard_transitions_processing,
|
run_shard_transitions_processing,
|
||||||
is_full_crosslink,
|
|
||||||
)
|
)
|
||||||
from eth2spec.test.helpers.shard_block import (
|
from eth2spec.test.helpers.shard_block import (
|
||||||
build_shard_block,
|
build_shard_block,
|
||||||
|
@ -92,31 +92,22 @@ def run_successful_crosslink_tests(spec, state, target_len_offset_slot):
|
||||||
|
|
||||||
@with_all_phases_except([PHASE0])
|
@with_all_phases_except([PHASE0])
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
|
@only_full_crosslink
|
||||||
def test_basic_crosslinks(spec, state):
|
def test_basic_crosslinks(spec, state):
|
||||||
if not is_full_crosslink(spec, state):
|
|
||||||
# Skip this test
|
|
||||||
return
|
|
||||||
|
|
||||||
yield from run_successful_crosslink_tests(spec, state, target_len_offset_slot=1)
|
yield from run_successful_crosslink_tests(spec, state, target_len_offset_slot=1)
|
||||||
|
|
||||||
|
|
||||||
@with_all_phases_except([PHASE0])
|
@with_all_phases_except([PHASE0])
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
|
@only_full_crosslink
|
||||||
def test_multiple_offset_slots(spec, state):
|
def test_multiple_offset_slots(spec, state):
|
||||||
if not is_full_crosslink(spec, state):
|
|
||||||
# Skip this test
|
|
||||||
return
|
|
||||||
|
|
||||||
yield from run_successful_crosslink_tests(spec, state, target_len_offset_slot=2)
|
yield from run_successful_crosslink_tests(spec, state, target_len_offset_slot=2)
|
||||||
|
|
||||||
|
|
||||||
@with_all_phases_except([PHASE0])
|
@with_all_phases_except([PHASE0])
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
|
@only_full_crosslink
|
||||||
def test_no_winning_root(spec, state):
|
def test_no_winning_root(spec, state):
|
||||||
if not is_full_crosslink(spec, state):
|
|
||||||
# Skip this test
|
|
||||||
return
|
|
||||||
|
|
||||||
state, shard, target_shard_slot = get_initial_env(spec, state, target_len_offset_slot=1)
|
state, shard, target_shard_slot = get_initial_env(spec, state, target_len_offset_slot=1)
|
||||||
init_slot = state.slot
|
init_slot = state.slot
|
||||||
|
|
||||||
|
@ -163,11 +154,8 @@ def test_no_winning_root(spec, state):
|
||||||
|
|
||||||
@with_all_phases_except([PHASE0])
|
@with_all_phases_except([PHASE0])
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
|
@only_full_crosslink
|
||||||
def test_wrong_shard_transition_root(spec, state):
|
def test_wrong_shard_transition_root(spec, state):
|
||||||
if not is_full_crosslink(spec, state):
|
|
||||||
# Skip this test
|
|
||||||
return
|
|
||||||
|
|
||||||
state, shard, target_shard_slot = get_initial_env(spec, state, target_len_offset_slot=1)
|
state, shard, target_shard_slot = get_initial_env(spec, state, target_len_offset_slot=1)
|
||||||
init_slot = state.slot
|
init_slot = state.slot
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
from typing import Dict, Sequence
|
from typing import Dict, Sequence
|
||||||
|
|
||||||
from eth2spec.test.context import (
|
from eth2spec.test.context import (
|
||||||
PHASE0,
|
PHASE0, MINIMAL,
|
||||||
with_all_phases_except,
|
with_all_phases_except,
|
||||||
spec_state_test,
|
spec_state_test,
|
||||||
|
only_full_crosslink,
|
||||||
|
with_configs,
|
||||||
)
|
)
|
||||||
from eth2spec.test.helpers.attestations import get_valid_on_time_attestation
|
from eth2spec.test.helpers.attestations import get_valid_on_time_attestation
|
||||||
from eth2spec.test.helpers.block import build_empty_block
|
from eth2spec.test.helpers.block import build_empty_block
|
||||||
from eth2spec.test.helpers.custody import (
|
from eth2spec.test.helpers.custody import (
|
||||||
get_custody_secret,
|
|
||||||
get_custody_slashable_test_vector,
|
get_custody_slashable_test_vector,
|
||||||
get_valid_chunk_challenge,
|
get_valid_chunk_challenge,
|
||||||
get_valid_custody_chunk_response,
|
get_valid_custody_chunk_response,
|
||||||
|
@ -16,13 +17,13 @@ from eth2spec.test.helpers.custody import (
|
||||||
get_valid_custody_slashing,
|
get_valid_custody_slashing,
|
||||||
get_valid_early_derived_secret_reveal,
|
get_valid_early_derived_secret_reveal,
|
||||||
)
|
)
|
||||||
|
from eth2spec.test.helpers.keys import privkeys
|
||||||
from eth2spec.test.helpers.shard_block import (
|
from eth2spec.test.helpers.shard_block import (
|
||||||
build_shard_block,
|
build_shard_block,
|
||||||
get_committee_index_of_shard,
|
get_committee_index_of_shard,
|
||||||
get_sample_shard_block_body,
|
get_sample_shard_block_body,
|
||||||
get_shard_transitions,
|
get_shard_transitions,
|
||||||
)
|
)
|
||||||
from eth2spec.test.helpers.shard_transitions import is_full_crosslink
|
|
||||||
from eth2spec.test.helpers.state import state_transition_and_sign_block, transition_to_valid_shard_slot, transition_to
|
from eth2spec.test.helpers.state import state_transition_and_sign_block, transition_to_valid_shard_slot, transition_to
|
||||||
|
|
||||||
|
|
||||||
|
@ -99,12 +100,8 @@ def run_beacon_block_with_shard_blocks(spec, state, target_len_offset_slot, comm
|
||||||
|
|
||||||
@with_all_phases_except([PHASE0])
|
@with_all_phases_except([PHASE0])
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
|
@only_full_crosslink
|
||||||
def test_process_beacon_block_with_normal_shard_transition(spec, state):
|
def test_process_beacon_block_with_normal_shard_transition(spec, state):
|
||||||
# NOTE: this test is only for full crosslink (minimal config), not for mainnet
|
|
||||||
if not is_full_crosslink(spec, state):
|
|
||||||
# skip
|
|
||||||
return
|
|
||||||
|
|
||||||
transition_to_valid_shard_slot(spec, state)
|
transition_to_valid_shard_slot(spec, state)
|
||||||
|
|
||||||
target_len_offset_slot = 1
|
target_len_offset_slot = 1
|
||||||
|
@ -117,12 +114,8 @@ def test_process_beacon_block_with_normal_shard_transition(spec, state):
|
||||||
|
|
||||||
@with_all_phases_except([PHASE0])
|
@with_all_phases_except([PHASE0])
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
|
@only_full_crosslink
|
||||||
def test_process_beacon_block_with_empty_proposal_transition(spec, state):
|
def test_process_beacon_block_with_empty_proposal_transition(spec, state):
|
||||||
# NOTE: this test is only for full crosslink (minimal config), not for mainnet
|
|
||||||
if not is_full_crosslink(spec, state):
|
|
||||||
# skip
|
|
||||||
return
|
|
||||||
|
|
||||||
transition_to_valid_shard_slot(spec, state)
|
transition_to_valid_shard_slot(spec, state)
|
||||||
|
|
||||||
target_len_offset_slot = 1
|
target_len_offset_slot = 1
|
||||||
|
@ -140,12 +133,8 @@ def test_process_beacon_block_with_empty_proposal_transition(spec, state):
|
||||||
|
|
||||||
@with_all_phases_except([PHASE0])
|
@with_all_phases_except([PHASE0])
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
|
@only_full_crosslink
|
||||||
def test_with_shard_transition_with_custody_challenge_and_response(spec, state):
|
def test_with_shard_transition_with_custody_challenge_and_response(spec, state):
|
||||||
# NOTE: this test is only for full crosslink (minimal config), not for mainnet
|
|
||||||
if not is_full_crosslink(spec, state):
|
|
||||||
# skip
|
|
||||||
return
|
|
||||||
|
|
||||||
transition_to_valid_shard_slot(spec, state)
|
transition_to_valid_shard_slot(spec, state)
|
||||||
|
|
||||||
# build shard block
|
# build shard block
|
||||||
|
@ -178,6 +167,7 @@ def test_with_shard_transition_with_custody_challenge_and_response(spec, state):
|
||||||
|
|
||||||
@with_all_phases_except([PHASE0])
|
@with_all_phases_except([PHASE0])
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
|
@with_configs([MINIMAL])
|
||||||
def test_custody_key_reveal(spec, state):
|
def test_custody_key_reveal(spec, state):
|
||||||
transition_to_valid_shard_slot(spec, state)
|
transition_to_valid_shard_slot(spec, state)
|
||||||
transition_to(spec, state, state.slot + spec.EPOCHS_PER_CUSTODY_PERIOD * spec.SLOTS_PER_EPOCH)
|
transition_to(spec, state, state.slot + spec.EPOCHS_PER_CUSTODY_PERIOD * spec.SLOTS_PER_EPOCH)
|
||||||
|
@ -202,12 +192,8 @@ def test_early_derived_secret_reveal(spec, state):
|
||||||
|
|
||||||
@with_all_phases_except([PHASE0])
|
@with_all_phases_except([PHASE0])
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
|
@only_full_crosslink
|
||||||
def test_custody_slashing(spec, state):
|
def test_custody_slashing(spec, state):
|
||||||
# NOTE: this test is only for full crosslink (minimal config), not for mainnet
|
|
||||||
if not is_full_crosslink(spec, state):
|
|
||||||
# skip
|
|
||||||
return
|
|
||||||
|
|
||||||
transition_to_valid_shard_slot(spec, state)
|
transition_to_valid_shard_slot(spec, state)
|
||||||
|
|
||||||
# Build shard block
|
# Build shard block
|
||||||
|
@ -215,7 +201,12 @@ def test_custody_slashing(spec, state):
|
||||||
committee_index = get_committee_index_of_shard(spec, state, state.slot, shard)
|
committee_index = get_committee_index_of_shard(spec, state, state.slot, shard)
|
||||||
# Create slashable shard block body
|
# Create slashable shard block body
|
||||||
validator_index = spec.get_beacon_committee(state, state.slot, committee_index)[0]
|
validator_index = spec.get_beacon_committee(state, state.slot, committee_index)[0]
|
||||||
custody_secret = get_custody_secret(spec, state, validator_index)
|
custody_secret = spec.get_custody_secret(
|
||||||
|
state,
|
||||||
|
validator_index,
|
||||||
|
privkeys[validator_index],
|
||||||
|
spec.get_current_epoch(state),
|
||||||
|
)
|
||||||
slashable_body = get_custody_slashable_test_vector(spec, custody_secret, length=100, slashable=True)
|
slashable_body = get_custody_slashable_test_vector(spec, custody_secret, length=100, slashable=True)
|
||||||
shard_block = build_shard_block(spec, state, shard, body=slashable_body, slot=state.slot, signed=True)
|
shard_block = build_shard_block(spec, state, shard, body=slashable_body, slot=state.slot, signed=True)
|
||||||
shard_block_dict: Dict[spec.Shard, Sequence[spec.SignedShardBlock]] = {shard: [shard_block]}
|
shard_block_dict: Dict[spec.Shard, Sequence[spec.SignedShardBlock]] = {shard: [shard_block]}
|
||||||
|
|
|
@ -4,12 +4,12 @@ from eth2spec.test.context import (
|
||||||
expect_assertion_error,
|
expect_assertion_error,
|
||||||
spec_state_test,
|
spec_state_test,
|
||||||
with_all_phases_except,
|
with_all_phases_except,
|
||||||
|
only_full_crosslink,
|
||||||
)
|
)
|
||||||
from eth2spec.test.helpers.shard_block import (
|
from eth2spec.test.helpers.shard_block import (
|
||||||
build_shard_block,
|
build_shard_block,
|
||||||
sign_shard_block,
|
sign_shard_block,
|
||||||
)
|
)
|
||||||
from eth2spec.test.helpers.shard_transitions import is_full_crosslink
|
|
||||||
from eth2spec.test.helpers.state import next_slot, transition_to_valid_shard_slot, transition_to
|
from eth2spec.test.helpers.state import next_slot, transition_to_valid_shard_slot, transition_to
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,11 +46,8 @@ def run_shard_blocks(spec, shard_state, signed_shard_block, beacon_parent_state,
|
||||||
@with_all_phases_except([PHASE0])
|
@with_all_phases_except([PHASE0])
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
@always_bls
|
@always_bls
|
||||||
|
@only_full_crosslink
|
||||||
def test_valid_shard_block(spec, state):
|
def test_valid_shard_block(spec, state):
|
||||||
if not is_full_crosslink(spec, state):
|
|
||||||
# skip
|
|
||||||
return
|
|
||||||
|
|
||||||
beacon_state = state.copy()
|
beacon_state = state.copy()
|
||||||
transition_to_valid_shard_slot(spec, beacon_state)
|
transition_to_valid_shard_slot(spec, beacon_state)
|
||||||
|
|
||||||
|
@ -68,11 +65,8 @@ def test_valid_shard_block(spec, state):
|
||||||
|
|
||||||
@with_all_phases_except([PHASE0])
|
@with_all_phases_except([PHASE0])
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
|
@only_full_crosslink
|
||||||
def test_invalid_shard_parent_root(spec, state):
|
def test_invalid_shard_parent_root(spec, state):
|
||||||
if not is_full_crosslink(spec, state):
|
|
||||||
# skip
|
|
||||||
return
|
|
||||||
|
|
||||||
beacon_state = state.copy()
|
beacon_state = state.copy()
|
||||||
transition_to_valid_shard_slot(spec, beacon_state)
|
transition_to_valid_shard_slot(spec, beacon_state)
|
||||||
|
|
||||||
|
@ -87,11 +81,8 @@ def test_invalid_shard_parent_root(spec, state):
|
||||||
|
|
||||||
@with_all_phases_except([PHASE0])
|
@with_all_phases_except([PHASE0])
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
|
@only_full_crosslink
|
||||||
def test_invalid_beacon_parent_root(spec, state):
|
def test_invalid_beacon_parent_root(spec, state):
|
||||||
if not is_full_crosslink(spec, state):
|
|
||||||
# skip
|
|
||||||
return
|
|
||||||
|
|
||||||
beacon_state = state.copy()
|
beacon_state = state.copy()
|
||||||
transition_to_valid_shard_slot(spec, beacon_state)
|
transition_to_valid_shard_slot(spec, beacon_state)
|
||||||
shard = 0
|
shard = 0
|
||||||
|
@ -105,11 +96,8 @@ def test_invalid_beacon_parent_root(spec, state):
|
||||||
|
|
||||||
@with_all_phases_except([PHASE0])
|
@with_all_phases_except([PHASE0])
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
|
@only_full_crosslink
|
||||||
def test_invalid_slot(spec, state):
|
def test_invalid_slot(spec, state):
|
||||||
if not is_full_crosslink(spec, state):
|
|
||||||
# skip
|
|
||||||
return
|
|
||||||
|
|
||||||
beacon_state = state.copy()
|
beacon_state = state.copy()
|
||||||
transition_to_valid_shard_slot(spec, beacon_state)
|
transition_to_valid_shard_slot(spec, beacon_state)
|
||||||
shard = 0
|
shard = 0
|
||||||
|
@ -124,11 +112,8 @@ def test_invalid_slot(spec, state):
|
||||||
|
|
||||||
@with_all_phases_except([PHASE0])
|
@with_all_phases_except([PHASE0])
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
|
@only_full_crosslink
|
||||||
def test_invalid_proposer_index(spec, state):
|
def test_invalid_proposer_index(spec, state):
|
||||||
if not is_full_crosslink(spec, state):
|
|
||||||
# skip
|
|
||||||
return
|
|
||||||
|
|
||||||
beacon_state = state.copy()
|
beacon_state = state.copy()
|
||||||
transition_to_valid_shard_slot(spec, beacon_state)
|
transition_to_valid_shard_slot(spec, beacon_state)
|
||||||
shard = 0
|
shard = 0
|
||||||
|
@ -148,12 +133,8 @@ def test_invalid_proposer_index(spec, state):
|
||||||
@with_all_phases_except([PHASE0])
|
@with_all_phases_except([PHASE0])
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
@always_bls
|
@always_bls
|
||||||
|
@only_full_crosslink
|
||||||
def test_out_of_bound_offset(spec, state):
|
def test_out_of_bound_offset(spec, state):
|
||||||
# TODO: Handle this edge case properly
|
|
||||||
if not is_full_crosslink(spec, state):
|
|
||||||
# skip
|
|
||||||
return
|
|
||||||
|
|
||||||
beacon_state = state.copy()
|
beacon_state = state.copy()
|
||||||
transition_to_valid_shard_slot(spec, beacon_state)
|
transition_to_valid_shard_slot(spec, beacon_state)
|
||||||
shard = 0
|
shard = 0
|
||||||
|
@ -173,11 +154,8 @@ def test_out_of_bound_offset(spec, state):
|
||||||
@with_all_phases_except([PHASE0])
|
@with_all_phases_except([PHASE0])
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
@always_bls
|
@always_bls
|
||||||
|
@only_full_crosslink
|
||||||
def test_invalid_offset(spec, state):
|
def test_invalid_offset(spec, state):
|
||||||
if not is_full_crosslink(spec, state):
|
|
||||||
# skip
|
|
||||||
return
|
|
||||||
|
|
||||||
beacon_state = state.copy()
|
beacon_state = state.copy()
|
||||||
transition_to_valid_shard_slot(spec, beacon_state)
|
transition_to_valid_shard_slot(spec, beacon_state)
|
||||||
# 4 is not in `SHARD_BLOCK_OFFSETS`
|
# 4 is not in `SHARD_BLOCK_OFFSETS`
|
||||||
|
@ -195,11 +173,8 @@ def test_invalid_offset(spec, state):
|
||||||
@with_all_phases_except([PHASE0])
|
@with_all_phases_except([PHASE0])
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
@always_bls
|
@always_bls
|
||||||
|
@only_full_crosslink
|
||||||
def test_empty_block_body(spec, state):
|
def test_empty_block_body(spec, state):
|
||||||
if not is_full_crosslink(spec, state):
|
|
||||||
# skip
|
|
||||||
return
|
|
||||||
|
|
||||||
beacon_state = state.copy()
|
beacon_state = state.copy()
|
||||||
transition_to_valid_shard_slot(spec, beacon_state)
|
transition_to_valid_shard_slot(spec, beacon_state)
|
||||||
shard = 0
|
shard = 0
|
||||||
|
@ -217,11 +192,8 @@ def test_empty_block_body(spec, state):
|
||||||
@with_all_phases_except([PHASE0])
|
@with_all_phases_except([PHASE0])
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
@always_bls
|
@always_bls
|
||||||
|
@only_full_crosslink
|
||||||
def test_invalid_signature(spec, state):
|
def test_invalid_signature(spec, state):
|
||||||
if not is_full_crosslink(spec, state):
|
|
||||||
# skip
|
|
||||||
return
|
|
||||||
|
|
||||||
beacon_state = state.copy()
|
beacon_state = state.copy()
|
||||||
transition_to_valid_shard_slot(spec, beacon_state)
|
transition_to_valid_shard_slot(spec, beacon_state)
|
||||||
shard = 0
|
shard = 0
|
||||||
|
@ -239,11 +211,8 @@ def test_invalid_signature(spec, state):
|
||||||
@with_all_phases_except([PHASE0])
|
@with_all_phases_except([PHASE0])
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
@always_bls
|
@always_bls
|
||||||
|
@only_full_crosslink
|
||||||
def test_max_offset(spec, state):
|
def test_max_offset(spec, state):
|
||||||
if not is_full_crosslink(spec, state):
|
|
||||||
# skip
|
|
||||||
return
|
|
||||||
|
|
||||||
beacon_state = state.copy()
|
beacon_state = state.copy()
|
||||||
transition_to_valid_shard_slot(spec, beacon_state)
|
transition_to_valid_shard_slot(spec, beacon_state)
|
||||||
shard = 0
|
shard = 0
|
||||||
|
@ -259,11 +228,8 @@ def test_max_offset(spec, state):
|
||||||
@with_all_phases_except([PHASE0])
|
@with_all_phases_except([PHASE0])
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
@always_bls
|
@always_bls
|
||||||
|
@only_full_crosslink
|
||||||
def test_pending_shard_parent_block(spec, state):
|
def test_pending_shard_parent_block(spec, state):
|
||||||
if not is_full_crosslink(spec, state):
|
|
||||||
# skip
|
|
||||||
return
|
|
||||||
|
|
||||||
# Block N
|
# Block N
|
||||||
beacon_state = state.copy()
|
beacon_state = state.copy()
|
||||||
transition_to_valid_shard_slot(spec, beacon_state)
|
transition_to_valid_shard_slot(spec, beacon_state)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
from eth2spec.utils.ssz.ssz_impl import hash_tree_root
|
from eth2spec.utils.ssz.ssz_impl import hash_tree_root
|
||||||
|
|
||||||
from eth2spec.test.context import PHASE0, spec_state_test, with_all_phases_except, never_bls
|
from eth2spec.test.context import PHASE0, spec_state_test, with_all_phases_except, never_bls, only_full_crosslink
|
||||||
from eth2spec.test.helpers.attestations import get_valid_on_time_attestation
|
from eth2spec.test.helpers.attestations import get_valid_on_time_attestation
|
||||||
from eth2spec.test.helpers.shard_block import (
|
from eth2spec.test.helpers.shard_block import (
|
||||||
build_shard_block,
|
build_shard_block,
|
||||||
|
@ -8,7 +8,6 @@ from eth2spec.test.helpers.shard_block import (
|
||||||
get_committee_index_of_shard,
|
get_committee_index_of_shard,
|
||||||
)
|
)
|
||||||
from eth2spec.test.helpers.fork_choice import add_block_to_store, get_anchor_root
|
from eth2spec.test.helpers.fork_choice import add_block_to_store, get_anchor_root
|
||||||
from eth2spec.test.helpers.shard_transitions import is_full_crosslink
|
|
||||||
from eth2spec.test.helpers.state import state_transition_and_sign_block
|
from eth2spec.test.helpers.state import state_transition_and_sign_block
|
||||||
from eth2spec.test.helpers.block import build_empty_block
|
from eth2spec.test.helpers.block import build_empty_block
|
||||||
|
|
||||||
|
@ -209,11 +208,8 @@ def create_simple_fork(spec, state, store, shard):
|
||||||
|
|
||||||
@with_all_phases_except([PHASE0])
|
@with_all_phases_except([PHASE0])
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
|
@only_full_crosslink
|
||||||
def test_shard_simple_fork(spec, state):
|
def test_shard_simple_fork(spec, state):
|
||||||
if not is_full_crosslink(spec, state):
|
|
||||||
# skip
|
|
||||||
return
|
|
||||||
|
|
||||||
spec.PHASE_1_GENESIS_SLOT = 0 # NOTE: mock genesis slot here
|
spec.PHASE_1_GENESIS_SLOT = 0 # NOTE: mock genesis slot here
|
||||||
state = spec.upgrade_to_phase1(state)
|
state = spec.upgrade_to_phase1(state)
|
||||||
shard = spec.Shard(1)
|
shard = spec.Shard(1)
|
||||||
|
@ -237,11 +233,8 @@ def test_shard_simple_fork(spec, state):
|
||||||
|
|
||||||
@with_all_phases_except([PHASE0])
|
@with_all_phases_except([PHASE0])
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
|
@only_full_crosslink
|
||||||
def test_shard_latest_messages_for_different_shards(spec, state):
|
def test_shard_latest_messages_for_different_shards(spec, state):
|
||||||
if not is_full_crosslink(spec, state):
|
|
||||||
# skip
|
|
||||||
return
|
|
||||||
|
|
||||||
spec.PHASE_1_GENESIS_SLOT = 0 # NOTE: mock genesis slot here
|
spec.PHASE_1_GENESIS_SLOT = 0 # NOTE: mock genesis slot here
|
||||||
state = spec.upgrade_to_phase1(state)
|
state = spec.upgrade_to_phase1(state)
|
||||||
shard_0 = spec.Shard(0)
|
shard_0 = spec.Shard(0)
|
||||||
|
|
|
@ -54,4 +54,3 @@ if __name__ == "__main__":
|
||||||
# gen_runner.run_generator(f"sanity", [
|
# gen_runner.run_generator(f"sanity", [
|
||||||
# create_provider(PHASE1, key, mod_name, 'mainnet') for key, mod_name in phase_1_mods
|
# create_provider(PHASE1, key, mod_name, 'mainnet') for key, mod_name in phase_1_mods
|
||||||
# ])
|
# ])
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue