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

PeerDAS cryptography: Add a missing check and a missing test vector (coverage report of test vectors) #3765

Merged
merged 2 commits into from
May 14, 2024

Conversation

asn-d6
Copy link
Contributor

@asn-d6 asn-d6 commented May 14, 2024

I spent some time checking which parts of c-kzg are not tested by the test vectors. I did this by exporting coverage information of the C code of c-kzg when the test vectors are tested through the Rust bindings. I was forced to go through the Rust bindings because only the bindings run the test vectors at the moment (and IMO that's fine).

For what it's worth, I used the cargo-llvm-cov project and the following command:
CC=clang LLVM_COV=llvm-cov LLVM_PROFDATA=llvm-profdata cargo llvm-cov --include-ffi --html.
In case you are curious, I attach a zip file (c_kzg_coverage.zip) with the coverage report of c-kzg (commit f5e4b030f) when running the tests of the Rust bindings.

All in all, the coverage results were very good (i.e. the test vectors are well thought out!).

In this PR, I fix some minor issues found during the above procedure:

  • I add a missing cell_id range check in recover_all_cells() (which was actually tested by the test vectors)
  • Add a test vector for too many cells in recover_all_cells() which represents the right side of the spec assertion: assert CELLS_PER_EXT_BLOB / 2 <= len(cell_ids) <= CELLS_PER_EXT_BLOB. The test vector is sorta rendundant because the combination of the duplicate cell_id check and the cell_id range check would have caught this edge case, but still worth checking explicitly since it's not trivial (and it shows up in the coverage as well).

Some more notes:

  • This c-kzg check shows up as unvisited in the coverage report, but it's not covered by the spec. We should either add it to the spec, or remove it from c-kzg?
  • This c-kzg check shows up as unvisited in the coverage report, but it's actually tested by the function's caller. Perhaps it should be an assert? Similar to the sanity check in recover cells?

@asn-d6 asn-d6 force-pushed the peerdas_more_tests branch from 7bcbefa to d92a91a Compare May 14, 2024 13:52
Copy link
Member

@jtraglia jtraglia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍 thanks! Both of your ckzg notes were useful too, I will fix those.

@jtraglia jtraglia added the EIP-7594 PeerDAS label May 14, 2024
@jtraglia jtraglia merged commit fdeff74 into ethereum:dev May 14, 2024
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
EIP-7594 PeerDAS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants