fix(gasmeter): account for new-account and memory gas in TRON instructions#120
Merged
CodeNinjaEvan merged 1 commit intoJun 25, 2026
Conversation
NATIVEDELEGATERESOURCE/NATIVEUNDELEGATERESOURCE may create a new account (add callNewAccountGas like NATIVEFREEZE); NATIVEVOTE reads memory but did not charge memory-expansion gas.
|
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. |
CodeNinjaEvan
approved these changes
Jun 25, 2026
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
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/NATIVEUNDELEGATERESOURCEdid not addcallNewAccountGas. Delegating resources to a non-existent address may create a new account, exactly likeNATIVEFREEZE(which already adds it). The two delegation opcodes are split out of the shared Stake-2.0 group and now addcallNewAccountGas; the other four V2 opcodes have no address operand and stay unchanged.NATIVEVOTEdid not charge memory-expansion gas. It reads two memory ranges (perSemanticInformation::readWriteOperations), but unlikeKECCAK256/LOG*/CALL*/CREATE*/RETURNit did not addmemoryGas(...). The two memory-expansion charges for its argument ranges are now included.Verification
solcbuilds cleanly;voteand delegate contracts still compile on both the legacy and via-IR pipelines.Targets
release_0.8.28.🤖 Generated with Claude Code