Conversation
palinatolmach
approved these changes
Jul 3, 2025
Co-authored-by: Palina <polina.tolmach@gmail.com>
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 of changes:
Ctxfloorfunction to calculate floor price for transactions#finalizeTxto take an additional parameter for floor gas costmaxIntto use the higher of the standard calculation or the floor price#tokensInCalldatato count zero and non-zero bytesfinalizeTxReasoning:
There are four cells used for gas computation
<gas>: gas available for current message<callGas>: gas explicitly allocated for a particular call or sub-call in the EVM.<gasLimit>: the gas limit of the block<gasUsed>: tracks the gas consumed up to the current point.<txGasLimit>: maximum amount of gas allowed to be executed by the transaction.#loadTxstarts a transaction, it takes thegasLimitvalue of the transaction and subtracts the21000 + (STANDARD_TOKEN_COST * tokens_in_calldata) + isContractCreation * (32000 + INITCODE_WORD_COST * words(calldata)). The result is then stored in the<gas>cell.#deductGaswill subtract from<gas>the cost of executing each opcode.#finalizeTx(false)rules, the refund mechanism is executed, and then the block gas used cell is incremented byGLIMIT - GAVAIL, which accounts for both the initial gas subtracted inloadTx, execution costs, and any refunds available.To apply the new formula
The gasUsed value is updated with the maximum value between
GLIMIT-GAVAILand21000 +TOTAL_COST_FLOOR_PER_TOKEN * tokens_in_calldata.