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

feat: Add method CairoRunner::initialize_function_runner_cairo1 #1151

Merged
merged 25 commits into from
May 11, 2023

Conversation

fmoletta
Copy link
Contributor

@fmoletta fmoletta commented May 10, 2023

This PR aims to solve the issue of CasmContractClass having the builtins stored by entrypoint instead of a universal builtin field.
In order to fix this, the method CairoRunner::initialize_function_runner_cairo1 was added which allows setting the program builtins

Checklist

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

@fmoletta fmoletta changed the title Add method `CairoRunner::run_from_entrypoint_with_builtins' Add method CairoRunner::run_from_entrypoint_with_builtins May 10, 2023
@github-actions
Copy link

github-actions bot commented May 10, 2023

Benchmark Results for unmodified programs 🚀

Command Mean [s] Min [s] Max [s] Relative
base blake2s_integration_benchmark 15.605 ± 0.204 15.271 15.987 1.01 ± 0.02
head blake2s_integration_benchmark 15.510 ± 0.221 15.227 15.906 1.00
Command Mean [s] Min [s] Max [s] Relative
base compare_arrays_200000 4.922 ± 0.062 4.821 5.019 1.01 ± 0.03
head compare_arrays_200000 4.883 ± 0.129 4.733 5.145 1.00
Command Mean [s] Min [s] Max [s] Relative
base dict_integration_benchmark 3.228 ± 0.059 3.161 3.336 1.03 ± 0.03
head dict_integration_benchmark 3.119 ± 0.056 3.062 3.231 1.00
Command Mean [s] Min [s] Max [s] Relative
base factorial_multirun 5.219 ± 0.065 5.133 5.323 1.00
head factorial_multirun 5.345 ± 0.099 5.201 5.481 1.02 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base fibonacci_1000_multirun 4.486 ± 0.048 4.421 4.578 1.00
head fibonacci_1000_multirun 4.521 ± 0.067 4.408 4.650 1.01 ± 0.02
Command Mean [ms] Min [ms] Max [ms] Relative
base field_arithmetic_get_square_benchmark 220.5 ± 22.4 198.7 262.5 1.06 ± 0.11
head field_arithmetic_get_square_benchmark 207.3 ± 7.2 194.1 216.0 1.00
Command Mean [s] Min [s] Max [s] Relative
base integration_builtins 14.753 ± 0.422 14.330 15.809 1.00
head integration_builtins 14.906 ± 0.484 14.372 16.118 1.01 ± 0.04
Command Mean [s] Min [s] Max [s] Relative
base keccak_integration_benchmark 16.213 ± 0.437 15.757 17.321 1.01 ± 0.03
head keccak_integration_benchmark 16.127 ± 0.241 15.800 16.440 1.00
Command Mean [s] Min [s] Max [s] Relative
base linear_search 5.019 ± 0.144 4.898 5.406 1.01 ± 0.03
head linear_search 4.984 ± 0.090 4.864 5.130 1.00
Command Mean [s] Min [s] Max [s] Relative
base math_cmp_and_pow_integration_benchmark 3.507 ± 0.048 3.443 3.571 1.02 ± 0.02
head math_cmp_and_pow_integration_benchmark 3.437 ± 0.062 3.374 3.543 1.00
Command Mean [s] Min [s] Max [s] Relative
base math_integration_benchmark 3.224 ± 0.063 3.107 3.329 1.02 ± 0.03
head math_integration_benchmark 3.172 ± 0.081 3.099 3.374 1.00
Command Mean [s] Min [s] Max [s] Relative
base memory_integration_benchmark 2.715 ± 0.039 2.668 2.801 1.01 ± 0.02
head memory_integration_benchmark 2.693 ± 0.018 2.666 2.717 1.00
Command Mean [s] Min [s] Max [s] Relative
base operations_with_data_structures_benchmarks 3.122 ± 0.028 3.087 3.171 1.00 ± 0.02
head operations_with_data_structures_benchmarks 3.122 ± 0.040 3.068 3.204 1.00
Command Mean [s] Min [s] Max [s] Relative
base pedersen 1.007 ± 0.015 0.993 1.043 1.01 ± 0.03
head pedersen 1.001 ± 0.026 0.972 1.043 1.00
Command Mean [s] Min [s] Max [s] Relative
base poseidon_integration_benchmark 1.765 ± 0.021 1.735 1.793 1.00 ± 0.02
head poseidon_integration_benchmark 1.763 ± 0.039 1.680 1.805 1.00
Command Mean [s] Min [s] Max [s] Relative
base secp_integration_benchmark 3.871 ± 0.062 3.784 3.959 1.00 ± 0.02
head secp_integration_benchmark 3.858 ± 0.051 3.786 3.966 1.00
Command Mean [s] Min [s] Max [s] Relative
base set_integration_benchmark 2.087 ± 0.021 2.054 2.125 1.00
head set_integration_benchmark 2.179 ± 0.039 2.130 2.267 1.04 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base uint256_integration_benchmark 9.463 ± 0.144 9.271 9.696 1.00
head uint256_integration_benchmark 9.506 ± 0.219 9.208 9.991 1.00 ± 0.03

@fmoletta fmoletta changed the title Add method CairoRunner::run_from_entrypoint_with_builtins feat: Add method CairoRunner::initialize_function_runner_cairo1 May 10, 2023
@fmoletta fmoletta marked this pull request as ready for review May 11, 2023 13:16
Copy link
Contributor

@Oppen Oppen 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 only have a non-blocking question about a comment.

src/vm/runners/cairo_runner.rs Outdated Show resolved Hide resolved
@Oppen
Copy link
Contributor

Oppen commented May 11, 2023

To save you time: the error in the tests for wasm boils down to the global prelude of Rust not being there. The new helpers and macro need to use crate::stdlib::String instead of just String.

@codecov
Copy link

codecov bot commented May 11, 2023

Codecov Report

Merging #1151 (ede6611) into main (385e293) will increase coverage by 0.00%.
The diff coverage is 98.95%.

@@           Coverage Diff           @@
##             main    #1151   +/-   ##
=======================================
  Coverage   97.07%   97.07%           
=======================================
  Files          88       88           
  Lines       35545    35583   +38     
=======================================
+ Hits        34506    34543   +37     
- Misses       1039     1040    +1     
Impacted Files Coverage Δ
src/vm/runners/cairo_runner.rs 98.11% <97.87%> (-0.03%) ⬇️
src/serde/deserialize_program.rs 97.48% <100.00%> (+<0.01%) ⬆️
src/types/program.rs 99.46% <100.00%> (+<0.01%) ⬆️
src/utils.rs 99.49% <100.00%> (+0.04%) ⬆️

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

CHANGELOG.md Outdated Show resolved Hide resolved
@pefontana pefontana added this pull request to the merge queue May 11, 2023
Merged via the queue into main with commit e970548 May 11, 2023
@pefontana pefontana deleted the swap-builtins-in-run-from-entrypoint branch May 11, 2023 18:35
kariy pushed a commit to dojoengine/cairo-rs that referenced this pull request Jun 23, 2023
…mbdaclass#1151)

* Move builtins field outside of shared_program_data

* Add method CairoRunner::run_from_entrypoint_with_builtins

* Add changelog entry

* Revert change

* Add `CairoRunner::initialize_function_runner_cairo1`

* Use initialize_function_runner_cairo1

* Update changelog

* Add feature flag

* Clippy

* Add missing import

* Fix std path

* Add path for Vec in program macro

* Add segment_arena to BuiltinName enum

* Add change to changelog

* Fix test func

* Add String & Vec imports for alloc feature

* Remove irrelevant information from doc comment

* Add path for String

* Fix import

* Fix test

* Fix test

* Fix test

* Fix typo in changelog

* Fix duplicate entry title in changelog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants