Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(tests): update kzg point evaulation test vectors to official setup #336

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ Test fixtures for use by clients are available for each release on the [Github r

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

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

### 🧪 Test Cases

- 🔀 [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)).

### 🛠️ Framework

- 🔀 Fixtures: Add a non-RLP format field (`rlp_decoded`) to invalid blocks ([#322](https://github.com/ethereum/execution-spec-tests/pull/322)).
Expand All @@ -24,6 +26,11 @@ Test fixtures for use by clients are available for each release on the [Github r
- ✨ Process: Added a Github pull request template ([#308](https://github.com/ethereum/execution-spec-tests/pull/308)).
- ✨ Docs: Changelog updated post release ([#321](https://github.com/ethereum/execution-spec-tests/pull/321)).
- ✨ 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)).
- 🔀 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))

### 💥 Breaking Change

- 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))

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

Expand Down
4 changes: 2 additions & 2 deletions evm-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ main:
ref: master
develop:
impl: geth
repo: marioevz/go-ethereum
ref: cancun-t8n
repo: lightclient/go-ethereum
ref: devnet-10
1 change: 1 addition & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ addopts =
-p pytest_plugins.test_help.test_help
-m "not eip_version_check"
--dist loadscope
--ignore tests/cancun/eip4844_blobs/point_evaluation_vectors/
32 changes: 29 additions & 3 deletions tests/cancun/eip4844_blobs/point_evaluation_vectors/README.md
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.
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()
Loading