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

create vm diff fuzzer #1358

Merged
merged 93 commits into from
Aug 30, 2023
Merged

create vm diff fuzzer #1358

merged 93 commits into from
Aug 30, 2023

Conversation

daphneherlambda
Copy link
Contributor

@daphneherlambda daphneherlambda commented Aug 2, 2023

Create diff fuzzer for vm for python hints

Description

This PR creates a python script that runs a differential fuzzer that compares rust vs py vm implementation of all hints containing SECP_P and shifts to the left.
The fuzzer generates a cairo program through a hint that is obtained through the VM code. Then the cairo program is compiled and ran on the python and rust implementations of the VM, both with the memory output enabled. The memory is then compared as a multi-set, meaning both memories must have the same values with the same repetitions but not necessarily the same order.

@github-actions
Copy link

github-actions bot commented Aug 2, 2023

Benchmark Results for unmodified programs 🚀

Command Mean [s] Min [s] Max [s] Relative
base big_factorial 5.392 ± 0.108 5.266 5.653 1.02 ± 0.02
head big_factorial 5.310 ± 0.064 5.235 5.441 1.00
Command Mean [s] Min [s] Max [s] Relative
base big_fibonacci 4.563 ± 0.072 4.471 4.729 1.02 ± 0.02
head big_fibonacci 4.495 ± 0.057 4.414 4.594 1.00
Command Mean [s] Min [s] Max [s] Relative
base blake2s_integration_benchmark 12.418 ± 0.102 12.297 12.617 1.00
head blake2s_integration_benchmark 12.775 ± 0.232 12.457 13.259 1.03 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base compare_arrays_200000 4.551 ± 0.052 4.479 4.625 1.01 ± 0.01
head compare_arrays_200000 4.504 ± 0.034 4.450 4.564 1.00
Command Mean [s] Min [s] Max [s] Relative
base dict_integration_benchmark 2.984 ± 0.023 2.928 3.009 1.00
head dict_integration_benchmark 3.061 ± 0.055 2.991 3.144 1.03 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base field_arithmetic_get_square_benchmark 2.084 ± 0.026 2.055 2.144 1.01 ± 0.02
head field_arithmetic_get_square_benchmark 2.060 ± 0.038 1.994 2.136 1.00
Command Mean [s] Min [s] Max [s] Relative
base integration_builtins 12.352 ± 0.136 12.224 12.633 1.00
head integration_builtins 12.611 ± 0.151 12.440 12.804 1.02 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base keccak_integration_benchmark 13.113 ± 0.162 12.894 13.311 1.01 ± 0.02
head keccak_integration_benchmark 12.959 ± 0.135 12.876 13.323 1.00
Command Mean [s] Min [s] Max [s] Relative
base linear_search 4.579 ± 0.031 4.546 4.641 1.00
head linear_search 4.579 ± 0.087 4.475 4.785 1.00 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base math_cmp_and_pow_integration_benchmark 3.319 ± 0.054 3.262 3.414 1.00 ± 0.02
head math_cmp_and_pow_integration_benchmark 3.306 ± 0.042 3.218 3.364 1.00
Command Mean [s] Min [s] Max [s] Relative
base math_integration_benchmark 2.964 ± 0.041 2.912 3.023 1.00
head math_integration_benchmark 2.975 ± 0.065 2.906 3.142 1.00 ± 0.03
Command Mean [s] Min [s] Max [s] Relative
base memory_integration_benchmark 2.720 ± 0.052 2.649 2.837 1.03 ± 0.02
head memory_integration_benchmark 2.643 ± 0.040 2.593 2.715 1.00
Command Mean [s] Min [s] Max [s] Relative
base operations_with_data_structures_benchmarks 2.847 ± 0.047 2.798 2.953 1.01 ± 0.02
head operations_with_data_structures_benchmarks 2.826 ± 0.021 2.779 2.862 1.00
Command Mean [s] Min [s] Max [s] Relative
base pedersen 1.056 ± 0.024 1.024 1.093 1.01 ± 0.02
head pedersen 1.041 ± 0.010 1.027 1.057 1.00
Command Mean [s] Min [s] Max [s] Relative
base poseidon_integration_benchmark 1.903 ± 0.034 1.838 1.957 1.00
head poseidon_integration_benchmark 1.909 ± 0.031 1.864 1.960 1.00 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base secp_integration_benchmark 3.774 ± 0.072 3.711 3.932 1.00 ± 0.02
head secp_integration_benchmark 3.756 ± 0.039 3.691 3.822 1.00
Command Mean [s] Min [s] Max [s] Relative
base set_integration_benchmark 2.349 ± 0.027 2.314 2.394 1.01 ± 0.02
head set_integration_benchmark 2.314 ± 0.026 2.286 2.366 1.00
Command Mean [s] Min [s] Max [s] Relative
base uint256_integration_benchmark 7.833 ± 0.075 7.732 7.939 1.00
head uint256_integration_benchmark 7.973 ± 0.123 7.781 8.242 1.02 ± 0.02

@codecov
Copy link

codecov bot commented Aug 3, 2023

Codecov Report

Merging #1358 (7737349) into main (27bcbeb) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main    #1358   +/-   ##
=======================================
  Coverage   96.96%   96.96%           
=======================================
  Files          94       94           
  Lines       38662    38662           
=======================================
  Hits        37490    37490           
  Misses       1172     1172           

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Makefile Outdated
cargo +nightly install cargo-fuzz
. cairo-vm-env/bin/activate; pip install atheris==2.2.2
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure if I should include this dependency in requirements.txt

@Juan-M-V Juan-M-V marked this pull request as ready for review August 3, 2023 20:05
@daphneherlambda daphneherlambda added the WIP work in progress label Aug 7, 2023
@Juan-M-V Juan-M-V added tests Implementation of tests and removed WIP work in progress labels Aug 22, 2023
CHANGELOG.md Outdated Show resolved Hide resolved
Makefile Outdated
Comment on lines 319 to 323
fuzzer-run-cairo-compiled:
cd fuzzer
cargo +nightly fuzz run --fuzz-dir . cairo_compiled_programs_fuzzer

diff-fuzz:
fuzzer-run-hint-diff:
Copy link
Member

Choose a reason for hiding this comment

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

Please add these targets to .PHONY

Copy link
Contributor

Choose a reason for hiding this comment

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

Resolved: e14a086

Copy link
Member

@fmoletta fmoletta left a comment

Choose a reason for hiding this comment

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

Looks good! Left some minor comments

Juan-M-V and others added 4 commits August 30, 2023 11:25
Co-authored-by: fmoletta <99273364+fmoletta@users.noreply.github.com>
Co-authored-by: fmoletta <99273364+fmoletta@users.noreply.github.com>
Co-authored-by: fmoletta <99273364+fmoletta@users.noreply.github.com>
@pefontana pefontana added this pull request to the merge queue Aug 30, 2023
Merged via the queue into main with commit bdebfde Aug 30, 2023
39 checks passed
@pefontana pefontana deleted the vm-diff-fuzzer branch August 30, 2023 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Implementation of tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants