-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
7 changed files
with
541 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 29 additions & 3 deletions
32
tests/cancun/eip4844_blobs/point_evaluation_vectors/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,39 @@ | ||
# KZG Point Evaluation Test Vectors | ||
|
||
This directory contains test vectors for the KZG point evaluation algorithm, compiled from different sources. | ||
This directory contains test vectors for the KZG point evaluation algorithm that are loaded and used throughout different tests. | ||
|
||
Each file must contain a JSON list of objects, each with the following fields: | ||
|
||
- `name`: a string describing the test case | ||
- `input`: object containing `commitment`, `proof`, `z` and `y` | ||
- `output`: expected output of the evaluation, true, false or null. | ||
|
||
The files are loaded and used throughout different test tests. | ||
## Generating The Test Vectors (used in v1.0.6 and on) | ||
|
||
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. | ||
|
||
The test vectors were generated as following: | ||
|
||
1. In the consensus-specs repo: | ||
|
||
```console | ||
cd tests/generators/kzg_4844/ | ||
rm -rf /tmp/kzg_4844_output | ||
mkdir /tmp/kzg_4844_output | ||
python -m main --output /tmp/kzg_4844_output | ||
``` | ||
|
||
2. In the execution-spec-tests repo: | ||
|
||
```console | ||
cd tests/cancun/4844_blobs/point_evaluation_vectors/ | ||
pip install -r requirements.txt | ||
python concat_kzg_vectors_to_json.py \ | ||
--input /tmp/kzg_4844_output/general/deneb/kzg/verify_kzg_proof/kzg-mainnet/ | ||
--output go_kzg_4844_verify_kzg_proof.json | ||
``` | ||
|
||
## Previous Versions of the Test Vectors (used up to v1.0.5) | ||
|
||
Current files and their sources: | ||
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: | ||
- `go_kzg_4844_verify_kzg_proof.json`: test vectors from the [go-kzg-4844](https://github.com/crate-crypto/go-kzg-4844) repository. |
57 changes: 57 additions & 0 deletions
57
tests/cancun/eip4844_blobs/point_evaluation_vectors/concat_kzg_vectors_to_json.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
""" | ||
Helper script to concatenate all the point evaluation test data.yaml files in | ||
a directory into a single JSON file for easier consumption in tests. | ||
""" | ||
import argparse | ||
import json | ||
from pathlib import Path | ||
|
||
import yaml # type: ignore | ||
|
||
|
||
def gather_yaml_data(directory: Path): # noqa: D103 | ||
all_data = [] | ||
|
||
# Loop through each directory in the main directory | ||
for sub_dir in sorted(directory.iterdir()): | ||
if sub_dir.is_dir(): | ||
yaml_file_path = sub_dir / "data.yaml" | ||
|
||
# Check if data.yaml exists in the directory | ||
if yaml_file_path.exists(): | ||
with yaml_file_path.open("r") as yaml_file: | ||
yaml_data = yaml.safe_load(yaml_file) | ||
# Append the data along with the directory name | ||
all_data.append( | ||
{ | ||
"input": yaml_data["input"], | ||
"output": yaml_data["output"], | ||
"name": sub_dir.name, | ||
} | ||
) | ||
return all_data | ||
|
||
|
||
def main(): # noqa: D103 | ||
parser = argparse.ArgumentParser( | ||
description="Concatenate the data from multiple data.yaml files into one JSON file." | ||
) | ||
parser.add_argument( | ||
"-i", | ||
"--input", | ||
type=Path, | ||
required=True, | ||
help="Input directory containing the YAML files.", | ||
) | ||
parser.add_argument( | ||
"-o", "--output", type=Path, required=True, help="Path to the output JSON file." | ||
) | ||
|
||
args = parser.parse_args() | ||
data = gather_yaml_data(args.input) | ||
with args.output.open("w") as json_file: | ||
json.dump(data, json_file, indent=2) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Oops, something went wrong.