The Language Server provides gas consumption analysis for assembly functions.
Gas consumption information is displayed in two ways:
- In the documentation when hovering over a function
- As inline hint after the opening bracket of the function body
The accuracy of gas calculations depends on the function complexity:
- Simple functions: Calculations are quite accurate
- Complex functions (with branches and loops): Calculations are approximate
The Language Server uses the following rules to estimate gas consumption:
- Take the branch with the highest gas consumption
- This provides a "worst-case scenario" estimation
- Applies to
while
,until
, andrepeat
statements - Gas consumption is calculated as:
loop_body_gas * coefficient
- Default coefficient is 5
- You can adjust this in VS Code settings:
- Open Settings
- Search for "Tact: Editor › Gas Calculation"
- Modify "Loop Gas Coefficient"
- Instructions without known gas costs are counted as zero gas
- This might lead to underestimation in some cases
- Use these calculations as guidelines rather than exact values
If you don't need gas calculations, you can disable them:
- Open VS Code Settings
- Search for "Tact: Editor › Gas Hints"
- Disable the relevant options:
- "Show Gas Consumption": For asm functions
- "Show Asm Instruction Gas": For individual instructions
- "Show Continuation Gas": For continuation blocks