Skip to content

Commit

Permalink
Merge branch 'dev' into upgrade-to-electra-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jtraglia authored Nov 4, 2024
2 parents d53419b + 49b6840 commit 5653d73
Show file tree
Hide file tree
Showing 33 changed files with 1,148 additions and 187 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,18 @@ jobs:
with:
name: test-reports-${{ matrix.version }}
path: tests/core/pyspec/test-reports

gen-modcheck:
runs-on: [self-hosted-ghr-custom, size-s-x64, profile-consensusSpecs]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12.4'
cache: ''
- name: Install pyspec requirements
run: make install_test
- name: Run generators with --modcheck
run: make generate_tests modcheck=true
14 changes: 8 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ COV_HTML_OUT_DIR=$(PY_SPEC_DIR)/$(COV_HTML_OUT)
COV_INDEX_FILE=$(COV_HTML_OUT_DIR)/index.html

CURRENT_DIR = ${CURDIR}
LINTER_CONFIG_FILE = $(CURRENT_DIR)/linter.ini
GENERATOR_ERROR_LOG_FILE = $(CURRENT_DIR)/$(TEST_VECTOR_DIR)/testgen_error_log.txt

SCRIPTS_DIR = ${CURRENT_DIR}/scripts
Expand Down Expand Up @@ -151,13 +150,16 @@ codespell:

lint: pyspec
. venv/bin/activate; cd $(PY_SPEC_DIR); \
flake8 --config $(LINTER_CONFIG_FILE) ./eth2spec \
&& python -m pylint --rcfile $(LINTER_CONFIG_FILE) $(PYLINT_SCOPE) \
&& python -m mypy --config-file $(LINTER_CONFIG_FILE) $(MYPY_SCOPE)
flake8 --config $(CURRENT_DIR)/flake8.ini ./eth2spec \
&& python -m pylint --rcfile $(CURRENT_DIR)/pylint.ini $(PYLINT_SCOPE) \
&& python -m mypy --config-file $(CURRENT_DIR)/mypy.ini $(MYPY_SCOPE)

lint_generators: pyspec
. venv/bin/activate; cd $(TEST_GENERATORS_DIR); \
flake8 --config $(LINTER_CONFIG_FILE)
flake8 --config $(CURRENT_DIR)/flake8.ini

# If set to true, it will not run generator tests.
modcheck ?= false

# Runs a generator, identified by param 1
define run_generator
Expand All @@ -177,7 +179,7 @@ define run_generator
. venv/bin/activate; \
pip3 install ../../../dist/eth2spec-*.whl; \
pip3 install 'eth2spec[generator]'; \
python3 main.py -o $(CURRENT_DIR)/$(TEST_VECTOR_DIR); \
python3 main.py -o $(CURRENT_DIR)/$(TEST_VECTOR_DIR) $(if $(filter true,$(modcheck)),--modcheck); \
echo "generator $(1) finished"
endef

Expand Down
3 changes: 3 additions & 0 deletions flake8.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[flake8]
ignore = E252,W504,W503
max-line-length = 120
18 changes: 0 additions & 18 deletions linter.ini

This file was deleted.

7 changes: 7 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[mypy]
disallow_incomplete_defs = True
disallow_untyped_defs = True
warn_unused_ignores = True
warn_unused_configs = True
warn_redundant_casts = True
ignore_missing_imports = True
3 changes: 3 additions & 0 deletions pylint.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[MESSAGES CONTROL]
disable = all
enable = unused-argument
2 changes: 1 addition & 1 deletion pysetup/md_doc_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
DENEB: CAPELLA,
ELECTRA: DENEB,
WHISK: CAPELLA,
EIP7594: DENEB,
EIP7594: ELECTRA,
EIP6800: DENEB,
EIP7732: ELECTRA,
}
Expand Down
2 changes: 1 addition & 1 deletion pysetup/spec_builders/eip7594.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class EIP7594SpecBuilder(BaseSpecBuilder):
@classmethod
def imports(cls, preset_name: str):
return f'''
from eth2spec.deneb import {preset_name} as deneb
from eth2spec.electra import {preset_name} as electra
'''


Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ def run(self):
python_requires=">=3.9, <4",
extras_require={
"test": ["pytest>=4.4", "pytest-cov", "pytest-xdist"],
"lint": ["flake8==5.0.4", "mypy==0.981", "pylint==2.15.3"],
"lint": ["flake8==5.0.4", "mypy==0.981", "pylint==3.3.1"],
"generator": ["setuptools>=72.0.0", "pytest>4.4", "python-snappy==0.7.3", "filelock", "pathos==0.3.0"],
"docs": ["mkdocs==1.4.2", "mkdocs-material==9.1.5", "mdx-truly-sane-lists==1.3", "mkdocs-awesome-pages-plugin==2.8.0"]
},
Expand All @@ -572,7 +572,7 @@ def run(self):
"py_ecc==6.0.0",
"milagro_bls_binding==1.9.0",
"remerkleable==0.1.28",
"trie==2.0.2",
"trie>=3,<4",
RUAMEL_YAML_VERSION,
"lru-dict==1.2.0",
MARKO_VERSION,
Expand Down
17 changes: 15 additions & 2 deletions specs/_features/eip7594/fork.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ def compute_fork_version(epoch: Epoch) -> Version:
"""
if epoch >= EIP7594_FORK_EPOCH:
return EIP7594_FORK_VERSION
if epoch >= ELECTRA_FORK_EPOCH:
return ELECTRA_FORK_VERSION
if epoch >= DENEB_FORK_EPOCH:
return DENEB_FORK_VERSION
if epoch >= CAPELLA_FORK_EPOCH:
Expand Down Expand Up @@ -71,8 +73,8 @@ If `state.slot % SLOTS_PER_EPOCH == 0` and `compute_epoch_at_slot(state.slot) ==
an irregular state change is made to upgrade to EIP7594.

```python
def upgrade_to_eip7594(pre: deneb.BeaconState) -> BeaconState:
epoch = deneb.get_current_epoch(pre)
def upgrade_to_eip7594(pre: electra.BeaconState) -> BeaconState:
epoch = electra.get_current_epoch(pre)
post = BeaconState(
# Versioning
genesis_time=pre.genesis_time,
Expand Down Expand Up @@ -119,6 +121,17 @@ def upgrade_to_eip7594(pre: deneb.BeaconState) -> BeaconState:
next_withdrawal_validator_index=pre.next_withdrawal_validator_index,
# Deep history valid from Capella onwards
historical_summaries=pre.historical_summaries,
# On-chain deposits
deposit_requests_start_index=pre.deposit_requests_start_index,
# Consolidations
deposit_balance_to_consume=pre.deposit_balance_to_consume,
exit_balance_to_consume=pre.exit_balance_to_consume,
earliest_exit_epoch=pre.earliest_exit_epoch,
consolidation_balance_to_consume=pre.consolidation_balance_to_consume,
earliest_consolidation_epoch=pre.earliest_consolidation_epoch,
pending_balance_deposits=pre.pending_balance_deposits,
pending_partial_withdrawals=pre.pending_partial_withdrawals,
pending_consolidations=pre.pending_consolidations,
)

return post
Expand Down
10 changes: 10 additions & 0 deletions specs/deneb/p2p-interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ The specification of these changes continues in the same format as the network s
- [BeaconBlocksByRange v2](#beaconblocksbyrange-v2)
- [BeaconBlocksByRoot v2](#beaconblocksbyroot-v2)
- [BlobSidecarsByRoot v1](#blobsidecarsbyroot-v1)
- [Blob retrieval via local execution layer client](#blob-retrieval-via-local-execution-layer-client)
- [BlobSidecarsByRange v1](#blobsidecarsbyrange-v1)
- [Design decision rationale](#design-decision-rationale)
- [Why are blobs relayed as a sidecar, separate from beacon blocks?](#why-are-blobs-relayed-as-a-sidecar-separate-from-beacon-blocks)
Expand Down Expand Up @@ -309,6 +310,15 @@ Clients SHOULD include a sidecar in the response as soon as it passes the gossip
Clients SHOULD NOT respond with sidecars related to blocks that fail gossip validation rules.
Clients SHOULD NOT respond with sidecars related to blocks that fail the beacon chain state transition

###### Blob retrieval via local execution layer client

In addition to `BlobSidecarsByRoot` requests, recent blobs MAY be retrieved by querying the Execution Layer (i.e. via `engine_getBlobsV1`).
Implementers are encouraged to leverage this method to increase the likelihood of incorporating and attesting to the last block when its proposer is not able to publish blobs on time.

When clients use the local execution layer to retrieve blobs, they MUST behave as if the corresponding `blob_sidecar` had been received via gossip. In particular they MUST:
* publish the corresponding `blob_sidecar` on the `blob_sidecar_{subnet_id}` subnet.
* update gossip rule related data structures (i.e. update the anti-equivocation cache).

##### BlobSidecarsByRange v1

**Protocol ID:** `/eth2/beacon_chain/req/blob_sidecars_by_range/1/`
Expand Down
Loading

0 comments on commit 5653d73

Please sign in to comment.