Skip to content

Commit 2f807e2

Browse files
authored
Add support for nightly tests (#7538)
This PR adds the ability to download [nightly reference tests from the consensus-specs repo](https://github.com/ethereum/consensus-specs/actions/workflows/generate_vectors.yml). This will be used by spec maintainers to ensure that there are no unexpected test failures prior to new releases. Also, we will keep track of test compliance with [this website](https://jtraglia.github.io/nyx/); eventually this will be integrated into Hive. * A new script (`download_test_vectors.sh`) is added to handle downloads. * The logic for downloading GitHub artifacts is a bit complex. * Rename the variables which store test versions: * `TESTS_TAG` to `CONSENSUS_SPECS_TEST_VERSION`. * `BLS_TEST_TAG` to `BLS_TEST_VERSION`, for consistency. * Delete tarballs after extracting them. * I see no need to keep these; they just use extra disk. * Consolidate `clean` rules into a single rule. * Do `clean` prior to downloading/extracting tests. * Remove `CURL` variable with GitHub token; don't need it for downloading releases. * Do `mkdir -p` when creating directories. * Probably more small stuff...
1 parent d457cee commit 2f807e2

File tree

3 files changed

+96
-32
lines changed

3 files changed

+96
-32
lines changed

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,9 @@ run-state-transition-tests:
218218
# Downloads and runs the EF test vectors.
219219
test-ef: make-ef-tests run-ef-tests
220220

221+
# Downloads and runs the nightly EF test vectors.
222+
test-ef-nightly: make-ef-tests-nightly run-ef-tests
223+
221224
# Downloads and runs the EF test vectors with nextest.
222225
nextest-ef: make-ef-tests nextest-run-ef-tests
223226

@@ -278,6 +281,10 @@ lint-full:
278281
make-ef-tests:
279282
make -C $(EF_TESTS)
280283

284+
# Download/extract the nightly EF test vectors.
285+
make-ef-tests-nightly:
286+
CONSENSUS_SPECS_TEST_VERSION=nightly make -C $(EF_TESTS)
287+
281288
# Verifies that crates compile with fuzzing features enabled
282289
arbitrary-fuzz:
283290
cargo check -p state_processing --features arbitrary-fuzz,$(TEST_FEATURES)

testing/ef_tests/Makefile

Lines changed: 21 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,33 @@
1-
TESTS_TAG := v1.6.0-alpha.0
2-
TESTS = general minimal mainnet
3-
TARBALLS = $(patsubst %,%-$(TESTS_TAG).tar.gz,$(TESTS))
4-
1+
# To download/extract nightly tests, run:
2+
# CONSENSUS_SPECS_TEST_VERSION=nightly make
3+
CONSENSUS_SPECS_TEST_VERSION ?= v1.6.0-alpha.0
54
REPO_NAME := consensus-spec-tests
65
OUTPUT_DIR := ./$(REPO_NAME)
7-
BASE_URL := https://github.com/ethereum/$(REPO_NAME)/releases/download/$(TESTS_TAG)
86

97
BLS_TEST_REPO_NAME := bls12-381-tests
10-
BLS_TEST_TAG := v0.1.1
8+
BLS_TEST_VERSION := v0.1.1
119
BLS_TEST = bls_tests_yaml
12-
BLS_TARBALL = $(patsubst %,%-$(BLS_TEST_TAG).tar.gz,$(BLS_TEST))
1310
BLS_OUTPUT_DIR := $(OUTPUT_DIR)/$(BLS_TEST_REPO_NAME)
14-
BLS_BASE_URL := https://github.com/ethereum/$(BLS_TEST_REPO_NAME)/releases/download/$(BLS_TEST_TAG)
11+
BLS_BASE_URL := https://github.com/ethereum/$(BLS_TEST_REPO_NAME)/releases/download/$(BLS_TEST_VERSION)
12+
13+
.PHONY: all clean
1514

16-
CURL := $(if $(LIGHTHOUSE_GITHUB_TOKEN),curl -L --header "Authorization: $(LIGHTHOUSE_GITHUB_TOKEN)",curl -L)
15+
all: clean $(OUTPUT_DIR) $(BLS_OUTPUT_DIR)
1716

18-
all:
19-
make $(OUTPUT_DIR)
20-
make $(BLS_OUTPUT_DIR)
17+
clean:
18+
rm -rf *.tar.gz $(OUTPUT_DIR) $(BLS_OUTPUT_DIR)
2119

22-
$(OUTPUT_DIR): $(TARBALLS)
23-
mkdir $(OUTPUT_DIR)
24-
for test_tarball in $^; do \
25-
tar -xzf $$test_tarball -C $(OUTPUT_DIR);\
20+
$(OUTPUT_DIR):
21+
mkdir -p $(OUTPUT_DIR)
22+
./download_test_vectors.sh $(CONSENSUS_SPECS_TEST_VERSION)
23+
for test_tarball in *.tar.gz; do \
24+
tar -xzf $$test_tarball -C $(OUTPUT_DIR); \
25+
rm -f $$test_tarball; \
2626
done
2727

2828
$(BLS_OUTPUT_DIR):
29-
mkdir $(BLS_OUTPUT_DIR)
30-
$(CURL) $(BLS_BASE_URL)/$(BLS_TEST).tar.gz -o $(BLS_TARBALL)
31-
tar -xzf $(BLS_TARBALL) -C $(BLS_OUTPUT_DIR)
32-
33-
%-$(TESTS_TAG).tar.gz:
34-
$(CURL) $(BASE_URL)/$*.tar.gz -o $@
35-
36-
clean-test-files:
37-
rm -rf $(OUTPUT_DIR) $(BLS_OUTPUT_DIR)
38-
39-
clean-archives:
40-
rm -f $(TARBALLS) $(BLS_TARBALL)
41-
42-
clean: clean-test-files clean-archives
43-
44-
.PHONY: clean clean-archives clean-test-files
29+
mkdir -p $(BLS_OUTPUT_DIR)
30+
curl --progress-bar --location --remote-name --show-error --retry 3 --retry-all-errors --fail \
31+
$(BLS_BASE_URL)/$(BLS_TEST).tar.gz
32+
tar -xzf *.tar.gz -C $(BLS_OUTPUT_DIR)
33+
rm -f *.tar.gz
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/usr/bin/env bash
2+
set -Eeuo pipefail
3+
4+
TESTS=("general" "minimal" "mainnet")
5+
6+
version=${1}
7+
if [[ "$version" == "nightly" ]]; then
8+
if [[ -z "${GITHUB_TOKEN:-}" ]]; then
9+
echo "Error GITHUB_TOKEN is not set"
10+
exit 1
11+
fi
12+
13+
for cmd in unzip jq; do
14+
if ! command -v "${cmd}" >/dev/null 2>&1; then
15+
echo "Error ${cmd} is not installed"
16+
exit 1
17+
fi
18+
done
19+
20+
repo="ethereum/consensus-specs"
21+
api="https://api.github.com"
22+
auth_header="Authorization: token ${GITHUB_TOKEN}"
23+
24+
run_id=$(curl -s -H "${auth_header}" \
25+
"${api}/repos/${repo}/actions/workflows/generate_vectors.yml/runs?branch=dev&status=success&per_page=1" |
26+
jq -r '.workflow_runs[0].id')
27+
28+
if [[ "${run_id}" == "null" || -z "${run_id}" ]]; then
29+
echo "No successful nightly workflow run found"
30+
exit 1
31+
fi
32+
33+
echo "Downloading nightly test vectors for run: ${run_id}"
34+
curl -s -H "${auth_header}" "${api}/repos/${repo}/actions/runs/${run_id}/artifacts" |
35+
jq -c '.artifacts[] | {name, url: .archive_download_url}' |
36+
while read -r artifact; do
37+
name=$(echo "${artifact}" | jq -r .name)
38+
url=$(echo "${artifact}" | jq -r .url)
39+
40+
if [[ "$name" == "consensustestgen.log" ]]; then
41+
continue
42+
fi
43+
44+
echo "Downloading artifact: ${name}"
45+
curl --progress-bar --location --show-error --retry 3 --retry-all-errors --fail \
46+
-H "${auth_header}" -H "Accept: application/vnd.github+json" \
47+
--output "${name}.zip" "${url}" || {
48+
echo "Failed to download ${name}"
49+
exit 1
50+
}
51+
52+
unzip -qo "${name}.zip"
53+
rm -f "${name}.zip"
54+
done
55+
else
56+
for test in "${TESTS[@]}"; do
57+
if [[ ! -e "${test}.tar.gz" ]]; then
58+
echo "Downloading: ${version}/${test}.tar.gz"
59+
curl --progress-bar --location --remote-name --show-error --retry 3 --retry-all-errors --fail \
60+
"https://github.com/ethereum/consensus-spec-tests/releases/download/${version}/${test}.tar.gz" \
61+
|| {
62+
echo "Curl failed. Aborting"
63+
rm -f "${test}.tar.gz"
64+
exit 1
65+
}
66+
fi
67+
done
68+
fi

0 commit comments

Comments
 (0)