lambdaclass / cairo-vm

cairo-vm is a Rust implementation of the Cairo VM. Cairo (CPU Algebraic Intermediate Representation) is a programming language for writing provable programs, where one party can prove to another that a certain computation was executed correctly without the need for this party to re-execute the same program.
https://lambdaclass.github.io/cairo-vm
Apache License 2.0
509 stars 142 forks source link

Cairo1 proof mode #1517

Closed MauroToscano closed 9 months ago

MauroToscano commented 9 months ago

Cairo1 proof mode

Description

This PR adds an initial working version of Cairo1 proof mode

In the future information should be added so [fp - 2] = fp can be enforced

codecov[bot] commented 9 months ago

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (8a2ef24) 96.82% compared to head (d777b30) 96.92%.

Files Patch % Lines
vm/src/vm/runners/cairo_runner.rs 97.43% 2 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1517 +/- ## ========================================== + Coverage 96.82% 96.92% +0.10% ========================================== Files 96 96 Lines 39744 39818 +74 ========================================== + Hits 38482 38594 +112 + Misses 1262 1224 -38 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

github-actions[bot] commented 9 months ago

Benchmark Results for unmodified programs :rocket:

Command Mean [s] Min [s] Max [s] Relative
base big_factorial 2.832 ± 0.032 2.792 2.897 1.00
head big_factorial 2.863 ± 0.022 2.841 2.911 1.01 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base big_fibonacci 2.433 ± 0.013 2.406 2.449 1.00
head big_fibonacci 2.434 ± 0.012 2.409 2.448 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base blake2s_integration_benchmark 7.046 ± 0.060 6.988 7.181 1.00 ± 0.02
head blake2s_integration_benchmark 7.036 ± 0.111 6.931 7.293 1.00
Command Mean [s] Min [s] Max [s] Relative
base compare_arrays_200000 2.541 ± 0.026 2.509 2.592 1.00
head compare_arrays_200000 2.549 ± 0.029 2.528 2.626 1.00 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base dict_integration_benchmark 1.735 ± 0.010 1.723 1.750 1.00
head dict_integration_benchmark 1.736 ± 0.011 1.725 1.759 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base field_arithmetic_get_square_benchmark 1.201 ± 0.017 1.182 1.243 1.00 ± 0.02
head field_arithmetic_get_square_benchmark 1.198 ± 0.009 1.184 1.214 1.00
Command Mean [s] Min [s] Max [s] Relative
base integration_builtins 7.037 ± 0.182 6.932 7.399 1.01 ± 0.03
head integration_builtins 6.981 ± 0.090 6.902 7.133 1.00
Command Mean [s] Min [s] Max [s] Relative
base keccak_integration_benchmark 7.096 ± 0.037 7.051 7.174 1.00
head keccak_integration_benchmark 7.193 ± 0.187 7.066 7.674 1.01 ± 0.03
Command Mean [s] Min [s] Max [s] Relative
base linear_search 2.558 ± 0.019 2.536 2.599 1.00
head linear_search 2.604 ± 0.101 2.549 2.889 1.02 ± 0.04
Command Mean [s] Min [s] Max [s] Relative
base math_cmp_and_pow_integration_benchmark 1.723 ± 0.009 1.710 1.740 1.01 ± 0.01
head math_cmp_and_pow_integration_benchmark 1.710 ± 0.017 1.692 1.751 1.00
Command Mean [s] Min [s] Max [s] Relative
base math_integration_benchmark 1.654 ± 0.011 1.639 1.681 1.00
head math_integration_benchmark 1.656 ± 0.013 1.634 1.672 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base memory_integration_benchmark 1.446 ± 0.005 1.436 1.453 1.00
head memory_integration_benchmark 1.461 ± 0.006 1.452 1.471 1.01 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base operations_with_data_structures_benchmarks 1.593 ± 0.020 1.570 1.632 1.00
head operations_with_data_structures_benchmarks 1.593 ± 0.009 1.582 1.605 1.00 ± 0.01
Command Mean [ms] Min [ms] Max [ms] Relative
base pedersen 622.0 ± 1.3 619.7 623.8 1.00
head pedersen 623.0 ± 5.0 618.1 633.6 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base poseidon_integration_benchmark 1.215 ± 0.006 1.206 1.228 1.00
head poseidon_integration_benchmark 1.218 ± 0.005 1.213 1.227 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base secp_integration_benchmark 2.138 ± 0.015 2.117 2.162 1.00 ± 0.01
head secp_integration_benchmark 2.130 ± 0.013 2.117 2.153 1.00
Command Mean [s] Min [s] Max [s] Relative
base set_integration_benchmark 1.212 ± 0.010 1.200 1.236 1.00 ± 0.01
head set_integration_benchmark 1.212 ± 0.006 1.204 1.223 1.00
Command Mean [s] Min [s] Max [s] Relative
base uint256_integration_benchmark 4.383 ± 0.039 4.339 4.468 1.00 ± 0.01
head uint256_integration_benchmark 4.370 ± 0.037 4.331 4.454 1.00
pefontana commented 9 months ago

should add a command line argument to set the run to proof_mode instead of just running proof_mode by default

Yes @fmoletta, that is the plan We talked with Mauro, first we can merge this to run always on proof mode, and then we can make a refactor so the user can decide if he wants to execute in proof mode or not