New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shift in AST IDs affects inlining and expression splitting decisions in Yul Optimizer, causing bytecode differences #14829
Comments
Thanks for the report! Unfortunately I can confirm that this is still reproducible on 0.8.24 and indeed looks like a difference in the bytecode coming from the optimizer. Including It only happens with the IR differences
Repro on the CLIHere's my CLI repro. For the ease of debugging it skips some options that are not relevant and also uses the same input files in both cases, just changing the command. json_file="input1.json"
for source_unit_name in $(jq --raw-output '.sources | keys[]' "$json_file"); do
mkdir -p ./"$(dirname "$source_unit_name")"
jq --raw-output '.sources["'"$source_unit_name"'"].content' "$json_file" > ./"$source_unit_name"
done
jq '.settings' "$json_file" --indent 4 function solc-universal-router {
solc \
--via-ir \
--optimize \
--no-cbor-metadata \
--debug-info none \
"solmate/=lib/solmate/" \
"permit2/=lib/permit2/" \
"forge-std/=lib/forge-std/src/" \
"@openzeppelin/=node_modules/@openzeppelin/" \
"@uniswap/=node_modules/@uniswap/" \
"ds-test/=lib/forge-std/lib/ds-test/src/" \
"$@"
}
function solc-universal-router-bin {
solc-universal-router --bin "$@" |
grep '======= contracts/UniversalRouter.sol:UniversalRouter =======' --after-context=2
}
diff --color --unified --report-identical-files \
<(solc-universal-router-bin contracts/UniversalRouter.sol contracts/DummyContract.sol | fold --width 100) \
<(solc-universal-router-bin contracts/UniversalRouter.sol | fold --width 100)
diff --color --unified --report-identical-files \
<(solc-universal-router --ir-optimized contracts/UniversalRouter.sol contracts/DummyContract.sol) \
<(solc-universal-router --ir-optimized contracts/UniversalRouter.sol) |
Description
This is probably related to #14494, I am using solc 0.8.23 and still encounter the issue
Steps to Reproduce
Here are two standard JSON input files:
input1.json
input2.json
The only difference between those is a small source file:
We are interested in the
UniversalRouter
bytecode. It was obtained by using the following command:Resulted bytecodes:
bytecode1.txt
bytecode2.txt
Bytecodes are expected to be equal, however they have a pretty big diff:
The text was updated successfully, but these errors were encountered: