Skip to content

Commit

Permalink
Rename LIGHTCLIENT -> LIGHTCLIENT_PATCH
Browse files Browse the repository at this point in the history
  • Loading branch information
hwwhww committed Dec 7, 2020
1 parent bda72e4 commit 6ee73a1
Show file tree
Hide file tree
Showing 20 changed files with 103 additions and 103 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ install_test:

test: pyspec
. venv/bin/activate; cd $(PY_SPEC_DIR); \
python -m pytest -n 4 --disable-bls --cov=eth2spec.phase0.spec --cov=eth2spec.phase1.spec --cov=eth2spec.lightclient.spec -cov-report="html:$(COV_HTML_OUT)" --cov-branch eth2spec
python -m pytest -n 4 --disable-bls --cov=eth2spec.phase0.spec --cov=eth2spec.phase1.spec --cov=eth2spec.lightclient_patch.spec -cov-report="html:$(COV_HTML_OUT)" --cov-branch eth2spec

find_test: pyspec
. venv/bin/activate; cd $(PY_SPEC_DIR); \
python -m pytest -k=$(K) --disable-bls --cov=eth2spec.phase0.spec --cov=eth2spec.phase1.spec --cov=eth2spec.lightclient.spec --cov-report="html:$(COV_HTML_OUT)" --cov-branch eth2spec
python -m pytest -k=$(K) --disable-bls --cov=eth2spec.phase0.spec --cov=eth2spec.phase1.spec --cov=eth2spec.lightclient_patch.spec --cov-report="html:$(COV_HTML_OUT)" --cov-branch eth2spec

citest: pyspec
mkdir -p tests/core/pyspec/test-reports/eth2spec; . venv/bin/activate; cd $(PY_SPEC_DIR); \
Expand All @@ -113,7 +113,7 @@ codespell:
lint: pyspec
. venv/bin/activate; cd $(PY_SPEC_DIR); \
flake8 --config $(LINTER_CONFIG_FILE) ./eth2spec \
&& mypy --config-file $(LINTER_CONFIG_FILE) -p eth2spec.phase0 -p eth2spec.phase1 -p eth2spec.lightclient
&& mypy --config-file $(LINTER_CONFIG_FILE) -p eth2spec.phase0 -p eth2spec.phase1 -p eth2spec.lightclient_patch

lint_generators: pyspec
. venv/bin/activate; cd $(TEST_GENERATORS_DIR); \
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ def combine_spec_objects(spec0: SpecObject, spec1: SpecObject) -> SpecObject:
fork_imports = {
'phase0': PHASE0_IMPORTS,
'phase1': PHASE1_IMPORTS,
'lightclient': LIGHTCLIENT_IMPORT,
'lightclient_patch': LIGHTCLIENT_IMPORT,
}


Expand Down Expand Up @@ -453,7 +453,7 @@ def finalize_options(self):
specs/phase1/shard-fork-choice.md
specs/phase1/validator.md
"""
elif self.spec_fork == "lightclient":
elif self.spec_fork == "lightclient_patch":
self.md_doc_paths = """
specs/phase0/beacon-chain.md
specs/phase0/fork-choice.md
Expand Down
18 changes: 9 additions & 9 deletions tests/core/pyspec/eth2spec/test/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from eth2spec.phase0 import spec as spec_phase0
from eth2spec.phase1 import spec as spec_phase1
from eth2spec.lightclient import spec as spec_lightclient
from eth2spec.lightclient_patch import spec as spec_lightclient_patch
from eth2spec.utils import bls

from .exceptions import SkippedTest
Expand All @@ -20,7 +20,7 @@
def reload_specs():
reload(spec_phase0)
reload(spec_phase1)
reload(spec_lightclient)
reload(spec_lightclient_patch)


# Some of the Spec module functionality is exposed here to deal with phase-specific changes.
Expand All @@ -30,9 +30,9 @@ def reload_specs():

PHASE0 = SpecForkName('phase0')
PHASE1 = SpecForkName('phase1')
LIGHTCLIENT = SpecForkName('lightclient')
LIGHTCLIENT_PATCH = SpecForkName('lightclient_patch')

ALL_PHASES = (PHASE0, PHASE1, LIGHTCLIENT)
ALL_PHASES = (PHASE0, PHASE1, LIGHTCLIENT_PATCH)

MAINNET = ConfigName('mainnet')
MINIMAL = ConfigName('minimal')
Expand Down Expand Up @@ -63,7 +63,7 @@ class SpecLightclient(Spec):
class SpecForks(TypedDict, total=False):
PHASE0: SpecPhase0
PHASE1: SpecPhase1
LIGHTCLIENT: SpecLightclient
LIGHTCLIENT_PATCH: SpecLightclient


def _prepare_state(balances_fn: Callable[[Any], Sequence[int]], threshold_fn: Callable[[Any], int],
Expand Down Expand Up @@ -346,16 +346,16 @@ def wrapper(*args, **kw):
phase_dir[PHASE0] = spec_phase0
if PHASE1 in available_phases:
phase_dir[PHASE1] = spec_phase1
if LIGHTCLIENT in available_phases:
phase_dir[LIGHTCLIENT] = spec_lightclient
if LIGHTCLIENT_PATCH in available_phases:
phase_dir[LIGHTCLIENT_PATCH] = spec_lightclient_patch

# return is ignored whenever multiple phases are ran. If
if PHASE0 in run_phases:
ret = fn(spec=spec_phase0, phases=phase_dir, *args, **kw)
if PHASE1 in run_phases:
ret = fn(spec=spec_phase1, phases=phase_dir, *args, **kw)
if LIGHTCLIENT in run_phases:
ret = fn(spec=spec_lightclient, phases=phase_dir, *args, **kw)
if LIGHTCLIENT_PATCH in run_phases:
ret = fn(spec=spec_lightclient_patch, phases=phase_dir, *args, **kw)
return ret
return wrapper
return decorator
Expand Down
4 changes: 2 additions & 2 deletions tests/core/pyspec/eth2spec/test/helpers/block.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from eth2spec.test.context import LIGHTCLIENT
from eth2spec.test.context import LIGHTCLIENT_PATCH
from eth2spec.test.helpers.keys import privkeys
from eth2spec.utils import bls
from eth2spec.utils.bls import only_with_bls
Expand Down Expand Up @@ -91,7 +91,7 @@ def build_empty_block(spec, state, slot=None):
empty_block.body.eth1_data.deposit_count = state.eth1_deposit_index
empty_block.parent_root = parent_block_root

if spec.fork == LIGHTCLIENT:
if spec.fork == LIGHTCLIENT_PATCH:
empty_block.sync_committee_signature = spec.G2_INFINITY_POINT_SIG

apply_randao_reveal(spec, state, empty_block)
Expand Down
4 changes: 2 additions & 2 deletions tests/core/pyspec/eth2spec/test/helpers/rewards.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from lru import LRU

from eth2spec.phase0 import spec as spec_phase0
from eth2spec.test.context import LIGHTCLIENT
from eth2spec.test.context import LIGHTCLIENT_PATCH
from eth2spec.test.helpers.attestations import cached_prepare_state_with_attestations
from eth2spec.test.helpers.deposits import mock_deposit
from eth2spec.test.helpers.state import next_epoch
Expand Down Expand Up @@ -160,7 +160,7 @@ def run_get_inactivity_penalty_deltas(spec, state):
continue

if spec.is_in_inactivity_leak(state):
if spec.fork == LIGHTCLIENT:
if spec.fork == LIGHTCLIENT_PATCH:
cancel_base_rewards_per_epoch = spec.BASE_REWARDS_PER_EPOCH - 1
else:
cancel_base_rewards_per_epoch = spec.BASE_REWARDS_PER_EPOCH
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from eth2spec.test.context import (
LIGHTCLIENT,
LIGHTCLIENT_PATCH,
spec_state_test, spec_test,
with_all_phases, single_phase,
with_phases, PHASE0,
Expand Down Expand Up @@ -163,7 +163,7 @@ def participation_tracker(slot, comm_index, comm):

pre_state = state.copy()

if spec.fork == LIGHTCLIENT:
if spec.fork == LIGHTCLIENT_PATCH:
sync_committee_indices = spec.get_sync_committee_indices(state, spec.get_current_epoch(state))

yield from run_process_rewards_and_penalties(spec, state)
Expand All @@ -177,7 +177,7 @@ def participation_tracker(slot, comm_index, comm):
if index in proposer_indices and index in participated:
assert state.balances[index] > pre_state.balances[index]
elif index in attesting_indices:
if spec.fork == LIGHTCLIENT and index in sync_committee_indices:
if spec.fork == LIGHTCLIENT_PATCH and index in sync_committee_indices:
# The sync committee reward has not been canceled, so the sync committee participants still earn it
assert state.balances[index] >= pre_state.balances[index]
else:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from eth2spec.test.context import PHASE0, PHASE1, LIGHTCLIENT, with_all_phases, spec_state_test
from eth2spec.test.context import PHASE0, PHASE1, LIGHTCLIENT_PATCH, with_all_phases, spec_state_test
from eth2spec.test.helpers.block import build_empty_block_for_next_slot
from eth2spec.test.helpers.attestations import get_valid_attestation, sign_attestation
from eth2spec.test.helpers.state import transition_to, state_transition_and_sign_block, next_epoch, next_slot
Expand All @@ -18,7 +18,7 @@ def run_on_attestation(spec, state, store, attestation, valid=True):
spec.on_attestation(store, attestation)

sample_index = indexed_attestation.attesting_indices[0]
if spec.fork in (PHASE0, LIGHTCLIENT):
if spec.fork in (PHASE0, LIGHTCLIENT_PATCH):
latest_message = spec.LatestMessage(
epoch=attestation.data.target.epoch,
root=attestation.data.beacon_block_root,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from eth2spec.test.context import (
PHASE0,
LIGHTCLIENT,
LIGHTCLIENT_PATCH,
with_all_phases_except,
spec_state_test,
always_bls,
Expand All @@ -13,7 +13,7 @@
)


@with_all_phases_except([PHASE0, LIGHTCLIENT])
@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH])
@spec_state_test
@always_bls
def test_on_time_success(spec, state):
Expand All @@ -24,7 +24,7 @@ def test_on_time_success(spec, state):
yield from run_attestation_processing(spec, state, attestation)


@with_all_phases_except([PHASE0, LIGHTCLIENT])
@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH])
@spec_state_test
@always_bls
def test_late_success(spec, state):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from eth2spec.test.helpers.state import transition_to, transition_to_valid_shard_slot
from eth2spec.test.context import (
PHASE0,
LIGHTCLIENT,
LIGHTCLIENT_PATCH,
MINIMAL,
expect_assertion_error,
disable_process_reveal_deadlines,
Expand Down Expand Up @@ -69,7 +69,7 @@ def run_custody_chunk_response_processing(spec, state, custody_response, valid=T
yield 'post', state


@with_all_phases_except([PHASE0, LIGHTCLIENT])
@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH])
@spec_state_test
@with_configs([MINIMAL], reason="too slow")
@disable_process_reveal_deadlines
Expand All @@ -93,7 +93,7 @@ def test_challenge_appended(spec, state):
yield from run_chunk_challenge_processing(spec, state, challenge)


@with_all_phases_except([PHASE0, LIGHTCLIENT])
@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH])
@spec_state_test
@disable_process_reveal_deadlines
@with_configs([MINIMAL], reason="too slow")
Expand All @@ -119,7 +119,7 @@ def test_challenge_empty_element_replaced(spec, state):
yield from run_chunk_challenge_processing(spec, state, challenge)


@with_all_phases_except([PHASE0, LIGHTCLIENT])
@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH])
@spec_state_test
@disable_process_reveal_deadlines
@with_configs([MINIMAL], reason="too slow")
Expand All @@ -145,7 +145,7 @@ def test_duplicate_challenge(spec, state):
yield from run_chunk_challenge_processing(spec, state, challenge, valid=False)


@with_all_phases_except([PHASE0, LIGHTCLIENT])
@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH])
@spec_state_test
@disable_process_reveal_deadlines
@with_configs([MINIMAL], reason="too slow")
Expand Down Expand Up @@ -173,7 +173,7 @@ def test_second_challenge(spec, state):
yield from run_chunk_challenge_processing(spec, state, challenge1)


@with_all_phases_except([PHASE0, LIGHTCLIENT])
@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH])
@spec_state_test
@disable_process_reveal_deadlines
@with_configs([MINIMAL], reason="too slow")
Expand All @@ -198,7 +198,7 @@ def test_multiple_epochs_custody(spec, state):
yield from run_chunk_challenge_processing(spec, state, challenge)


@with_all_phases_except([PHASE0, LIGHTCLIENT])
@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH])
@spec_state_test
@disable_process_reveal_deadlines
@with_configs([MINIMAL], reason="too slow")
Expand All @@ -223,7 +223,7 @@ def test_many_epochs_custody(spec, state):
yield from run_chunk_challenge_processing(spec, state, challenge)


@with_all_phases_except([PHASE0, LIGHTCLIENT])
@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH])
@spec_state_test
@disable_process_reveal_deadlines
@with_configs([MINIMAL], reason="too slow")
Expand All @@ -244,7 +244,7 @@ def test_off_chain_attestation(spec, state):
yield from run_chunk_challenge_processing(spec, state, challenge)


@with_all_phases_except([PHASE0, LIGHTCLIENT])
@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH])
@spec_state_test
@disable_process_reveal_deadlines
@with_configs([MINIMAL], reason="too slow")
Expand Down Expand Up @@ -276,7 +276,7 @@ def test_custody_response(spec, state):
yield from run_custody_chunk_response_processing(spec, state, custody_response)


@with_all_phases_except([PHASE0, LIGHTCLIENT])
@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH])
@spec_state_test
@disable_process_reveal_deadlines
@with_configs([MINIMAL], reason="too slow")
Expand Down Expand Up @@ -307,7 +307,7 @@ def test_custody_response_chunk_index_2(spec, state):
yield from run_custody_chunk_response_processing(spec, state, custody_response)


@with_all_phases_except([PHASE0, LIGHTCLIENT])
@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH])
@spec_state_test
@disable_process_reveal_deadlines
@with_configs([MINIMAL], reason="too slow")
Expand Down Expand Up @@ -339,7 +339,7 @@ def test_custody_response_multiple_epochs(spec, state):
yield from run_custody_chunk_response_processing(spec, state, custody_response)


@with_all_phases_except([PHASE0, LIGHTCLIENT])
@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH])
@spec_state_test
@disable_process_reveal_deadlines
@with_configs([MINIMAL], reason="too slow")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from eth2spec.test.helpers.custody import get_valid_custody_key_reveal
from eth2spec.test.context import (
PHASE0,
LIGHTCLIENT,
LIGHTCLIENT_PATCH,
with_all_phases_except,
spec_state_test,
expect_assertion_error,
Expand Down Expand Up @@ -40,7 +40,7 @@ def run_custody_key_reveal_processing(spec, state, custody_key_reveal, valid=Tru
yield 'post', state


@with_all_phases_except([PHASE0, LIGHTCLIENT])
@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH])
@spec_state_test
@always_bls
def test_success(spec, state):
Expand All @@ -50,7 +50,7 @@ def test_success(spec, state):
yield from run_custody_key_reveal_processing(spec, state, custody_key_reveal)


@with_all_phases_except([PHASE0, LIGHTCLIENT])
@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH])
@spec_state_test
@always_bls
def test_reveal_too_early(spec, state):
Expand All @@ -59,7 +59,7 @@ def test_reveal_too_early(spec, state):
yield from run_custody_key_reveal_processing(spec, state, custody_key_reveal, False)


@with_all_phases_except([PHASE0, LIGHTCLIENT])
@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH])
@spec_state_test
@always_bls
def test_wrong_period(spec, state):
Expand All @@ -68,7 +68,7 @@ def test_wrong_period(spec, state):
yield from run_custody_key_reveal_processing(spec, state, custody_key_reveal, False)


@with_all_phases_except([PHASE0, LIGHTCLIENT])
@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH])
@spec_state_test
@always_bls
def test_late_reveal(spec, state):
Expand All @@ -78,7 +78,7 @@ def test_late_reveal(spec, state):
yield from run_custody_key_reveal_processing(spec, state, custody_key_reveal)


@with_all_phases_except([PHASE0, LIGHTCLIENT])
@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH])
@spec_state_test
@always_bls
def test_double_reveal(spec, state):
Expand Down
Loading

0 comments on commit 6ee73a1

Please sign in to comment.