Skip to content

feature(sierra): Added cost-token for blake.#9506

Merged
orizi merged 1 commit intomainfrom
orizi/01-20-feature_sierra_added_cost-token_for_blake
Jan 27, 2026
Merged

feature(sierra): Added cost-token for blake.#9506
orizi merged 1 commit intomainfrom
orizi/01-20-feature_sierra_added_cost-token_for_blake

Conversation

@orizi
Copy link
Collaborator

@orizi orizi commented Jan 20, 2026

Summary

Added Blake hash function as a cost token type for gas calculations. This PR implements proper gas accounting for the Blake hash function by adding a new Blake cost token type and updating the gas cost calculation for Blake operations.


Type of change

Please check one:

  • Bug fix (fixes incorrect behavior)
  • New feature
  • Performance improvement
  • Documentation change with concrete technical impact
  • Style, wording, formatting, or typo-only change

Why is this change needed?

Previously, the Blake hash function was using a placeholder gas cost calculation without a dedicated cost token. This PR adds proper gas accounting for Blake operations by introducing a dedicated Blake cost token type with an appropriate gas cost value (491), similar to how other builtin operations are handled.


What was the behavior or documentation before?

Before this change, the Blake hash function had a TODO comment indicating that a Blake token needed to be added to the gas cost calculation. It was using a simple constant cost without accounting for the actual computational complexity of the operation.


What is the behavior or documentation after?

After this change, Blake hash operations properly account for gas using a dedicated Blake cost token type with a gas cost of 491. This ensures that gas calculations accurately reflect the computational cost of using the Blake hash function, similar to other builtin operations like Pedersen, Poseidon, etc.


Additional context

This change ensures consistent gas accounting across all cryptographic primitives in the system. The Blake hash function now has proper gas accounting like other builtins, which is important for accurate resource usage estimation.

@reviewable-StarkWare
Copy link

This change is Reviewable

Copy link
Collaborator Author

orizi commented Jan 20, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@orizi orizi marked this pull request as ready for review January 20, 2026 16:11
@orizi orizi force-pushed the orizi/01-20-feature_sierra_added_cost-token_for_blake branch 2 times, most recently from bacb6f4 to 154b923 Compare January 22, 2026 18:08
@ilyalesokhin-starkware
Copy link
Contributor

crates/cairo-lang-starknet-classes/src/allowed_libfuncs_lists/audited.json line 18 at r1 (raw file):

      "bitwise": null,
      "blake2s_compress": { "major": 1, "minor": 8, "patch": 0 },
      "blake2s_finalize": { "major": 1, "minor": 8, "patch": 0 },

why in audited? is it for testing?

Code quote:

      "blake2s_compress": { "major": 1, "minor": 8, "patch": 0 },
      "blake2s_finalize": { "major": 1, "minor": 8, "patch": 0 },

Copy link
Contributor

@ilyalesokhin-starkware ilyalesokhin-starkware left a comment

Choose a reason for hiding this comment

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

@ilyalesokhin-starkware reviewed 8 files and all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @liorgold2).

SIERRA_UPDATE_PATCH_CHANGE_TAG=Only added function to starknet.
@orizi orizi force-pushed the orizi/01-20-feature_sierra_added_cost-token_for_blake branch from 154b923 to 7955d84 Compare January 26, 2026 12:23
@orizi orizi enabled auto-merge January 26, 2026 13:32
Copy link
Collaborator Author

@orizi orizi left a comment

Choose a reason for hiding this comment

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

@orizi reviewed 2 files and all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @liorgold2).

@orizi orizi added this pull request to the merge queue Jan 27, 2026
Merged via the queue into main with commit b71fdd8 Jan 27, 2026
55 checks passed
@orizi orizi deleted the orizi/01-20-feature_sierra_added_cost-token_for_blake branch January 27, 2026 14:36
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