Conversation
eytan-starkware
left a comment
There was a problem hiding this comment.
@eytan-starkware reviewed 2 files and all commit messages, and made 2 comments.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @ilyalesokhin-starkware, @orizi, and @TomerStarkware).
crates/cairo-lang-sierra-gas/src/core_libfunc_cost_base.rs line 816 at r1 (raw file):
/// Returns a precost value for a libfunc - the cost of non-step tokens. /// This is a helper function to implement costing both for creating /// gas equations and getting actual gas cost after having a solution.
Should also be removed with postcost
0119921 to
78aee97
Compare
orizi
left a comment
There was a problem hiding this comment.
@orizi reviewed 1 file and all commit messages, and resolved 1 discussion.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @ilyalesokhin-starkware and @TomerStarkware).
…gas` functions. SIERRA_UPDATE_PATCH_CHANGE_TAG=No interface change.
719e5a8 to
67c062a
Compare
78aee97 to
d734bfa
Compare
orizi
left a comment
There was a problem hiding this comment.
@orizi reviewed 1 file and all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @ilyalesokhin-starkware and @TomerStarkware).

Summary
Refactored the gas cost calculation in Sierra by adding methods to the
BranchCostenum that encapsulate the logic for calculating pre-cost and post-cost. This change simplifies thecore_libfunc_costfunction incore_libfunc_cost.rsby leveraging these new methods instead of using the previous approach withzip_eq.Type of change
Please check one:
Why is this change needed?
The previous implementation used separate functions for pre-cost and post-cost calculations, which required zipping the results together. This approach was less maintainable and less efficient. By moving the cost calculation logic into methods on the
BranchCostenum, we make the code more modular and easier to understand.What was the behavior or documentation before?
Previously, the code used separate
core_libfunc_precostandcore_libfunc_postcostfunctions, and then zipped their results together in thecore_libfunc_costfunction. This approach was more complex and less direct.What is the behavior or documentation after?
Now, the
BranchCostenum hasprecostandpostcostmethods that encapsulate the cost calculation logic. Thecore_libfunc_costfunction incore_libfunc_cost.rsdirectly uses these methods, making the code more straightforward and maintainable.Additional context
This refactoring maintains backward compatibility by keeping the original
core_libfunc_precostandcore_libfunc_postcostfunctions, but they now delegate to the new methods. This allows for a gradual transition to the new approach.