Merge branch 'dev' into fork-choice-test-vectors

This commit is contained in:
Hsiao-Wei Wang 2021-03-12 00:34:23 +08:00
commit 216bbb0a46
No known key found for this signature in database
GPG Key ID: 1111A8A81778319E
51 changed files with 260 additions and 260 deletions

2
.gitignore vendored
View File

@ -17,7 +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/
tests/core/pyspec/eth2spec/altair/
# coverage reports
.htmlcov

View File

@ -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 $(SPEC_DIR)/lightclient/*.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)/altair/*.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,7 +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)/altair
rm -rf $(PY_SPEC_DIR)/$(COV_HTML_OUT)
rm -rf $(PY_SPEC_DIR)/.coverage
rm -rf $(PY_SPEC_DIR)/test-reports
@ -86,11 +86,11 @@ install_test:
test: pyspec
. venv/bin/activate; cd $(PY_SPEC_DIR); \
python3 -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
python3 -m pytest -n 4 --disable-bls --cov=eth2spec.phase0.spec --cov=eth2spec.phase1.spec --cov=eth2spec.altair.spec -cov-report="html:$(COV_HTML_OUT)" --cov-branch eth2spec
find_test: pyspec
. venv/bin/activate; cd $(PY_SPEC_DIR); \
python3 -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
python3 -m pytest -k=$(K) --disable-bls --cov=eth2spec.phase0.spec --cov=eth2spec.phase1.spec --cov=eth2spec.altair.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); \
@ -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_patch
&& mypy --config-file $(LINTER_CONFIG_FILE) -p eth2spec.phase0 -p eth2spec.phase1 -p eth2spec.altair
lint_generators: pyspec
. venv/bin/activate; cd $(TEST_GENERATORS_DIR); \

View File

@ -21,10 +21,11 @@ Core specifications for Eth2 clients be found in [specs](specs/). These are divi
* [Honest Validator](specs/phase0/validator.md)
* [P2P Networking](specs/phase0/p2p-interface.md)
### Light clients
### Altair
* [Beacon chain changes](specs/lightclient/beacon-chain.md)
* [Light client sync protocol](specs/lightclient/sync-protocol.md)
* [Beacon chain changes](specs/altair/beacon-chain.md)
* [Altair fork](specs/altair/fork.md)
* [Light client sync protocol](specs/altair/sync-protocol.md)
### Sharding

View File

@ -1,15 +1,15 @@
# Mainnet preset - lightclient patch
# Mainnet preset - Altair
CONFIG_NAME: "mainnet"
# Updated penalty values
# ---------------------------------------------------------------
# 3 * 2**24) (= 50,331,648)
HF1_INACTIVITY_PENALTY_QUOTIENT: 50331648
ALTAIR_INACTIVITY_PENALTY_QUOTIENT: 50331648
# 2**6 (= 64)
HF1_MIN_SLASHING_PENALTY_QUOTIENT: 64
ALTAIR_MIN_SLASHING_PENALTY_QUOTIENT: 64
# 2
HF1_PROPORTIONAL_SLASHING_MULTIPLIER: 2
ALTAIR_PROPORTIONAL_SLASHING_MULTIPLIER: 2
# Misc

View File

@ -1,15 +1,15 @@
# Minimal preset - lightclient patch
# Minimal preset - Altair
CONFIG_NAME: "minimal"
# Updated penalty values
# ---------------------------------------------------------------
# 3 * 2**24) (= 50,331,648)
HF1_INACTIVITY_PENALTY_QUOTIENT: 50331648
ALTAIR_INACTIVITY_PENALTY_QUOTIENT: 50331648
# 2**6 (= 64)
HF1_MIN_SLASHING_PENALTY_QUOTIENT: 64
ALTAIR_MIN_SLASHING_PENALTY_QUOTIENT: 64
# 2
HF1_PROPORTIONAL_SLASHING_MULTIPLIER: 2
ALTAIR_PROPORTIONAL_SLASHING_MULTIPLIER: 2
# Misc

View File

@ -179,7 +179,7 @@ from eth2spec.utils import bls
from eth2spec.utils.hash_function import hash
# Whenever lightclient is loaded, make sure we have the latest phase0
# Whenever altair is loaded, make sure we have the latest phase0
from importlib import reload
reload(phase0)
@ -386,7 +386,7 @@ def combine_spec_objects(spec0: SpecObject, spec1: SpecObject) -> SpecObject:
fork_imports = {
'phase0': PHASE0_IMPORTS,
'phase1': PHASE1_IMPORTS,
'lightclient_patch': LIGHTCLIENT_IMPORT,
'altair': LIGHTCLIENT_IMPORT,
}
@ -453,16 +453,16 @@ class PySpecCommand(Command):
specs/phase1/shard-fork-choice.md
specs/phase1/validator.md
"""
elif self.spec_fork == "lightclient_patch":
elif self.spec_fork == "altair":
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/fork.md
specs/altair/beacon-chain.md
specs/altair/fork.md
"""
# TODO: add specs/lightclient/sync-protocol.md back when the GeneralizedIndex helpers are included.
# TODO: add specs/altair/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)

View File

@ -1,4 +1,4 @@
# Ethereum 2.0 HF1
# Ethereum 2.0 Altair
## Table of contents
@ -55,7 +55,7 @@
## Introduction
This is a patch implementing the first hard fork to the beacon chain, tentatively named HF1 pending a permanent name.
Altair is a patch implementing the first hard fork to the beacon chain.
It has four main features:
* Light client support via sync committees
@ -108,9 +108,9 @@ This patch updates a few configuration values to move penalty constants toward t
| Name | Value |
| - | - |
| `HF1_INACTIVITY_PENALTY_QUOTIENT` | `uint64(3 * 2**24)` (= 50,331,648) |
| `HF1_MIN_SLASHING_PENALTY_QUOTIENT` | `uint64(2**6)` (=64) |
| `HF1_PROPORTIONAL_SLASHING_MULTIPLIER` | `uint64(2)` |
| `ALTAIR_INACTIVITY_PENALTY_QUOTIENT` | `uint64(3 * 2**24)` (= 50,331,648) |
| `ALTAIR_MIN_SLASHING_PENALTY_QUOTIENT` | `uint64(2**6)` (=64) |
| `ALTAIR_PROPORTIONAL_SLASHING_MULTIPLIER` | `uint64(2)` |
### Misc
@ -152,8 +152,8 @@ class BeaconBlockBody(Container):
deposits: List[Deposit, MAX_DEPOSITS]
voluntary_exits: List[SignedVoluntaryExit, MAX_VOLUNTARY_EXITS]
# Sync committee aggregate signature
sync_committee_bits: Bitvector[SYNC_COMMITTEE_SIZE] # [New in HF1]
sync_committee_signature: BLSSignature # [New in HF1]
sync_committee_bits: Bitvector[SYNC_COMMITTEE_SIZE] # [New in Altair]
sync_committee_signature: BLSSignature # [New in Altair]
```
#### `BeaconState`
@ -379,7 +379,7 @@ def get_inactivity_penalty_deltas(state: BeaconState) -> Tuple[Sequence[Gwei], S
effective_balance = state.validators[index].effective_balance
penalties[index] += Gwei(
effective_balance * get_finality_delay(state)
// HF1_INACTIVITY_PENALTY_QUOTIENT
// ALTAIR_INACTIVITY_PENALTY_QUOTIENT
)
rewards = [Gwei(0) for _ in range(len(state.validators))]
@ -391,7 +391,7 @@ def get_inactivity_penalty_deltas(state: BeaconState) -> Tuple[Sequence[Gwei], S
#### New `slash_validator`
*Note*: The function `slash_validator` is modified
with the substitution of `MIN_SLASHING_PENALTY_QUOTIENT` with `HF1_MIN_SLASHING_PENALTY_QUOTIENT`.
with the substitution of `MIN_SLASHING_PENALTY_QUOTIENT` with `ALTAIR_MIN_SLASHING_PENALTY_QUOTIENT`.
```python
def slash_validator(state: BeaconState,
@ -406,7 +406,7 @@ def slash_validator(state: BeaconState,
validator.slashed = True
validator.withdrawable_epoch = max(validator.withdrawable_epoch, Epoch(epoch + EPOCHS_PER_SLASHINGS_VECTOR))
state.slashings[epoch % EPOCHS_PER_SLASHINGS_VECTOR] += validator.effective_balance
decrease_balance(state, slashed_index, validator.effective_balance // HF1_MIN_SLASHING_PENALTY_QUOTIENT)
decrease_balance(state, slashed_index, validator.effective_balance // ALTAIR_MIN_SLASHING_PENALTY_QUOTIENT)
# Apply proposer and whistleblower rewards
proposer_index = get_beacon_proposer_index(state)
@ -425,8 +425,8 @@ 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) # [Modified in HF1]
process_sync_committee(state, block.body) # [New in HF1]
process_operations(state, block.body) # [Modified in Altair]
process_sync_committee(state, block.body) # [New in Altair]
```
#### Modified `process_attestation`
@ -519,9 +519,8 @@ def process_deposit(state: BeaconState, deposit: Deposit) -> None:
# Add validator and balance entries
state.validators.append(get_validator_from_deposit(state, deposit))
state.balances.append(amount)
# [Added in hf-1] Initialize empty participation flags for new validator
state.previous_epoch_participation.append(ParticipationFlags(0b0000_0000))
state.current_epoch_participation.append(ParticipationFlags(0b0000_0000))
state.previous_epoch_participation.append(ParticipationFlags(0b0000_0000)) # [New in Altair]
state.current_epoch_participation.append(ParticipationFlags(0b0000_0000)) # [New in Altair]
else:
# Increase balance by deposit amount
index = ValidatorIndex(validator_pubkeys.index(pubkey))
@ -561,17 +560,17 @@ def process_sync_committee(state: BeaconState, body: BeaconBlockBody) -> None:
```python
def process_epoch(state: BeaconState) -> None:
process_justification_and_finalization(state) # [Modified in HF1]
process_rewards_and_penalties(state) # [Modified in HF1]
process_justification_and_finalization(state) # [Modified in Altair]
process_rewards_and_penalties(state) # [Modified in Altair]
process_registry_updates(state)
process_slashings(state) # [Modified in HF1]
process_slashings(state) # [Modified in Altair]
process_eth1_data_reset(state)
process_effective_balance_updates(state)
process_slashings_reset(state)
process_randao_mixes_reset(state)
process_historical_roots_update(state)
process_participation_flag_updates(state) # [New in HF1]
process_sync_committee_updates(state) # [New in HF1]
process_participation_flag_updates(state) # [New in Altair]
process_sync_committee_updates(state) # [New in Altair]
```
#### Justification and finalization
@ -642,13 +641,13 @@ def process_rewards_and_penalties(state: BeaconState) -> None:
#### Slashings
*Note*: The function `process_slashings` is modified to use `HF1_PROPORTIONAL_SLASHING_MULTIPLIER`.
*Note*: The function `process_slashings` is modified to use `ALTAIR_PROPORTIONAL_SLASHING_MULTIPLIER`.
```python
def process_slashings(state: BeaconState) -> None:
epoch = get_current_epoch(state)
total_balance = get_total_active_balance(state)
adjusted_total_slashing_balance = min(sum(state.slashings) * HF1_PROPORTIONAL_SLASHING_MULTIPLIER, total_balance)
adjusted_total_slashing_balance = min(sum(state.slashings) * ALTAIR_PROPORTIONAL_SLASHING_MULTIPLIER, total_balance)
for index, validator in enumerate(state.validators):
if validator.slashed and epoch + EPOCHS_PER_SLASHINGS_VECTOR // 2 == validator.withdrawable_epoch:
increment = EFFECTIVE_BALANCE_INCREMENT # Factored out from penalty numerator to avoid uint64 overflow

View File

@ -25,21 +25,21 @@ Warning: this configuration is not definitive.
| Name | Value |
| - | - |
| `LIGHTCLIENT_PATCH_FORK_VERSION` | `Version('0x01000000')` |
| `LIGHTCLIENT_PATCH_FORK_SLOT` | `Slot(0)` **TBD** |
| `ALTAIR_FORK_VERSION` | `Version('0x01000000')` |
| `ALTAIR_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`.
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 `ALTAIR_FORK_SLOT`, where `ALTAIR_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.
After `process_slots` of Phase 0 finishes, if `state.slot == ALTAIR_FORK_SLOT`, an irregular state change is made to upgrade to light-client patch.
```python
def upgrade_to_lightclient_patch(pre: phase0.BeaconState) -> BeaconState:
def upgrade_to_altair(pre: phase0.BeaconState) -> BeaconState:
epoch = get_current_epoch(pre)
post = BeaconState(
genesis_time=pre.genesis_time,
@ -47,7 +47,7 @@ def upgrade_to_lightclient_patch(pre: phase0.BeaconState) -> BeaconState:
slot=pre.slot,
fork=Fork(
previous_version=pre.fork.current_version,
current_version=LIGHTCLIENT_PATCH_FORK_VERSION,
current_version=ALTAIR_FORK_VERSION,
epoch=epoch,
),
# History

View File

@ -1,5 +1,5 @@
from eth2spec.test.context import (
PHASE0, LIGHTCLIENT_PATCH,
PHASE0, ALTAIR,
with_phases,
with_custom_state,
spec_test, with_state,
@ -12,7 +12,7 @@ from eth2spec.test.helpers.state import (
)
HF1_FORK_TEST_META_TAGS = {
ALTAIR_FORK_TEST_META_TAGS = {
'fork': 'altair',
}
@ -20,7 +20,7 @@ HF1_FORK_TEST_META_TAGS = {
def run_fork_test(post_spec, pre_state):
yield 'pre', pre_state
post_state = post_spec.upgrade_to_lightclient_patch(pre_state)
post_state = post_spec.upgrade_to_altair(pre_state)
# Stable fields
stable_fields = [
@ -47,67 +47,67 @@ def run_fork_test(post_spec, pre_state):
assert getattr(pre_state, field) != getattr(post_state, field)
assert pre_state.fork.current_version == post_state.fork.previous_version
assert post_state.fork.current_version == post_spec.LIGHTCLIENT_PATCH_FORK_VERSION
assert post_state.fork.current_version == post_spec.ALTAIR_FORK_VERSION
assert post_state.fork.epoch == post_spec.get_current_epoch(post_state)
yield 'post', post_state
@with_phases(phases=[PHASE0], other_phases=[LIGHTCLIENT_PATCH])
@with_phases(phases=[PHASE0], other_phases=[ALTAIR])
@spec_test
@with_state
@with_meta_tags(HF1_FORK_TEST_META_TAGS)
@with_meta_tags(ALTAIR_FORK_TEST_META_TAGS)
def test_fork_base_state(spec, phases, state):
yield from run_fork_test(phases[LIGHTCLIENT_PATCH], state)
yield from run_fork_test(phases[ALTAIR], state)
@with_phases(phases=[PHASE0], other_phases=[LIGHTCLIENT_PATCH])
@with_phases(phases=[PHASE0], other_phases=[ALTAIR])
@spec_test
@with_state
@with_meta_tags(HF1_FORK_TEST_META_TAGS)
@with_meta_tags(ALTAIR_FORK_TEST_META_TAGS)
def test_fork_next_epoch(spec, phases, state):
next_epoch(spec, state)
yield from run_fork_test(phases[LIGHTCLIENT_PATCH], state)
yield from run_fork_test(phases[ALTAIR], state)
@with_phases(phases=[PHASE0], other_phases=[LIGHTCLIENT_PATCH])
@with_phases(phases=[PHASE0], other_phases=[ALTAIR])
@spec_test
@with_state
@with_meta_tags(HF1_FORK_TEST_META_TAGS)
@with_meta_tags(ALTAIR_FORK_TEST_META_TAGS)
def test_fork_next_epoch_with_block(spec, phases, state):
next_epoch_via_block(spec, state)
yield from run_fork_test(phases[LIGHTCLIENT_PATCH], state)
yield from run_fork_test(phases[ALTAIR], state)
@with_phases(phases=[PHASE0], other_phases=[LIGHTCLIENT_PATCH])
@with_phases(phases=[PHASE0], other_phases=[ALTAIR])
@spec_test
@with_state
@with_meta_tags(HF1_FORK_TEST_META_TAGS)
@with_meta_tags(ALTAIR_FORK_TEST_META_TAGS)
def test_fork_many_next_epoch(spec, phases, state):
for _ in range(3):
next_epoch(spec, state)
yield from run_fork_test(phases[LIGHTCLIENT_PATCH], state)
yield from run_fork_test(phases[ALTAIR], state)
@with_phases(phases=[PHASE0], other_phases=[LIGHTCLIENT_PATCH])
@with_phases(phases=[PHASE0], other_phases=[ALTAIR])
@with_custom_state(balances_fn=low_balances, threshold_fn=lambda spec: spec.EJECTION_BALANCE)
@spec_test
@with_meta_tags(HF1_FORK_TEST_META_TAGS)
@with_meta_tags(ALTAIR_FORK_TEST_META_TAGS)
def test_fork_random_low_balances(spec, phases, state):
yield from run_fork_test(phases[LIGHTCLIENT_PATCH], state)
yield from run_fork_test(phases[ALTAIR], state)
@with_phases(phases=[PHASE0], other_phases=[LIGHTCLIENT_PATCH])
@with_phases(phases=[PHASE0], other_phases=[ALTAIR])
@with_custom_state(balances_fn=misc_balances, threshold_fn=lambda spec: spec.EJECTION_BALANCE)
@spec_test
@with_meta_tags(HF1_FORK_TEST_META_TAGS)
@with_meta_tags(ALTAIR_FORK_TEST_META_TAGS)
def test_fork_random_misc_balances(spec, phases, state):
yield from run_fork_test(phases[LIGHTCLIENT_PATCH], state)
yield from run_fork_test(phases[ALTAIR], state)
@with_phases(phases=[PHASE0], other_phases=[LIGHTCLIENT_PATCH])
@with_phases(phases=[PHASE0], other_phases=[ALTAIR])
@with_custom_state(balances_fn=large_validator_set, threshold_fn=lambda spec: spec.EJECTION_BALANCE)
@spec_test
@with_meta_tags(HF1_FORK_TEST_META_TAGS)
@with_meta_tags(ALTAIR_FORK_TEST_META_TAGS)
def test_fork_random_large_validator_set(spec, phases, state):
yield from run_fork_test(phases[LIGHTCLIENT_PATCH], state)
yield from run_fork_test(phases[ALTAIR], state)

View File

@ -2,7 +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.altair import spec as spec_altair
from eth2spec.utils import bls
from .exceptions import SkippedTest
@ -20,7 +20,7 @@ from importlib import reload
def reload_specs():
reload(spec_phase0)
reload(spec_phase1)
reload(spec_lightclient_patch)
reload(spec_altair)
# Some of the Spec module functionality is exposed here to deal with phase-specific changes.
@ -30,9 +30,9 @@ ConfigName = NewType("ConfigName", str)
PHASE0 = SpecForkName('phase0')
PHASE1 = SpecForkName('phase1')
LIGHTCLIENT_PATCH = SpecForkName('lightclient_patch')
ALTAIR = SpecForkName('altair')
ALL_PHASES = (PHASE0, PHASE1, LIGHTCLIENT_PATCH)
ALL_PHASES = (PHASE0, PHASE1, ALTAIR)
MAINNET = ConfigName('mainnet')
MINIMAL = ConfigName('minimal')
@ -40,7 +40,7 @@ MINIMAL = ConfigName('minimal')
ALL_CONFIGS = (MINIMAL, MAINNET)
# The forks that output to the test vectors.
TESTGEN_FORKS = (PHASE0, LIGHTCLIENT_PATCH)
TESTGEN_FORKS = (PHASE0, ALTAIR)
# TODO: currently phases are defined as python modules.
# It would be better if they would be more well-defined interfaces for stronger typing.
@ -66,7 +66,7 @@ class SpecLightclient(Spec):
class SpecForks(TypedDict, total=False):
PHASE0: SpecPhase0
PHASE1: SpecPhase1
LIGHTCLIENT_PATCH: SpecLightclient
ALTAIR: SpecLightclient
def _prepare_state(balances_fn: Callable[[Any], Sequence[int]], threshold_fn: Callable[[Any], int],
@ -82,8 +82,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:
state = phases[LIGHTCLIENT_PATCH].upgrade_to_lightclient_patch(state)
elif spec.fork == ALTAIR:
state = phases[ALTAIR].upgrade_to_altair(state)
return state
@ -352,16 +352,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
if ALTAIR in available_phases:
phase_dir[ALTAIR] = spec_altair
# 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)
if ALTAIR in run_phases:
ret = fn(spec=spec_altair, phases=phase_dir, *args, **kw)
return ret
return wrapper
return decorator
@ -397,9 +397,9 @@ def only_full_crosslink(fn):
return wrapper
def is_post_lightclient_patch(spec):
def is_post_altair(spec):
if spec.fork in [PHASE0, PHASE1]:
# TODO: PHASE1 fork is temporarily parallel to LIGHTCLIENT_PATCH.
# Will make PHASE1 fork inherit LIGHTCLIENT_PATCH later.
# TODO: PHASE1 fork is temporarily parallel to ALTAIR.
# Will make PHASE1 fork inherit ALTAIR later.
return False
return True

View File

@ -2,7 +2,7 @@ from lru import LRU
from typing import List
from eth2spec.test.context import expect_assertion_error, PHASE1, is_post_lightclient_patch
from eth2spec.test.context import expect_assertion_error, PHASE1, is_post_altair
from eth2spec.test.helpers.state import state_transition_and_sign_block, next_epoch, next_slot
from eth2spec.test.helpers.block import build_empty_block_for_next_slot
from eth2spec.test.helpers.shard_transitions import get_shard_transition_of_committee
@ -30,7 +30,7 @@ def run_attestation_processing(spec, state, attestation, valid=True):
yield 'post', None
return
if not is_post_lightclient_patch(spec):
if not is_post_altair(spec):
current_epoch_count = len(state.current_epoch_attestations)
previous_epoch_count = len(state.previous_epoch_attestations)
@ -38,7 +38,7 @@ def run_attestation_processing(spec, state, attestation, valid=True):
spec.process_attestation(state, attestation)
# Make sure the attestation has been processed
if not is_post_lightclient_patch(spec):
if not is_post_altair(spec):
if attestation.data.target.epoch == spec.get_current_epoch(state):
assert len(state.current_epoch_attestations) == current_epoch_count + 1
else:
@ -320,7 +320,7 @@ def prepare_state_with_attestations(spec, state, participation_fn=None):
next_slot(spec, state)
assert state.slot == next_epoch_start_slot + spec.MIN_ATTESTATION_INCLUSION_DELAY
if not is_post_lightclient_patch(spec):
if not is_post_altair(spec):
assert len(state.previous_epoch_attestations) == len(attestations)
return attestations

View File

@ -1,4 +1,4 @@
from eth2spec.test.context import is_post_lightclient_patch
from eth2spec.test.context import is_post_altair
from eth2spec.test.helpers.keys import privkeys
from eth2spec.utils import bls
from eth2spec.utils.bls import only_with_bls
@ -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 is_post_lightclient_patch(spec):
if is_post_altair(spec):
empty_block.body.sync_committee_signature = spec.G2_POINT_AT_INFINITY
apply_randao_reveal(spec, state, empty_block)

View File

@ -1,5 +1,5 @@
from eth2spec.test.context import is_post_lightclient_patch
from eth2spec.test.context import is_post_altair
def get_process_calls(spec):
@ -16,8 +16,8 @@ def get_process_calls(spec):
'process_slashings_reset',
'process_randao_mixes_reset',
'process_historical_roots_update',
# HF1 replaced `process_participation_record_updates` with `process_participation_flag_updates`
'process_participation_flag_updates' if is_post_lightclient_patch(spec) else (
# Altair replaced `process_participation_record_updates` with `process_participation_flag_updates`
'process_participation_flag_updates' if is_post_altair(spec) else (
'process_participation_record_updates'
),
'process_sync_committee_updates',

View File

@ -1,12 +1,12 @@
from eth2spec.test.context import is_post_lightclient_patch
from eth2spec.test.context import is_post_altair
from eth2spec.test.helpers.block_header import sign_block_header
from eth2spec.test.helpers.keys import pubkey_to_privkey
from eth2spec.test.helpers.state import get_balance
def get_min_slashing_penalty_quotient(spec):
if is_post_lightclient_patch(spec):
return spec.HF1_MIN_SLASHING_PENALTY_QUOTIENT
if is_post_altair(spec):
return spec.ALTAIR_MIN_SLASHING_PENALTY_QUOTIENT
else:
return spec.MIN_SLASHING_PENALTY_QUOTIENT

View File

@ -2,7 +2,7 @@ from random import Random
from lru import LRU
from eth2spec.phase0 import spec as spec_phase0
from eth2spec.test.context import is_post_lightclient_patch
from eth2spec.test.context import is_post_altair
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
@ -39,7 +39,7 @@ def run_deltas(spec, state):
"""
yield 'pre', state
if is_post_lightclient_patch(spec):
if is_post_altair(spec):
def get_source_deltas(state):
return spec.get_flag_deltas(state, spec.TIMELY_SOURCE_FLAG_INDEX, spec.TIMELY_SOURCE_FLAG_NUMERATOR)
@ -52,21 +52,21 @@ def run_deltas(spec, state):
yield from run_attestation_component_deltas(
spec,
state,
spec.get_source_deltas if not is_post_lightclient_patch(spec) else get_source_deltas,
spec.get_source_deltas if not is_post_altair(spec) else get_source_deltas,
spec.get_matching_source_attestations,
'source_deltas',
)
yield from run_attestation_component_deltas(
spec,
state,
spec.get_target_deltas if not is_post_lightclient_patch(spec) else get_target_deltas,
spec.get_target_deltas if not is_post_altair(spec) else get_target_deltas,
spec.get_matching_target_attestations,
'target_deltas',
)
yield from run_attestation_component_deltas(
spec,
state,
spec.get_head_deltas if not is_post_lightclient_patch(spec) else get_head_deltas,
spec.get_head_deltas if not is_post_altair(spec) else get_head_deltas,
spec.get_matching_head_attestations,
'head_deltas',
)
@ -93,7 +93,7 @@ def run_attestation_component_deltas(spec, state, component_delta_fn, matching_a
yield deltas_name, Deltas(rewards=rewards, penalties=penalties)
if not is_post_lightclient_patch(spec):
if not is_post_altair(spec):
matching_attestations = matching_att_fn(state, spec.get_previous_epoch(state))
matching_indices = spec.get_unslashed_attesting_indices(state, matching_attestations)
else:
@ -129,7 +129,7 @@ def run_get_inclusion_delay_deltas(spec, state):
Run ``get_inclusion_delay_deltas``, yielding:
- inclusion delay deltas ('inclusion_delay_deltas')
"""
if is_post_lightclient_patch(spec):
if is_post_altair(spec):
# No inclusion_delay_deltas
yield 'inclusion_delay_deltas', Deltas(rewards=[0] * len(state.validators),
penalties=[0] * len(state.validators))
@ -182,7 +182,7 @@ def run_get_inactivity_penalty_deltas(spec, state):
yield 'inactivity_penalty_deltas', Deltas(rewards=rewards, penalties=penalties)
if not is_post_lightclient_patch(spec):
if not is_post_altair(spec):
matching_attestations = spec.get_matching_target_attestations(state, spec.get_previous_epoch(state))
matching_attesting_indices = spec.get_unslashed_attesting_indices(state, matching_attestations)
else:
@ -200,7 +200,7 @@ def run_get_inactivity_penalty_deltas(spec, state):
if spec.is_in_inactivity_leak(state):
# Compute base_penalty
if not is_post_lightclient_patch(spec):
if not is_post_altair(spec):
cancel_base_rewards_per_epoch = spec.BASE_REWARDS_PER_EPOCH
base_reward = spec.get_base_reward(state, index)
base_penalty = cancel_base_rewards_per_epoch * base_reward - spec.get_proposer_reward(state, index)
@ -308,7 +308,7 @@ def run_test_full_all_correct(spec, state):
def run_test_full_but_partial_participation(spec, state, rng=Random(5522)):
cached_prepare_state_with_attestations(spec, state)
if not is_post_lightclient_patch(spec):
if not is_post_altair(spec):
for a in state.previous_epoch_attestations:
a.aggregation_bits = [rng.choice([True, False]) for _ in a.aggregation_bits]
else:
@ -323,7 +323,7 @@ def run_test_partial(spec, state, fraction_filled):
cached_prepare_state_with_attestations(spec, state)
# Remove portion of attestations
if not is_post_lightclient_patch(spec):
if not is_post_altair(spec):
num_attestations = int(len(state.previous_epoch_attestations) * fraction_filled)
state.previous_epoch_attestations = state.previous_epoch_attestations[:num_attestations]
else:
@ -383,7 +383,7 @@ def run_test_some_very_low_effective_balances_that_attested(spec, state):
def run_test_some_very_low_effective_balances_that_did_not_attest(spec, state):
cached_prepare_state_with_attestations(spec, state)
if not is_post_lightclient_patch(spec):
if not is_post_altair(spec):
# Remove attestation
attestation = state.previous_epoch_attestations[0]
state.previous_epoch_attestations = state.previous_epoch_attestations[1:]
@ -502,7 +502,7 @@ def run_test_full_random(spec, state, rng=Random(8020)):
cached_prepare_state_with_attestations(spec, state)
if not is_post_lightclient_patch(spec):
if not is_post_altair(spec):
for pending_attestation in state.previous_epoch_attestations:
# ~1/3 have bad target
if rng.randint(0, 2) == 0:

View File

@ -1,4 +1,4 @@
from eth2spec.test.context import is_post_lightclient_patch, spec_state_test, with_all_phases
from eth2spec.test.context import is_post_altair, spec_state_test, with_all_phases
from eth2spec.test.helpers.epoch_processing import (
run_epoch_processing_with,
)
@ -16,7 +16,7 @@ def add_mock_attestations(spec, state, epoch, source, target, sufficient_support
previous_epoch = spec.get_previous_epoch(state)
current_epoch = spec.get_current_epoch(state)
if not is_post_lightclient_patch(spec):
if not is_post_altair(spec):
if current_epoch == epoch:
attestations = state.current_epoch_attestations
elif previous_epoch == epoch:
@ -61,7 +61,7 @@ def add_mock_attestations(spec, state, epoch, source, target, sufficient_support
aggregation_bits[i] = 0
# Update state
if not is_post_lightclient_patch(spec):
if not is_post_altair(spec):
attestations.append(spec.PendingAttestation(
aggregation_bits=aggregation_bits,
data=spec.AttestationData(

View File

@ -5,7 +5,7 @@ from eth2spec.test.context import (
with_custom_state,
zero_activation_threshold,
misc_balances, low_single_balance,
is_post_lightclient_patch,
is_post_altair,
)
from eth2spec.test.helpers.state import (
next_epoch,
@ -161,7 +161,7 @@ def run_with_participation(spec, state, participation_fn):
attestations = prepare_state_with_attestations(spec, state, participation_fn=participation_tracker)
pre_state = state.copy()
if not is_post_lightclient_patch(spec):
if not is_post_altair(spec):
proposer_indices = [a.proposer_index for a in state.previous_epoch_attestations]
else:
sync_committee_indices = spec.get_sync_committee_indices(state, spec.get_current_epoch(state))
@ -173,11 +173,11 @@ def run_with_participation(spec, state, participation_fn):
for index in range(len(pre_state.validators)):
if spec.is_in_inactivity_leak(state):
# Proposers can still make money during a leak before LIGHTCLIENT_PATCH
if not is_post_lightclient_patch(spec) and index in proposer_indices and index in participated:
# Proposers can still make money during a leak before ALTAIR
if not is_post_altair(spec) and index in proposer_indices and index in participated:
assert state.balances[index] > pre_state.balances[index]
elif index in attesting_indices:
if is_post_lightclient_patch(spec) and index in sync_committee_indices:
if is_post_altair(spec) 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:
@ -428,7 +428,7 @@ def test_attestations_some_slashed(spec, state):
for i in range(spec.MIN_PER_EPOCH_CHURN_LIMIT):
spec.slash_validator(state, attesting_indices_before_slashings[i])
if not is_post_lightclient_patch(spec):
if not is_post_altair(spec):
assert len(state.previous_epoch_attestations) == len(attestations)
pre_state = state.copy()

View File

@ -1,4 +1,4 @@
from eth2spec.test.context import spec_state_test, with_all_phases, is_post_lightclient_patch
from eth2spec.test.context import spec_state_test, with_all_phases, is_post_altair
from eth2spec.test.helpers.epoch_processing import (
run_epoch_processing_with, run_epoch_processing_to
)
@ -24,8 +24,8 @@ def slash_validators(spec, state, indices, out_epochs):
def get_slashing_multiplier(spec):
if is_post_lightclient_patch(spec):
return spec.HF1_PROPORTIONAL_SLASHING_MULTIPLIER
if is_post_altair(spec):
return spec.ALTAIR_PROPORTIONAL_SLASHING_MULTIPLIER
else:
return spec.PROPORTIONAL_SLASHING_MULTIPLIER

View File

@ -35,7 +35,7 @@ from eth2spec.test.context import (
with_configs,
with_custom_state,
large_validator_set,
is_post_lightclient_patch,
is_post_altair,
)
@ -781,14 +781,14 @@ def test_attestation(spec, state):
spec, state, shard_transition=shard_transition, index=index, signed=True, on_time=True
)
if not is_post_lightclient_patch(spec):
if not is_post_altair(spec):
pre_current_attestations_len = len(state.current_epoch_attestations)
# Add to state via block transition
attestation_block.body.attestations.append(attestation)
signed_attestation_block = state_transition_and_sign_block(spec, state, attestation_block)
if not is_post_lightclient_patch(spec):
if not is_post_altair(spec):
assert len(state.current_epoch_attestations) == pre_current_attestations_len + 1
# Epoch transition should move to previous_epoch_attestations
pre_current_attestations_root = spec.hash_tree_root(state.current_epoch_attestations)
@ -801,7 +801,7 @@ def test_attestation(spec, state):
yield 'blocks', [signed_attestation_block, signed_epoch_block]
yield 'post', state
if not is_post_lightclient_patch(spec):
if not is_post_altair(spec):
assert len(state.current_epoch_attestations) == 0
assert spec.hash_tree_root(state.previous_epoch_attestations) == pre_current_attestations_root
else:

View File

@ -1,4 +1,4 @@
from eth2spec.test.context import PHASE0, PHASE1, LIGHTCLIENT_PATCH, with_all_phases, spec_state_test
from eth2spec.test.context import PHASE0, PHASE1, ALTAIR, 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,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_PATCH):
if spec.fork in (PHASE0, ALTAIR):
latest_message = spec.LatestMessage(
epoch=attestation.data.target.epoch,
root=attestation.data.beacon_block_root,

View File

@ -1,6 +1,6 @@
from eth2spec.test.context import (
PHASE0,
LIGHTCLIENT_PATCH,
ALTAIR,
with_all_phases_except,
spec_state_test,
always_bls,
@ -13,7 +13,7 @@ from eth2spec.test.helpers.attestations import (
)
@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
@always_bls
def test_on_time_success(spec, state):
@ -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_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
@always_bls
def test_late_success(spec, state):

View File

@ -9,7 +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,
ALTAIR,
MINIMAL,
expect_assertion_error,
disable_process_reveal_deadlines,
@ -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_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
@with_configs([MINIMAL], reason="too slow")
@disable_process_reveal_deadlines
@ -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_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
@disable_process_reveal_deadlines
@with_configs([MINIMAL], reason="too slow")
@ -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_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
@disable_process_reveal_deadlines
@with_configs([MINIMAL], reason="too slow")
@ -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_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
@disable_process_reveal_deadlines
@with_configs([MINIMAL], reason="too slow")
@ -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_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
@disable_process_reveal_deadlines
@with_configs([MINIMAL], reason="too slow")
@ -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_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
@disable_process_reveal_deadlines
@with_configs([MINIMAL], reason="too slow")
@ -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_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
@disable_process_reveal_deadlines
@with_configs([MINIMAL], reason="too slow")
@ -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_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
@disable_process_reveal_deadlines
@with_configs([MINIMAL], reason="too slow")
@ -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_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
@disable_process_reveal_deadlines
@with_configs([MINIMAL], reason="too slow")
@ -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_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
@disable_process_reveal_deadlines
@with_configs([MINIMAL], reason="too slow")
@ -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_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
@disable_process_reveal_deadlines
@with_configs([MINIMAL], reason="too slow")

View File

@ -1,7 +1,7 @@
from eth2spec.test.helpers.custody import get_valid_custody_key_reveal
from eth2spec.test.context import (
PHASE0,
LIGHTCLIENT_PATCH,
ALTAIR,
with_all_phases_except,
spec_state_test,
expect_assertion_error,
@ -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_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
@always_bls
def test_success(spec, state):
@ -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_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
@always_bls
def test_reveal_too_early(spec, state):
@ -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_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
@always_bls
def test_wrong_period(spec, state):
@ -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_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
@always_bls
def test_late_reveal(spec, state):
@ -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_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
@always_bls
def test_double_reveal(spec, state):

View File

@ -11,7 +11,7 @@ from eth2spec.test.helpers.state import get_balance, transition_to
from eth2spec.test.context import (
PHASE0,
MINIMAL,
LIGHTCLIENT_PATCH,
ALTAIR,
with_all_phases_except,
spec_state_test,
expect_assertion_error,
@ -113,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, LIGHTCLIENT_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
@disable_process_reveal_deadlines
@with_configs([MINIMAL], reason="too slow")
@ -121,7 +121,7 @@ def test_custody_slashing(spec, state):
yield from run_standard_custody_slashing_test(spec, state)
@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
@disable_process_reveal_deadlines
@with_configs([MINIMAL], reason="too slow")
@ -129,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, LIGHTCLIENT_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
@disable_process_reveal_deadlines
@with_configs([MINIMAL], reason="too slow")
@ -137,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, LIGHTCLIENT_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
@disable_process_reveal_deadlines
@with_configs([MINIMAL], reason="too slow")
@ -145,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, LIGHTCLIENT_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
@disable_process_reveal_deadlines
@with_configs([MINIMAL], reason="too slow")

View File

@ -2,7 +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,
ALTAIR,
with_all_phases_except,
spec_state_test,
expect_assertion_error,
@ -42,7 +42,7 @@ def run_early_derived_secret_reveal_processing(spec, state, randao_key_reveal, v
yield 'post', state
@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
@always_bls
def test_success(spec, state):
@ -51,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, LIGHTCLIENT_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
@never_bls
def test_reveal_from_current_epoch(spec, state):
@ -60,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, LIGHTCLIENT_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
@never_bls
def test_reveal_from_past_epoch(spec, state):
@ -70,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, LIGHTCLIENT_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
@always_bls
def test_reveal_with_custody_padding(spec, state):
@ -82,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, LIGHTCLIENT_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
@always_bls
def test_reveal_with_custody_padding_minus_one(spec, state):
@ -94,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, LIGHTCLIENT_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
@never_bls
def test_double_reveal(spec, state):
@ -115,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, LIGHTCLIENT_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
@never_bls
def test_revealer_is_slashed(spec, state):
@ -125,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, LIGHTCLIENT_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
@never_bls
def test_far_future_epoch(spec, state):

View File

@ -1,6 +1,6 @@
from eth2spec.test.context import (
PHASE0,
LIGHTCLIENT_PATCH,
ALTAIR,
with_all_phases_except,
only_full_crosslink,
spec_state_test,
@ -91,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, LIGHTCLIENT_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@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, LIGHTCLIENT_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@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, LIGHTCLIENT_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
@only_full_crosslink
def test_no_winning_root(spec, state):
@ -153,7 +153,7 @@ def test_no_winning_root(spec, state):
assert state.shard_states == pre_shard_states
@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
@only_full_crosslink
def test_wrong_shard_transition_root(spec, state):

View File

@ -8,7 +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,
ALTAIR,
MINIMAL,
spec_state_test,
with_all_phases_except,
@ -26,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, LIGHTCLIENT_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
@with_configs([MINIMAL], reason="too slow")
def test_validator_slashed_after_chunk_challenge(spec, state):

View File

@ -1,6 +1,6 @@
from eth2spec.test.context import (
PHASE0,
LIGHTCLIENT_PATCH,
ALTAIR,
)
from eth2spec.test.helpers.custody import (
get_valid_chunk_challenge,
@ -30,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, LIGHTCLIENT_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
def test_validator_withdrawal_delay(spec, state):
transition_to_valid_shard_slot(spec, state)
@ -43,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, LIGHTCLIENT_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
def test_validator_withdrawal_reenable_after_custody_reveal(spec, state):
transition_to_valid_shard_slot(spec, state)
@ -68,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, LIGHTCLIENT_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
def test_validator_withdrawal_suspend_after_chunk_challenge(spec, state):
transition_to_valid_shard_slot(spec, state)
@ -117,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, LIGHTCLIENT_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
def test_validator_withdrawal_resume_after_chunk_challenge_response(spec, state):
transition_to_valid_shard_slot(spec, state)

View File

@ -4,7 +4,7 @@ from eth2spec.test.helpers.custody import (
from eth2spec.test.helpers.state import transition_to
from eth2spec.test.context import (
PHASE0,
LIGHTCLIENT_PATCH,
ALTAIR,
MINIMAL,
with_all_phases_except,
with_configs,
@ -18,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, LIGHTCLIENT_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
@with_configs([MINIMAL], reason="too slow")
def test_validator_slashed_after_reveal_deadline(spec, state):
@ -38,7 +38,7 @@ def test_validator_slashed_after_reveal_deadline(spec, state):
assert state.validators[0].slashed == 1
@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
@with_configs([MINIMAL], reason="too slow")
def test_validator_not_slashed_after_reveal(spec, state):

View File

@ -2,7 +2,7 @@ from typing import Dict, Sequence
from eth2spec.test.context import (
PHASE0,
LIGHTCLIENT_PATCH,
ALTAIR,
MINIMAL,
with_all_phases_except,
spec_state_test,
@ -100,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, LIGHTCLIENT_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
@only_full_crosslink
def test_process_beacon_block_with_normal_shard_transition(spec, state):
@ -114,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, LIGHTCLIENT_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
@only_full_crosslink
def test_process_beacon_block_with_empty_proposal_transition(spec, state):
@ -133,7 +133,7 @@ def test_process_beacon_block_with_empty_proposal_transition(spec, state):
#
@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
@only_full_crosslink
def test_with_shard_transition_with_custody_challenge_and_response(spec, state):
@ -167,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, LIGHTCLIENT_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
@with_configs([MINIMAL])
def test_custody_key_reveal(spec, state):
@ -181,7 +181,7 @@ def test_custody_key_reveal(spec, state):
yield from run_beacon_block(spec, state, block)
@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
def test_early_derived_secret_reveal(spec, state):
transition_to_valid_shard_slot(spec, state)
@ -192,7 +192,7 @@ def test_early_derived_secret_reveal(spec, state):
yield from run_beacon_block(spec, state, block)
@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
@only_full_crosslink
def test_custody_slashing(spec, state):

View File

@ -1,6 +1,6 @@
from eth2spec.test.context import (
PHASE0,
LIGHTCLIENT_PATCH,
ALTAIR,
always_bls,
expect_assertion_error,
spec_state_test,
@ -44,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, LIGHTCLIENT_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
@always_bls
@only_full_crosslink
@ -64,7 +64,7 @@ def test_valid_shard_block(spec, state):
#
@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
@only_full_crosslink
def test_invalid_shard_parent_root(spec, state):
@ -80,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, LIGHTCLIENT_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
@only_full_crosslink
def test_invalid_beacon_parent_root(spec, state):
@ -95,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, LIGHTCLIENT_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
@only_full_crosslink
def test_invalid_slot(spec, state):
@ -111,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, LIGHTCLIENT_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
@only_full_crosslink
def test_invalid_proposer_index(spec, state):
@ -131,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, LIGHTCLIENT_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
@always_bls
@only_full_crosslink
@ -152,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, LIGHTCLIENT_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
@always_bls
@only_full_crosslink
@ -171,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, LIGHTCLIENT_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
@always_bls
@only_full_crosslink
@ -190,7 +190,7 @@ def test_empty_block_body(spec, state):
#
@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
@always_bls
@only_full_crosslink
@ -209,7 +209,7 @@ def test_invalid_signature(spec, state):
#
@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
@always_bls
@only_full_crosslink
@ -226,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, LIGHTCLIENT_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
@always_bls
@only_full_crosslink

View File

@ -2,7 +2,7 @@ from eth2spec.utils.ssz.ssz_impl import hash_tree_root
from eth2spec.test.context import (
PHASE0,
LIGHTCLIENT_PATCH,
ALTAIR,
spec_state_test,
with_all_phases_except,
never_bls,
@ -152,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, LIGHTCLIENT_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
@never_bls # Set to never_bls for testing `check_pending_shard_blocks`
def test_basic(spec, state):
@ -213,7 +213,7 @@ def create_simple_fork(spec, state, store, shard):
return head_block, forking_block
@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
@only_full_crosslink
def test_shard_simple_fork(spec, state):
@ -238,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, LIGHTCLIENT_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
@only_full_crosslink
def test_shard_latest_messages_for_different_shards(spec, state):

View File

@ -1,13 +1,13 @@
from eth2spec.test.context import (
PHASE0,
LIGHTCLIENT_PATCH,
ALTAIR,
with_all_phases_except,
spec_state_test,
)
from eth2spec.test.helpers.state import next_epoch
@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
def test_get_committee_count_delta(spec, state):
assert spec.get_committee_count_delta(state, 0, 0) == 0
@ -24,7 +24,7 @@ def test_get_committee_count_delta(spec, state):
)
@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
def test_get_start_shard_current_epoch_start(spec, state):
assert state.current_epoch_start_shard == 0
@ -40,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, LIGHTCLIENT_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
def test_get_start_shard_next_slot(spec, state):
next_epoch(spec, state)
@ -58,7 +58,7 @@ def test_get_start_shard_next_slot(spec, state):
assert start_shard == expected_start_shard
@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
def test_get_start_shard_previous_slot(spec, state):
next_epoch(spec, state)
@ -77,7 +77,7 @@ def test_get_start_shard_previous_slot(spec, state):
assert start_shard == expected_start_shard
@with_all_phases_except([PHASE0, LIGHTCLIENT_PATCH])
@with_all_phases_except([PHASE0, ALTAIR])
@spec_state_test
def test_get_start_shard_far_past_epoch(spec, state):
initial_epoch = spec.get_current_epoch(state)

View File

@ -22,7 +22,7 @@ Key of valid `fork` strings that might be found in `meta.yaml`
| String ID | Pre-fork | Post-fork | Function |
| - | - | - | - |
| `altair` | Phase 0 | Altair | `upgrade_to_lightclient_patch` |
| `altair` | Phase 0 | Altair | `upgrade_to_altair` |
### `pre.ssz_snappy`

View File

@ -163,14 +163,14 @@ Another example, to generate tests from pytests:
```python
from eth2spec.phase0 import spec as spec_phase0
from eth2spec.lightclient_patch import spec as spec_lightclient_patch
from eth2spec.altair import spec as spec_altair
from eth2spec.phase1 import spec as spec_phase1
from eth2spec.test.context import PHASE0, PHASE1, LIGHTCLIENT_PATCH
from eth2spec.test.context import PHASE0, PHASE1, ALTAIR
from eth2spec.gen_helpers.gen_from_tests.gen import run_state_test_generators
specs = (spec_phase0, spec_lightclient_patch, spec_phase1)
specs = (spec_phase0, spec_altair, spec_phase1)
if __name__ == "__main__":
@ -178,7 +178,7 @@ if __name__ == "__main__":
'blocks',
'slots',
]}
lightclient_patch_mods = {**{key: 'eth2spec.test.lightclient_patch.sanity.test_' + key for key in [
altair_mods = {**{key: 'eth2spec.test.altair.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 [
@ -188,7 +188,7 @@ if __name__ == "__main__":
all_mods = {
PHASE0: phase_0_mods,
LIGHTCLIENT_PATCH: lightclient_patch_mods,
ALTAIR: altair_mods,
PHASE1: phase_1_mods,
}

View File

@ -1,11 +1,11 @@
from eth2spec.gen_helpers.gen_from_tests.gen import run_state_test_generators
from eth2spec.phase0 import spec as spec_phase0
from eth2spec.lightclient_patch import spec as spec_lightclient_patch
from eth2spec.altair import spec as spec_altair
from eth2spec.phase1 import spec as spec_phase1
from eth2spec.test.context import PHASE0, PHASE1, LIGHTCLIENT_PATCH
from eth2spec.test.context import PHASE0, PHASE1, ALTAIR
specs = (spec_phase0, spec_lightclient_patch, spec_phase1)
specs = (spec_phase0, spec_altair, spec_phase1)
if __name__ == "__main__":
@ -21,8 +21,8 @@ if __name__ == "__main__":
'historical_roots_update',
'participation_record_updates',
]}
lightclient_patch_mods = {
**{key: 'eth2spec.test.lightclient_patch.epoch_processing.test_process_' + key for key in [
altair_mods = {
**{key: 'eth2spec.test.altair.epoch_processing.test_process_' + key for key in [
'sync_committee_updates',
]},
**phase_0_mods,
@ -35,7 +35,7 @@ if __name__ == "__main__":
all_mods = {
PHASE0: phase_0_mods,
LIGHTCLIENT_PATCH: lightclient_patch_mods,
ALTAIR: altair_mods,
PHASE1: phase_1_mods,
}

View File

@ -1,22 +1,22 @@
from eth2spec.gen_helpers.gen_from_tests.gen import run_state_test_generators
from eth2spec.phase0 import spec as spec_phase0
from eth2spec.lightclient_patch import spec as spec_lightclient_patch
from eth2spec.altair import spec as spec_altair
from eth2spec.phase1 import spec as spec_phase1
from eth2spec.test.context import PHASE0, PHASE1, LIGHTCLIENT_PATCH
from eth2spec.test.context import PHASE0, PHASE1, ALTAIR
specs = (spec_phase0, spec_lightclient_patch, spec_phase1)
specs = (spec_phase0, spec_altair, spec_phase1)
if __name__ == "__main__":
phase_0_mods = {'finality': 'eth2spec.test.phase0.finality.test_finality'}
# No additional lightclient_patch or phase 1 specific finality tests, yet.
lightclient_patch_mods = phase_0_mods
# No additional altair or phase 1 specific finality tests, yet.
altair_mods = phase_0_mods
phase_1_mods = phase_0_mods
all_mods = {
PHASE0: phase_0_mods,
LIGHTCLIENT_PATCH: lightclient_patch_mods,
ALTAIR: altair_mods,
PHASE1: phase_1_mods,
}

View File

@ -1,11 +1,11 @@
from importlib import reload
from typing import Iterable
from eth2spec.test.context import PHASE0, LIGHTCLIENT_PATCH, MINIMAL, MAINNET
from eth2spec.test.context import PHASE0, ALTAIR, MINIMAL, MAINNET
from eth2spec.config import config_util
from eth2spec.test.lightclient_patch.fork import test_fork as test_altair_forks
from eth2spec.test.altair.fork import test_fork as test_altair_forks
from eth2spec.phase0 import spec as spec_phase0
from eth2spec.lightclient_patch import spec as spec_lightclient_patch
from eth2spec.altair import spec as spec_altair
from eth2spec.gen_helpers.gen_base import gen_runner, gen_typing
from eth2spec.gen_helpers.gen_from_tests.gen import generate_from_tests
@ -16,7 +16,7 @@ def create_provider(tests_src, config_name: str, phase: str, fork_name: str) ->
def prepare_fn(configs_path: str) -> str:
config_util.prepare_config(configs_path, config_name)
reload(spec_phase0)
reload(spec_lightclient_patch)
reload(spec_altair)
return config_name
def cases_fn() -> Iterable[gen_typing.TestCase]:
@ -33,6 +33,6 @@ def create_provider(tests_src, config_name: str, phase: str, fork_name: str) ->
if __name__ == "__main__":
gen_runner.run_generator("forks", [
create_provider(test_altair_forks, MINIMAL, PHASE0, LIGHTCLIENT_PATCH),
create_provider(test_altair_forks, MAINNET, PHASE0, LIGHTCLIENT_PATCH),
create_provider(test_altair_forks, MINIMAL, PHASE0, ALTAIR),
create_provider(test_altair_forks, MAINNET, PHASE0, ALTAIR),
])

View File

@ -1,11 +1,11 @@
from eth2spec.gen_helpers.gen_from_tests.gen import run_state_test_generators
from eth2spec.phase0 import spec as spec_phase0
from eth2spec.lightclient_patch import spec as spec_lightclient_patch
from eth2spec.altair import spec as spec_altair
from eth2spec.phase1 import spec as spec_phase1
from eth2spec.test.context import PHASE0, PHASE1, LIGHTCLIENT_PATCH
from eth2spec.test.context import PHASE0, PHASE1, ALTAIR
specs = (spec_phase0, spec_lightclient_patch, spec_phase1)
specs = (spec_phase0, spec_altair, spec_phase1)
if __name__ == "__main__":
@ -17,8 +17,8 @@ if __name__ == "__main__":
'proposer_slashing',
'voluntary_exit',
]}
lightclient_patch_mods = {
**{key: 'eth2spec.test.lightclient_patch.block_processing.test_process_' + key for key in [
altair_mods = {
**{key: 'eth2spec.test.altair.block_processing.test_process_' + key for key in [
'sync_committee',
]},
**phase_0_mods,
@ -34,7 +34,7 @@ if __name__ == "__main__":
all_mods = {
PHASE0: phase_0_mods,
LIGHTCLIENT_PATCH: lightclient_patch_mods,
ALTAIR: altair_mods,
PHASE1: phase_1_mods,
}

View File

@ -1,11 +1,11 @@
from eth2spec.gen_helpers.gen_from_tests.gen import run_state_test_generators
from eth2spec.phase0 import spec as spec_phase0
from eth2spec.lightclient_patch import spec as spec_lightclient_patch
from eth2spec.altair import spec as spec_altair
from eth2spec.phase1 import spec as spec_phase1
from eth2spec.test.context import PHASE0, PHASE1, LIGHTCLIENT_PATCH
from eth2spec.test.context import PHASE0, PHASE1, ALTAIR
specs = (spec_phase0, spec_lightclient_patch, spec_phase1)
specs = (spec_phase0, spec_altair, spec_phase1)
if __name__ == "__main__":
@ -14,13 +14,13 @@ if __name__ == "__main__":
'leak',
'random',
]}
# No additional lightclient_patch or phase 1 specific rewards tests, yet.
lightclient_patch_mods = phase_0_mods
# No additional altair or phase 1 specific rewards tests, yet.
altair_mods = phase_0_mods
phase_1_mods = phase_0_mods
all_mods = {
PHASE0: phase_0_mods,
LIGHTCLIENT_PATCH: lightclient_patch_mods,
ALTAIR: altair_mods,
PHASE1: phase_1_mods,
}

View File

@ -1,12 +1,12 @@
from eth2spec.phase0 import spec as spec_phase0
from eth2spec.lightclient_patch import spec as spec_lightclient_patch
from eth2spec.altair import spec as spec_altair
from eth2spec.phase1 import spec as spec_phase1
from eth2spec.test.context import PHASE0, PHASE1, LIGHTCLIENT_PATCH
from eth2spec.test.context import PHASE0, PHASE1, ALTAIR
from eth2spec.gen_helpers.gen_from_tests.gen import run_state_test_generators
specs = (spec_phase0, spec_lightclient_patch, spec_phase1)
specs = (spec_phase0, spec_altair, spec_phase1)
if __name__ == "__main__":
@ -14,7 +14,7 @@ if __name__ == "__main__":
'blocks',
'slots',
]}
lightclient_patch_mods = {**{key: 'eth2spec.test.lightclient_patch.sanity.test_' + key for key in [
altair_mods = {**{key: 'eth2spec.test.altair.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 [
@ -24,7 +24,7 @@ if __name__ == "__main__":
all_mods = {
PHASE0: phase_0_mods,
LIGHTCLIENT_PATCH: lightclient_patch_mods,
ALTAIR: altair_mods,
PHASE1: phase_1_mods,
}

View File

@ -9,8 +9,8 @@ from eth2spec.debug import random_value, encode
from eth2spec.config import config_util
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.test.context import PHASE1, LIGHTCLIENT_PATCH, TESTGEN_FORKS, MINIMAL, MAINNET
from eth2spec.altair import spec as spec_altair
from eth2spec.test.context import PHASE1, ALTAIR, TESTGEN_FORKS, MINIMAL, MAINNET
from eth2spec.utils.ssz.ssz_typing import Container
from eth2spec.utils.ssz.ssz_impl import (
hash_tree_root,
@ -65,7 +65,7 @@ def create_provider(fork_name, config_name: str, seed: int, mode: random_value.R
config_util.prepare_config(configs_path, config_name)
reload(spec_phase0)
reload(spec_phase1)
reload(spec_lightclient_patch)
reload(spec_altair)
return config_name
def cases_fn() -> Iterable[gen_typing.TestCase]:
@ -73,8 +73,8 @@ def create_provider(fork_name, config_name: str, seed: int, mode: random_value.R
spec = spec_phase0
if fork_name == PHASE1:
spec = spec_phase1
if fork_name == LIGHTCLIENT_PATCH:
spec = spec_lightclient_patch
if fork_name == ALTAIR:
spec = spec_altair
for (i, (name, ssz_type)) in enumerate(get_spec_ssz_types(spec)):
yield from ssz_static_cases(fork_name, seed * 1000 + i, name, ssz_type, mode, chaos, count)