Skip to content

Conversation

@avivg-starkware
Copy link
Contributor

@avivg-starkware avivg-starkware commented Feb 10, 2026

Note

Medium Risk
Touches core gas accounting used for block capacity checks; while largely a refactor, mistakes could change fee/proving-gas calculations and bouncer behavior.

Overview
Switches proving-gas and VM-resources gas accounting from builtin-only counters to a generalized Cairo primitive counter map (builtins + opcodes), renaming builtins_to_gas to cairo_primitives_to_gas and routing gas-weight lookup through BuiltinGasCosts::get_cairo_primitive_gas_cost.

Updates bouncer gas computations (vm_resources_to_gas, sierra_gas_to_steps_gas, proving-gas calculation) and adjusts tests accordingly; current support for opcodes is limited to blake, with TODOs noting that true opcode counting still needs to be wired into resource tracking.

Written by Cursor Bugbot for commit f0672b5. This will update automatically on new commits. Configure here.

@reviewable-StarkWare
Copy link

This change is Reviewable

Copy link
Contributor Author

avivg-starkware commented Feb 10, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

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

@avivg-starkware avivg-starkware marked this pull request as ready for review February 10, 2026 13:26
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/get_cairo_primitive_cost branch from dfeb234 to 48bc7b3 Compare February 10, 2026 14:00
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/cairo_primitives_to_gas branch from f43a78f to e9e6ef3 Compare February 10, 2026 14:00
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/get_cairo_primitive_cost branch from 48bc7b3 to 8469e09 Compare February 10, 2026 14:05
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/cairo_primitives_to_gas branch 2 times, most recently from 6b6c67b to ddde9e6 Compare February 10, 2026 14:31
@avivg-starkware avivg-starkware changed the base branch from avivg/blockifier/get_cairo_primitive_cost to graphite-base/12462 February 10, 2026 14:34
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/cairo_primitives_to_gas branch from ddde9e6 to 2c59ece Compare February 10, 2026 14:50
@avivg-starkware avivg-starkware changed the base branch from graphite-base/12462 to avivg/blockifier/get_cairo_primitive_cost February 10, 2026 14:50
@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/cairo_primitives_to_gas branch 2 times, most recently from 4a50c7f to 31ccc82 Compare February 10, 2026 14:56
@avivg-starkware avivg-starkware changed the base branch from avivg/blockifier/get_cairo_primitive_cost to graphite-base/12462 February 10, 2026 15:25
Copy link
Contributor Author

@avivg-starkware avivg-starkware left a comment

Choose a reason for hiding this comment

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

@avivg-starkware made 3 comments.
Reviewable status: 0 of 3 files reviewed, 3 unresolved discussions (waiting on @noaov1).


crates/blockifier/src/bouncer.rs line 693 at r2 (raw file):

) -> GasAmount {
    // TODO(AvivG): To support opcodes in the computation, pass cairo_primitive_counter_map to this
    // function

implemented in next PR

Code quote:

    // TODO(AvivG): To support opcodes in the computation, pass cairo_primitive_counter_map to this
    // function

crates/blockifier/src/bouncer.rs line 709 at r2 (raw file):

    versioned_constants: &VersionedConstants,
) -> GasAmount {
    // TODO(AvivG): To support opcodes in the computation, resources should include opcode counters.

Will be implemented as part of converting ExecutionResources to ExtendedExecutionResources

Code quote:

// TODO(AvivG): To support opcodes in the computation, resources should include opcode counters.

crates/blockifier/src/bouncer.rs line 746 at r2 (raw file):

    // NOTE: 'blake' is currently the only supported opcode, by being included in the
    // builtin_gas_costs.
    cairo_primitives_gas_costs: &BuiltinGasCosts,

I don't really like this, however, I'm not sure if it's worth making drastic changes. nothing enforces that all entries in CairoPrimitiveCounterMap exist in BuiltinGasCosts
What do you think about adding a test for that sake?

Code quote:

pub fn cairo_primitives_to_gas(
    cairo_primitives_counters: &CairoPrimitiveCounterMap,
    // NOTE: 'blake' is currently the only supported opcode, by being included in the
    // builtin_gas_costs.
    cairo_primitives_gas_costs: &BuiltinGasCosts,

@avivg-starkware avivg-starkware force-pushed the avivg/blockifier/cairo_primitives_to_gas branch from 31ccc82 to f0672b5 Compare February 10, 2026 15:44
@avivg-starkware avivg-starkware changed the base branch from graphite-base/12462 to avivg/blockifier/get_cairo_primitive_cost February 10, 2026 15:44
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.

2 participants