diff --git a/.gitignore b/.gitignore index bcd96f885..17d058225 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ eth2.0-spec-tests/ # Dynamically built from Markdown spec tests/core/pyspec/eth2spec/phase0/ tests/core/pyspec/eth2spec/phase1/ +tests/core/pyspec/eth2spec/lightclient_patch/ # coverage reports .htmlcov diff --git a/Makefile b/Makefile index 8fa104444..987650948 100644 --- a/Makefile +++ b/Makefile @@ -20,7 +20,7 @@ GENERATOR_VENVS = $(patsubst $(GENERATOR_DIR)/%, $(GENERATOR_DIR)/%venv, $(GENER # To check generator matching: #$(info $$GENERATOR_TARGETS is [${GENERATOR_TARGETS}]) -MARKDOWN_FILES = $(wildcard $(SPEC_DIR)/phase0/*.md) $(wildcard $(SPEC_DIR)/phase1/*.md) $(wildcard $(SSZ_DIR)/*.md) $(wildcard $(SPEC_DIR)/networking/*.md) $(wildcard $(SPEC_DIR)/validator/*.md) +MARKDOWN_FILES = $(wildcard $(SPEC_DIR)/phase0/*.md) $(wildcard $(SPEC_DIR)/phase1/*.md) $(wildcard $(SPEC_DIR)/lightclient/*.md) $(wildcard $(SSZ_DIR)/*.md) $(wildcard $(SPEC_DIR)/networking/*.md) $(wildcard $(SPEC_DIR)/validator/*.md) COV_HTML_OUT=.htmlcov COV_INDEX_FILE=$(PY_SPEC_DIR)/$(COV_HTML_OUT)/index.html @@ -49,6 +49,7 @@ partial_clean: rm -rf $(DEPOSIT_CONTRACT_TESTER_DIR)/.pytest_cache rm -rf $(PY_SPEC_DIR)/phase0 rm -rf $(PY_SPEC_DIR)/phase1 + rm -rf $(PY_SPEC_DIR)/lightclient rm -rf $(PY_SPEC_DIR)/$(COV_HTML_OUT) rm -rf $(PY_SPEC_DIR)/.coverage rm -rf $(PY_SPEC_DIR)/test-reports @@ -85,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-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-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); \ @@ -112,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 + && 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); \ diff --git a/configs/mainnet/lightclient_patch.yaml b/configs/mainnet/lightclient_patch.yaml new file mode 100644 index 000000000..64c05a720 --- /dev/null +++ b/configs/mainnet/lightclient_patch.yaml @@ -0,0 +1,21 @@ +# Mainnet preset - lightclient patch + +CONFIG_NAME: "mainnet" + +# Misc +# --------------------------------------------------------------- +# 2**10 (=1,024) +SYNC_COMMITTEE_SIZE: 1024 +# 2**6 (=64) +SYNC_COMMITTEE_PUBKEY_AGGREGATES_SIZE: 64 + + +# Time parameters +# --------------------------------------------------------------- +# 2**8 (= 256) +EPOCHS_PER_SYNC_COMMITTEE_PERIOD: 256 + + +# Signature domains +# --------------------------------------------------------------- +DOMAIN_SYNC_COMMITTEE: 0x07000000 diff --git a/configs/minimal/lightclient_patch.yaml b/configs/minimal/lightclient_patch.yaml new file mode 100644 index 000000000..ba1179a2b --- /dev/null +++ b/configs/minimal/lightclient_patch.yaml @@ -0,0 +1,21 @@ +# Minimal preset - lightclient patch + +CONFIG_NAME: "minimal" + +# Misc +# --------------------------------------------------------------- +# [customized] +SYNC_COMMITTEE_SIZE: 64 +# [customized] +SYNC_COMMITTEE_PUBKEY_AGGREGATES_SIZE: 16 + + +# Time parameters +# --------------------------------------------------------------- +# 2**8 (= 256) +EPOCHS_PER_SYNC_COMMITTEE_PERIOD: 256 + + +# Signature domains +# --------------------------------------------------------------- +DOMAIN_SYNC_COMMITTEE: 0x07000000 diff --git a/setup.py b/setup.py index 9c2de0751..bd043dccc 100644 --- a/setup.py +++ b/setup.py @@ -52,8 +52,9 @@ def get_spec(file_name: str) -> SpecObject: else: # Handle function definitions & ssz_objects if pulling_from is not None: - if len(line) > 18 and line[:6] == 'class ' and line[-12:] == '(Container):': - name = line[6:-12] + if len(line) > 18 and line[:6] == 'class ' and (line[-12:] == '(Container):' or '(phase' in line): + end = -12 if line[-12:] == '(Container):' else line.find('(') + name = line[6:end] # Check consistency with markdown header assert name == current_name block_type = CodeBlockType.SSZ @@ -156,6 +157,40 @@ SSZObject = TypeVar('SSZObject', bound=View) CONFIG_NAME = 'mainnet' ''' +LIGHTCLIENT_IMPORT = '''from eth2spec.phase0 import spec as phase0 +from eth2spec.config.config_util import apply_constants_config +from typing import ( + Any, Dict, Set, Sequence, NewType, Tuple, TypeVar, Callable, Optional +) + +from dataclasses import ( + dataclass, + field, +) + +from lru import LRU + +from eth2spec.utils.ssz.ssz_impl import hash_tree_root, copy, uint_to_bytes +from eth2spec.utils.ssz.ssz_typing import ( + View, boolean, Container, List, Vector, uint8, uint32, uint64, + Bytes1, Bytes4, Bytes32, Bytes48, Bytes96, Bitlist, Bitvector, +) +from eth2spec.utils import bls + +from eth2spec.utils.hash_function import hash + +# Whenever lightclient is loaded, make sure we have the latest phase0 +from importlib import reload +reload(phase0) + + +SSZVariableName = str +GeneralizedIndex = NewType('GeneralizedIndex', int) +SSZObject = TypeVar('SSZObject', bound=View) + +CONFIG_NAME = 'mainnet' +''' + SUNDRY_CONSTANTS_FUNCTIONS = ''' def ceillog2(x: int) -> uint64: if x < 1: @@ -351,6 +386,7 @@ def combine_spec_objects(spec0: SpecObject, spec1: SpecObject) -> SpecObject: fork_imports = { 'phase0': PHASE0_IMPORTS, 'phase1': PHASE1_IMPORTS, + 'lightclient_patch': LIGHTCLIENT_IMPORT, } @@ -417,6 +453,16 @@ class PySpecCommand(Command): specs/phase1/shard-fork-choice.md specs/phase1/validator.md """ + elif self.spec_fork == "lightclient_patch": + self.md_doc_paths = """ + specs/phase0/beacon-chain.md + specs/phase0/fork-choice.md + specs/phase0/validator.md + specs/phase0/weak-subjectivity.md + specs/lightclient/beacon-chain.md + specs/lightclient/lightclient-fork.md + """ + # TODO: add specs/lightclient/sync-protocol.md back when the GeneralizedIndex helpers are included. else: raise Exception('no markdown files specified, and spec fork "%s" is unknown', self.spec_fork) @@ -539,7 +585,7 @@ setup( "py_ecc==5.0.0", "milagro_bls_binding==1.5.0", "dataclasses==0.6", - "remerkleable==0.1.17", + "remerkleable==0.1.18", "ruamel.yaml==0.16.5", "lru-dict==1.1.6" ] diff --git a/specs/lightclient/beacon-chain.md b/specs/lightclient/beacon-chain.md new file mode 100644 index 000000000..3b03ad853 --- /dev/null +++ b/specs/lightclient/beacon-chain.md @@ -0,0 +1,249 @@ +# Ethereum 2.0 Light Client Support + +## Table of contents + + + + + +- [Introduction](#introduction) +- [Constants](#constants) +- [Configuration](#configuration) + - [Constants](#constants-1) + - [Misc](#misc) + - [Time parameters](#time-parameters) + - [Domain types](#domain-types) +- [Containers](#containers) + - [Extended containers](#extended-containers) + - [`BeaconBlockBody`](#beaconblockbody) + - [`BeaconState`](#beaconstate) + - [New containers](#new-containers) + - [`SyncCommittee`](#synccommittee) +- [Helper functions](#helper-functions) + - [`Predicates`](#predicates) + - [`eth2_fast_aggregate_verify`](#eth2_fast_aggregate_verify) + - [Beacon state accessors](#beacon-state-accessors) + - [`get_sync_committee_indices`](#get_sync_committee_indices) + - [`get_sync_committee`](#get_sync_committee) + - [Block processing](#block-processing) + - [Sync committee processing](#sync-committee-processing) + - [Epoch processing](#epoch-processing) + - [Components of attestation deltas](#components-of-attestation-deltas) + - [Final updates](#final-updates) + + + + +## Introduction + +This is a standalone beacon chain patch adding light client support via sync committees. + +## Constants + +| Name | Value | +| - | - | +| `BASE_REWARDS_PER_EPOCH` | `uint64(5)` | + +## Configuration + +### Constants + +| Name | Value | +| - | - | +| `G2_POINT_AT_INFINITY` | `BLSSignature(b'\xc0' + b'\x00' * 95)` | + +### Misc + +| Name | Value | +| - | - | +| `SYNC_COMMITTEE_SIZE` | `uint64(2**10)` (= 1024) | +| `SYNC_COMMITTEE_PUBKEY_AGGREGATES_SIZE` | `uint64(2**6)` (= 64) | + +### Time parameters + +| Name | Value | Unit | Duration | +| - | - | :-: | :-: | +| `EPOCHS_PER_SYNC_COMMITTEE_PERIOD` | `Epoch(2**8)` (= 256) | epochs | ~27 hours | + +### Domain types + +| Name | Value | +| - | - | +| `DOMAIN_SYNC_COMMITTEE` | `DomainType('0x07000000')` | + +## Containers + +### Extended containers + +*Note*: Extended SSZ containers inherit all fields from the parent in the original +order and append any additional fields to the end. + +#### `BeaconBlockBody` + +```python +class BeaconBlockBody(phase0.BeaconBlockBody): + # Sync committee aggregate signature + sync_committee_bits: Bitvector[SYNC_COMMITTEE_SIZE] + sync_committee_signature: BLSSignature +``` + +#### `BeaconState` + +```python +class BeaconState(phase0.BeaconState): + # Sync committees + current_sync_committee: SyncCommittee + next_sync_committee: SyncCommittee +``` + +### New containers + +#### `SyncCommittee` + +```python +class SyncCommittee(Container): + pubkeys: Vector[BLSPubkey, SYNC_COMMITTEE_SIZE] + pubkey_aggregates: Vector[BLSPubkey, SYNC_COMMITTEE_SIZE // SYNC_COMMITTEE_PUBKEY_AGGREGATES_SIZE] +``` + +## Helper functions + +### `Predicates` + +#### `eth2_fast_aggregate_verify` + +```python +def eth2_fast_aggregate_verify(pubkeys: Sequence[BLSPubkey], message: Bytes32, signature: BLSSignature) -> bool: + """ + Wrapper to ``bls.FastAggregateVerify`` accepting the ``G2_POINT_AT_INFINITY`` signature when ``pubkeys`` is empty. + """ + if len(pubkeys) == 0 and signature == G2_POINT_AT_INFINITY: + return True + return bls.FastAggregateVerify(pubkeys, message, signature) +``` + +### Beacon state accessors + +#### `get_sync_committee_indices` + +```python +def get_sync_committee_indices(state: BeaconState, epoch: Epoch) -> Sequence[ValidatorIndex]: + """ + Return the sync committee indices for a given state and epoch. + """ + MAX_RANDOM_BYTE = 2**8 - 1 + base_epoch = Epoch((max(epoch // EPOCHS_PER_SYNC_COMMITTEE_PERIOD, 1) - 1) * EPOCHS_PER_SYNC_COMMITTEE_PERIOD) + active_validator_indices = get_active_validator_indices(state, base_epoch) + active_validator_count = uint64(len(active_validator_indices)) + seed = get_seed(state, base_epoch, DOMAIN_SYNC_COMMITTEE) + i = 0 + sync_committee_indices: List[ValidatorIndex] = [] + while len(sync_committee_indices) < SYNC_COMMITTEE_SIZE: + shuffled_index = compute_shuffled_index(uint64(i % active_validator_count), active_validator_count, seed) + candidate_index = active_validator_indices[shuffled_index] + random_byte = hash(seed + uint_to_bytes(uint64(i // 32)))[i % 32] + effective_balance = state.validators[candidate_index].effective_balance + if effective_balance * MAX_RANDOM_BYTE >= MAX_EFFECTIVE_BALANCE * random_byte: + sync_committee_indices.append(candidate_index) + i += 1 + return sync_committee_indices +``` + +#### `get_sync_committee` + +```python +def get_sync_committee(state: BeaconState, epoch: Epoch) -> SyncCommittee: + """ + Return the sync committee for a given state and epoch. + """ + indices = get_sync_committee_indices(state, epoch) + validators = [state.validators[index] for index in indices] + pubkeys = [validator.pubkey for validator in validators] + aggregates = [ + bls.AggregatePKs(pubkeys[i:i + SYNC_COMMITTEE_PUBKEY_AGGREGATES_SIZE]) + for i in range(0, len(pubkeys), SYNC_COMMITTEE_PUBKEY_AGGREGATES_SIZE) + ] + return SyncCommittee(pubkeys=pubkeys, pubkey_aggregates=aggregates) +``` + +### Block processing + +```python +def process_block(state: BeaconState, block: BeaconBlock) -> None: + process_block_header(state, block) + process_randao(state, block.body) + process_eth1_data(state, block.body) + process_operations(state, block.body) + # Light client support + process_sync_committee(state, block.body) +``` + +#### Sync committee processing + +```python +def process_sync_committee(state: BeaconState, body: BeaconBlockBody) -> None: + # Verify sync committee aggregate signature signing over the previous slot block root + previous_slot = Slot(max(int(state.slot), 1) - 1) + committee_indices = get_sync_committee_indices(state, get_current_epoch(state)) + participant_indices = [index for index, bit in zip(committee_indices, body.sync_committee_bits) if bit] + committee_pubkeys = state.current_sync_committee.pubkeys + participant_pubkeys = [pubkey for pubkey, bit in zip(committee_pubkeys, body.sync_committee_bits) if bit] + domain = get_domain(state, DOMAIN_SYNC_COMMITTEE, compute_epoch_at_slot(previous_slot)) + signing_root = compute_signing_root(get_block_root_at_slot(state, previous_slot), domain) + assert eth2_fast_aggregate_verify(participant_pubkeys, signing_root, body.sync_committee_signature) + + # Reward sync committee participants + proposer_reward = Gwei(0) + active_validator_count = uint64(len(get_active_validator_indices(state, get_current_epoch(state)))) + for participant_index in participant_indices: + base_reward = get_base_reward(state, participant_index) + max_participant_reward = base_reward - base_reward // PROPOSER_REWARD_QUOTIENT + reward = Gwei(max_participant_reward * active_validator_count // len(committee_indices) // SLOTS_PER_EPOCH) + increase_balance(state, participant_index, reward) + proposer_reward += base_reward // PROPOSER_REWARD_QUOTIENT + + # Reward beacon proposer + increase_balance(state, get_beacon_proposer_index(state), proposer_reward) +``` + +### Epoch processing + +#### Components of attestation deltas + +*Note*: The function `get_inactivity_penalty_deltas` is modified with `BASE_REWARDS_PER_EPOCH` replaced by `BASE_REWARDS_PER_EPOCH - 1`. + +```python +def get_inactivity_penalty_deltas(state: BeaconState) -> Tuple[Sequence[Gwei], Sequence[Gwei]]: + """ + Return inactivity reward/penalty deltas for each validator. + """ + penalties = [Gwei(0) for _ in range(len(state.validators))] + if is_in_inactivity_leak(state): + matching_target_attestations = get_matching_target_attestations(state, get_previous_epoch(state)) + matching_target_attesting_indices = get_unslashed_attesting_indices(state, matching_target_attestations) + for index in get_eligible_validator_indices(state): + # Penalize validator so that optimal attestation performance is rewarded with one base reward per epoch + base_reward = get_base_reward(state, index) + penalties[index] += Gwei((BASE_REWARDS_PER_EPOCH - 1) * base_reward - get_proposer_reward(state, index)) + if index not in matching_target_attesting_indices: + effective_balance = state.validators[index].effective_balance + penalties[index] += Gwei(effective_balance * get_finality_delay(state) // INACTIVITY_PENALTY_QUOTIENT) + + # No rewards associated with inactivity penalties + rewards = [Gwei(0) for _ in range(len(state.validators))] + return rewards, penalties +``` + +#### Final updates + +*Note*: The function `process_final_updates` is modified to handle sync committee updates. + +```python +def process_final_updates(state: BeaconState) -> None: + # FIXME: unfold the full `process_final_updates` to avoid side effects. + phase0.process_final_updates(state) + next_epoch = get_current_epoch(state) + Epoch(1) + if next_epoch % EPOCHS_PER_SYNC_COMMITTEE_PERIOD == 0: + state.current_sync_committee = state.next_sync_committee + state.next_sync_committee = get_sync_committee(state, next_epoch + EPOCHS_PER_SYNC_COMMITTEE_PERIOD) +``` diff --git a/specs/lightclient/lightclient-fork.md b/specs/lightclient/lightclient-fork.md new file mode 100644 index 000000000..568a9793b --- /dev/null +++ b/specs/lightclient/lightclient-fork.md @@ -0,0 +1,83 @@ +# Ethereum 2.0 Light Client Support -- From Phase 0 to Light Client Patch + +**Notice**: This document is a work-in-progress for researchers and implementers. + +## Table of contents + + + + +- [Introduction](#introduction) +- [Configuration](#configuration) +- [Fork to Light-client patch](#fork-to-light-client-patch) + - [Fork trigger](#fork-trigger) + - [Upgrading the state](#upgrading-the-state) + + + +## Introduction + +This document describes the process of moving from Phase 0 to Phase 1 of Ethereum 2.0. + +## Configuration + +Warning: this configuration is not definitive. + +| Name | Value | +| - | - | +| `LIGHTCLIENT_PATCH_FORK_VERSION` | `Version('0x01000000')` | +| `LIGHTCLIENT_PATCH_FORK_SLOT` | `Slot(0)` **TBD** | + +## Fork to Light-client patch + +### Fork trigger + +TBD. Social consensus, along with state conditions such as epoch boundary, finality, deposits, active validator count, etc. may be part of the decision process to trigger the fork. For now we assume the condition will be triggered at slot `LIGHTCLIENT_PATCH_FORK_SLOT`, where `LIGHTCLIENT_PATCH_FORK_SLOT % SLOTS_PER_EPOCH == 0`. + +### Upgrading the state + +After `process_slots` of Phase 0 finishes, if `state.slot == LIGHTCLIENT_PATCH_FORK_SLOT`, an irregular state change is made to upgrade to light-client patch. + +```python +def upgrade_to_lightclient_patch(pre: phase0.BeaconState) -> BeaconState: + epoch = get_current_epoch(pre) + post = BeaconState( + genesis_time=pre.genesis_time, + slot=pre.slot, + fork=Fork( + previous_version=pre.fork.current_version, + current_version=LIGHTCLIENT_PATCH_FORK_VERSION, + epoch=epoch, + ), + # History + latest_block_header=pre.latest_block_header, + block_roots=pre.block_roots, + state_roots=pre.state_roots, + historical_roots=pre.historical_roots, + # Eth1 + eth1_data=pre.eth1_data, + eth1_data_votes=pre.eth1_data_votes, + eth1_deposit_index=pre.eth1_deposit_index, + # Registry + validators=pre.validators, + balances=pre.balances, + # Randomness + randao_mixes=pre.randao_mixes, + # Slashings + slashings=pre.slashings, + # Attestations + # previous_epoch_attestations is cleared on upgrade. + previous_epoch_attestations=List[PendingAttestation, MAX_ATTESTATIONS * SLOTS_PER_EPOCH](), + # empty in pre state, since the upgrade is performed just after an epoch boundary. + current_epoch_attestations=List[PendingAttestation, MAX_ATTESTATIONS * SLOTS_PER_EPOCH](), + # Finality + justification_bits=pre.justification_bits, + previous_justified_checkpoint=pre.previous_justified_checkpoint, + current_justified_checkpoint=pre.current_justified_checkpoint, + finalized_checkpoint=pre.finalized_checkpoint, + ) + # Fill in sync committees + post.current_sync_committee = get_sync_committee(post, get_current_epoch(post)) + post.next_sync_committee = get_sync_committee(post, get_current_epoch(post) + EPOCHS_PER_SYNC_COMMITTEE_PERIOD) + return post +``` diff --git a/specs/lightclient/sync-protocol.md b/specs/lightclient/sync-protocol.md new file mode 100644 index 000000000..310aad2df --- /dev/null +++ b/specs/lightclient/sync-protocol.md @@ -0,0 +1,184 @@ +# Minimal Light Client + +**Notice**: This document is a work-in-progress for researchers and implementers. + +## Table of contents + + + + + +- [Introduction](#introduction) +- [Constants](#constants) +- [Configuration](#configuration) + - [Misc](#misc) + - [Time parameters](#time-parameters) +- [Containers](#containers) + - [`LightClientSnapshot`](#lightclientsnapshot) + - [`LightClientUpdate`](#lightclientupdate) + - [`LightClientStore`](#lightclientstore) +- [Light client state updates](#light-client-state-updates) + - [`is_valid_light_client_update`](#is_valid_light_client_update) + - [`apply_light_client_update`](#apply_light_client_update) + - [`process_light_client_update`](#process_light_client_update) + + + + +## Introduction + +Eth2 is designed to be light client friendly for constrained environments to +access Eth2 with reasonable safety and liveness. +Such environments include resource-constrained devices (e.g. phones for trust-minimised wallets) +and metered VMs (e.g. blockchain VMs for cross-chain bridges). + +This document suggests a minimal light client design for the beacon chain that +uses sync committees introduced in [this beacon chain extension](./beacon-chain.md). + +## Constants + +| Name | Value | +| - | - | +| `FINALIZED_ROOT_INDEX` | `Index(BeaconState, 'finalized_checkpoint', 'root')` | +| `NEXT_SYNC_COMMITTEE_INDEX` | `Index(BeaconState, 'next_sync_committee')` | + +## Configuration + +### Misc + +| Name | Value | +| - | - | +| `MIN_SYNC_COMMITTEE_PARTICIPANTS` | `1` | +| `MAX_VALID_LIGHT_CLIENT_UPDATES` | `uint64(2**64 - 1)` | + +### Time parameters + +| Name | Value | Unit | Duration | +| - | - | :-: | :-: | +| `LIGHT_CLIENT_UPDATE_TIMEOUT` | `Slot(2**13)` | slots | ~27 hours | + +## Containers + +#### `LightClientSnapshot` + +```python +class LightClientSnapshot(Container): + # Beacon block header + header: BeaconBlockHeader + # Sync committees corresponding to the header + current_sync_committee: SyncCommittee + next_sync_committee: SyncCommittee +``` + +#### `LightClientUpdate` + +```python +class LightClientUpdate(Container): + # Update beacon block header + header: BeaconBlockHeader + # Next sync committee corresponding to the header + next_sync_committee: SyncCommittee + next_sync_committee_branch: Vector[Bytes32, log2(NEXT_SYNC_COMMITTEE_INDEX)] + # Finality proof for the update header + finality_header: BeaconBlockHeader + finality_branch: Vector[Bytes32, log2(FINALIZED_ROOT_INDEX)] + # Sync committee aggregate signature + sync_committee_bits: Bitvector[SYNC_COMMITTEE_SIZE] + sync_committee_signature: BLSSignature + # Fork version for the aggregate signature + fork_version: Version +``` + +#### `LightClientStore` + +```python +class LightClientStore(Container): + snapshot: LightClientSnapshot + valid_updates: List[LightClientUpdate, MAX_VALID_LIGHT_CLIENT_UPDATES] +``` + +## Light client state updates + +A light client maintains its state in a `store` object of type `LightClientStore` and receives `update` objects of type `LightClientUpdate`. Every `update` triggers `process_light_client_update(store, update, current_slot)` where `current_slot` is the current slot based on some local clock. + +#### `is_valid_light_client_update` + +```python +def is_valid_light_client_update(snapshot: LightClientSnapshot, update: LightClientUpdate) -> bool: + # Verify update slot is larger than snapshot slot + assert update.header.slot > snapshot.header.slot + + # Verify update does not skip a sync committee period + snapshot_period = compute_epoch_at_slot(snapshot.header.slot) // EPOCHS_PER_SYNC_COMMITTEE_PERIOD + update_period = compute_epoch_at_slot(update.header.slot) // EPOCHS_PER_SYNC_COMMITTEE_PERIOD + assert update_period in (snapshot_period, snapshot_period + 1) + + # Verify update header root is the finalized root of the finality header, if specified + if update.finality_header == BeaconBlockHeader(): + signed_header = update.header + assert update.finality_branch == [ZERO_HASH for _ in range(log2(FINALIZED_ROOT_INDEX))] + else: + signed_header = update.finality_header + assert is_valid_merkle_branch( + leaf=hash_tree_root(update.header), + branch=update.finality_branch, + depth=log2(FINALIZED_ROOT_INDEX), + index=FINALIZED_ROOT_INDEX % 2**log2(FINALIZED_ROOT_INDEX), + root=update.finality_header.state_root, + ) + + # Verify update next sync committee if the update period incremented + if update_period == snapshot_period: + sync_committee = snapshot.current_sync_committee + assert update.next_sync_committee_branch == [ZERO_HASH for _ in range(log2(NEXT_SYNC_COMMITTEE_INDEX))] + else: + sync_committee = snapshot.next_sync_committee + assert is_valid_merkle_branch( + leaf=hash_tree_root(update.next_sync_committee), + branch=update.next_sync_committee_branch, + depth=log2(NEXT_SYNC_COMMITTEE_INDEX), + index=NEXT_SYNC_COMMITTEE_INDEX % 2**log2(NEXT_SYNC_COMMITTEE_INDEX), + root=update.header.state_root, + ) + + # Verify sync committee has sufficient participants + assert sum(update.sync_committee_bits) >= MIN_SYNC_COMMITTEE_PARTICIPANTS + + # Verify sync committee aggregate signature + participant_pubkeys = [pubkey for (bit, pubkey) in zip(update.sync_committee_bits, sync_committee.pubkeys) if bit] + domain = compute_domain(DOMAIN_SYNC_COMMITTEE, update.fork_version) + signing_root = compute_signing_root(signed_header, domain) + assert bls.FastAggregateVerify(participant_pubkeys, signing_root, update.sync_committee_signature) + + return True +``` + +#### `apply_light_client_update` + +```python +def apply_light_client_update(snapshot: LightClientSnapshot, update: LightClientUpdate) -> None: + snapshot_period = compute_epoch_at_slot(snapshot.header.slot) // EPOCHS_PER_SYNC_COMMITTEE_PERIOD + update_period = compute_epoch_at_slot(update.header.slot) // EPOCHS_PER_SYNC_COMMITTEE_PERIOD + if update_period == snapshot_period + 1: + snapshot.current_sync_committee = snapshot.next_sync_committee + snapshot.next_sync_committee = update.next_sync_committee + snapshot.header = update.header +``` + +#### `process_light_client_update` + +```python +def process_light_client_update(store: LightClientStore, update: LightClientUpdate, current_slot: Slot) -> None: + # Validate update + assert is_valid_light_client_update(store.snapshot, update) + store.valid_updates.append(update) + + if sum(update.sync_committee_bits) * 3 > len(update.sync_committee_bits) * 2 and update.header != update.finality_header: + # Apply update if 2/3 quorum is reached and we have a finality proof + apply_light_client_update(store, update) + store.valid_updates = [] + elif current_slot > snapshot.header.slot + LIGHT_CLIENT_UPDATE_TIMEOUT: + # Forced best update when the update timeout has elapsed + apply_light_client_update(store, max(store.valid_updates, key=lambda update: sum(update.sync_committee_bits))) + store.valid_updates = [] +``` diff --git a/specs/phase0/validator.md b/specs/phase0/validator.md index cb45e65e8..97b1acd92 100644 --- a/specs/phase0/validator.md +++ b/specs/phase0/validator.md @@ -327,7 +327,9 @@ def get_eth1_vote(state: BeaconState, eth1_chain: Sequence[Eth1Block]) -> Eth1Da valid_votes = [vote for vote in state.eth1_data_votes if vote in votes_to_consider] # Default vote on latest eth1 block data in the period range unless eth1 chain is not live - default_vote = votes_to_consider[len(votes_to_consider) - 1] if any(votes_to_consider) else state.eth1_data + # Non-substantive casting for linter + state_eth1_data: Eth1Data = state.eth1_data + default_vote = votes_to_consider[len(votes_to_consider) - 1] if any(votes_to_consider) else state_eth1_data return max( valid_votes, diff --git a/tests/core/pyspec/eth2spec/test/context.py b/tests/core/pyspec/eth2spec/test/context.py index cfd6724ed..d19547477 100644 --- a/tests/core/pyspec/eth2spec/test/context.py +++ b/tests/core/pyspec/eth2spec/test/context.py @@ -2,6 +2,7 @@ import pytest from eth2spec.phase0 import spec as spec_phase0 from eth2spec.phase1 import spec as spec_phase1 +from eth2spec.lightclient_patch import spec as spec_lightclient_patch from eth2spec.utils import bls from .exceptions import SkippedTest @@ -19,6 +20,7 @@ from importlib import reload def reload_specs(): reload(spec_phase0) reload(spec_phase1) + reload(spec_lightclient_patch) # Some of the Spec module functionality is exposed here to deal with phase-specific changes. @@ -28,7 +30,9 @@ ConfigName = NewType("ConfigName", str) PHASE0 = SpecForkName('phase0') PHASE1 = SpecForkName('phase1') -ALL_PHASES = (PHASE0, PHASE1) +LIGHTCLIENT_PATCH = SpecForkName('lightclient_patch') + +ALL_PHASES = (PHASE0, PHASE1, LIGHTCLIENT_PATCH) MAINNET = ConfigName('mainnet') MINIMAL = ConfigName('minimal') @@ -47,14 +51,18 @@ class SpecPhase0(Spec): class SpecPhase1(Spec): - def upgrade_to_phase1(self, state: spec_phase0.BeaconState) -> spec_phase1.BeaconState: - ... + ... + + +class SpecLightclient(Spec): + ... # add transfer, bridge, etc. as the spec evolves class SpecForks(TypedDict, total=False): PHASE0: SpecPhase0 PHASE1: SpecPhase1 + LIGHTCLIENT_PATCH: SpecLightclient def _prepare_state(balances_fn: Callable[[Any], Sequence[int]], threshold_fn: Callable[[Any], int], @@ -70,6 +78,8 @@ def _prepare_state(balances_fn: Callable[[Any], Sequence[int]], threshold_fn: Ca # TODO: instead of upgrading a test phase0 genesis state we can also write a phase1 state helper. # Decide based on performance/consistency results later. state = phases[PHASE1].upgrade_to_phase1(state) + elif spec.fork == LIGHTCLIENT_PATCH: # not generalizing this just yet, unclear final spec fork/patch order. + state = phases[LIGHTCLIENT_PATCH].upgrade_to_lightclient_patch(state) return state @@ -337,12 +347,16 @@ def with_phases(phases, other_phases=None): phase_dir[PHASE0] = spec_phase0 if PHASE1 in available_phases: phase_dir[PHASE1] = spec_phase1 + 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_PATCH in run_phases: + ret = fn(spec=spec_lightclient_patch, phases=phase_dir, *args, **kw) return ret return wrapper return decorator diff --git a/tests/core/pyspec/eth2spec/test/helpers/block.py b/tests/core/pyspec/eth2spec/test/helpers/block.py index 69cb59021..c4d8f1931 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/block.py +++ b/tests/core/pyspec/eth2spec/test/helpers/block.py @@ -1,3 +1,4 @@ +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 @@ -89,6 +90,10 @@ def build_empty_block(spec, state, slot=None): empty_block.proposer_index = spec.get_beacon_proposer_index(state) empty_block.body.eth1_data.deposit_count = state.eth1_deposit_index empty_block.parent_root = parent_block_root + + if spec.fork == LIGHTCLIENT_PATCH: + empty_block.body.sync_committee_signature = spec.G2_POINT_AT_INFINITY + apply_randao_reveal(spec, state, empty_block) return empty_block diff --git a/tests/core/pyspec/eth2spec/test/helpers/rewards.py b/tests/core/pyspec/eth2spec/test/helpers/rewards.py index c11ba1ec1..dc355972f 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/rewards.py +++ b/tests/core/pyspec/eth2spec/test/helpers/rewards.py @@ -2,6 +2,7 @@ from random import Random from lru import LRU from eth2spec.phase0 import spec as spec_phase0 +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 @@ -159,8 +160,12 @@ def run_get_inactivity_penalty_deltas(spec, state): continue if spec.is_in_inactivity_leak(state): + 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 base_reward = spec.get_base_reward(state, index) - base_penalty = spec.BASE_REWARDS_PER_EPOCH * base_reward - spec.get_proposer_reward(state, index) + base_penalty = cancel_base_rewards_per_epoch * base_reward - spec.get_proposer_reward(state, index) if not has_enough_for_reward(spec, state, index): assert penalties[index] == 0 elif index in matching_attesting_indices: diff --git a/tests/core/pyspec/eth2spec/test/lightclient_patch/sanity/test_blocks.py b/tests/core/pyspec/eth2spec/test/lightclient_patch/sanity/test_blocks.py new file mode 100644 index 000000000..4fbdfc371 --- /dev/null +++ b/tests/core/pyspec/eth2spec/test/lightclient_patch/sanity/test_blocks.py @@ -0,0 +1,102 @@ +import random +from eth2spec.test.helpers.keys import privkeys +from eth2spec.utils import bls +from eth2spec.test.helpers.state import ( + state_transition_and_sign_block, + next_epoch, +) +from eth2spec.test.helpers.block import ( + build_empty_block_for_next_slot, +) +from eth2spec.test.context import ( + PHASE0, PHASE1, + with_all_phases_except, + spec_state_test, +) + + +def compute_sync_committee_signature(spec, state, slot, privkey): + domain = spec.get_domain(state, spec.DOMAIN_SYNC_COMMITTEE, spec.compute_epoch_at_slot(slot)) + if slot == state.slot: + block_root = build_empty_block_for_next_slot(spec, state).parent_root + else: + block_root = spec.get_block_root_at_slot(state, slot) + signing_root = spec.compute_signing_root(block_root, domain) + return bls.Sign(privkey, signing_root) + + +def compute_aggregate_sync_committee_signature(spec, state, slot, participants): + if len(participants) == 0: + return spec.G2_POINT_AT_INFINITY + + signatures = [] + for validator_index in participants: + privkey = privkeys[validator_index] + signatures.append( + compute_sync_committee_signature( + spec, + state, + slot, + privkey, + ) + ) + return bls.Aggregate(signatures) + + +def run_sync_committee_sanity_test(spec, state, fraction_full=1.0): + committee = spec.get_sync_committee_indices(state, spec.get_current_epoch(state)) + participants = random.sample(committee, int(len(committee) * fraction_full)) + + yield 'pre', state + + block = build_empty_block_for_next_slot(spec, state) + block.body.sync_committee_bits = [index in participants for index in committee] + block.body.sync_committee_signature = compute_aggregate_sync_committee_signature( + spec, + state, + block.slot - 1, + participants, + ) + signed_block = state_transition_and_sign_block(spec, state, block) + + yield 'blocks', [signed_block] + yield 'post', state + + +@with_all_phases_except([PHASE0, PHASE1]) +@spec_state_test +def test_full_sync_committee_committee(spec, state): + next_epoch(spec, state) + yield from run_sync_committee_sanity_test(spec, state, fraction_full=1.0) + + +@with_all_phases_except([PHASE0, PHASE1]) +@spec_state_test +def test_half_sync_committee_committee(spec, state): + next_epoch(spec, state) + yield from run_sync_committee_sanity_test(spec, state, fraction_full=0.5) + + +@with_all_phases_except([PHASE0, PHASE1]) +@spec_state_test +def test_empty_sync_committee_committee(spec, state): + next_epoch(spec, state) + yield from run_sync_committee_sanity_test(spec, state, fraction_full=0.0) + + +@with_all_phases_except([PHASE0, PHASE1]) +@spec_state_test +def test_full_sync_committee_committee_genesis(spec, state): + yield from run_sync_committee_sanity_test(spec, state, fraction_full=1.0) + + +@with_all_phases_except([PHASE0, PHASE1]) +@spec_state_test +def test_half_sync_committee_committee_genesis(spec, state): + yield from run_sync_committee_sanity_test(spec, state, fraction_full=0.5) + + +@with_all_phases_except([PHASE0, PHASE1]) +@spec_state_test +def test_empty_sync_committee_committee_genesis(spec, state): + yield from run_sync_committee_sanity_test(spec, state, fraction_full=0.0) diff --git a/tests/core/pyspec/eth2spec/test/phase0/epoch_processing/test_process_rewards_and_penalties.py b/tests/core/pyspec/eth2spec/test/phase0/epoch_processing/test_process_rewards_and_penalties.py index 661a00014..dd3cbb791 100644 --- a/tests/core/pyspec/eth2spec/test/phase0/epoch_processing/test_process_rewards_and_penalties.py +++ b/tests/core/pyspec/eth2spec/test/phase0/epoch_processing/test_process_rewards_and_penalties.py @@ -1,4 +1,5 @@ from eth2spec.test.context import ( + LIGHTCLIENT_PATCH, spec_state_test, spec_test, with_all_phases, single_phase, with_phases, PHASE0, @@ -162,6 +163,9 @@ def run_with_participation(spec, state, participation_fn): pre_state = state.copy() + 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) attesting_indices = spec.get_unslashed_attesting_indices(state, attestations) @@ -172,9 +176,13 @@ def run_with_participation(spec, state, participation_fn): # Proposers can still make money during a leak if index in proposer_indices and index in participated: assert state.balances[index] > pre_state.balances[index] - # If not proposer but participated optimally, should have exactly neutral balance elif index in attesting_indices: - assert state.balances[index] == pre_state.balances[index] + 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: + # If not proposer but participated optimally, should have exactly neutral balance + assert state.balances[index] == pre_state.balances[index] else: assert state.balances[index] < pre_state.balances[index] else: diff --git a/tests/core/pyspec/eth2spec/test/phase0/unittests/fork_choice/test_on_attestation.py b/tests/core/pyspec/eth2spec/test/phase0/unittests/fork_choice/test_on_attestation.py index 63b0572b1..05f0fb051 100644 --- a/tests/core/pyspec/eth2spec/test/phase0/unittests/fork_choice/test_on_attestation.py +++ b/tests/core/pyspec/eth2spec/test/phase0/unittests/fork_choice/test_on_attestation.py @@ -1,4 +1,4 @@ -from eth2spec.test.context import PHASE0, 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 @@ -18,12 +18,12 @@ 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 == PHASE0: + if spec.fork in (PHASE0, LIGHTCLIENT_PATCH): latest_message = spec.LatestMessage( epoch=attestation.data.target.epoch, root=attestation.data.beacon_block_root, ) - else: + elif spec.fork == PHASE1: latest_message = spec.LatestMessage( epoch=attestation.data.target.epoch, root=attestation.data.beacon_block_root, diff --git a/tests/core/pyspec/eth2spec/test/phase1/block_processing/test_process_attestation.py b/tests/core/pyspec/eth2spec/test/phase1/block_processing/test_process_attestation.py index a0cf7472f..5b2f952ae 100644 --- a/tests/core/pyspec/eth2spec/test/phase1/block_processing/test_process_attestation.py +++ b/tests/core/pyspec/eth2spec/test/phase1/block_processing/test_process_attestation.py @@ -1,5 +1,6 @@ from eth2spec.test.context import ( PHASE0, + LIGHTCLIENT_PATCH, with_all_phases_except, spec_state_test, always_bls, @@ -12,7 +13,7 @@ from eth2spec.test.helpers.attestations import ( ) -@with_all_phases_except([PHASE0]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test @always_bls def test_on_time_success(spec, state): @@ -23,7 +24,7 @@ def test_on_time_success(spec, state): yield from run_attestation_processing(spec, state, attestation) -@with_all_phases_except([PHASE0]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test @always_bls def test_late_success(spec, state): diff --git a/tests/core/pyspec/eth2spec/test/phase1/block_processing/test_process_chunk_challenge.py b/tests/core/pyspec/eth2spec/test/phase1/block_processing/test_process_chunk_challenge.py index e916010b2..27829e4a0 100644 --- a/tests/core/pyspec/eth2spec/test/phase1/block_processing/test_process_chunk_challenge.py +++ b/tests/core/pyspec/eth2spec/test/phase1/block_processing/test_process_chunk_challenge.py @@ -9,6 +9,7 @@ from eth2spec.test.helpers.attestations import ( from eth2spec.test.helpers.state import transition_to, transition_to_valid_shard_slot from eth2spec.test.context import ( PHASE0, + LIGHTCLIENT_PATCH, MINIMAL, expect_assertion_error, disable_process_reveal_deadlines, @@ -68,7 +69,7 @@ def run_custody_chunk_response_processing(spec, state, custody_response, valid=T yield 'post', state -@with_all_phases_except([PHASE0]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test @with_configs([MINIMAL], reason="too slow") @disable_process_reveal_deadlines @@ -92,7 +93,7 @@ def test_challenge_appended(spec, state): yield from run_chunk_challenge_processing(spec, state, challenge) -@with_all_phases_except([PHASE0]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test @disable_process_reveal_deadlines @with_configs([MINIMAL], reason="too slow") @@ -118,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]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test @disable_process_reveal_deadlines @with_configs([MINIMAL], reason="too slow") @@ -144,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]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test @disable_process_reveal_deadlines @with_configs([MINIMAL], reason="too slow") @@ -172,7 +173,7 @@ def test_second_challenge(spec, state): yield from run_chunk_challenge_processing(spec, state, challenge1) -@with_all_phases_except([PHASE0]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test @disable_process_reveal_deadlines @with_configs([MINIMAL], reason="too slow") @@ -197,7 +198,7 @@ def test_multiple_epochs_custody(spec, state): yield from run_chunk_challenge_processing(spec, state, challenge) -@with_all_phases_except([PHASE0]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test @disable_process_reveal_deadlines @with_configs([MINIMAL], reason="too slow") @@ -222,7 +223,7 @@ def test_many_epochs_custody(spec, state): yield from run_chunk_challenge_processing(spec, state, challenge) -@with_all_phases_except([PHASE0]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test @disable_process_reveal_deadlines @with_configs([MINIMAL], reason="too slow") @@ -243,7 +244,7 @@ def test_off_chain_attestation(spec, state): yield from run_chunk_challenge_processing(spec, state, challenge) -@with_all_phases_except([PHASE0]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test @disable_process_reveal_deadlines @with_configs([MINIMAL], reason="too slow") @@ -275,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]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test @disable_process_reveal_deadlines @with_configs([MINIMAL], reason="too slow") @@ -306,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]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test @disable_process_reveal_deadlines @with_configs([MINIMAL], reason="too slow") @@ -338,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]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test @disable_process_reveal_deadlines @with_configs([MINIMAL], reason="too slow") diff --git a/tests/core/pyspec/eth2spec/test/phase1/block_processing/test_process_custody_key_reveal.py b/tests/core/pyspec/eth2spec/test/phase1/block_processing/test_process_custody_key_reveal.py index cb96c97e1..00a6112bf 100644 --- a/tests/core/pyspec/eth2spec/test/phase1/block_processing/test_process_custody_key_reveal.py +++ b/tests/core/pyspec/eth2spec/test/phase1/block_processing/test_process_custody_key_reveal.py @@ -1,6 +1,7 @@ from eth2spec.test.helpers.custody import get_valid_custody_key_reveal from eth2spec.test.context import ( PHASE0, + LIGHTCLIENT_PATCH, with_all_phases_except, spec_state_test, expect_assertion_error, @@ -39,7 +40,7 @@ def run_custody_key_reveal_processing(spec, state, custody_key_reveal, valid=Tru yield 'post', state -@with_all_phases_except([PHASE0]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test @always_bls def test_success(spec, state): @@ -49,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]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test @always_bls def test_reveal_too_early(spec, state): @@ -58,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]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test @always_bls def test_wrong_period(spec, state): @@ -67,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]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test @always_bls def test_late_reveal(spec, state): @@ -77,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]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test @always_bls def test_double_reveal(spec, state): diff --git a/tests/core/pyspec/eth2spec/test/phase1/block_processing/test_process_custody_slashing.py b/tests/core/pyspec/eth2spec/test/phase1/block_processing/test_process_custody_slashing.py index fc7efa5bc..1f46bcf05 100644 --- a/tests/core/pyspec/eth2spec/test/phase1/block_processing/test_process_custody_slashing.py +++ b/tests/core/pyspec/eth2spec/test/phase1/block_processing/test_process_custody_slashing.py @@ -11,6 +11,7 @@ from eth2spec.test.helpers.state import get_balance, transition_to from eth2spec.test.context import ( PHASE0, MINIMAL, + LIGHTCLIENT_PATCH, with_all_phases_except, spec_state_test, expect_assertion_error, @@ -112,7 +113,7 @@ def run_standard_custody_slashing_test(spec, yield from run_custody_slashing_processing(spec, state, slashing, valid=valid, correct=correct) -@with_all_phases_except([PHASE0]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test @disable_process_reveal_deadlines @with_configs([MINIMAL], reason="too slow") @@ -120,7 +121,7 @@ def test_custody_slashing(spec, state): yield from run_standard_custody_slashing_test(spec, state) -@with_all_phases_except([PHASE0]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test @disable_process_reveal_deadlines @with_configs([MINIMAL], reason="too slow") @@ -128,7 +129,7 @@ def test_incorrect_custody_slashing(spec, state): yield from run_standard_custody_slashing_test(spec, state, correct=False) -@with_all_phases_except([PHASE0]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test @disable_process_reveal_deadlines @with_configs([MINIMAL], reason="too slow") @@ -136,7 +137,7 @@ def test_multiple_epochs_custody(spec, state): yield from run_standard_custody_slashing_test(spec, state, shard_lateness=spec.SLOTS_PER_EPOCH * 3) -@with_all_phases_except([PHASE0]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test @disable_process_reveal_deadlines @with_configs([MINIMAL], reason="too slow") @@ -144,7 +145,7 @@ def test_many_epochs_custody(spec, state): yield from run_standard_custody_slashing_test(spec, state, shard_lateness=spec.SLOTS_PER_EPOCH * 5) -@with_all_phases_except([PHASE0]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test @disable_process_reveal_deadlines @with_configs([MINIMAL], reason="too slow") diff --git a/tests/core/pyspec/eth2spec/test/phase1/block_processing/test_process_early_derived_secret_reveal.py b/tests/core/pyspec/eth2spec/test/phase1/block_processing/test_process_early_derived_secret_reveal.py index 668561261..3094f795b 100644 --- a/tests/core/pyspec/eth2spec/test/phase1/block_processing/test_process_early_derived_secret_reveal.py +++ b/tests/core/pyspec/eth2spec/test/phase1/block_processing/test_process_early_derived_secret_reveal.py @@ -2,6 +2,7 @@ from eth2spec.test.helpers.custody import get_valid_early_derived_secret_reveal from eth2spec.test.helpers.state import next_epoch_via_block, get_balance from eth2spec.test.context import ( PHASE0, + LIGHTCLIENT_PATCH, with_all_phases_except, spec_state_test, expect_assertion_error, @@ -41,7 +42,7 @@ def run_early_derived_secret_reveal_processing(spec, state, randao_key_reveal, v yield 'post', state -@with_all_phases_except([PHASE0]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test @always_bls def test_success(spec, state): @@ -50,7 +51,7 @@ def test_success(spec, state): yield from run_early_derived_secret_reveal_processing(spec, state, randao_key_reveal) -@with_all_phases_except([PHASE0]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test @never_bls def test_reveal_from_current_epoch(spec, state): @@ -59,7 +60,7 @@ def test_reveal_from_current_epoch(spec, state): yield from run_early_derived_secret_reveal_processing(spec, state, randao_key_reveal, False) -@with_all_phases_except([PHASE0]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test @never_bls def test_reveal_from_past_epoch(spec, state): @@ -69,7 +70,7 @@ def test_reveal_from_past_epoch(spec, state): yield from run_early_derived_secret_reveal_processing(spec, state, randao_key_reveal, False) -@with_all_phases_except([PHASE0]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test @always_bls def test_reveal_with_custody_padding(spec, state): @@ -81,7 +82,7 @@ def test_reveal_with_custody_padding(spec, state): yield from run_early_derived_secret_reveal_processing(spec, state, randao_key_reveal, True) -@with_all_phases_except([PHASE0]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test @always_bls def test_reveal_with_custody_padding_minus_one(spec, state): @@ -93,7 +94,7 @@ def test_reveal_with_custody_padding_minus_one(spec, state): yield from run_early_derived_secret_reveal_processing(spec, state, randao_key_reveal, True) -@with_all_phases_except([PHASE0]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test @never_bls def test_double_reveal(spec, state): @@ -114,7 +115,7 @@ def test_double_reveal(spec, state): yield from run_early_derived_secret_reveal_processing(spec, state, randao_key_reveal2, False) -@with_all_phases_except([PHASE0]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test @never_bls def test_revealer_is_slashed(spec, state): @@ -124,7 +125,7 @@ def test_revealer_is_slashed(spec, state): yield from run_early_derived_secret_reveal_processing(spec, state, randao_key_reveal, False) -@with_all_phases_except([PHASE0]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test @never_bls def test_far_future_epoch(spec, state): diff --git a/tests/core/pyspec/eth2spec/test/phase1/block_processing/test_process_shard_transition.py b/tests/core/pyspec/eth2spec/test/phase1/block_processing/test_process_shard_transition.py index b0a51557a..d2b7962b6 100644 --- a/tests/core/pyspec/eth2spec/test/phase1/block_processing/test_process_shard_transition.py +++ b/tests/core/pyspec/eth2spec/test/phase1/block_processing/test_process_shard_transition.py @@ -1,5 +1,6 @@ from eth2spec.test.context import ( PHASE0, + LIGHTCLIENT_PATCH, with_all_phases_except, only_full_crosslink, spec_state_test, @@ -90,21 +91,21 @@ def run_successful_crosslink_tests(spec, state, target_len_offset_slot): assert bool(pending_attestation.crosslink_success) is True -@with_all_phases_except([PHASE0]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test @only_full_crosslink def test_basic_crosslinks(spec, state): yield from run_successful_crosslink_tests(spec, state, target_len_offset_slot=1) -@with_all_phases_except([PHASE0]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test @only_full_crosslink def test_multiple_offset_slots(spec, state): yield from run_successful_crosslink_tests(spec, state, target_len_offset_slot=2) -@with_all_phases_except([PHASE0]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test @only_full_crosslink def test_no_winning_root(spec, state): @@ -152,7 +153,7 @@ def test_no_winning_root(spec, state): assert state.shard_states == pre_shard_states -@with_all_phases_except([PHASE0]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test @only_full_crosslink def test_wrong_shard_transition_root(spec, state): diff --git a/tests/core/pyspec/eth2spec/test/phase1/epoch_processing/test_process_challenge_deadlines.py b/tests/core/pyspec/eth2spec/test/phase1/epoch_processing/test_process_challenge_deadlines.py index e270ff615..0350324a5 100644 --- a/tests/core/pyspec/eth2spec/test/phase1/epoch_processing/test_process_challenge_deadlines.py +++ b/tests/core/pyspec/eth2spec/test/phase1/epoch_processing/test_process_challenge_deadlines.py @@ -8,6 +8,7 @@ from eth2spec.test.helpers.attestations import ( from eth2spec.test.helpers.state import transition_to, transition_to_valid_shard_slot from eth2spec.test.context import ( PHASE0, + LIGHTCLIENT_PATCH, MINIMAL, spec_state_test, with_all_phases_except, @@ -25,7 +26,7 @@ def run_process_challenge_deadlines(spec, state): yield from run_epoch_processing_with(spec, state, 'process_challenge_deadlines') -@with_all_phases_except([PHASE0]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test @with_configs([MINIMAL], reason="too slow") def test_validator_slashed_after_chunk_challenge(spec, state): diff --git a/tests/core/pyspec/eth2spec/test/phase1/epoch_processing/test_process_custody_final_updates.py b/tests/core/pyspec/eth2spec/test/phase1/epoch_processing/test_process_custody_final_updates.py index 0541411da..5994306d9 100644 --- a/tests/core/pyspec/eth2spec/test/phase1/epoch_processing/test_process_custody_final_updates.py +++ b/tests/core/pyspec/eth2spec/test/phase1/epoch_processing/test_process_custody_final_updates.py @@ -1,5 +1,6 @@ from eth2spec.test.context import ( PHASE0, + LIGHTCLIENT_PATCH, ) from eth2spec.test.helpers.custody import ( get_valid_chunk_challenge, @@ -29,7 +30,7 @@ def run_process_custody_final_updates(spec, state): yield from run_epoch_processing_with(spec, state, 'process_custody_final_updates') -@with_all_phases_except([PHASE0]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test def test_validator_withdrawal_delay(spec, state): transition_to_valid_shard_slot(spec, state) @@ -42,7 +43,7 @@ def test_validator_withdrawal_delay(spec, state): assert state.validators[0].withdrawable_epoch == spec.FAR_FUTURE_EPOCH -@with_all_phases_except([PHASE0]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test def test_validator_withdrawal_reenable_after_custody_reveal(spec, state): transition_to_valid_shard_slot(spec, state) @@ -67,7 +68,7 @@ def test_validator_withdrawal_reenable_after_custody_reveal(spec, state): assert state.validators[0].withdrawable_epoch < spec.FAR_FUTURE_EPOCH -@with_all_phases_except([PHASE0]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test def test_validator_withdrawal_suspend_after_chunk_challenge(spec, state): transition_to_valid_shard_slot(spec, state) @@ -116,7 +117,7 @@ def test_validator_withdrawal_suspend_after_chunk_challenge(spec, state): assert state.validators[validator_index].withdrawable_epoch == spec.FAR_FUTURE_EPOCH -@with_all_phases_except([PHASE0]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test def test_validator_withdrawal_resume_after_chunk_challenge_response(spec, state): transition_to_valid_shard_slot(spec, state) diff --git a/tests/core/pyspec/eth2spec/test/phase1/epoch_processing/test_process_reveal_deadlines.py b/tests/core/pyspec/eth2spec/test/phase1/epoch_processing/test_process_reveal_deadlines.py index 5777e184a..3c2060ba5 100644 --- a/tests/core/pyspec/eth2spec/test/phase1/epoch_processing/test_process_reveal_deadlines.py +++ b/tests/core/pyspec/eth2spec/test/phase1/epoch_processing/test_process_reveal_deadlines.py @@ -4,6 +4,7 @@ from eth2spec.test.helpers.custody import ( from eth2spec.test.helpers.state import transition_to from eth2spec.test.context import ( PHASE0, + LIGHTCLIENT_PATCH, MINIMAL, with_all_phases_except, with_configs, @@ -17,7 +18,7 @@ def run_process_challenge_deadlines(spec, state): yield from run_epoch_processing_with(spec, state, 'process_challenge_deadlines') -@with_all_phases_except([PHASE0]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test @with_configs([MINIMAL], reason="too slow") def test_validator_slashed_after_reveal_deadline(spec, state): @@ -37,7 +38,7 @@ def test_validator_slashed_after_reveal_deadline(spec, state): assert state.validators[0].slashed == 1 -@with_all_phases_except([PHASE0]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test @with_configs([MINIMAL], reason="too slow") def test_validator_not_slashed_after_reveal(spec, state): diff --git a/tests/core/pyspec/eth2spec/test/phase1/sanity/test_blocks.py b/tests/core/pyspec/eth2spec/test/phase1/sanity/test_blocks.py index 922b604ad..ba47adde9 100644 --- a/tests/core/pyspec/eth2spec/test/phase1/sanity/test_blocks.py +++ b/tests/core/pyspec/eth2spec/test/phase1/sanity/test_blocks.py @@ -1,7 +1,9 @@ from typing import Dict, Sequence from eth2spec.test.context import ( - PHASE0, MINIMAL, + PHASE0, + LIGHTCLIENT_PATCH, + MINIMAL, with_all_phases_except, spec_state_test, only_full_crosslink, @@ -98,7 +100,7 @@ def run_beacon_block_with_shard_blocks(spec, state, target_len_offset_slot, comm assert post_shard_state.gasprice > pre_gasprice -@with_all_phases_except([PHASE0]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test @only_full_crosslink def test_process_beacon_block_with_normal_shard_transition(spec, state): @@ -112,7 +114,7 @@ def test_process_beacon_block_with_normal_shard_transition(spec, state): yield from run_beacon_block_with_shard_blocks(spec, state, target_len_offset_slot, committee_index, shard) -@with_all_phases_except([PHASE0]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test @only_full_crosslink def test_process_beacon_block_with_empty_proposal_transition(spec, state): @@ -131,7 +133,7 @@ def test_process_beacon_block_with_empty_proposal_transition(spec, state): # -@with_all_phases_except([PHASE0]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test @only_full_crosslink def test_with_shard_transition_with_custody_challenge_and_response(spec, state): @@ -165,7 +167,7 @@ def test_with_shard_transition_with_custody_challenge_and_response(spec, state): yield from run_beacon_block(spec, state, block) -@with_all_phases_except([PHASE0]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test @with_configs([MINIMAL]) def test_custody_key_reveal(spec, state): @@ -179,7 +181,7 @@ def test_custody_key_reveal(spec, state): yield from run_beacon_block(spec, state, block) -@with_all_phases_except([PHASE0]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test def test_early_derived_secret_reveal(spec, state): transition_to_valid_shard_slot(spec, state) @@ -190,7 +192,7 @@ def test_early_derived_secret_reveal(spec, state): yield from run_beacon_block(spec, state, block) -@with_all_phases_except([PHASE0]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test @only_full_crosslink def test_custody_slashing(spec, state): diff --git a/tests/core/pyspec/eth2spec/test/phase1/sanity/test_shard_blocks.py b/tests/core/pyspec/eth2spec/test/phase1/sanity/test_shard_blocks.py index ab66314e5..1590d2a6e 100644 --- a/tests/core/pyspec/eth2spec/test/phase1/sanity/test_shard_blocks.py +++ b/tests/core/pyspec/eth2spec/test/phase1/sanity/test_shard_blocks.py @@ -1,5 +1,6 @@ from eth2spec.test.context import ( PHASE0, + LIGHTCLIENT_PATCH, always_bls, expect_assertion_error, spec_state_test, @@ -43,7 +44,7 @@ def run_shard_blocks(spec, shard_state, signed_shard_block, beacon_parent_state, shard_state.latest_block_root == pre_shard_state.latest_block_root -@with_all_phases_except([PHASE0]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test @always_bls @only_full_crosslink @@ -63,7 +64,7 @@ def test_valid_shard_block(spec, state): # -@with_all_phases_except([PHASE0]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test @only_full_crosslink def test_invalid_shard_parent_root(spec, state): @@ -79,7 +80,7 @@ def test_invalid_shard_parent_root(spec, state): yield from run_shard_blocks(spec, shard_state, signed_shard_block, beacon_state, valid=False) -@with_all_phases_except([PHASE0]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test @only_full_crosslink def test_invalid_beacon_parent_root(spec, state): @@ -94,7 +95,7 @@ def test_invalid_beacon_parent_root(spec, state): yield from run_shard_blocks(spec, shard_state, signed_shard_block, beacon_state, valid=False) -@with_all_phases_except([PHASE0]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test @only_full_crosslink def test_invalid_slot(spec, state): @@ -110,7 +111,7 @@ def test_invalid_slot(spec, state): yield from run_shard_blocks(spec, shard_state, signed_shard_block, beacon_state, valid=False) -@with_all_phases_except([PHASE0]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test @only_full_crosslink def test_invalid_proposer_index(spec, state): @@ -130,7 +131,7 @@ def test_invalid_proposer_index(spec, state): yield from run_shard_blocks(spec, shard_state, signed_shard_block, beacon_state, valid=False) -@with_all_phases_except([PHASE0]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test @always_bls @only_full_crosslink @@ -151,7 +152,7 @@ def test_out_of_bound_offset(spec, state): yield from run_shard_blocks(spec, shard_state, signed_shard_block, beacon_state, valid=False) -@with_all_phases_except([PHASE0]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test @always_bls @only_full_crosslink @@ -170,7 +171,7 @@ def test_invalid_offset(spec, state): yield from run_shard_blocks(spec, shard_state, signed_shard_block, beacon_state, valid=False) -@with_all_phases_except([PHASE0]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test @always_bls @only_full_crosslink @@ -189,7 +190,7 @@ def test_empty_block_body(spec, state): # -@with_all_phases_except([PHASE0]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test @always_bls @only_full_crosslink @@ -208,7 +209,7 @@ def test_invalid_signature(spec, state): # -@with_all_phases_except([PHASE0]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test @always_bls @only_full_crosslink @@ -225,7 +226,7 @@ def test_max_offset(spec, state): yield from run_shard_blocks(spec, shard_state, signed_shard_block, beacon_state) -@with_all_phases_except([PHASE0]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test @always_bls @only_full_crosslink diff --git a/tests/core/pyspec/eth2spec/test/phase1/unittests/fork_choice/test_on_shard_block.py b/tests/core/pyspec/eth2spec/test/phase1/unittests/fork_choice/test_on_shard_block.py index 30eaa8d80..66d254ed1 100644 --- a/tests/core/pyspec/eth2spec/test/phase1/unittests/fork_choice/test_on_shard_block.py +++ b/tests/core/pyspec/eth2spec/test/phase1/unittests/fork_choice/test_on_shard_block.py @@ -1,6 +1,13 @@ 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, only_full_crosslink +from eth2spec.test.context import ( + PHASE0, + LIGHTCLIENT_PATCH, + 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.shard_block import ( build_shard_block, @@ -145,7 +152,7 @@ def create_and_apply_beacon_and_shard_blocks(spec, state, store, shard, shard_bl return has_shard_committee -@with_all_phases_except([PHASE0]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test @never_bls # Set to never_bls for testing `check_pending_shard_blocks` def test_basic(spec, state): @@ -206,7 +213,7 @@ def create_simple_fork(spec, state, store, shard): return head_block, forking_block -@with_all_phases_except([PHASE0]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test @only_full_crosslink def test_shard_simple_fork(spec, state): @@ -231,7 +238,7 @@ def test_shard_simple_fork(spec, state): assert spec.get_shard_head(store, shard) == forking_block.message.hash_tree_root() -@with_all_phases_except([PHASE0]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test @only_full_crosslink def test_shard_latest_messages_for_different_shards(spec, state): diff --git a/tests/core/pyspec/eth2spec/test/phase1/unittests/test_get_start_shard.py b/tests/core/pyspec/eth2spec/test/phase1/unittests/test_get_start_shard.py index a802d6c3c..030357655 100644 --- a/tests/core/pyspec/eth2spec/test/phase1/unittests/test_get_start_shard.py +++ b/tests/core/pyspec/eth2spec/test/phase1/unittests/test_get_start_shard.py @@ -1,12 +1,13 @@ from eth2spec.test.context import ( PHASE0, + LIGHTCLIENT_PATCH, with_all_phases_except, spec_state_test, ) from eth2spec.test.helpers.state import next_epoch -@with_all_phases_except([PHASE0]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test def test_get_committee_count_delta(spec, state): assert spec.get_committee_count_delta(state, 0, 0) == 0 @@ -23,7 +24,7 @@ def test_get_committee_count_delta(spec, state): ) -@with_all_phases_except([PHASE0]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test def test_get_start_shard_current_epoch_start(spec, state): assert state.current_epoch_start_shard == 0 @@ -39,7 +40,7 @@ def test_get_start_shard_current_epoch_start(spec, state): assert start_shard == state.current_epoch_start_shard -@with_all_phases_except([PHASE0]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test def test_get_start_shard_next_slot(spec, state): next_epoch(spec, state) @@ -57,7 +58,7 @@ def test_get_start_shard_next_slot(spec, state): assert start_shard == expected_start_shard -@with_all_phases_except([PHASE0]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test def test_get_start_shard_previous_slot(spec, state): next_epoch(spec, state) @@ -76,7 +77,7 @@ def test_get_start_shard_previous_slot(spec, state): assert start_shard == expected_start_shard -@with_all_phases_except([PHASE0]) +@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH]) @spec_state_test def test_get_start_shard_far_past_epoch(spec, state): initial_epoch = spec.get_current_epoch(state)