@@ -13,19 +13,17 @@ ALL_EXECUTABLE_SPEC_NAMES = \
1313 eip6800 \
1414 eip7441 \
1515 eip7732 \
16- eip7805
16+ eip7805
1717
1818# A list of fake targets.
1919.PHONY : \
2020 clean \
2121 coverage \
22- detect_errors \
23- gen_all \
24- gen_list \
2522 help \
2623 kzg_setups \
2724 lint \
2825 pyspec \
26+ reftests \
2927 serve_docs \
3028 test
3129
@@ -38,17 +36,14 @@ NORM = $(shell tput sgr0)
3836
3937# Print target descriptions.
4038help :
41- @echo " make $( BOLD) clean$( NORM) -- delete all untracked files"
42- @echo " make $( BOLD) coverage$( NORM) -- run pyspec tests with coverage"
43- @echo " make $( BOLD) detect_errors$( NORM) -- detect generator errors"
44- @echo " make $( BOLD) gen_<gen>$( NORM) -- run a single generator"
45- @echo " make $( BOLD) gen_all$( NORM) -- run all generators"
46- @echo " make $( BOLD) gen_list$( NORM) -- list all generator targets"
47- @echo " make $( BOLD) kzg_setups$( NORM) -- generate trusted setups"
48- @echo " make $( BOLD) lint$( NORM) -- run the linters"
49- @echo " make $( BOLD) pyspec$( NORM) -- generate python specifications"
50- @echo " make $( BOLD) serve_docs$( NORM) -- start a local docs web server"
51- @echo " make $( BOLD) test$( NORM) -- run pyspec tests"
39+ @echo " make $( BOLD) clean$( NORM) -- delete all untracked files"
40+ @echo " make $( BOLD) coverage$( NORM) -- run pyspec tests with coverage"
41+ @echo " make $( BOLD) kzg_setups$( NORM) -- generate trusted setups"
42+ @echo " make $( BOLD) lint$( NORM) -- run the linters"
43+ @echo " make $( BOLD) pyspec$( NORM) -- build python specifications"
44+ @echo " make $( BOLD) reftests$( NORM) -- generate reference tests"
45+ @echo " make $( BOLD) serve_docs$( NORM) -- start a local docs web server"
46+ @echo " make $( BOLD) test$( NORM) -- run pyspec tests"
5247
5348# ##############################################################################
5449# Virtual Environment
@@ -64,7 +59,7 @@ MDFORMAT_VENV = $(VENV)/bin/mdformat
6459$(VENV ) :
6560 @echo " Creating virtual environment"
6661 @python3 -m venv $(VENV )
67- @$(PIP_VENV ) install --quiet uv==0.5.24
62+ @$(PIP_VENV ) install --quiet --upgrade uv
6863
6964# ##############################################################################
7065# Specification
@@ -189,82 +184,58 @@ MARKDOWN_FILES = $(CURDIR)/README.md \
189184
190185# Check for mistakes.
191186lint : pyspec
192- @$(MDFORMAT_VENV ) --number $(MARKDOWN_FILES )
187+ @$(MDFORMAT_VENV ) --number --wrap=80 $(MARKDOWN_FILES )
193188 @$(CODESPELL_VENV ) . --skip " ./.git,$( VENV) ,$( PYSPEC_DIR) /.mypy_cache" -I .codespell-whitelist
194- @$(PYTHON_VENV ) -m black $(CURDIR ) /tests
189+ @$(PYTHON_VENV ) -m isort --quiet $(CURDIR ) /tests
190+ @$(PYTHON_VENV ) -m black --quiet $(CURDIR ) /tests
195191 @$(PYTHON_VENV ) -m pylint --rcfile $(PYLINT_CONFIG ) $(PYLINT_SCOPE )
196192 @$(PYTHON_VENV ) -m mypy --config-file $(MYPY_CONFIG ) $(MYPY_SCOPE )
197193
198194# ##############################################################################
199195# Generators
200196# ##############################################################################
201197
202- TEST_VECTOR_DIR = $(CURDIR ) /../consensus-spec-tests/tests
203- GENERATOR_DIR = $(CURDIR ) /tests/generators
204- SCRIPTS_DIR = $(CURDIR ) /scripts
205- GENERATOR_ERROR_LOG_FILE = $(TEST_VECTOR_DIR ) /testgen_error_log.txt
206- GENERATORS = $(sort $(dir $(wildcard $(GENERATOR_DIR ) /* /.) ) )
207- GENERATOR_TARGETS = $(patsubst $(GENERATOR_DIR ) /% /, gen_% , $(GENERATORS ) )
208198COMMA: = ,
199+ TEST_VECTOR_DIR = $(CURDIR ) /../consensus-spec-tests/tests
209200
210- # List available generators.
211- gen_list :
212- @for target in $(shell echo $(GENERATOR_TARGETS ) | tr ' ' '\n' | sort -n) ; do \
213- echo $$ target; \
214- done
215-
216- # Run one generator.
201+ # Generate reference tests.
217202# This will forcibly rebuild pyspec just in case.
218- # To print more details, append verbose=true, eg:
219- # make gen_bls verbose=true
220- # To check modules for a generator, append modcheck=true, eg:
221- # make gen_genesis modcheck=true
222- # To run the generator for a specific test, append k=<test>, eg:
223- # make gen_operations k=invalid_committee_index
224- # To run the generator for a specific fork, append fork=<fork>, eg:
225- # make gen_operations fork=fulu
226- # To run the generator for a specific preset, append preset=<preset>, eg:
227- # make gen_operations preset=mainnet
228- # To run the generator for a list of tests, forks, and/or presets, append them as comma-separated lists, eg:
229- # make gen_operations k=invalid_committee_index,invalid_too_many_committee_bits
203+ # To generate reference tests for a single runner, append runner=<runner>, eg:
204+ # make reftests runner=bls
205+ # To generate reference tests with more details, append verbose=true, eg:
206+ # make reftests runner=bls verbose=true
207+ # To generate reference tests with fewer threads, append threads=N, eg:
208+ # make reftests runner=bls threads=1
209+ # To generate reference tests for a specific test, append k=<test>, eg:
210+ # make reftests runner=operations k=invalid_committee_index
211+ # To generate reference tests for a specific fork, append fork=<fork>, eg:
212+ # make reftests runner=operations fork=fulu
213+ # To generate reference tests for a specific preset, append preset=<preset>, eg:
214+ # make reftests runner=operations preset=mainnet
215+ # To generate reference tests for a list of tests, forks, and/or presets, append them as comma-separated lists, eg:
216+ # make reftests runner=operations k=invalid_committee_index,invalid_too_many_committee_bits
230217# Or all at the same time, eg:
231- # make gen_operations preset=mainnet fork=fulu k=invalid_committee_index
232- gen_ % : MAYBE_VERBOSE := $(if $(filter true,$(verbose ) ) ,--verbose)
233- gen_ % : MAYBE_MODCHECK := $(if $(filter true, $( modcheck ) ) ,--modcheck )
234- gen_ % : MAYBE_TESTS := $(if $(k ) ,--case-list $(subst ${COMMA}, ,$(k ) ) )
235- gen_ % : MAYBE_FORKS := $(if $(fork ) ,--fork-list $(subst ${COMMA}, ,$(fork ) ) )
236- gen_ % : MAYBE_PRESETS := $(if $(preset ) ,--preset-list $(subst ${COMMA}, ,$(preset ) ) )
237- gen_ % : pyspec
238- @mkdir -p $( TEST_VECTOR_DIR )
239- @$(PYTHON_VENV ) $( GENERATOR_DIR ) / $* /main.py \
218+ # make reftests runner=operations preset=mainnet fork=fulu k=invalid_committee_index
219+ reftests : MAYBE_VERBOSE := $(if $(filter true,$(verbose ) ) ,--verbose)
220+ reftests : MAYBE_THREADS := $(if $(threads ) ,--threads= $( threads ) )
221+ reftests : MAYBE_RUNNERS := $(if $(runner ) ,--runners $(subst ${COMMA}, ,$(runner ) ) )
222+ reftests : MAYBE_TESTS := $(if $(k ) ,--cases $(subst ${COMMA}, ,$(k ) ) )
223+ reftests : MAYBE_FORKS := $(if $(fork ) ,--forks $(subst ${COMMA}, ,$(fork ) ) )
224+ reftests : MAYBE_PRESETS := $( if $( preset ) ,--presets $( subst ${COMMA}, , $( preset ) ) )
225+ reftests : pyspec
226+ @$(PYTHON_VENV ) -m tests.generators.main \
240227 --output $(TEST_VECTOR_DIR ) \
241228 $(MAYBE_VERBOSE ) \
242- $(MAYBE_MODCHECK ) \
229+ $(MAYBE_THREADS ) \
230+ $(MAYBE_RUNNERS ) \
243231 $(MAYBE_TESTS ) \
244232 $(MAYBE_FORKS ) \
245233 $(MAYBE_PRESETS )
246234
247- # Run all generators then check for errors.
248- gen_all : $(GENERATOR_TARGETS )
249- @$(MAKE ) detect_errors
250-
251- # Detect errors in generators.
252- detect_errors : $(TEST_VECTOR_DIR )
253- @incomplete_files=$$(find $(TEST_VECTOR_DIR ) -name "INCOMPLETE" ) ; \
254- if [ -n " $$ incomplete_files" ]; then \
255- echo " [ERROR] incomplete detected" ; \
256- exit 1; \
257- fi
258- @if [ -f $( GENERATOR_ERROR_LOG_FILE) ]; then \
259- echo " [ERROR] $( GENERATOR_ERROR_LOG_FILE) file exists" ; \
260- exit 1; \
261- fi
262- @echo " [PASSED] no errors detected"
263-
264235# Generate KZG trusted setups for testing.
265236kzg_setups : pyspec
266237 @for preset in minimal mainnet; do \
267- $(PYTHON_VENV ) $(SCRIPTS_DIR ) /gen_kzg_trusted_setups.py \
238+ $(PYTHON_VENV ) $(CURDIR ) /scripts /gen_kzg_trusted_setups.py \
268239 --secret=1337 \
269240 --g1-length=4096 \
270241 --g2-length=65 \
0 commit comments