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
514 stars 145 forks source link

Use return type info from sierra when serializing return values in cairo1-run crate #1665

Closed fmoletta closed 6 months ago

fmoletta commented 6 months ago

Closes #1664 Uses sierra program data to serialize each return value according to its concrete type. Removes the public serialize_output function in favor of an internal serialize_output function used by cairo_run_program. Possible follow up work: See if we can find the names of the enum variants & struct fields in the sierra program data and include them in the serialization.

codecov[bot] commented 6 months ago

Codecov Report

Attention: Patch coverage is 90.41916% with 32 lines in your changes are missing coverage. Please review.

Project coverage is 96.64%. Comparing base (0b6d116) to head (014b4af).

Files Patch % Lines
cairo1-run/src/cairo_run.rs 90.18% 32 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1665 +/- ## ========================================== - Coverage 96.70% 96.64% -0.07% ========================================== Files 95 95 Lines 38154 38375 +221 ========================================== + Hits 36897 37087 +190 - Misses 1257 1288 +31 ```

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

github-actions[bot] commented 6 months ago

Benchmark Results for unmodified programs :rocket:

Command Mean [s] Min [s] Max [s] Relative
base big_factorial 2.281 ± 0.053 2.234 2.409 1.01 ± 0.02
head big_factorial 2.252 ± 0.015 2.225 2.270 1.00
Command Mean [s] Min [s] Max [s] Relative
base big_fibonacci 2.293 ± 0.055 2.249 2.395 1.00 ± 0.04
head big_fibonacci 2.293 ± 0.073 2.238 2.471 1.00
Command Mean [s] Min [s] Max [s] Relative
base blake2s_integration_benchmark 8.333 ± 0.116 8.218 8.512 1.00
head blake2s_integration_benchmark 8.367 ± 0.120 8.218 8.530 1.00 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base compare_arrays_200000 2.330 ± 0.043 2.267 2.403 1.00
head compare_arrays_200000 2.342 ± 0.040 2.310 2.445 1.00 ± 0.03
Command Mean [s] Min [s] Max [s] Relative
base dict_integration_benchmark 1.443 ± 0.022 1.426 1.494 1.00
head dict_integration_benchmark 1.445 ± 0.022 1.423 1.498 1.00 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base field_arithmetic_get_square_benchmark 1.292 ± 0.012 1.275 1.310 1.00
head field_arithmetic_get_square_benchmark 1.304 ± 0.014 1.284 1.328 1.01 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base integration_builtins 8.427 ± 0.128 8.278 8.576 1.00
head integration_builtins 8.437 ± 0.153 8.279 8.619 1.00 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base keccak_integration_benchmark 8.632 ± 0.144 8.477 8.804 1.00
head keccak_integration_benchmark 8.708 ± 0.123 8.504 8.844 1.01 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base linear_search 2.318 ± 0.026 2.297 2.386 1.00
head linear_search 2.344 ± 0.026 2.317 2.406 1.01 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base math_cmp_and_pow_integration_benchmark 1.575 ± 0.015 1.558 1.610 1.01 ± 0.01
head math_cmp_and_pow_integration_benchmark 1.564 ± 0.012 1.550 1.586 1.00
Command Mean [s] Min [s] Max [s] Relative
base math_integration_benchmark 1.415 ± 0.014 1.401 1.437 1.00
head math_integration_benchmark 1.422 ± 0.009 1.406 1.432 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base memory_integration_benchmark 1.270 ± 0.039 1.247 1.370 1.00 ± 0.03
head memory_integration_benchmark 1.266 ± 0.020 1.245 1.303 1.00
Command Mean [s] Min [s] Max [s] Relative
base operations_with_data_structures_benchmarks 1.591 ± 0.007 1.582 1.600 1.00
head operations_with_data_structures_benchmarks 1.601 ± 0.007 1.592 1.616 1.01 ± 0.01
Command Mean [ms] Min [ms] Max [ms] Relative
base pedersen 589.9 ± 1.1 588.0 591.4 1.00
head pedersen 592.0 ± 4.5 588.4 601.2 1.00 ± 0.01
Command Mean [ms] Min [ms] Max [ms] Relative
base poseidon_integration_benchmark 983.7 ± 6.8 973.1 993.8 1.00
head poseidon_integration_benchmark 986.5 ± 11.9 977.6 1016.9 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base secp_integration_benchmark 1.869 ± 0.005 1.860 1.877 1.00
head secp_integration_benchmark 1.874 ± 0.052 1.844 2.019 1.00 ± 0.03
Command Mean [ms] Min [ms] Max [ms] Relative
base set_integration_benchmark 743.8 ± 2.4 740.6 748.4 1.00
head set_integration_benchmark 747.0 ± 4.7 742.2 759.1 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base uint256_integration_benchmark 4.607 ± 0.033 4.542 4.639 1.00
head uint256_integration_benchmark 4.658 ± 0.165 4.559 5.118 1.01 ± 0.04