ethereum / solidity

Solidity, the Smart Contract Programming Language
https://soliditylang.org
GNU General Public License v3.0
23.35k stars 5.77k forks source link

solc --gas outputs nothing #15219

Open haoyang9804 opened 4 months ago

haoyang9804 commented 4 months ago

Description

Just as the title mentioned, solc --gas does not output a gas esitimation.

Environment

Steps to Reproduce

pragma solidity ^0.8.0;

contract Test {
    uint[] array;

    function testGasEstimation() public {
        array.push(1);
    }
}

Execute the above example and the output is

Warning: This is a pre-release compiler version, please do not use it in production.

Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: <SPDX-License>" to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information.

No gas estimation found.

mehtavishwa30 commented 4 months ago

Hey @haoyang9804! Thanks for reporting this bug.

As mentioned in https://github.com/ethereum/solidity/issues/13566, solc --gas has not been actively maintained and we plan to remove it in the next breaking version as the estimator isn't heavily used in practice.

As per our knowledge, there are no major tools that depend on it. So we would love to know if you have a specific use-case for it or any other dependency that the team should consider before deprecating it.

haoyang9804 commented 4 months ago

Hey @haoyang9804! Thanks for reporting this bug.

As mentioned in #13566, solc --gas has not been actively maintained and we plan to remove it in the next breaking version as the estimator isn't heavily used in practice.

As per our knowledge, there are no major tools that depend on it. So we would love to know if you have a specific use-case for it or any other dependency that the team should consider before deprecating it.

Thanks for your kind reply. Honestly, I don't have a designated scenario where this flag is necessary. I encountered this error while experimenting with the compiler for smart contract compilation, and I mistakenly regarded it as an error.