fix(codegen): fix legacy ICE when calling getchainparameter#123
Merged
CodeNinjaEvan merged 2 commits intoJun 25, 2026
Merged
Conversation
getchainparameter is a bare-call precompile-read, so its encodeInPlace starts out true, but it was missing from the list that forces encodeInPlace=false. Its argument is encoded padded, and encodeToMemory rejects the in-place + padded combination, so any contract calling getchainparameter raised an InternalCompilerError on the legacy pipeline.
Compiles a contract calling getchainparameter with --no-cbor-metadata --bin; before the fix this aborts with an ICE, after it produces bytecode.
|
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
Calling the TRON
getchainparameterbuiltin aborts the compiler with an internal error on the (default) legacy pipeline.The bug
GetChainParameteris a bare-call precompile-read, so inappendExternalFunctionCallitsencodeInPlaceflag starts outtrue, but it was missing from the list that forcesencodeInPlace = false. Its argument is encoded padded, andCompilerUtils::encodeToMemoryrejects the in-place + padded combination with a hard assert. As a result, any contract that callsgetchainparametercrashes the compiler on the legacy pipeline:via-IR is unaffected (it uses the unified tuple encoder), so this only bites the default pipeline.
The fix
Add
GetChainParameterto theencodeInPlace = falselist inappendExternalFunctionCall, next to the other precompile-reads. Its argument is then encoded padded (as the precompile expects) and the legacy pipeline compiles it correctly.Test
Adds
cmdlineTests/getchainparameter_legacy, which compiles the contract above on the legacy pipeline with--no-cbor-metadata --bin. Before the fix it ICEs (exit 2); after it produces bytecode.Targets
release_0.8.28.🤖 Generated with Claude Code