fix(executor): account for tip when computing max L2 gas limit#3346
Open
AvivYossef-starkware wants to merge 1 commit intoequilibriumco:mainfrom
Open
fix(executor): account for tip when computing max L2 gas limit#3346AvivYossef-starkware wants to merge 1 commit intoequilibriumco:mainfrom
AvivYossef-starkware wants to merge 1 commit intoequilibriumco:mainfrom
Conversation
The max L2 gas amount covered by balance was computed by dividing the remaining balance by `max_price_per_unit`. However, the blockifier's `max_possible_fee` multiplies by `(max_price_per_unit + tip)`. When the tip is non-zero, this mismatch causes the inflated L2 gas bound to exceed the account balance, rejecting transactions that succeed on-chain. Fix: divide by `(max_price_per_unit + tip)` to match the blockifier's fee calculation. Observed on mainnet block 8821583 (tx index 1) where tip=1001 caused the balance check to fail by ~128 trillion FRI.
Contributor
|
just a general question, maybe you'll know, why is the tip accounted per gas unit? From the docs I can see it is correct, but |
zvolin
approved these changes
Apr 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Account for the tip when computing the maximum L2 gas amount covered by the account balance during fee estimation.
Problem:
get_max_l2_gas_amount_covered_by_balancedivides remaining balance byl2_gas.max_price_per_unitto compute the max affordable L2 gas. However, the blockifier'smax_possible_fee(used inverify_can_pay_committed_bounds) computesmax_amount * (max_price + tip). When tip > 0, the inflated L2 gas bound exceeds the account balance, causingstarknet_simulateTransactionsto reject transactions that succeeded on-chain.Fix: Divide by
(max_price_per_unit + tip)to match the blockifier's fee calculation.Impact: Observed on mainnet block 8821583 (tx index 1, tip=1001). The old formula computed
max_l2_gas = 128,174,880,959. The blockifier then checked128,174,880,959 * (60,200,000,000 + 1001) = 7.716T > balance of 7.716T— failing by ~128 trillion FRI due to the unaccounted tip. The fix computesmax_l2_gas = 128,174,878,828which passes the balance check.Note: Juno has the same bug in
calculate_max_l2_gas_covered(vm/rust/src/entrypoint/execute/process/binary_search_execution.rs:201).CHANGELOG.md