Skip to content

fix(codegen): fix legacy ICE when calling getchainparameter#123

Merged
CodeNinjaEvan merged 2 commits into
tronprotocol:release_0.8.28from
yanghang8612:fix/tron-getchainparameter-ice
Jun 25, 2026
Merged

fix(codegen): fix legacy ICE when calling getchainparameter#123
CodeNinjaEvan merged 2 commits into
tronprotocol:release_0.8.28from
yanghang8612:fix/tron-getchainparameter-ice

Conversation

@yanghang8612

Copy link
Copy Markdown

Summary

Calling the TRON getchainparameter builtin aborts the compiler with an internal error on the (default) legacy pipeline.

The bug

GetChainParameter is a bare-call precompile-read, so in appendExternalFunctionCall its encodeInPlace flag starts out true, but it was missing from the list that forces encodeInPlace = false. Its argument is encoded padded, and CompilerUtils::encodeToMemory rejects the in-place + padded combination with a hard assert. As a result, any contract that calls getchainparameter crashes the compiler on the legacy pipeline:

contract C {
    function f() public view returns (uint) {
        return getchainparameter(0);
    }
}
$ solc --bin C.sol
Internal compiler error:
.../libsolidity/codegen/CompilerUtils.cpp(449): ... encodeToMemory(...)
std::exception::what: Non-padded and in-place encoding can only be combined.

via-IR is unaffected (it uses the unified tuple encoder), so this only bites the default pipeline.

The fix

Add GetChainParameter to the encodeInPlace = false list in appendExternalFunctionCall, 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

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.
@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 12:54
@CodeNinjaEvan CodeNinjaEvan merged commit b0f332e into tronprotocol:release_0.8.28 Jun 25, 2026
1 check 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