Turn off phase1 testgen and turn on lightclient_patch testgen

This commit is contained in:
Hsiao-Wei Wang 2021-02-15 18:38:20 +08:00
parent 019deb81fd
commit 600a4daddf
No known key found for this signature in database
GPG Key ID: 1111A8A81778319E
8 changed files with 126 additions and 71 deletions

View File

@ -1,5 +1,5 @@
from inspect import getmembers, isfunction from inspect import getmembers, isfunction
from typing import Any, Iterable from typing import Any, Iterable, Dict
from gen_base.gen_typing import TestCase from gen_base.gen_typing import TestCase
@ -38,3 +38,13 @@ def generate_from_tests(runner_name: str, handler_name: str, src: Any,
# TODO: with_all_phases and other per-phase tooling, should be replaced with per-fork equivalent. # TODO: with_all_phases and other per-phase tooling, should be replaced with per-fork equivalent.
case_fn=lambda: tfn(generator_mode=True, phase=fork_name, bls_active=bls_active) case_fn=lambda: tfn(generator_mode=True, phase=fork_name, bls_active=bls_active)
) )
def get_provider(create_provider_fn, config_name, fork_name, all_mods):
for key, mod_name in all_mods[fork_name].items():
yield create_provider_fn(
fork_name=fork_name,
handler_name=key,
tests_src_mod_name=mod_name,
config_name=config_name,
)

View File

@ -37,6 +37,10 @@ ALL_PHASES = (PHASE0, PHASE1, LIGHTCLIENT_PATCH)
MAINNET = ConfigName('mainnet') MAINNET = ConfigName('mainnet')
MINIMAL = ConfigName('minimal') MINIMAL = ConfigName('minimal')
ALL_CONFIGS = (MINIMAL, MAINNET)
# The forks that output to the test vectors.
TESTGEN_FORKS = (PHASE0, LIGHTCLIENT_PATCH)
# 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.

View File

@ -1,12 +1,13 @@
from typing import Iterable from typing import Iterable
from gen_base import gen_runner, gen_typing from gen_base import gen_runner, gen_typing
from gen_from_tests.gen import generate_from_tests from gen_from_tests.gen import generate_from_tests, get_provider
from importlib import reload, import_module from importlib import reload, import_module
from eth2spec.config import config_util from eth2spec.config import config_util
from eth2spec.phase0 import spec as spec_phase0 from eth2spec.phase0 import spec as spec_phase0
from eth2spec.lightclient_patch import spec as spec_lightclient_patch
from eth2spec.phase1 import spec as spec_phase1 from eth2spec.phase1 import spec as spec_phase1
from eth2spec.test.context import PHASE0, PHASE1 from eth2spec.test.context import PHASE0, PHASE1, LIGHTCLIENT_PATCH, TESTGEN_FORKS, ALL_CONFIGS
from eth2spec.utils import bls from eth2spec.utils import bls
@ -15,6 +16,7 @@ def create_provider(fork_name: str, handler_name: str,
def prepare_fn(configs_path: str) -> str: def prepare_fn(configs_path: str) -> str:
config_util.prepare_config(configs_path, config_name) config_util.prepare_config(configs_path, config_name)
reload(spec_phase0) reload(spec_phase0)
reload(spec_lightclient_patch)
reload(spec_phase1) reload(spec_phase1)
bls.use_milagro() bls.use_milagro()
return config_name return config_name
@ -44,21 +46,28 @@ if __name__ == "__main__":
'historical_roots_update', 'historical_roots_update',
'participation_record_updates', 'participation_record_updates',
]} ]}
lightclient_patch_mods = {
**{key: 'eth2spec.test.lightclient_patch.epoch_processing.test_process_' + key for key in [
'sync_committee_updates',
]},
**phase_0_mods,
} # also run the previous phase 0 tests
phase_1_mods = {**{key: 'eth2spec.test.phase1.epoch_processing.test_process_' + key for key in [ phase_1_mods = {**{key: 'eth2spec.test.phase1.epoch_processing.test_process_' + key for key in [
'reveal_deadlines', 'reveal_deadlines',
'challenge_deadlines', 'challenge_deadlines',
'custody_final_updates', 'custody_final_updates',
]}, **phase_0_mods} # also run the previous phase 0 tests (but against phase 1 spec) ]}, **phase_0_mods} # also run the previous phase 0 tests (but against phase 1 spec)
gen_runner.run_generator(f"epoch_processing", [ all_mods = {
create_provider(PHASE0, key, mod_name, 'minimal') for key, mod_name in phase_0_mods.items() PHASE0: phase_0_mods,
]) LIGHTCLIENT_PATCH: lightclient_patch_mods,
gen_runner.run_generator(f"epoch_processing", [ PHASE1: phase_1_mods,
create_provider(PHASE0, key, mod_name, 'mainnet') for key, mod_name in phase_0_mods.items() }
])
gen_runner.run_generator(f"epoch_processing", [ for config_name in ALL_CONFIGS:
create_provider(PHASE1, key, mod_name, 'minimal') for key, mod_name in phase_1_mods.items() for fork_name in TESTGEN_FORKS:
]) if fork_name in all_mods:
gen_runner.run_generator(f"epoch_processing", [ gen_runner.run_generator(f"epoch_processing", get_provider(
create_provider(PHASE1, key, mod_name, 'mainnet') for key, mod_name in phase_1_mods.items() create_provider_fn=create_provider, config_name=config_name,
]) fork_name=fork_name, all_mods=all_mods,
))

View File

@ -1,27 +1,30 @@
from typing import Iterable from typing import Iterable
from importlib import reload from importlib import reload, import_module
from gen_base import gen_runner, gen_typing from gen_base import gen_runner, gen_typing
from gen_from_tests.gen import generate_from_tests from gen_from_tests.gen import generate_from_tests, get_provider
from eth2spec.test.context import PHASE0, PHASE1 from eth2spec.test.context import PHASE0, PHASE1, LIGHTCLIENT_PATCH, TESTGEN_FORKS, ALL_CONFIGS
from eth2spec.test.phase0.finality import test_finality
from eth2spec.config import config_util from eth2spec.config import config_util
from eth2spec.phase0 import spec as spec_phase0 from eth2spec.phase0 import spec as spec_phase0
from eth2spec.lightclient_patch import spec as spec_lightclient_patch
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
def create_provider(fork_name: str, handler_name: str, tests_src, config_name: str) -> gen_typing.TestProvider: def create_provider(fork_name: str, handler_name: str,
tests_src_mod_name: str, config_name: str) -> gen_typing.TestProvider:
def prepare_fn(configs_path: str) -> str: def prepare_fn(configs_path: str) -> str:
config_util.prepare_config(configs_path, config_name) config_util.prepare_config(configs_path, config_name)
reload(spec_phase0) reload(spec_phase0)
reload(spec_lightclient_patch)
reload(spec_phase1) reload(spec_phase1)
bls.use_milagro() bls.use_milagro()
return config_name return config_name
def cases_fn() -> Iterable[gen_typing.TestCase]: def cases_fn() -> Iterable[gen_typing.TestCase]:
tests_src = import_module(tests_src_mod_name)
return generate_from_tests( return generate_from_tests(
runner_name='finality', runner_name='finality',
handler_name=handler_name, handler_name=handler_name,
@ -33,11 +36,21 @@ def create_provider(fork_name: str, handler_name: str, tests_src, config_name: s
if __name__ == "__main__": if __name__ == "__main__":
# No additional phase 1 specific rewards tests, yet. phase_0_mods = {'finality': 'eth2spec.test.phase0.finality.test_finality'}
key = 'finality' # No additional lightclient_patch or phase 1 specific finality tests, yet.
gen_runner.run_generator("finality", [ lightclient_patch_mods = phase_0_mods
create_provider(PHASE0, 'finality', test_finality, 'minimal'), phase_1_mods = phase_0_mods
create_provider(PHASE0, 'finality', test_finality, 'mainnet'),
create_provider(PHASE1, 'finality', test_finality, 'minimal'), all_mods = {
create_provider(PHASE1, 'finality', test_finality, 'mainnet'), PHASE0: phase_0_mods,
]) LIGHTCLIENT_PATCH: lightclient_patch_mods,
PHASE1: phase_1_mods,
}
for config_name in ALL_CONFIGS:
for fork_name in TESTGEN_FORKS:
if fork_name in all_mods:
gen_runner.run_generator(f"finality", get_provider(
create_provider_fn=create_provider, config_name=config_name,
fork_name=fork_name, all_mods=all_mods,
))

View File

@ -1,12 +1,13 @@
from typing import Iterable from typing import Iterable
from gen_base import gen_runner, gen_typing from gen_base import gen_runner, gen_typing
from gen_from_tests.gen import generate_from_tests from gen_from_tests.gen import generate_from_tests, get_provider
from importlib import reload, import_module from importlib import reload, import_module
from eth2spec.config import config_util from eth2spec.config import config_util
from eth2spec.phase0 import spec as spec_phase0 from eth2spec.phase0 import spec as spec_phase0
from eth2spec.lightclient_patch import spec as spec_lightclient_patch
from eth2spec.phase1 import spec as spec_phase1 from eth2spec.phase1 import spec as spec_phase1
from eth2spec.test.context import PHASE0, PHASE1 from eth2spec.test.context import PHASE0, PHASE1, LIGHTCLIENT_PATCH, TESTGEN_FORKS, ALL_CONFIGS
from eth2spec.utils import bls from eth2spec.utils import bls
@ -15,6 +16,7 @@ def create_provider(fork_name: str, handler_name: str,
def prepare_fn(configs_path: str) -> str: def prepare_fn(configs_path: str) -> str:
config_util.prepare_config(configs_path, config_name) config_util.prepare_config(configs_path, config_name)
reload(spec_phase0) reload(spec_phase0)
reload(spec_lightclient_patch)
reload(spec_phase1) reload(spec_phase1)
bls.use_milagro() bls.use_milagro()
return config_name return config_name
@ -40,6 +42,12 @@ if __name__ == "__main__":
'proposer_slashing', 'proposer_slashing',
'voluntary_exit', 'voluntary_exit',
]} ]}
lightclient_patch_mods = {
**{key: 'eth2spec.test.lightclient_patch.block_processing.test_process_' + key for key in [
'sync_committee',
]},
**phase_0_mods,
} # also run the previous phase 0 tests
phase_1_mods = {**{key: 'eth2spec.test.phase1.block_processing.test_process_' + key for key in [ phase_1_mods = {**{key: 'eth2spec.test.phase1.block_processing.test_process_' + key for key in [
'attestation', 'attestation',
'chunk_challenge', 'chunk_challenge',
@ -49,15 +57,16 @@ if __name__ == "__main__":
'shard_transition', 'shard_transition',
]}, **phase_0_mods} # also run the previous phase 0 tests (but against phase 1 spec) ]}, **phase_0_mods} # also run the previous phase 0 tests (but against phase 1 spec)
gen_runner.run_generator(f"operations", [ all_mods = {
create_provider(PHASE0, key, mod_name, 'minimal') for key, mod_name in phase_0_mods.items() PHASE0: phase_0_mods,
]) LIGHTCLIENT_PATCH: lightclient_patch_mods,
gen_runner.run_generator(f"operations", [ PHASE1: phase_1_mods,
create_provider(PHASE0, key, mod_name, 'mainnet') for key, mod_name in phase_0_mods.items() }
])
gen_runner.run_generator(f"operations", [ for config_name in ALL_CONFIGS:
create_provider(PHASE1, key, mod_name, 'minimal') for key, mod_name in phase_1_mods.items() for fork_name in TESTGEN_FORKS:
]) if fork_name in all_mods:
gen_runner.run_generator(f"operations", [ gen_runner.run_generator(f"operations", get_provider(
create_provider(PHASE1, key, mod_name, 'mainnet') for key, mod_name in phase_1_mods.items() create_provider_fn=create_provider, config_name=config_name,
]) fork_name=fork_name, all_mods=all_mods,
))

View File

@ -1,12 +1,13 @@
from typing import Iterable from typing import Iterable
from gen_base import gen_runner, gen_typing from gen_base import gen_runner, gen_typing
from gen_from_tests.gen import generate_from_tests from gen_from_tests.gen import generate_from_tests, get_provider
from importlib import reload, import_module from importlib import reload, import_module
from eth2spec.config import config_util from eth2spec.config import config_util
from eth2spec.phase0 import spec as spec_phase0 from eth2spec.phase0 import spec as spec_phase0
from eth2spec.lightclient_patch import spec as spec_lightclient_patch
from eth2spec.phase1 import spec as spec_phase1 from eth2spec.phase1 import spec as spec_phase1
from eth2spec.test.context import PHASE0, PHASE1 from eth2spec.test.context import PHASE0, PHASE1, LIGHTCLIENT_PATCH, TESTGEN_FORKS, ALL_CONFIGS
from eth2spec.utils import bls from eth2spec.utils import bls
@ -15,6 +16,7 @@ def create_provider(fork_name: str, handler_name: str,
def prepare_fn(configs_path: str) -> str: def prepare_fn(configs_path: str) -> str:
config_util.prepare_config(configs_path, config_name) config_util.prepare_config(configs_path, config_name)
reload(spec_phase0) reload(spec_phase0)
reload(spec_lightclient_patch)
reload(spec_phase1) reload(spec_phase1)
bls.use_milagro() bls.use_milagro()
return config_name return config_name
@ -37,18 +39,20 @@ if __name__ == "__main__":
'leak', 'leak',
'random', 'random',
]} ]}
# No additional phase 1 specific rewards tests, yet. # No additional lightclient_patch or phase 1 specific rewards tests, yet.
lightclient_patch_mods = phase_0_mods
phase_1_mods = phase_0_mods phase_1_mods = phase_0_mods
gen_runner.run_generator(f"rewards", [ all_mods = {
create_provider(PHASE0, key, mod_name, 'minimal') for key, mod_name in phase_0_mods.items() PHASE0: phase_0_mods,
]) LIGHTCLIENT_PATCH: lightclient_patch_mods,
gen_runner.run_generator(f"rewards", [ PHASE1: phase_1_mods,
create_provider(PHASE0, key, mod_name, 'mainnet') for key, mod_name in phase_0_mods.items() }
])
gen_runner.run_generator(f"rewards", [ for config_name in ALL_CONFIGS:
create_provider(PHASE1, key, mod_name, 'minimal') for key, mod_name in phase_1_mods.items() for fork_name in TESTGEN_FORKS:
]) if fork_name in all_mods:
gen_runner.run_generator(f"rewards", [ gen_runner.run_generator(f"rewards", get_provider(
create_provider(PHASE1, key, mod_name, 'mainnet') for key, mod_name in phase_1_mods.items() create_provider_fn=create_provider, config_name=config_name,
]) fork_name=fork_name, all_mods=all_mods,
))

View File

@ -1,12 +1,13 @@
from typing import Iterable from typing import Iterable
from gen_base import gen_runner, gen_typing from gen_base import gen_runner, gen_typing
from gen_from_tests.gen import generate_from_tests from gen_from_tests.gen import generate_from_tests, get_provider
from importlib import reload, import_module from importlib import reload, import_module
from eth2spec.config import config_util from eth2spec.config import config_util
from eth2spec.phase0 import spec as spec_phase0 from eth2spec.phase0 import spec as spec_phase0
from eth2spec.lightclient_patch import spec as spec_lightclient_patch
from eth2spec.phase1 import spec as spec_phase1 from eth2spec.phase1 import spec as spec_phase1
from eth2spec.test.context import PHASE0, PHASE1 from eth2spec.test.context import PHASE0, PHASE1, LIGHTCLIENT_PATCH, TESTGEN_FORKS, ALL_CONFIGS
from eth2spec.utils import bls from eth2spec.utils import bls
@ -15,6 +16,7 @@ def create_provider(fork_name: str, handler_name: str,
def prepare_fn(configs_path: str) -> str: def prepare_fn(configs_path: str) -> str:
config_util.prepare_config(configs_path, config_name) config_util.prepare_config(configs_path, config_name)
reload(spec_phase0) reload(spec_phase0)
reload(spec_lightclient_patch)
reload(spec_phase1) reload(spec_phase1)
bls.use_milagro() bls.use_milagro()
return config_name return config_name
@ -36,20 +38,24 @@ if __name__ == "__main__":
'blocks', 'blocks',
'slots', 'slots',
]} ]}
lightclient_patch_mods = {**{key: 'eth2spec.test.lightclient_patch.sanity.test_' + key for key in [
'blocks',
]}, **phase_0_mods} # also run the previous phase 0 tests
phase_1_mods = {**{key: 'eth2spec.test.phase1.sanity.test_' + key for key in [ phase_1_mods = {**{key: 'eth2spec.test.phase1.sanity.test_' + key for key in [
'blocks', # more phase 1 specific block tests 'blocks', # more phase 1 specific block tests
'shard_blocks', 'shard_blocks',
]}, **phase_0_mods} # also run the previous phase 0 tests (but against phase 1 spec) ]}, **phase_0_mods} # also run the previous phase 0 tests (but against phase 1 spec)
gen_runner.run_generator(f"sanity", [ all_mods = {
create_provider(PHASE0, key, mod_name, 'minimal') for key, mod_name in phase_0_mods.items() PHASE0: phase_0_mods,
]) LIGHTCLIENT_PATCH: lightclient_patch_mods,
gen_runner.run_generator(f"sanity", [ PHASE1: phase_1_mods,
create_provider(PHASE0, key, mod_name, 'mainnet') for key, mod_name in phase_0_mods.items() }
])
gen_runner.run_generator(f"sanity", [ for config_name in ALL_CONFIGS:
create_provider(PHASE1, key, mod_name, 'minimal') for key, mod_name in phase_1_mods.items() for fork_name in TESTGEN_FORKS:
]) if fork_name in all_mods:
gen_runner.run_generator(f"sanity", [ gen_runner.run_generator(f"sanity", get_provider(
create_provider(PHASE1, key, mod_name, 'mainnet') for key, mod_name in phase_1_mods.items() create_provider_fn=create_provider, config_name=config_name,
]) fork_name=fork_name, all_mods=all_mods,
))