Skip to content

Commit 4871503

Browse files
authored
Merge pull request #336 from danceratopz/feat/tests/update-kzg-point-evaluation-test-vectors-to-official-setup
feat(tests): update kzg point evaulation test vectors to official setup
2 parents f94de0e + 2de35d0 commit 4871503

File tree

7 files changed

+541
-149
lines changed

7 files changed

+541
-149
lines changed

docs/CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ Test fixtures for use by clients are available for each release on the [Github r
44

55
**Key:** ✨ = New, 🐞 = Fixed, 🔀 = Changed, 💥 = Breaking change.
66

7-
## 🔜 [Unreleased - v1.0.6](https://github.com/ethereum/execution-spec-tests/releases/tag/v1.0.6) - 2023-xx-xx
7+
## 🔜 [Unreleased - v1.0.6](https://github.com/ethereum/execution-spec-tests/releases/tag/v1.0.6) - 2023-10-19: 🐍🏖️ Cancun Devnet 10
88

99
### 🧪 Test Cases
1010

11+
- 🔀 [EIP-4844](https://eips.ethereum.org/EIPS/eip-4844): Update KZG point evaluation test vectors to use data from the official KZG setup and Mainnet Trusted Setup ([#336](https://github.com/ethereum/execution-spec-tests/pull/336)).
12+
1113
### 🛠️ Framework
1214

1315
- 🔀 Fixtures: Add a non-RLP format field (`rlp_decoded`) to invalid blocks ([#322](https://github.com/ethereum/execution-spec-tests/pull/322)).
@@ -24,6 +26,11 @@ Test fixtures for use by clients are available for each release on the [Github r
2426
- ✨ Process: Added a Github pull request template ([#308](https://github.com/ethereum/execution-spec-tests/pull/308)).
2527
- ✨ Docs: Changelog updated post release ([#321](https://github.com/ethereum/execution-spec-tests/pull/321)).
2628
- ✨ Docs: Add [a section explaining execution-spec-tests release artifacts](https://ethereum.github.io/execution-spec-tests/main/getting_started/using_fixtures/) ([#334](https://github.com/ethereum/execution-spec-tests/pull/334)).
29+
- 🔀 T8N Tool: Branch used to generate the tests for Cancun is now [lightclient/go-ethereum@devnet-10](https://github.com/lightclient/go-ethereum/tree/devnet-10) ([#336](https://github.com/ethereum/execution-spec-tests/pull/336))
30+
31+
### 💥 Breaking Change
32+
33+
- Fixtures now use the Mainnet Trusted Setup merged on [consensus-specs#3521](https://github.com/ethereum/consensus-specs/pull/3521) ([#336](https://github.com/ethereum/execution-spec-tests/pull/336))
2734

2835
## [v1.0.5](https://github.com/ethereum/execution-spec-tests/releases/tag/v1.0.5) - 2023-09-26: 🐍🏖️ Cancun Devnet 9 Release 3
2936

evm-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ main:
44
ref: master
55
develop:
66
impl: geth
7-
repo: marioevz/go-ethereum
8-
ref: cancun-t8n
7+
repo: lightclient/go-ethereum
8+
ref: devnet-10

pytest.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ addopts =
1010
-p pytest_plugins.test_help.test_help
1111
-m "not eip_version_check"
1212
--dist loadscope
13+
--ignore tests/cancun/eip4844_blobs/point_evaluation_vectors/
Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,39 @@
11
# KZG Point Evaluation Test Vectors
22

3-
This directory contains test vectors for the KZG point evaluation algorithm, compiled from different sources.
3+
This directory contains test vectors for the KZG point evaluation algorithm that are loaded and used throughout different tests.
44

55
Each file must contain a JSON list of objects, each with the following fields:
6+
67
- `name`: a string describing the test case
78
- `input`: object containing `commitment`, `proof`, `z` and `y`
89
- `output`: expected output of the evaluation, true, false or null.
910

10-
The files are loaded and used throughout different test tests.
11+
## Generating The Test Vectors (used in v1.0.6 and on)
12+
13+
From execution-spec-tests release v1.0.6 and on, the point evaluation test vectors were generated using commit [63aa303c](https://github.com/ethereum/consensus-specs/tree/63aa303c5a2cf46ea98edbf3f82286079651bb78) from the [official-kzg](https://github.com/ethereum/consensus-specs/commits/official-kzg) [consensus-specs](https://github.com/ethereum/consensus-specs) branch.
14+
15+
The test vectors were generated as following:
16+
17+
1. In the consensus-specs repo:
18+
19+
```console
20+
cd tests/generators/kzg_4844/
21+
rm -rf /tmp/kzg_4844_output
22+
mkdir /tmp/kzg_4844_output
23+
python -m main --output /tmp/kzg_4844_output
24+
```
25+
26+
2. In the execution-spec-tests repo:
27+
28+
```console
29+
cd tests/cancun/4844_blobs/point_evaluation_vectors/
30+
pip install -r requirements.txt
31+
python concat_kzg_vectors_to_json.py \
32+
--input /tmp/kzg_4844_output/general/deneb/kzg/verify_kzg_proof/kzg-mainnet/
33+
--output go_kzg_4844_verify_kzg_proof.json
34+
```
35+
36+
## Previous Versions of the Test Vectors (used up to v1.0.5)
1137

12-
Current files and their sources:
38+
The test vectors up and including execution-spec-tests [release v1.0.5](https://github.com/ethereum/execution-spec-tests/releases/tag/v1.0.5) were:
1339
- `go_kzg_4844_verify_kzg_proof.json`: test vectors from the [go-kzg-4844](https://github.com/crate-crypto/go-kzg-4844) repository.
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
"""
2+
Helper script to concatenate all the point evaluation test data.yaml files in
3+
a directory into a single JSON file for easier consumption in tests.
4+
"""
5+
import argparse
6+
import json
7+
from pathlib import Path
8+
9+
import yaml # type: ignore
10+
11+
12+
def gather_yaml_data(directory: Path): # noqa: D103
13+
all_data = []
14+
15+
# Loop through each directory in the main directory
16+
for sub_dir in sorted(directory.iterdir()):
17+
if sub_dir.is_dir():
18+
yaml_file_path = sub_dir / "data.yaml"
19+
20+
# Check if data.yaml exists in the directory
21+
if yaml_file_path.exists():
22+
with yaml_file_path.open("r") as yaml_file:
23+
yaml_data = yaml.safe_load(yaml_file)
24+
# Append the data along with the directory name
25+
all_data.append(
26+
{
27+
"input": yaml_data["input"],
28+
"output": yaml_data["output"],
29+
"name": sub_dir.name,
30+
}
31+
)
32+
return all_data
33+
34+
35+
def main(): # noqa: D103
36+
parser = argparse.ArgumentParser(
37+
description="Concatenate the data from multiple data.yaml files into one JSON file."
38+
)
39+
parser.add_argument(
40+
"-i",
41+
"--input",
42+
type=Path,
43+
required=True,
44+
help="Input directory containing the YAML files.",
45+
)
46+
parser.add_argument(
47+
"-o", "--output", type=Path, required=True, help="Path to the output JSON file."
48+
)
49+
50+
args = parser.parse_args()
51+
data = gather_yaml_data(args.input)
52+
with args.output.open("w") as json_file:
53+
json.dump(data, json_file, indent=2)
54+
55+
56+
if __name__ == "__main__":
57+
main()

0 commit comments

Comments
 (0)