fix(zk-verifier): real Groth16 weights in verify_proof benchmark#88
Merged
Conversation
do_verify previously short-circuited to 'return true' under
feature = \"runtime-benchmarks\", so the benchmark only measured FRAME
overhead (~µs) instead of the real BN254 pairing cost (~8-10 ms).
This caused a severe weight underestimation — a potential DoS vector.
Fix:
- Remove 'runtime-benchmarks' from the #[cfg] bypass in do_verify.
Short-circuit now applies only in #[cfg(test)].
- Embed real Groth16 fixtures via include_bytes!:
src/bench_fixtures/vk_transfer.bin (488 B, arkworks VK)
src/bench_fixtures/proof_transfer.bin (128 B, compressed proof)
src/bench_fixtures/public_inputs_transfer.bin (224 B, 7×32 B LE)
- benchmarking.rs verify_proof now uses the real fixtures so that
weight generation on Hetzner CCX33 captures true on-chain cost.
- Add scripts/generate-bench-fixtures.mjs to regenerate fixtures
after any circuit change.
Closes: #<issue>
Version: 0.7.0
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
do_verify previously short-circuited to 'return true' under feature = "runtime-benchmarks", so the benchmark only measured FRAME overhead (~µs) instead of the real BN254 pairing cost (~8-10 ms). This caused a severe weight underestimation — a potential DoS vector.
Fix:
src/bench_fixtures/vk_transfer.bin (488 B, arkworks VK)
src/bench_fixtures/proof_transfer.bin (128 B, compressed proof)
src/bench_fixtures/public_inputs_transfer.bin (224 B, 7×32 B LE)
weight generation on Hetzner CCX33 captures true on-chain cost.
after any circuit change.
Closes: #
Version: 0.7.0