Skip to content

blockifier: bump execute_max_sierra_gas 1.1B -> 1.11B (SNIP-40)#14176

Merged
matanl-starkware merged 2 commits into
mainfrom
matanl/snip40-max-execute-gas
May 25, 2026
Merged

blockifier: bump execute_max_sierra_gas 1.1B -> 1.11B (SNIP-40)#14176
matanl-starkware merged 2 commits into
mainfrom
matanl/snip40-max-execute-gas

Conversation

@matanl-starkware
Copy link
Copy Markdown
Collaborator

Per SNIP-40 "More Frequent Blocks", raise EXECUTE_MAX_SIERRA_GAS from
1,100,000,000 to 1,110,000,000 L2 gas. This 0.9% headroom is intended to keep
storage-heavy transactions under the per-tx limit after the StorageRead/Write
gas-cost bump in the next PR.

Note: this PR touches constants.cairo but leaves program_hash.json and
allowed_virtual_os_program_hashes unchanged. The OS program hash needs to be
regenerated by recompiling the Cairo OS after both cairo-touching SNIP-40 PRs
land (this one + the StorageRead/Write change on top).

Spec: https://community.starknet.io/t/snip-40-more-frequent-blocks/116203

Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com

@reviewable-StarkWare
Copy link
Copy Markdown

This change is Reviewable

@cursor
Copy link
Copy Markdown

cursor Bot commented May 24, 2026

PR Summary

High Risk
Changes consensus-critical OS gas limits, syscall pricing, and program hashes; misaligned rollout would reject txs or break proving until nodes upgrade together.

Overview
Implements SNIP-40 gas and OS updates for Starknet 0.14.3: per-transaction execute headroom and higher storage syscall charging, with matching gateway limits and regenerated program hashes.

Execute L2 gas ceiling rises from 1,100,000,000 to 1,110,000,000 (EXECUTE_MAX_SIERRA_GAS in constants.cairo, execute_max_sierra_gas in blockifier 0.14.3 versioned constants, and gateway max_l2_gas_amount / config schema defaults). Gateway stateless validation stays aligned with that cap.

Storage syscall costs increase in the OS (STORAGE_READ_GAS_COST 18070 → 24070, STORAGE_WRITE_GAS_COST 44970 → 59970) and in blockifier OS resource step counts for StorageRead / StorageWrite. Blockifier and central systest expectations (gas consumed, fees, blob fixtures) are updated accordingly.

Client-side proving: allowed_virtual_os_program_hashes entry and program_hash.json (os, virtual_os) reflect the recompiled Cairo OS after these constant changes.

Reviewed by Cursor Bugbot for commit 7a27a2c. Bugbot is set up for automated code reviews on this repo. Configure here.

Comment thread crates/blockifier/resources/blockifier_versioned_constants_0_14_3.json Outdated
Copy link
Copy Markdown
Collaborator

@dorimedini-starkware dorimedini-starkware left a comment

Choose a reason for hiding this comment

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

@dorimedini-starkware reviewed 4 files and all commit messages, and made 1 comment.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on matanl-starkware).

Comment thread crates/blockifier/resources/blockifier_versioned_constants_0_14_3.json Outdated
@matanl-starkware matanl-starkware force-pushed the matanl/snip40-gas-target branch from 1994eb6 to 9b035e1 Compare May 25, 2026 08:00
@matanl-starkware matanl-starkware force-pushed the matanl/snip40-max-execute-gas branch from 32ca6eb to 974e149 Compare May 25, 2026 08:00
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 974e149. Configure here.

Comment thread crates/apollo_starknet_os_program/src/program_hash.json Outdated
Comment thread crates/apollo_deployments/resources/app_configs/gateway_config.json
Copy link
Copy Markdown
Collaborator

@dorimedini-starkware dorimedini-starkware left a comment

Choose a reason for hiding this comment

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

@dorimedini-starkware reviewed 4 files and all commit messages, made 1 comment, and resolved 1 discussion.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on matanl-starkware).

Comment thread crates/apollo_starknet_os_program/src/program_hash.json Outdated
@matanl-starkware matanl-starkware changed the base branch from matanl/snip40-gas-target to graphite-base/14176 May 25, 2026 11:31
@matanl-starkware matanl-starkware force-pushed the matanl/snip40-max-execute-gas branch from 974e149 to 4393e3e Compare May 25, 2026 11:31
@matanl-starkware matanl-starkware changed the base branch from graphite-base/14176 to main May 25, 2026 11:31
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 25, 2026

Copy link
Copy Markdown
Collaborator

@dorimedini-starkware dorimedini-starkware left a comment

Choose a reason for hiding this comment

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

@dorimedini-starkware reviewed 15 files and all commit messages, made 1 comment, and resolved 1 discussion.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on matanl-starkware).


crates/blockifier/src/execution/deprecated_syscalls/deprecated_syscalls_test.rs line 358 at r4 (raw file):

        resources: (&get_const_syscall_resources(DeprecatedSyscallSelector::CallContract)
            + &ExecutionResources {
                n_steps: 920,

another +210 step addition, i.e. one read and one write, please use formula

Code quote:

n_steps: 920,

@matanl-starkware matanl-starkware force-pushed the matanl/snip40-max-execute-gas branch from eb6b738 to 6056a1b Compare May 25, 2026 12:57
@matanl-starkware
Copy link
Copy Markdown
Collaborator Author

@dorimedini-starkware addressed your latest comment on deprecated_syscalls_test.rs:358 — force-pushed the fix. The outer call_contract resources now use the same derivation pattern as the other two sites:

n_steps: 81
    + get_const_syscall_resources(SyscallSelector::StorageRead).n_steps
    + get_const_syscall_resources(SyscallSelector::StorageWrite).n_steps,

Verifies on both sides of SNIP-40: pre-cost-bump 81 + 180 + 449 = 710, post-cost-bump 81 + 240 + 599 = 920 ✓. Tests pass locally.

@matanl-starkware matanl-starkware force-pushed the matanl/snip40-max-execute-gas branch from 6056a1b to ea30372 Compare May 25, 2026 13:01
Copy link
Copy Markdown
Collaborator Author

@matanl-starkware matanl-starkware left a comment

Choose a reason for hiding this comment

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

@matanl-starkware made 1 comment.
Reviewable status: 4 of 18 files reviewed, 1 unresolved discussion (waiting on dorimedini-starkware).


crates/blockifier/src/execution/deprecated_syscalls/deprecated_syscalls_test.rs line 358 at r4 (raw file):

Previously, dorimedini-starkware wrote…

another +210 step addition, i.e. one read and one write, please use formula

Done.

Copy link
Copy Markdown
Collaborator

@dorimedini-starkware dorimedini-starkware left a comment

Choose a reason for hiding this comment

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

@dorimedini-starkware reviewed 14 files and all commit messages, and resolved 1 discussion.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on matanl-starkware).

matanl-starkware and others added 2 commits May 25, 2026 16:39
Per SNIP-40 "More Frequent Blocks", raise EXECUTE_MAX_SIERRA_GAS from
1,100,000,000 to 1,110,000,000 L2 gas. This 0.9% headroom is intended to keep
storage-heavy transactions under the per-tx limit after the StorageRead/Write
gas-cost bump in the next PR.

Note: this PR touches constants.cairo but leaves program_hash.json and
allowed_virtual_os_program_hashes unchanged. The OS program hash needs to be
regenerated by recompiling the Cairo OS after both cairo-touching SNIP-40 PRs
land (this one + the StorageRead/Write change on top).

Spec: https://community.starknet.io/t/snip-40-more-frequent-blocks/116203

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Per SNIP-40 "More Frequent Blocks":
  StorageRead:  18,070 -> 24,070 L2 gas  (n_steps 180 -> 240)
  StorageWrite: 44,970 -> 59,970 L2 gas  (n_steps 449 -> 599)

The +33% bump offsets the cost reduction from fewer per-cell accesses per
block at the new 1.5s block time, keeping per-block proving cost roughly
flat.

JSON drives constants.cairo via test_os_constants regeneration:
  STORAGE_READ_GAS_COST  18070 -> 24070
  STORAGE_WRITE_GAS_COST 44970 -> 59970

program_hash.json regenerated via UPDATE_EXPECT=1 cargo test
test_program_hashes (covers cairo deltas from this PR + the previous
EXECUTE_MAX_SIERRA_GAS bump in the stack).

Test fixtures updated:
- expect! blocks via UPDATE_EXPECT=1 (call_contract, deploy, library_call,
  meta_tx, storage_read_write, transactions_test - declare/deploy/invoke/l1).
- Hardcoded n_steps in deprecated_syscalls_test: 671 -> 881 (inner: +60r
  +150w), 710 -> 920 (outer with descendant deltas).
- transactions_test::test_invoke_tx Cairo1 expected gas: 330470 -> 414470
  (4 reads + 4 writes * delta = +84000).
- execution_flavors_test transfer scenario step budget: +6104 -> +6944
  (matches SNIP-37's +4332 -> +6104 pattern for 4r+4w deltas).

Not changed: allowed_virtual_os_program_hashes still holds the two
pre-SNIP-40 entries. Updating this list is a separate policy decision
(authoritative virtual_os hash from the proof team) and is not strictly
required for the gas-cost change to function.

Spec: https://community.starknet.io/t/snip-40-more-frequent-blocks/116203

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@matanl-starkware matanl-starkware force-pushed the matanl/snip40-max-execute-gas branch from ea30372 to 7a27a2c Compare May 25, 2026 13:40
Copy link
Copy Markdown
Collaborator Author

@matanl-starkware matanl-starkware left a comment

Choose a reason for hiding this comment

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

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

@matanl-starkware matanl-starkware added this pull request to the merge queue May 25, 2026
Merged via the queue into main with commit 9688eae May 25, 2026
44 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators May 27, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants