Skip to content

fix(gasmeter): account for new-account and memory gas in TRON instructions#120

Merged
CodeNinjaEvan merged 1 commit into
tronprotocol:release_0.8.28from
yanghang8612:fix/tron-gas-metering
Jun 25, 2026
Merged

fix(gasmeter): account for new-account and memory gas in TRON instructions#120
CodeNinjaEvan merged 1 commit into
tronprotocol:release_0.8.28from
yanghang8612:fix/tron-gas-metering

Conversation

@yanghang8612

Copy link
Copy Markdown

Summary

Two TRON instructions are under-charged in libevmasm/GasMeter.cpp, so the optimizer's gas estimates are inconsistent with comparable opcodes. This only affects compile-time gas estimation, not runtime correctness.

Fixes

  • NATIVEDELEGATERESOURCE / NATIVEUNDELEGATERESOURCE did not add callNewAccountGas. Delegating resources to a non-existent address may create a new account, exactly like NATIVEFREEZE (which already adds it). The two delegation opcodes are split out of the shared Stake-2.0 group and now add callNewAccountGas; the other four V2 opcodes have no address operand and stay unchanged.
  • NATIVEVOTE did not charge memory-expansion gas. It reads two memory ranges (per SemanticInformation::readWriteOperations), but unlike KECCAK256 / LOG* / CALL* / CREATE* / RETURN it did not add memoryGas(...). The two memory-expansion charges for its argument ranges are now included.

Verification

solc builds cleanly; vote and delegate contracts still compile on both the legacy and via-IR pipelines.

Targets release_0.8.28.

🤖 Generated with Claude Code

NATIVEDELEGATERESOURCE/NATIVEUNDELEGATERESOURCE may create a new account
(add callNewAccountGas like NATIVEFREEZE); NATIVEVOTE reads memory but did
not charge memory-expansion gas.
@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.

@yanghang8612 yanghang8612 marked this pull request as ready for review June 25, 2026 02:45
@CodeNinjaEvan CodeNinjaEvan merged commit c7c7d8a into tronprotocol:release_0.8.28 Jun 25, 2026
2 checks passed
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