Skip to content

[Sierra-Emu] Fix felt-dict's overflow, circuits libfuncs and implement missing EcPoint libfunc #1208

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

Open
wants to merge 50 commits into
base: main
Choose a base branch
from

Conversation

FrancoGiachetta
Copy link
Contributor

@FrancoGiachetta FrancoGiachetta commented May 5, 2025

This PR fixes some issues:

FeltDict libfuncs:

  • There was issue while running corelib's tests which produced an overflow. This was related with the amount of initial gas passed to the executor which was u64::MAX. It was change to match the amount of gas needed by the test.
  • felt252_dict_get libfunc was always returning the default value of a Felt, which was intented only in cases where the dict didn't contain the key received as argument.

Circuits libfuncs:

  • Implements missing branch in circuit_try_into_circuit_modulus.
  • Implements circuit_u96_limbs_less_than_guarantee_verify libfunc which was noop before.
  • Fixes circuit_add_input which wasn't checking correctly when to stop adding inputs.
  • Removes a panic when trying the invert a non-invertible circuit input.

"EcPoint" libfuncs

  • Implements ec_zero libfunc

Checklist

  • Linked to Github Issue
  • Unit tests added
  • Integration tests added.
  • This change requires new documentation.
    • Documentation has been added/updated.

Copy link

github-actions bot commented May 5, 2025

Benchmark results Main vs HEAD.

Base

Command Mean [s] Min [s] Max [s] Relative
base dict_insert.cairo (JIT) 5.119 ± 0.060 5.047 5.246 1.02 ± 0.01
base dict_insert.cairo (AOT) 5.024 ± 0.034 4.989 5.084 1.00

Head

Command Mean [s] Min [s] Max [s] Relative
head dict_insert.cairo (JIT) 5.094 ± 0.042 5.020 5.152 1.02 ± 0.01
head dict_insert.cairo (AOT) 4.993 ± 0.015 4.977 5.024 1.00

Base

Command Mean [s] Min [s] Max [s] Relative
base dict_snapshot.cairo (JIT) 5.013 ± 0.028 4.976 5.064 1.02 ± 0.01
base dict_snapshot.cairo (AOT) 4.919 ± 0.030 4.882 4.971 1.00

Head

Command Mean [s] Min [s] Max [s] Relative
head dict_snapshot.cairo (JIT) 5.060 ± 0.038 5.004 5.108 1.01 ± 0.01
head dict_snapshot.cairo (AOT) 5.003 ± 0.049 4.921 5.087 1.00

Base

Command Mean [s] Min [s] Max [s] Relative
base factorial_2M.cairo (JIT) 5.393 ± 0.036 5.351 5.460 1.01 ± 0.01
base factorial_2M.cairo (AOT) 5.335 ± 0.039 5.291 5.412 1.00

Head

Command Mean [s] Min [s] Max [s] Relative
head factorial_2M.cairo (JIT) 5.446 ± 0.037 5.374 5.515 1.03 ± 0.01
head factorial_2M.cairo (AOT) 5.305 ± 0.021 5.276 5.334 1.00

Base

Command Mean [s] Min [s] Max [s] Relative
base fib_2M.cairo (JIT) 4.911 ± 0.027 4.860 4.946 1.01 ± 0.01
base fib_2M.cairo (AOT) 4.883 ± 0.047 4.802 4.959 1.00

Head

Command Mean [s] Min [s] Max [s] Relative
head fib_2M.cairo (JIT) 4.938 ± 0.043 4.857 4.982 1.02 ± 0.01
head fib_2M.cairo (AOT) 4.834 ± 0.026 4.799 4.881 1.00

Base

Command Mean [s] Min [s] Max [s] Relative
base linear_search.cairo (JIT) 5.119 ± 0.023 5.090 5.166 1.03 ± 0.01
base linear_search.cairo (AOT) 4.955 ± 0.026 4.908 5.001 1.00

Head

Command Mean [s] Min [s] Max [s] Relative
head linear_search.cairo (JIT) 5.175 ± 0.063 5.077 5.264 1.01 ± 0.02
head linear_search.cairo (AOT) 5.116 ± 0.077 4.934 5.213 1.00

Base

Command Mean [s] Min [s] Max [s] Relative
base logistic_map.cairo (JIT) 5.192 ± 0.049 5.142 5.299 1.04 ± 0.01
base logistic_map.cairo (AOT) 5.016 ± 0.019 4.982 5.043 1.00

Head

Command Mean [s] Min [s] Max [s] Relative
head logistic_map.cairo (JIT) 5.199 ± 0.030 5.149 5.233 1.04 ± 0.01
head logistic_map.cairo (AOT) 5.010 ± 0.037 4.969 5.075 1.00

Copy link

github-actions bot commented May 5, 2025

Benchmarking results

Benchmark for program dict_insert

Open benchmarks
Command Mean [s] Min [s] Max [s] Relative
Cairo-vm (Rust, Cairo 1) 11.441 ± 0.063 11.353 11.537 2.31 ± 0.02
cairo-native (embedded AOT) 4.947 ± 0.028 4.889 4.983 1.00
cairo-native (embedded JIT using LLVM's ORC Engine) 5.118 ± 0.076 5.048 5.310 1.03 ± 0.02

Benchmark for program dict_snapshot

Open benchmarks
Command Mean [ms] Min [ms] Max [ms] Relative
Cairo-vm (Rust, Cairo 1) 816.3 ± 4.4 811.7 823.9 1.00
cairo-native (embedded AOT) 4874.2 ± 35.0 4834.5 4959.0 5.97 ± 0.05
cairo-native (embedded JIT using LLVM's ORC Engine) 5022.3 ± 64.8 4960.3 5189.0 6.15 ± 0.09

Benchmark for program factorial_2M

Open benchmarks
Command Mean [s] Min [s] Max [s] Relative
Cairo-vm (Rust, Cairo 1) 5.287 ± 0.031 5.247 5.341 1.00
cairo-native (embedded AOT) 5.304 ± 0.053 5.250 5.394 1.00 ± 0.01
cairo-native (embedded JIT using LLVM's ORC Engine) 5.350 ± 0.081 5.273 5.537 1.01 ± 0.02

Benchmark for program fib_2M

Open benchmarks
Command Mean [s] Min [s] Max [s] Relative
Cairo-vm (Rust, Cairo 1) 5.093 ± 0.024 5.061 5.139 1.06 ± 0.01
cairo-native (embedded AOT) 4.847 ± 0.062 4.778 4.987 1.00 ± 0.01
cairo-native (embedded JIT using LLVM's ORC Engine) 4.826 ± 0.033 4.775 4.875 1.00

Benchmark for program linear_search

Open benchmarks
Command Mean [ms] Min [ms] Max [ms] Relative
Cairo-vm (Rust, Cairo 1) 814.8 ± 6.2 806.8 828.2 1.00
cairo-native (embedded AOT) 4925.2 ± 27.4 4893.9 4983.4 6.04 ± 0.06
cairo-native (embedded JIT using LLVM's ORC Engine) 5053.1 ± 53.7 4982.0 5152.1 6.20 ± 0.08

Benchmark for program logistic_map

Open benchmarks
Command Mean [ms] Min [ms] Max [ms] Relative
Cairo-vm (Rust, Cairo 1) 531.8 ± 8.6 524.4 553.5 1.00
cairo-native (embedded AOT) 5060.7 ± 30.3 5019.9 5125.3 9.52 ± 0.16
cairo-native (embedded JIT using LLVM's ORC Engine) 5247.8 ± 26.3 5207.2 5281.5 9.87 ± 0.17

Copy link

github-actions bot commented May 5, 2025

✅ Code is now correctly formatted.

@codecov-commenter
Copy link

codecov-commenter commented May 5, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.48%. Comparing base (a4be0f6) to head (64e439a).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1208   +/-   ##
=======================================
  Coverage   80.48%   80.48%           
=======================================
  Files         110      110           
  Lines       29580    29580           
=======================================
  Hits        23807    23807           
  Misses       5773     5773           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@FrancoGiachetta FrancoGiachetta marked this pull request as ready for review May 7, 2025 19:07
@FrancoGiachetta FrancoGiachetta marked this pull request as draft May 9, 2025 15:31
@FrancoGiachetta FrancoGiachetta marked this pull request as ready for review May 9, 2025 17:45
Copy link
Contributor

@JulianGCalderon JulianGCalderon left a comment

Choose a reason for hiding this comment

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

Looking good, I left two small comments.

Copy link
Contributor

@JulianGCalderon JulianGCalderon left a comment

Choose a reason for hiding this comment

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

LGTM, I suggested a small correction

Copy link
Contributor

@JulianGCalderon JulianGCalderon left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
review-ready A PR that is ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants