fix(vm): account for tip when computing max L2 gas limit#3562
Open
AvivYossef-starkware wants to merge 1 commit intoNethermindEth:mainfrom
Open
fix(vm): account for tip when computing max L2 gas limit#3562AvivYossef-starkware wants to merge 1 commit intoNethermindEth:mainfrom
AvivYossef-starkware wants to merge 1 commit intoNethermindEth: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, tip=1001).
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3562 +/- ##
==========================================
- Coverage 75.70% 70.78% -4.93%
==========================================
Files 389 396 +7
Lines 35512 36853 +1341
==========================================
- Hits 26885 26086 -799
- Misses 6753 8943 +2190
+ Partials 1874 1824 -50 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Summary
Account for the tip when computing the maximum L2 gas amount covered by the account balance in
calculate_max_l2_gas_covered.Problem: The remaining balance is divided by
l2_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_per_unit + 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) > balance— failing by ~128 trillion FRI. The fix computes a slightly lowermax_l2_gasthat passes the balance check.Note: Same bug exists in Pathfinder (fix submitted at equilibriumco/pathfinder#3346).