Skip to content

Commit 11cfd96

Browse files
authored
Merge branch 'dev' into consolidation-switch-to-comp
2 parents a7b0d6f + 85e2452 commit 11cfd96

File tree

64 files changed

+877
-649
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+877
-649
lines changed

.github/workflows/generate_vectors.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,19 @@ on:
1212
default: dev
1313
type: string
1414
required: true
15+
schedule:
16+
- cron: '0 2 * * *'
1517

1618
jobs:
1719
generate-tests:
18-
runs-on: [self-hosted-ghr-custom, size-chungus-x64, profile-consensusSpecs]
20+
runs-on: [self-hosted-ghr-custom, size-xl-x64, profile-consensusSpecs]
1921
steps:
2022
- name: Checkout repository
2123
uses: actions/checkout@v4
2224
with:
2325
repository: 'ethereum/consensus-specs'
2426
path: 'consensus-specs'
25-
ref: ${{ inputs.source_ref }}
27+
ref: ${{ inputs.ref || 'dev' }}
2628
- name: Checkout consensus-spec-tests repository
2729
uses: actions/checkout@v4
2830
with:
@@ -50,6 +52,16 @@ jobs:
5052
cp -r presets/ ../consensus-spec-tests/presets
5153
cp -r configs/ ../consensus-spec-tests/configs
5254
find . -type d -empty -delete
55+
- name: Check for errors
56+
run: |
57+
if grep -q "\[ERROR\]" consensustestgen.log; then
58+
echo "There is an error in the log"
59+
exit 1
60+
fi
61+
if find . -type f -name "INCOMPLETE" | grep -q "INCOMPLETE"; then
62+
echo "There is an INCOMPLETE file"
63+
exit 1
64+
fi
5365
- name: Archive configurations
5466
run: |
5567
cd consensus-spec-tests

Makefile

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ MARKDOWN_FILES = $(wildcard $(SPEC_DIR)/*/*.md) \
3434
$(wildcard $(SPEC_DIR)/_features/*/*/*.md) \
3535
$(wildcard $(SSZ_DIR)/*.md)
3636

37-
ALL_EXECUTABLE_SPEC_NAMES = phase0 altair bellatrix capella deneb electra whisk eip6800 eip7732
37+
ALL_EXECUTABLE_SPEC_NAMES = phase0 altair bellatrix capella deneb electra whisk eip6800 eip7594 eip7732
3838
# The parameters for commands. Use `foreach` to avoid listing specs again.
3939
COVERAGE_SCOPE := $(foreach S,$(ALL_EXECUTABLE_SPEC_NAMES), --cov=eth2spec.$S.$(TEST_PRESET_TYPE))
4040
PYLINT_SCOPE := $(foreach S,$(ALL_EXECUTABLE_SPEC_NAMES), ./eth2spec/$S)
@@ -96,13 +96,16 @@ dist_check:
9696
dist_upload:
9797
python3 -m twine upload dist/*
9898

99+
build_wheel: install_test pyspec
100+
. venv/bin/activate && \
101+
python3 -m build --no-isolation --outdir ./dist ./
99102

100103
# "make generate_tests" to run all generators
101104
generate_tests: $(GENERATOR_TARGETS)
102105

103106
# "make pyspec" to create the pyspec for all phases.
104107
pyspec:
105-
python3 -m venv venv; . venv/bin/activate; python3 setup.py pyspecdev
108+
@python3 -m venv venv; . venv/bin/activate; python3 setup.py pyspecdev
106109

107110
# check the setup tool requirements
108111
preinstallation:
@@ -138,13 +141,21 @@ endif
138141
open_cov:
139142
((open "$(COV_INDEX_FILE)" || xdg-open "$(COV_INDEX_FILE)") &> /dev/null) &
140143

144+
# Check all files and error if any ToC were modified.
141145
check_toc: $(MARKDOWN_FILES:=.toc)
146+
@[ "$$(find . -name '*.md.tmp' -print -quit)" ] && exit 1 || exit 0
142147

148+
# Generate ToC sections & save copy of original if modified.
143149
%.toc:
144-
cp $* $*.tmp && \
145-
doctoc $* && \
146-
diff -q $* $*.tmp && \
147-
rm $*.tmp
150+
@cp $* $*.tmp; \
151+
doctoc $* > /dev/null; \
152+
if diff -q $* $*.tmp > /dev/null; then \
153+
echo "Good $*"; \
154+
rm $*.tmp; \
155+
else \
156+
echo "\033[1;33m Bad $*\033[0m"; \
157+
echo "\033[1;34m See $*.tmp\033[0m"; \
158+
fi
148159

149160
codespell:
150161
codespell . --skip "./.git,./venv,$(PY_SPEC_DIR)/.mypy_cache" -I .codespell-whitelist
@@ -195,7 +206,8 @@ define run_generator
195206
cd $(GENERATOR_DIR)/$(1); \
196207
if ! test -d venv; then python3 -m venv venv; fi; \
197208
. venv/bin/activate; \
198-
pip3 install -r requirements.txt; \
209+
pip3 install ../../../dist/eth2spec-*.whl; \
210+
pip3 install 'eth2spec[generator]'; \
199211
python3 main.py -o $(CURRENT_DIR)/$(TEST_VECTOR_DIR); \
200212
echo "generator $(1) finished"
201213
endef
@@ -217,7 +229,7 @@ gen_kzg_setups:
217229

218230
# For any generator, build it using the run_generator function.
219231
# (creation of output dir is a dependency)
220-
gen_%: $(TEST_VECTOR_DIR)
232+
gen_%: build_wheel $(TEST_VECTOR_DIR)
221233
$(call run_generator,$*)
222234

223235
detect_generator_incomplete: $(TEST_VECTOR_DIR)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This repository hosts the current Ethereum proof-of-stake specifications. Discus
88

99
## Specs
1010

11-
[![GitHub release](https://img.shields.io/github/v/release/ethereum/eth2.0-specs)](https://github.com/ethereum/eth2.0-specs/releases/) [![PyPI version](https://badge.fury.io/py/eth2spec.svg)](https://badge.fury.io/py/eth2spec)
11+
[![GitHub release](https://img.shields.io/github/v/release/ethereum/consensus-specs)](https://github.com/ethereum/consensus-specs/releases/) [![PyPI version](https://badge.fury.io/py/eth2spec.svg)](https://badge.fury.io/py/eth2spec) [![testgen](https://github.com/ethereum/consensus-specs/actions/workflows/generate_vectors.yml/badge.svg?branch=dev&event=schedule)](https://github.com/ethereum/consensus-specs/actions/workflows/generate_vectors.yml)
1212

1313
Core specifications for Ethereum proof-of-stake clients can be found in [specs](specs/). These are divided into features.
1414
Features are researched and developed in parallel, and then consolidated into sequential upgrades when ready.

presets/minimal/electra.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,5 @@ MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD: 2
4141

4242
# Withdrawals processing
4343
# ---------------------------------------------------------------
44-
# 2**0 ( = 1) pending withdrawals
45-
MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP: 1
44+
# 2**1 ( = 2) pending withdrawals
45+
MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP: 2

pysetup/helpers.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ def format_constant(name: str, vardef: VariableDefinition) -> str:
119119
hardcoded_func_dep_presets = reduce(lambda obj, builder: {**obj, **builder.hardcoded_func_dep_presets(spec_object)}, builders, {})
120120
# Concatenate all strings
121121
imports = reduce(lambda txt, builder: (txt + "\n\n" + builder.imports(preset_name) ).strip("\n"), builders, "")
122+
classes = reduce(lambda txt, builder: (txt + "\n\n" + builder.classes() ).strip("\n"), builders, "")
122123
preparations = reduce(lambda txt, builder: (txt + "\n\n" + builder.preparations() ).strip("\n"), builders, "")
123124
sundry_functions = reduce(lambda txt, builder: (txt + "\n\n" + builder.sundry_functions() ).strip("\n"), builders, "")
124125
# Keep engine from the most recent fork
@@ -154,6 +155,8 @@ def format_constant(name: str, vardef: VariableDefinition) -> str:
154155
constant_vars_spec,
155156
preset_vars_spec,
156157
config_spec,
158+
# Custom classes which are not required to be SSZ containers.
159+
classes,
157160
ordered_class_objects_spec,
158161
protocols_spec,
159162
functions_spec,

pysetup/spec_builders/base.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ def imports(cls, preset_name: str) -> str:
1515
"""
1616
return ""
1717

18+
@classmethod
19+
def classes(cls) -> str:
20+
"""
21+
Define special classes.
22+
"""
23+
return ""
24+
1825
@classmethod
1926
def preparations(cls) -> str:
2027
"""

pysetup/spec_builders/deneb.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,21 @@ def imports(cls, preset_name: str):
1212
from eth2spec.capella import {preset_name} as capella
1313
'''
1414

15+
@classmethod
16+
def classes(cls):
17+
return f'''
18+
class BLSFieldElement(bls.Scalar):
19+
pass
20+
21+
22+
class Polynomial(list):
23+
def __init__(self, evals: Optional[Sequence[BLSFieldElement]] = None):
24+
if evals is None:
25+
evals = [BLSFieldElement(0)] * FIELD_ELEMENTS_PER_BLOB
26+
if len(evals) != FIELD_ELEMENTS_PER_BLOB:
27+
raise ValueError("expected FIELD_ELEMENTS_PER_BLOB evals")
28+
super().__init__(evals)
29+
'''
1530

1631
@classmethod
1732
def preparations(cls):

pysetup/spec_builders/eip7594.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,41 @@ def imports(cls, preset_name: str):
1212
return f'''
1313
from eth2spec.deneb import {preset_name} as deneb
1414
'''
15-
15+
16+
17+
@classmethod
18+
def classes(cls):
19+
return f'''
20+
class PolynomialCoeff(list):
21+
def __init__(self, coeffs: Sequence[BLSFieldElement]):
22+
if len(coeffs) > FIELD_ELEMENTS_PER_EXT_BLOB:
23+
raise ValueError("expected <= FIELD_ELEMENTS_PER_EXT_BLOB coeffs")
24+
super().__init__(coeffs)
25+
26+
27+
class Coset(list):
28+
def __init__(self, coeffs: Optional[Sequence[BLSFieldElement]] = None):
29+
if coeffs is None:
30+
coeffs = [BLSFieldElement(0)] * FIELD_ELEMENTS_PER_CELL
31+
if len(coeffs) != FIELD_ELEMENTS_PER_CELL:
32+
raise ValueError("expected FIELD_ELEMENTS_PER_CELL coeffs")
33+
super().__init__(coeffs)
34+
35+
36+
class CosetEvals(list):
37+
def __init__(self, evals: Optional[Sequence[BLSFieldElement]] = None):
38+
if evals is None:
39+
evals = [BLSFieldElement(0)] * FIELD_ELEMENTS_PER_CELL
40+
if len(evals) != FIELD_ELEMENTS_PER_CELL:
41+
raise ValueError("expected FIELD_ELEMENTS_PER_CELL coeffs")
42+
super().__init__(evals)
43+
'''
1644

1745
@classmethod
1846
def sundry_functions(cls) -> str:
1947
return """
2048
def retrieve_column_sidecars(beacon_block_root: Root) -> Sequence[DataColumnSidecar]:
49+
# pylint: disable=unused-argument
2150
return []
2251
"""
2352

pysetup/spec_builders/electra.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,41 @@ def hardcoded_ssz_dep_constants(cls) -> Dict[str, str]:
1919
'CURRENT_SYNC_COMMITTEE_GINDEX_ELECTRA': 'GeneralizedIndex(86)',
2020
'NEXT_SYNC_COMMITTEE_GINDEX_ELECTRA': 'GeneralizedIndex(87)',
2121
}
22+
23+
24+
@classmethod
25+
def execution_engine_cls(cls) -> str:
26+
return """
27+
class NoopExecutionEngine(ExecutionEngine):
28+
29+
def notify_new_payload(self: ExecutionEngine,
30+
execution_payload: ExecutionPayload,
31+
execution_requests: ExecutionRequests,
32+
parent_beacon_block_root: Root) -> bool:
33+
return True
34+
35+
def notify_forkchoice_updated(self: ExecutionEngine,
36+
head_block_hash: Hash32,
37+
safe_block_hash: Hash32,
38+
finalized_block_hash: Hash32,
39+
payload_attributes: Optional[PayloadAttributes]) -> Optional[PayloadId]:
40+
pass
41+
42+
def get_payload(self: ExecutionEngine, payload_id: PayloadId) -> GetPayloadResponse:
43+
# pylint: disable=unused-argument
44+
raise NotImplementedError("no default block production")
45+
46+
def is_valid_block_hash(self: ExecutionEngine,
47+
execution_payload: ExecutionPayload,
48+
parent_beacon_block_root: Root) -> bool:
49+
return True
50+
51+
def is_valid_versioned_hashes(self: ExecutionEngine, new_payload_request: NewPayloadRequest) -> bool:
52+
return True
53+
54+
def verify_and_notify_new_payload(self: ExecutionEngine,
55+
new_payload_request: NewPayloadRequest) -> bool:
56+
return True
57+
58+
59+
EXECUTION_ENGINE = NoopExecutionEngine()"""

requirements_preinstallation.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
pip>=24.0.0
22
wheel>=0.44.0
33
setuptools>=72.0.0
4-
pylint>=3.2.0
4+
pylint>=3.2.0
5+
build>=1.2.2

0 commit comments

Comments
 (0)