Merge branch 'dev' into leak-scores

This commit is contained in:
Danny Ryan 2021-03-11 09:28:58 -07:00
commit 79f351cfca
No known key found for this signature in database
GPG Key ID: 2765A792E42CE07A
75 changed files with 359 additions and 396 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)
@ -576,16 +576,17 @@ setup(
extras_require={
"test": ["pytest>=4.4", "pytest-cov", "pytest-xdist"],
"lint": ["flake8==3.7.7", "mypy==0.750"],
"generator": ["python-snappy==0.5.4"],
},
install_requires=[
"eth-utils>=1.3.0,<2",
"eth-typing>=2.1.0,<3.0.0",
"pycryptodome==3.9.4",
"py_ecc==5.1.0",
"py_ecc==5.2.0",
"milagro_bls_binding==1.6.3",
"dataclasses==0.6",
"remerkleable==0.1.18",
"ruamel.yaml==0.16.5",
"lru-dict==1.1.6"
"lru-dict==1.1.6",
]
)

View File

@ -1,4 +1,4 @@
# Ethereum 2.0 HF1
# Ethereum 2.0 Altair
## Table of contents
@ -56,7 +56,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
@ -109,9 +109,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
@ -151,8 +151,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`
@ -181,18 +181,18 @@ class BeaconState(Container):
# Slashings
slashings: Vector[Gwei, EPOCHS_PER_SLASHINGS_VECTOR] # Per-epoch sums of slashed effective balances
# Participation
previous_epoch_participation: List[ParticipationFlags, VALIDATOR_REGISTRY_LIMIT] # [New in HF1]
current_epoch_participation: List[ParticipationFlags, VALIDATOR_REGISTRY_LIMIT] # [New in HF1]
previous_epoch_participation: List[ParticipationFlags, VALIDATOR_REGISTRY_LIMIT] # [New in Altair]
current_epoch_participation: List[ParticipationFlags, VALIDATOR_REGISTRY_LIMIT] # [New in Altair]
# Finality
justification_bits: Bitvector[JUSTIFICATION_BITS_LENGTH] # Bit set for every recent justified epoch
previous_justified_checkpoint: Checkpoint
current_justified_checkpoint: Checkpoint
finalized_checkpoint: Checkpoint
# Light client sync committees
current_sync_committee: SyncCommittee # [New in HF1]
next_sync_committee: SyncCommittee # [New in HF1]
current_sync_committee: SyncCommittee # [New in Altair]
next_sync_committee: SyncCommittee # [New in Altair]
# Leak
leak_scores: List[uint64, VALIDATOR_REGISTRY_LIMIT] # [New in HF1]
leak_scores: List[uint64, VALIDATOR_REGISTRY_LIMIT] # [New in Altair]
```
### New containers
@ -380,7 +380,7 @@ def get_inactivity_penalty_deltas(state: BeaconState) -> Tuple[Sequence[Gwei], S
if index not in matching_target_attesting_indices and state.leak_scores[index] >= LEAK_SCORE_BIAS:
effective_balance = state.validators[index].effective_balance
leak_penalty = Gwei(
effective_balance * state.leak_scores[index] // LEAK_SCORE_BIAS // HF1_INACTIVITY_PENALTY_QUOTIENT
effective_balance * state.leak_scores[index] // LEAK_SCORE_BIAS // ALTAIR_INACTIVITY_PENALTY_QUOTIENT
)
penalties[index] += leak_penalty
@ -392,7 +392,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,
@ -407,7 +407,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)
@ -426,8 +426,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`
@ -520,9 +520,9 @@ 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)
state.previous_epoch_participation.append(ParticipationFlags(0b0000_0000)) # New in HF1
state.current_epoch_participation.append(ParticipationFlags(0b0000_0000)) # New in HF1
state.leak_scores.append(0) # New in HF1
state.previous_epoch_participation.append(ParticipationFlags(0b0000_0000)) # [New in Altair]
state.current_epoch_participation.append(ParticipationFlags(0b0000_0000)) # [New in Altair]
state.leak_scores.append(0) # [New in Altair]
else:
# Increase balance by deposit amount
index = ValidatorIndex(validator_pubkeys.index(pubkey))
@ -562,18 +562,18 @@ 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_leak_updates(state) # [New in HF1]
process_rewards_and_penalties(state) # [Modified in HF1]
process_justification_and_finalization(state) # [Modified in Altair]
process_leak_updates(state) # [New 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
@ -661,13 +661,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(
# Versioning
@ -48,7 +48,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

@ -8,6 +8,8 @@ from ruamel.yaml import (
YAML,
)
from snappy import compress
from eth2spec.test import context
from eth2spec.test.exceptions import SkippedTest
@ -181,7 +183,8 @@ def dump_yaml_fn(data: Any, name: str, file_mode: str, yaml_encoder: YAML):
def dump_ssz_fn(data: AnyStr, name: str, file_mode: str):
def dump(case_path: Path):
out_path = case_path / Path(name + '.ssz')
out_path = case_path / Path(name + '.ssz_snappy')
compressed = compress(data)
with out_path.open(file_mode + 'b') as f: # write in raw binary mode
f.write(data)
f.write(compressed)
return dump

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
@ -34,13 +34,13 @@ def run_deltas(spec, state):
- source deltas ('source_deltas')
- target deltas ('target_deltas')
- head deltas ('head_deltas')
- not if is_post_lightclient_patch(spec)
- not if is_post_altair(spec)
- inclusion delay deltas ('inclusion_delay_deltas')
- inactivity penalty deltas ('inactivity_penalty_deltas')
"""
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)
@ -53,25 +53,25 @@ 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',
)
if not is_post_lightclient_patch(spec):
if not is_post_altair(spec):
yield from run_get_inclusion_delay_deltas(spec, state)
yield from run_get_inactivity_penalty_deltas(spec, state)
@ -95,7 +95,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:
@ -131,7 +131,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))
@ -184,7 +184,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:
@ -202,7 +202,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)
@ -311,7 +311,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:
@ -326,7 +326,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:
@ -386,7 +386,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:]
@ -505,7 +505,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,
@ -34,7 +34,7 @@ def validate_resulting_balances(spec, pre_state, post_state, attestations):
for index in range(len(pre_state.validators)):
if not spec.is_active_validator(pre_state.validators[index], current_epoch):
assert post_state.balances[index] == pre_state.balances[index]
elif not is_post_lightclient_patch(spec):
elif not is_post_altair(spec):
proposer_indices = [a.proposer_index for a in post_state.previous_epoch_attestations]
if spec.is_in_inactivity_leak(post_state):
# Proposers can still make money during a leak before LIGHTCLIENT_PATCH
@ -432,7 +432,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

@ -1,5 +1,4 @@
from typing import Dict, Any
from eth2spec.debug.encode import encode
from eth2spec.utils.ssz.ssz_typing import View
from eth2spec.utils.ssz.ssz_impl import serialize
@ -39,24 +38,20 @@ def vector_test(description: str = None):
if value is None:
continue
if isinstance(value, View):
yield key, 'data', encode(value)
yield key, 'ssz', serialize(value)
elif isinstance(value, bytes):
yield key, 'data', encode(value)
yield key, 'ssz', value
elif isinstance(value, list) and all([isinstance(el, (View, bytes)) for el in value]):
for i, el in enumerate(value):
if isinstance(el, View):
yield f'{key}_{i}', 'data', encode(el)
yield f'{key}_{i}', 'ssz', serialize(el)
elif isinstance(el, bytes):
yield f'{key}_{i}', 'data', encode(el)
yield f'{key}_{i}', 'ssz', el
yield f'{key}_count', 'meta', len(value)
else:
# Not a ssz value.
# The data will now just be yielded as any python data,
# something that should be encodeable by the generator runner.
# something that should be encodable by the generator runner.
yield key, 'data', value
# check generator mode, may be None/else.

View File

@ -132,21 +132,25 @@ Cases are split up too. This enables diffing of parts of the test case, tracking
### `<output part>`
E.g. `pre.yaml`, `deposit.yaml`, `post.yaml`.
Diffing a `pre.yaml` and `post.yaml` provides all the information for testing, good for readability of the change.
Then the difference between pre and post can be compared to anything that changes the pre state, e.g. `deposit.yaml`
These files allow for custom formats for some parts of the test. E.g. something encoded in SSZ.
Or to avoid large files, the SSZ can be compressed with Snappy.
E.g. `pre.ssz_snappy`, `deposit.ssz_snappy`, `post.ssz_snappy`.
Some yaml files have copies, but formatted as raw SSZ bytes: `pre.ssz`, `deposit.ssz`, `post.ssz`.
The yaml files are intended to be deprecated, and clients should shift to ssz inputs for efficiency.
Deprecation will start once a viewer of SSZ test-cases is in place, to maintain a standard of readable test cases.
This also means that some clients can drop legacy YAML -> JSON/other -> SSZ work-arounds.
(These were implemented to support the uint64 YAML, hex strings, etc. Things that were not idiomatic to their language.)
Diffing a `pre.ssz_snappy` and `post.ssz_snappy` provides all the information for testing, when decompressed and decoded.
Then the difference between pre and post can be compared to anything that changes the pre state, e.g. `deposit.ssz_snappy`
YAML is generally used for test metadata, and for tests that do not use SSZ: e.g. shuffling and BLS tests.
In this case, there is no point in adding special SSZ types. And the size and efficiency of YAML is acceptable.
#### Common output formats
Between all types of tests, a few formats are common:
- **`.yaml`**: A YAML file containing structured data to describe settings or test contents.
- **`.ssz`**: A file containing raw SSZ-encoded data. Previously widely used in tests, but replaced with compressed variant.
- **`.ssz_snappy`**: Like `.ssz`, but compressed with Snappy block compression.
Snappy block compression is already applied to SSZ in Eth2 gossip, available in client implementations, and thus chosen as compression method.
Yaml will not be deprecated for tests that do not use SSZ: e.g. shuffling and BLS tests.
In this case, there is no work around for loading necessary anyway, and the size and efficiency of yaml is acceptable.
#### Special output parts

View File

@ -15,18 +15,13 @@ description: string -- Optional description of test case, purely for debuggin
bls_setting: int -- see general test-format spec.
```
### `pre.yaml`
### `pre.ssz_snappy`
A YAML-encoded `BeaconState`, the state before running the epoch sub-transition.
A SSZ-snappy encoded `BeaconState`, the state before running the epoch sub-transition.
Also available as `pre.ssz`.
### `post.ssz_snappy`
### `post.yaml`
A YAML-encoded `BeaconState`, the state after applying the epoch sub-transition.
Also available as `post.ssz`.
A SSZ-snappy encoded `BeaconState`, the state after applying the epoch sub-transition.
## Condition

View File

@ -14,11 +14,11 @@ bls_setting: int -- see general test-format spec.
blocks_count: int -- the number of blocks processed in this test.
```
### `pre.yaml`
### `pre.ssz_snappy`
A YAML-encoded `BeaconState`, the state before running the block transitions.
A SSZ-snappy encoded `BeaconState`, the state before running the block transitions.
Also available as `pre.ssz`.
Also available as `pre.ssz_snappy`.
### `blocks_<index>.yaml`
@ -28,13 +28,11 @@ A series of files, with `<index>` in range `[0, blocks_count)`. Blocks need to b
Each file is a YAML-encoded `SignedBeaconBlock`.
Each block is also available as `blocks_<index>.ssz`
Each block is also available as `blocks_<index>.ssz_snappy`
### `post.yaml`
### `post.ssz_snappy`
A YAML-encoded `BeaconState`, the state after applying the block transitions.
Also available as `post.ssz`.
A SSZ-snappy encoded `BeaconState`, the state after applying the block transitions.
## Condition

View File

@ -22,19 +22,15 @@ 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.yaml`
### `pre.ssz_snappy`
A YAML-encoded `BeaconState`, the state before running the fork transition.
A SSZ-snappy encoded `BeaconState`, the state before running the fork transition.
Also available as `pre.ssz`.
### `post.ssz_snappy`
### `post.yaml`
A YAML-encoded `BeaconState`, the state after applying the fork transition.
Also available as `post.ssz`.
A SSZ-snappy encoded `BeaconState`, the state after applying the fork transition.
*Note*: This type is the `BeaconState` after the fork and is *not* the same type as `pre`.

View File

@ -4,11 +4,9 @@ Tests the initialization of a genesis state based on Eth1 data.
## Test case format
### `eth1_block_hash.yaml`
### `eth1_block_hash.ssz_snappy`
A `Bytes32` hex encoded, with prefix 0x. The root of the Eth1 block.
Also available as `eth1_block_hash.ssz`.
A SSZ-snappy encoded root of the Eth1 block.
### `eth1_timestamp.yaml`
@ -22,18 +20,15 @@ A yaml file to help read the deposit count:
deposits_count: int -- Amount of deposits.
```
### `deposits_<index>.yaml`
### `deposits_<index>.ssz_snappy`
A series of files, with `<index>` in range `[0, deposits_count)`. Deposits need to be processed in order.
Each file is a YAML-encoded `Deposit` object.
Each file is a SSZ-snappy encoded `Deposit` object.
Each deposit is also available as `deposits_<index>.ssz`.
### `state.ssz_snappy`
### `state.yaml`
The expected genesis state. A SSZ-snappy encoded `BeaconState` object.
The expected genesis state. A YAML-encoded `BeaconState` object.
Also available as `state.ssz`.
## Processing

View File

@ -4,11 +4,10 @@ Tests if a genesis state is valid, i.e. if it counts as trigger to launch.
## Test case format
### `genesis.yaml`
### `genesis.ssz_snappy`
A `BeaconState`, the state to validate as genesis candidate.
A SSZ-snappy encoded `BeaconState`, the state to validate as genesis candidate.
Also available as `genesis.ssz`.
### `is_valid.yaml`

View File

@ -12,23 +12,17 @@ description: string -- Optional description of test case, purely for debuggin
bls_setting: int -- see general test-format spec.
```
### `pre.yaml`
### `pre.ssz_snappy`
A YAML-encoded `BeaconState`, the state before applying the operation.
A SSZ-snappy encoded `BeaconState`, the state before applying the operation.
Also available as `pre.ssz`.
### `<input-name>.ssz_snappy`
### `<input-name>.yaml`
A SSZ-snappy encoded operation object, e.g. a `ProposerSlashing`, or `Deposit`.
A YAML-encoded operation object, e.g. a `ProposerSlashing`, or `Deposit`.
### `post.ssz_snappy`
Also available as `<input-name>.ssz`.
### `post.yaml`
A YAML-encoded `BeaconState`, the state after applying the operation. No value if operation processing is aborted.
Also available as `post.ssz`.
A SSZ-snappy encoded `BeaconState`, the state after applying the operation. No value if operation processing is aborted.
## Condition

View File

@ -23,41 +23,29 @@ description: string -- Optional description of test case, purely for debuggin
_Note_: No signature verification happens within rewards sub-functions. These
tests can safely be run with or without BLS enabled.
### `pre.yaml`
### `pre.ssz_snappy`
A YAML-encoded `BeaconState`, the state before running the rewards sub-function.
A SSZ-snappy encoded `BeaconState`, the state before running the rewards sub-function.
Also available as `pre.ssz`.
### `source_deltas.ssz_snappy`
### `source_deltas.yaml`
A SSZ-snappy encoded `Deltas` representing the rewards and penalties returned by the rewards the `get_source_deltas` function
A YAML-encoded `Deltas` representing the rewards and penalties returned by the rewards the `get_source_deltas` function
### `target_deltas.ssz_snappy`
Also available as `source_deltas.ssz`.
A SSZ-snappy encoded `Deltas` representing the rewards and penalties returned by the rewards the `get_target_deltas` function
### `target_deltas.yaml`
### `head_deltas.ssz_snappy`
A YAML-encoded `Deltas` representing the rewards and penalties returned by the rewards the `get_target_deltas` function
A SSZ-snappy encoded `Deltas` representing the rewards and penalties returned by the rewards the `get_head_deltas` function
Also available as `target_deltas.ssz`.
### `inclusion_delay_deltas.ssz_snappy`
### `head_deltas.yaml`
A SSZ-snappy encoded `Deltas` representing the rewards and penalties returned by the rewards the `get_inclusion_delay_deltas` function
A YAML-encoded `Deltas` representing the rewards and penalties returned by the rewards the `get_head_deltas` function
### `inactivity_penalty_deltas.ssz_snappy`
Also available as `head_deltas.ssz`.
### `inclusion_delay_deltas.yaml`
A YAML-encoded `Deltas` representing the rewards and penalties returned by the rewards the `get_inclusion_delay_deltas` function
Also available as `inclusion_delay_deltas.ssz`.
### `inactivity_penalty_deltas.yaml`
A YAML-encoded `Deltas` representing the rewards and penalties returned by the rewards the `get_inactivity_penalty_deltas` function
Also available as `inactivity_penalty_deltas.ssz`.
A SSZ-snappy encoded `Deltas` representing the rewards and penalties returned by the rewards the `get_inactivity_penalty_deltas` function
## Condition

View File

@ -14,27 +14,21 @@ blocks_count: int -- the number of blocks processed in this test.
```
### `pre.yaml`
### `pre.ssz_snappy`
A YAML-encoded `BeaconState`, the state before running the block transitions.
Also available as `pre.ssz`.
A SSZ-snappy encoded `BeaconState`, the state before running the block transitions.
### `blocks_<index>.yaml`
### `blocks_<index>.ssz_snappy`
A series of files, with `<index>` in range `[0, blocks_count)`. Blocks need to be processed in order,
following the main transition function (i.e. process slot and epoch transitions in between blocks as normal)
Each file is a YAML-encoded `SignedBeaconBlock`.
Each file is a SSZ-snappy encoded `SignedBeaconBlock`.
Each block is also available as `blocks_<index>.ssz`
### `post.ssz_snappy`
### `post.yaml`
A YAML-encoded `BeaconState`, the state after applying the block transitions.
Also available as `post.ssz`.
A SSZ-snappy encoded `BeaconState`, the state after applying the block transitions.
## Condition

View File

@ -16,7 +16,7 @@ bls_setting: int -- see general test-format spec.
A YAML-encoded `BeaconState`, the state before running the transitions.
Also available as `pre.ssz`.
Also available as `pre.ssz_snappy`.
### `slots.yaml`
@ -27,7 +27,7 @@ An integer. The amount of slots to process (i.e. the difference in slots between
A YAML-encoded `BeaconState`, the state after applying the transitions.
Also available as `post.ssz`.
Also available as `post.ssz_snappy`.
### Processing

View File

@ -33,7 +33,7 @@ Each of the handlers encodes the SSZ type declaration in the file-name. See [Typ
### `valid`
Valid has 3 parts: `meta.yaml`, `serialized.ssz`, `value.yaml`
Valid has 3 parts: `meta.yaml`, `serialized.ssz_snappy`, `value.yaml`
### `meta.yaml`
@ -46,9 +46,9 @@ root: Bytes32 -- Hash-tree-root of the object
The `Bytes32` is encoded as a string, hexadecimal encoding, prefixed with `0x`.
### `serialized.ssz`
### `serialized.ssz_snappy`
The serialized form of the object, as raw SSZ bytes.
The serialized form of the object, as snappy-compressed SSZ bytes.
### `value.yaml`
@ -64,7 +64,7 @@ The conditions are the same for each type:
## `invalid`
Test cases in the `invalid` suite only include the `serialized.ssz`
Test cases in the `invalid` suite only include the `serialized.ssz_snappy`
#### Condition

View File

@ -18,7 +18,7 @@ One can iterate over the handlers, and select the type based on the handler name
Suites are then the same format, but each specialized in one randomization mode.
Some randomization modes may only produce a single test case (e.g. the all-zeroes case).
The output parts are: `roots.yaml`, `serialized.ssz`, `value.yaml`
The output parts are: `roots.yaml`, `serialized.ssz_snappy`, `value.yaml`
### `roots.yaml`
@ -26,13 +26,13 @@ The output parts are: `roots.yaml`, `serialized.ssz`, `value.yaml`
root: bytes32 -- string, hash-tree-root of the value, hex encoded, with prefix 0x
```
### `serialized.ssz`
### `serialized.ssz_snappy`
The raw encoded bytes.
The SSZ-snappy encoded bytes.
### `value.yaml`
The same value as `serialized.ssz`, represented as YAML.
The same value as `serialized.ssz_snappy`, represented as YAML.
## Condition

View File

@ -79,7 +79,7 @@ It's recommended to extend the base-generator.
Create a `requirements.txt` in the root of your generator directory:
```
pytest>=4.4
../../../
../../../[generator]
```
The config helper and pyspec is optional, but preferred. We encourage generators to derive tests from the spec itself in order to prevent code duplication and outdated tests.
@ -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,2 +1,2 @@
pytest>=4.4
../../../
../../../[generator]

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,2 +1,2 @@
pytest>=4.4
../../../
../../../[generator]

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,2 +1,2 @@
pytest>=4.4
../../../
../../../[generator]

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,2 +1,2 @@
pytest>=4.4
../../../
../../../[generator]

View File

@ -1,2 +1,2 @@
pytest>=4.4
../../../
../../../[generator]

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,2 +1,2 @@
pytest>=4.4
../../../
../../../[generator]

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,2 +1,2 @@
pytest>=4.4
../../../
../../../[generator]

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

@ -1,2 +1,2 @@
pytest>=4.4
../../../
../../../[generator]

View File

@ -1,2 +1,2 @@
pytest>=4.4
../../../
../../../[generator]

View File

@ -1,2 +1,2 @@
pytest>=4.4
../../../
../../../[generator]

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)

View File

@ -1,2 +1,2 @@
pytest>=4.4
../../../
../../../[generator]