2019-03-18 16:18:57 +00:00
|
|
|
SPEC_DIR = ./specs
|
2020-01-10 18:42:55 +00:00
|
|
|
SSZ_DIR = ./ssz
|
|
|
|
TEST_LIBS_DIR = ./tests/core
|
2020-09-15 03:19:50 +00:00
|
|
|
TEST_GENERATORS_DIR = ./tests/generators
|
2021-04-21 01:17:33 +00:00
|
|
|
# The working dir during testing
|
2019-03-27 16:35:46 +00:00
|
|
|
PY_SPEC_DIR = $(TEST_LIBS_DIR)/pyspec
|
2021-04-21 01:17:33 +00:00
|
|
|
ETH2SPEC_MODULE_DIR = $(PY_SPEC_DIR)/eth2spec
|
|
|
|
TEST_REPORT_DIR = $(PY_SPEC_DIR)/test-reports
|
2021-08-19 04:41:51 +00:00
|
|
|
TEST_VECTOR_DIR = ../consensus-spec-tests/tests
|
2020-01-10 18:42:55 +00:00
|
|
|
GENERATOR_DIR = ./tests/generators
|
2020-07-23 14:16:40 +00:00
|
|
|
SOLIDITY_DEPOSIT_CONTRACT_DIR = ./solidity_deposit_contract
|
|
|
|
SOLIDITY_DEPOSIT_CONTRACT_SOURCE = ${SOLIDITY_DEPOSIT_CONTRACT_DIR}/deposit_contract.sol
|
|
|
|
SOLIDITY_FILE_NAME = deposit_contract.json
|
2020-08-17 16:10:28 +00:00
|
|
|
DEPOSIT_CONTRACT_TESTER_DIR = ${SOLIDITY_DEPOSIT_CONTRACT_DIR}/web3_tester
|
2019-04-11 09:25:00 +00:00
|
|
|
CONFIGS_DIR = ./configs
|
2023-01-03 15:23:09 +00:00
|
|
|
TEST_PRESET_TYPE ?= minimal
|
2024-01-04 16:09:06 +00:00
|
|
|
NUMBER_OF_CORES=16
|
2019-03-27 16:35:46 +00:00
|
|
|
# Collect a list of generator names
|
2019-07-30 10:49:18 +00:00
|
|
|
GENERATORS = $(sort $(dir $(wildcard $(GENERATOR_DIR)/*/.)))
|
|
|
|
# Map this list of generator paths to "gen_{generator name}" entries
|
|
|
|
GENERATOR_TARGETS = $(patsubst $(GENERATOR_DIR)/%/, gen_%, $(GENERATORS))
|
2019-03-28 16:16:18 +00:00
|
|
|
GENERATOR_VENVS = $(patsubst $(GENERATOR_DIR)/%, $(GENERATOR_DIR)/%venv, $(GENERATORS))
|
2023-04-18 10:31:34 +00:00
|
|
|
# Documents
|
|
|
|
DOCS_DIR = ./docs
|
|
|
|
SSZ_DIR = ./ssz
|
|
|
|
SYNC_DIR = ./sync
|
|
|
|
FORK_CHOICE_DIR = ./fork_choice
|
2019-03-18 22:20:24 +00:00
|
|
|
|
2019-07-30 10:49:18 +00:00
|
|
|
# To check generator matching:
|
|
|
|
#$(info $$GENERATOR_TARGETS is [${GENERATOR_TARGETS}])
|
|
|
|
|
2023-02-28 15:37:12 +00:00
|
|
|
MARKDOWN_FILES = $(wildcard $(SPEC_DIR)/*/*.md) \
|
|
|
|
$(wildcard $(SPEC_DIR)/*/*/*.md) \
|
|
|
|
$(wildcard $(SPEC_DIR)/_features/*/*.md) \
|
|
|
|
$(wildcard $(SPEC_DIR)/_features/*/*/*.md) \
|
2022-07-15 12:05:45 +00:00
|
|
|
$(wildcard $(SSZ_DIR)/*.md)
|
2019-12-10 16:07:30 +00:00
|
|
|
|
2024-04-16 01:45:40 +00:00
|
|
|
ALL_EXECUTABLE_SPEC_NAMES = phase0 altair bellatrix capella deneb electra whisk
|
2023-02-24 09:56:38 +00:00
|
|
|
# The parameters for commands. Use `foreach` to avoid listing specs again.
|
2023-12-14 16:56:41 +00:00
|
|
|
COVERAGE_SCOPE := $(foreach S,$(ALL_EXECUTABLE_SPEC_NAMES), --cov=eth2spec.$S.$(TEST_PRESET_TYPE))
|
|
|
|
PYLINT_SCOPE := $(foreach S,$(ALL_EXECUTABLE_SPEC_NAMES), ./eth2spec/$S)
|
|
|
|
MYPY_SCOPE := $(foreach S,$(ALL_EXECUTABLE_SPEC_NAMES), -p eth2spec.$S)
|
2023-02-24 09:56:38 +00:00
|
|
|
|
2019-06-14 23:13:29 +00:00
|
|
|
COV_HTML_OUT=.htmlcov
|
2021-04-21 01:17:33 +00:00
|
|
|
COV_HTML_OUT_DIR=$(PY_SPEC_DIR)/$(COV_HTML_OUT)
|
|
|
|
COV_INDEX_FILE=$(COV_HTML_OUT_DIR)/index.html
|
2019-03-18 22:20:24 +00:00
|
|
|
|
2020-06-18 10:55:15 +00:00
|
|
|
CURRENT_DIR = ${CURDIR}
|
|
|
|
LINTER_CONFIG_FILE = $(CURRENT_DIR)/linter.ini
|
2021-03-16 18:41:44 +00:00
|
|
|
GENERATOR_ERROR_LOG_FILE = $(CURRENT_DIR)/$(TEST_VECTOR_DIR)/testgen_error_log.txt
|
2020-06-18 06:28:56 +00:00
|
|
|
|
2022-09-27 09:30:35 +00:00
|
|
|
SCRIPTS_DIR = ${CURRENT_DIR}/scripts
|
|
|
|
|
2020-07-23 14:16:40 +00:00
|
|
|
export DAPP_SKIP_BUILD:=1
|
|
|
|
export DAPP_SRC:=$(SOLIDITY_DEPOSIT_CONTRACT_DIR)
|
|
|
|
export DAPP_LIB:=$(SOLIDITY_DEPOSIT_CONTRACT_DIR)/lib
|
|
|
|
export DAPP_JSON:=build/combined.json
|
|
|
|
|
2020-01-25 00:26:10 +00:00
|
|
|
.PHONY: clean partial_clean all test citest lint generate_tests pyspec install_test open_cov \
|
2020-01-22 17:09:40 +00:00
|
|
|
install_deposit_contract_tester test_deposit_contract install_deposit_contract_compiler \
|
2021-03-16 18:41:44 +00:00
|
|
|
compile_deposit_contract test_compile_deposit_contract check_toc \
|
|
|
|
detect_generator_incomplete detect_generator_error_log
|
2019-03-27 16:35:46 +00:00
|
|
|
|
2019-07-30 10:49:18 +00:00
|
|
|
all: $(PY_SPEC_ALL_TARGETS)
|
2019-03-18 22:20:24 +00:00
|
|
|
|
2019-06-30 15:53:21 +00:00
|
|
|
# deletes everything except the venvs
|
2019-06-30 08:58:04 +00:00
|
|
|
partial_clean:
|
2019-07-30 10:49:18 +00:00
|
|
|
rm -rf $(TEST_VECTOR_DIR)
|
2019-03-28 16:05:40 +00:00
|
|
|
rm -rf $(GENERATOR_VENVS)
|
2020-01-25 00:26:10 +00:00
|
|
|
rm -rf .pytest_cache
|
|
|
|
rm -f .coverage
|
2019-06-30 08:58:04 +00:00
|
|
|
rm -rf $(PY_SPEC_DIR)/.pytest_cache
|
2020-01-22 17:09:40 +00:00
|
|
|
rm -rf $(DEPOSIT_CONTRACT_TESTER_DIR)/.pytest_cache
|
2021-04-21 01:17:33 +00:00
|
|
|
rm -rf $(COV_HTML_OUT_DIR)
|
|
|
|
rm -rf $(TEST_REPORT_DIR)
|
2020-01-25 00:26:10 +00:00
|
|
|
rm -rf eth2spec.egg-info dist build
|
2023-02-24 09:56:38 +00:00
|
|
|
rm -rf build;
|
2023-12-14 16:56:41 +00:00
|
|
|
@for spec_name in $(ALL_EXECUTABLE_SPEC_NAMES) ; do \
|
2023-02-24 09:56:38 +00:00
|
|
|
echo $$spec_name; \
|
|
|
|
rm -rf $(ETH2SPEC_MODULE_DIR)/$$spec_name; \
|
|
|
|
done
|
2019-03-18 22:20:24 +00:00
|
|
|
|
2019-06-30 09:18:36 +00:00
|
|
|
clean: partial_clean
|
2020-01-25 00:26:10 +00:00
|
|
|
rm -rf venv
|
2022-03-22 20:05:56 +00:00
|
|
|
# legacy cleanup. The pyspec venv should be located at the repository root
|
2019-06-30 08:58:04 +00:00
|
|
|
rm -rf $(PY_SPEC_DIR)/venv
|
2020-01-22 17:09:40 +00:00
|
|
|
rm -rf $(DEPOSIT_CONTRACT_COMPILER_DIR)/venv
|
|
|
|
rm -rf $(DEPOSIT_CONTRACT_TESTER_DIR)/venv
|
2019-06-30 08:58:04 +00:00
|
|
|
|
2020-02-05 17:38:21 +00:00
|
|
|
# The pyspec is rebuilt to enforce the /specs being part of eth2specs source distribution. It could be forgotten otherwise.
|
|
|
|
dist_build: pyspec
|
|
|
|
python3 setup.py sdist bdist_wheel
|
|
|
|
|
|
|
|
dist_check:
|
|
|
|
python3 -m twine check dist/*
|
|
|
|
|
|
|
|
dist_upload:
|
|
|
|
python3 -m twine upload dist/*
|
|
|
|
|
|
|
|
|
2019-07-30 10:49:18 +00:00
|
|
|
# "make generate_tests" to run all generators
|
2020-01-25 00:26:10 +00:00
|
|
|
generate_tests: $(GENERATOR_TARGETS)
|
|
|
|
|
|
|
|
# "make pyspec" to create the pyspec for all phases.
|
|
|
|
pyspec:
|
2023-01-03 15:23:09 +00:00
|
|
|
python3 -m venv venv; . venv/bin/activate; python3 setup.py pyspecdev
|
2019-04-20 01:33:15 +00:00
|
|
|
|
2023-07-14 13:37:51 +00:00
|
|
|
# check the setup tool requirements
|
|
|
|
preinstallation:
|
2024-05-07 08:34:25 +00:00
|
|
|
python3 -m venv venv && \
|
|
|
|
. venv/bin/activate && \
|
2023-07-14 13:37:51 +00:00
|
|
|
python3 -m pip install -r requirements_preinstallation.txt
|
|
|
|
|
|
|
|
install_test: preinstallation
|
2024-05-07 08:34:25 +00:00
|
|
|
. venv/bin/activate && \
|
|
|
|
python3 -m pip install -e .[lint,test]
|
2019-03-18 22:20:24 +00:00
|
|
|
|
2023-01-03 15:23:09 +00:00
|
|
|
# Testing against `minimal` or `mainnet` config by default
|
2020-01-25 00:26:10 +00:00
|
|
|
test: pyspec
|
|
|
|
. venv/bin/activate; cd $(PY_SPEC_DIR); \
|
2023-02-24 09:56:38 +00:00
|
|
|
python3 -m pytest -n 4 --disable-bls $(COVERAGE_SCOPE) --cov-report="html:$(COV_HTML_OUT)" --cov-branch eth2spec
|
2020-03-20 19:38:36 +00:00
|
|
|
|
2023-01-03 15:23:09 +00:00
|
|
|
# Testing against `minimal` or `mainnet` config by default
|
2020-03-20 19:38:36 +00:00
|
|
|
find_test: pyspec
|
|
|
|
. venv/bin/activate; cd $(PY_SPEC_DIR); \
|
2023-02-24 09:56:38 +00:00
|
|
|
python3 -m pytest -k=$(K) --disable-bls $(COVERAGE_SCOPE) --cov-report="html:$(COV_HTML_OUT)" --cov-branch eth2spec
|
2019-04-20 01:33:15 +00:00
|
|
|
|
2020-01-25 00:26:10 +00:00
|
|
|
citest: pyspec
|
2022-07-04 15:06:42 +00:00
|
|
|
mkdir -p $(TEST_REPORT_DIR);
|
2021-10-18 10:30:33 +00:00
|
|
|
ifdef fork
|
|
|
|
. venv/bin/activate; cd $(PY_SPEC_DIR); \
|
2024-01-04 16:09:06 +00:00
|
|
|
python3 -m pytest -n $(NUMBER_OF_CORES) --bls-type=fastest --preset=$(TEST_PRESET_TYPE) --fork=$(fork) --junitxml=test-reports/test_results.xml eth2spec
|
2021-10-18 10:30:33 +00:00
|
|
|
else
|
|
|
|
. venv/bin/activate; cd $(PY_SPEC_DIR); \
|
2024-01-04 16:09:06 +00:00
|
|
|
python3 -m pytest -n $(NUMBER_OF_CORES) --bls-type=fastest --preset=$(TEST_PRESET_TYPE) --junitxml=test-reports/test_results.xml eth2spec
|
2021-10-18 10:30:33 +00:00
|
|
|
endif
|
|
|
|
|
2019-06-14 21:12:04 +00:00
|
|
|
|
|
|
|
open_cov:
|
|
|
|
((open "$(COV_INDEX_FILE)" || xdg-open "$(COV_INDEX_FILE)") &> /dev/null) &
|
2019-05-09 05:11:07 +00:00
|
|
|
|
2019-12-10 16:07:30 +00:00
|
|
|
check_toc: $(MARKDOWN_FILES:=.toc)
|
|
|
|
|
|
|
|
%.toc:
|
|
|
|
cp $* $*.tmp && \
|
|
|
|
doctoc $* && \
|
|
|
|
diff -q $* $*.tmp && \
|
|
|
|
rm $*.tmp
|
|
|
|
|
2019-12-16 11:55:18 +00:00
|
|
|
codespell:
|
2023-01-03 15:23:09 +00:00
|
|
|
codespell . --skip "./.git,./venv,$(PY_SPEC_DIR)/.mypy_cache" -I .codespell-whitelist
|
2019-12-16 11:55:18 +00:00
|
|
|
|
2020-01-25 00:26:10 +00:00
|
|
|
lint: pyspec
|
|
|
|
. venv/bin/activate; cd $(PY_SPEC_DIR); \
|
2020-06-18 06:28:56 +00:00
|
|
|
flake8 --config $(LINTER_CONFIG_FILE) ./eth2spec \
|
2023-06-08 12:00:49 +00:00
|
|
|
&& python -m pylint --rcfile $(LINTER_CONFIG_FILE) $(PYLINT_SCOPE) \
|
|
|
|
&& python -m mypy --config-file $(LINTER_CONFIG_FILE) $(MYPY_SCOPE)
|
2019-05-09 05:11:07 +00:00
|
|
|
|
2020-09-15 03:19:50 +00:00
|
|
|
lint_generators: pyspec
|
|
|
|
. venv/bin/activate; cd $(TEST_GENERATORS_DIR); \
|
2022-09-28 04:22:53 +00:00
|
|
|
flake8 --config $(LINTER_CONFIG_FILE)
|
2020-09-15 03:19:50 +00:00
|
|
|
|
2020-01-22 17:09:40 +00:00
|
|
|
compile_deposit_contract:
|
2020-07-23 14:16:40 +00:00
|
|
|
@cd $(SOLIDITY_DEPOSIT_CONTRACT_DIR)
|
|
|
|
@git submodule update --recursive --init
|
|
|
|
@solc --metadata-literal --optimize --optimize-runs 5000000 --bin --abi --combined-json=abi,bin,bin-runtime,srcmap,srcmap-runtime,ast,metadata,storage-layout --overwrite -o build $(SOLIDITY_DEPOSIT_CONTRACT_SOURCE) $(SOLIDITY_DEPOSIT_CONTRACT_DIR)/tests/deposit_contract.t.sol
|
|
|
|
@/bin/echo -n '{"abi": ' > $(SOLIDITY_FILE_NAME)
|
|
|
|
@cat build/DepositContract.abi >> $(SOLIDITY_FILE_NAME)
|
|
|
|
@/bin/echo -n ', "bytecode": "0x' >> $(SOLIDITY_FILE_NAME)
|
|
|
|
@cat build/DepositContract.bin >> $(SOLIDITY_FILE_NAME)
|
|
|
|
@/bin/echo -n '"}' >> $(SOLIDITY_FILE_NAME)
|
|
|
|
|
2020-08-17 16:10:28 +00:00
|
|
|
test_deposit_contract:
|
|
|
|
dapp test -v --fuzz-runs 5
|
|
|
|
|
|
|
|
install_deposit_contract_web3_tester:
|
2021-01-05 13:00:52 +00:00
|
|
|
cd $(DEPOSIT_CONTRACT_TESTER_DIR); python3 -m venv venv; . venv/bin/activate; python3 -m pip install -r requirements.txt
|
2020-08-17 16:10:28 +00:00
|
|
|
|
|
|
|
test_deposit_contract_web3_tests:
|
|
|
|
cd $(DEPOSIT_CONTRACT_TESTER_DIR); . venv/bin/activate; \
|
2021-01-05 13:00:52 +00:00
|
|
|
python3 -m pytest .
|
2020-01-22 17:09:40 +00:00
|
|
|
|
2019-07-30 10:49:18 +00:00
|
|
|
# Runs a generator, identified by param 1
|
|
|
|
define run_generator
|
2019-04-20 02:23:10 +00:00
|
|
|
# Started!
|
|
|
|
# Create output directory
|
|
|
|
# Navigate to the generator
|
|
|
|
# Create a virtual environment, if it does not exist already
|
|
|
|
# Activate the venv, this is where dependencies are installed for the generator
|
|
|
|
# Install all the necessary requirements
|
|
|
|
# Run the generator. The generator is assumed to have an "main.py" file.
|
|
|
|
# We output to the tests dir (generator program should accept a "-o <filepath>" argument.
|
2019-07-30 20:17:44 +00:00
|
|
|
# `-l minimal general` can be added to the generator call to filter to smaller configs, when testing.
|
2019-04-20 02:23:10 +00:00
|
|
|
echo "generator $(1) started"; \
|
2019-07-30 10:49:18 +00:00
|
|
|
mkdir -p $(TEST_VECTOR_DIR); \
|
|
|
|
cd $(GENERATOR_DIR)/$(1); \
|
2019-04-22 16:56:21 +00:00
|
|
|
if ! test -d venv; then python3 -m venv venv; fi; \
|
2019-04-20 02:23:10 +00:00
|
|
|
. venv/bin/activate; \
|
|
|
|
pip3 install -r requirements.txt; \
|
2021-05-18 16:29:24 +00:00
|
|
|
python3 main.py -o $(CURRENT_DIR)/$(TEST_VECTOR_DIR); \
|
2019-04-20 02:23:10 +00:00
|
|
|
echo "generator $(1) finished"
|
2019-03-27 16:35:46 +00:00
|
|
|
endef
|
|
|
|
|
2021-09-10 14:56:27 +00:00
|
|
|
# The tests dir itself is simply built by creating the directory (recursively creating deeper directories if necessary)
|
2019-07-30 10:49:18 +00:00
|
|
|
$(TEST_VECTOR_DIR):
|
|
|
|
$(info creating test output directory, for generators: ${GENERATOR_TARGETS})
|
2019-03-27 16:35:46 +00:00
|
|
|
mkdir -p $@
|
2019-07-30 10:49:18 +00:00
|
|
|
$(TEST_VECTOR_DIR)/:
|
|
|
|
$(info ignoring duplicate tests dir)
|
2019-03-27 16:35:46 +00:00
|
|
|
|
2022-09-27 09:30:35 +00:00
|
|
|
gen_kzg_setups:
|
|
|
|
cd $(SCRIPTS_DIR); \
|
|
|
|
if ! test -d venv; then python3 -m venv venv; fi; \
|
|
|
|
. venv/bin/activate; \
|
|
|
|
pip3 install -r requirements.txt; \
|
2023-02-16 15:47:28 +00:00
|
|
|
python3 ./gen_kzg_trusted_setups.py --secret=1337 --g1-length=4096 --g2-length=65 --output-dir ${CURRENT_DIR}/presets/minimal/trusted_setups; \
|
2022-12-13 10:13:22 +00:00
|
|
|
python3 ./gen_kzg_trusted_setups.py --secret=1337 --g1-length=4096 --g2-length=65 --output-dir ${CURRENT_DIR}/presets/mainnet/trusted_setups
|
2022-09-27 09:30:35 +00:00
|
|
|
|
2019-07-30 10:49:18 +00:00
|
|
|
# For any generator, build it using the run_generator function.
|
2019-03-28 16:24:18 +00:00
|
|
|
# (creation of output dir is a dependency)
|
2020-01-25 00:26:10 +00:00
|
|
|
gen_%: $(TEST_VECTOR_DIR)
|
2019-07-30 10:49:18 +00:00
|
|
|
$(call run_generator,$*)
|
2021-03-16 18:41:44 +00:00
|
|
|
|
|
|
|
detect_generator_incomplete: $(TEST_VECTOR_DIR)
|
|
|
|
find $(TEST_VECTOR_DIR) -name "INCOMPLETE"
|
|
|
|
|
|
|
|
detect_generator_error_log: $(TEST_VECTOR_DIR)
|
|
|
|
[ -f $(GENERATOR_ERROR_LOG_FILE) ] && echo "[ERROR] $(GENERATOR_ERROR_LOG_FILE) file exists" || echo "[PASSED] error log file does not exist"
|
2023-04-18 10:31:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
# For docs reader
|
|
|
|
install_docs:
|
|
|
|
python3 -m venv venv; . venv/bin/activate; python3 -m pip install -e .[docs];
|
|
|
|
|
|
|
|
copy_docs:
|
|
|
|
cp -r $(SPEC_DIR) $(DOCS_DIR);
|
|
|
|
cp -r $(SYNC_DIR) $(DOCS_DIR);
|
|
|
|
cp -r $(SSZ_DIR) $(DOCS_DIR);
|
|
|
|
cp -r $(FORK_CHOICE_DIR) $(DOCS_DIR);
|
|
|
|
cp $(CURRENT_DIR)/README.md $(DOCS_DIR)/README.md
|
|
|
|
|
|
|
|
build_docs: copy_docs
|
|
|
|
. venv/bin/activate;
|
|
|
|
mkdocs build
|
|
|
|
|
|
|
|
serve_docs:
|
2024-02-16 04:29:00 +00:00
|
|
|
. venv/bin/activate;
|
2023-04-18 10:31:34 +00:00
|
|
|
mkdocs serve
|