Optimized code takes 10 times MORE than unoptimized code
- Dominant language
- C++
- Stars
- 25.7k
- Forks
- 6.2k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 21
Description
## Description
While testing the code for https://github.com/lacchain/sol-falcon-verify/tree/main
I tried to enable optimization, but instead of normal 5M gas for "verify", enabling optimization turned into 40M gas
The source code uses solidity 0.7, and it is hard to convert it to 0.8, since it mixes uint and int types.
It could be that this bug is already resolved in latest solidity, but I have no way to test
In order to test for gas, I added the following modifier, and applied it to the `verify()` function:
```solidity
import 'hardhat/console.sol';
...
modifier dumpGas {
uint preGas = gasleft();
_;
console.log("== Gas used: %d", preGas - gasleft());
}
```
-->
Contributor guide
Research direction
Reproduce the gas comparison using the linked sol-falcon-verify project, Solidity 0.7, the verify() function, and the supplied dumpGas modifier with optimization enabled and disabled. Compare the result against the latest Solidity compiler to determine whether the discrepancy remains; done means isolating a reproducible optimizer issue or confirming it is version-specific.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, solidity
- Domain
- blockchain, compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100