From c72f5bb4a0985ada4e12e0194b5bfd90e10f2756 Mon Sep 17 00:00:00 2001 From: Asuka Date: Thu, 25 Jun 2026 19:23:37 +0800 Subject: [PATCH 1/2] fix(codegen): fix legacy ICE when calling getchainparameter 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. --- libsolidity/codegen/ExpressionCompiler.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp index 5d52feefa860..735a994a830f 100644 --- a/libsolidity/codegen/ExpressionCompiler.cpp +++ b/libsolidity/codegen/ExpressionCompiler.cpp @@ -3161,6 +3161,7 @@ void ExpressionCompiler::appendExternalFunctionCall( || _functionType.kind() == FunctionType::Kind::TotalVoteCount || _functionType.kind() == FunctionType::Kind::ReceivedVoteCount || _functionType.kind() == FunctionType::Kind::UsedVoteCount + || _functionType.kind() == FunctionType::Kind::GetChainParameter || _functionType.kind() == FunctionType::Kind::AvailableUnfreezeV2Size || _functionType.kind() == FunctionType::Kind::UnfreezableBalanceV2 || _functionType.kind() == FunctionType::Kind::ExpireUnfreezeBalanceV2 From 5406c3f4fa8aae5b40bde590139a0041430d5233 Mon Sep 17 00:00:00 2001 From: Asuka Date: Thu, 25 Jun 2026 19:31:10 +0800 Subject: [PATCH 2/2] test: cmdlineTest for getchainparameter 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. --- test/cmdlineTests/getchainparameter_legacy/args | 1 + test/cmdlineTests/getchainparameter_legacy/input.sol | 12 ++++++++++++ test/cmdlineTests/getchainparameter_legacy/output | 4 ++++ 3 files changed, 17 insertions(+) create mode 100644 test/cmdlineTests/getchainparameter_legacy/args create mode 100644 test/cmdlineTests/getchainparameter_legacy/input.sol create mode 100644 test/cmdlineTests/getchainparameter_legacy/output diff --git a/test/cmdlineTests/getchainparameter_legacy/args b/test/cmdlineTests/getchainparameter_legacy/args new file mode 100644 index 000000000000..7940c577e4ee --- /dev/null +++ b/test/cmdlineTests/getchainparameter_legacy/args @@ -0,0 +1 @@ +--no-cbor-metadata --bin diff --git a/test/cmdlineTests/getchainparameter_legacy/input.sol b/test/cmdlineTests/getchainparameter_legacy/input.sol new file mode 100644 index 000000000000..0f00472e8270 --- /dev/null +++ b/test/cmdlineTests/getchainparameter_legacy/input.sol @@ -0,0 +1,12 @@ +// SPDX-License-Identifier: GPL-3.0 +pragma solidity >= 0.0.0; + +// Regression test: calling getchainparameter used to abort the legacy pipeline +// with an ICE ("Non-padded and in-place encoding can only be combined."). +// Producing bytecode here (no metadata) means it compiled successfully. + +contract C { + function f() public view returns (uint) { + return getchainparameter(0); + } +} diff --git a/test/cmdlineTests/getchainparameter_legacy/output b/test/cmdlineTests/getchainparameter_legacy/output new file mode 100644 index 000000000000..e2be82583e9c --- /dev/null +++ b/test/cmdlineTests/getchainparameter_legacy/output @@ -0,0 +1,4 @@ + +======= getchainparameter_legacy/input.sol:C ======= +Binary: +6080604052348015600e575f5ffd5b50d380156019575f5ffd5b50d280156024575f5ffd5b5061019f806100325f395ff3fe608060405234801561000f575f5ffd5b50d3801561001b575f5ffd5b50d28015610027575f5ffd5b5060043610610041575f3560e01c806326121ff014610045575b5f5ffd5b61004d610063565b60405161005a91906100d2565b60405180910390f35b5f630100000b5f604051610077919061012d565b602060405180830381855afa158015610092573d5f5f3e3d5ffd5b5050506040513d601f19601f820116820180604052508101906100b59190610174565b905090565b5f819050919050565b6100cc816100ba565b82525050565b5f6020820190506100e55f8301846100c3565b92915050565b5f819050919050565b5f819050919050565b5f61011761011261010d846100eb565b6100f4565b6100ba565b9050919050565b610127816100fd565b82525050565b5f6020820190506101405f83018461011e565b92915050565b5f5ffd5b610153816100ba565b811461015d575f5ffd5b50565b5f8151905061016e8161014a565b92915050565b5f6020828403121561018957610188610146565b5b5f61019684828501610160565b9150509291505056