Skip to content

fix(evmasm): align gas estimates with TVM pricing - #145

Merged
CodeNinjaEvan merged 3 commits into
tronprotocol:release_0.8.30from
yanghang8612:fix/release-0.8.30-gasmeter-tvm-pricing
Jul 28, 2026
Merged

fix(evmasm): align gas estimates with TVM pricing#145
CodeNinjaEvan merged 3 commits into
tronprotocol:release_0.8.30from
yanghang8612:fix/release-0.8.30-gasmeter-tvm-pricing

Conversation

@yanghang8612

@yanghang8612 yanghang8612 commented Jul 28, 2026

Copy link
Copy Markdown

Summary

  • align GasMeter pricing with java-tron/TVM Energy costs instead of inheriting Ethereum fork pricing
  • cover SLOAD, SSTORE, BALANCE, EXTCODE*, CALL*, SELFDESTRUCT, TOKENBALANCE, ISCONTRACT, and CALLTOKEN
  • charge value transfer and new-account costs conditionally
  • use the fixed TVM call price in pre-Tangerine gasNeededByCaller fallback paths
  • name TVM-specific constants consistently as operationGasInTVM
  • add focused unit coverage for the TVM cost table and conditional call costs

Root cause

GasMeter reused Ethereum EVM-version-dependent costs such as EIP-1884, EIP-2200, and EIP-2929. TVM uses its own fixed Energy schedule for these opcodes, so compiler gas annotations and optimizer cost heuristics diverged substantially from java-tron execution costs. The pre-Tangerine call fallback paths also derived retained gas from the Ethereum-version-dependent call price.

This change affects compiler-side estimates and optimizer heuristics only. It does not change the Energy charged by java-tron at runtime.

Validation

  • cmake --build build -j4 --target soltest
  • build/test/soltest --run_test=EvmasmGasMeter -- --no-semantic-tests — 8 test cases passed
  • git diff --check release_0.8.30...HEAD

@github-actions

Copy link
Copy Markdown

Thank you for your contribution to the Solidity compiler! A team member will follow up shortly.

If you haven't read our contributing guidelines and our review checklist before, please do it now, this makes the reviewing process and accepting your contribution smoother.

If you have any questions or need our help, feel free to post them in the PR or talk to us directly on the #solidity-dev channel on Matrix.

The pre-tangerine-whistle fallback paths in both code generators still
derived the retained-gas amount from Ethereum fork-dependent
GasCosts::callGas(). Switch them to the fixed TVM price for consistency
with the GasMeter alignment.

Also add GasMeter unit coverage for the SELFDESTRUCT estimate
(tvmSelfdestructGas + callNewAccountGas).
@yanghang8612
yanghang8612 marked this pull request as ready for review July 28, 2026 05:51
@CodeNinjaEvan
CodeNinjaEvan merged commit f024f31 into tronprotocol:release_0.8.30 Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants