eth-brownie / brownie

A Python-based development and testing framework for smart contracts targeting the Ethereum Virtual Machine.
https://eth-brownie.readthedocs.io
MIT License
2.64k stars 550 forks source link

Unable publish source code with solidity version >= 0.8.0 #1114

Closed maxsiz closed 3 years ago

maxsiz commented 3 years ago

Environment information

What was wrong?

Every time when I try publish multifile source on Etherscan with sol version more then 0.8.0 error is occur.

Verification complete. Result: Fail - Unable to verify

But when i just change solidity version in pragma - all is ok.

I have check in console First.get_verification_info() - So in case sol >= 0.8.0 function return only
first file in sources.

At the same time, the deployment goes well in both cases.

Example sources are below.

pragma solidity ^0.7.4;

File 1 (First.sol)

// SPDX-License-Identifier: MIT
pragma solidity ^0.7.4;
import "./Second.sol";
contract First is Second {
    function name() public view  returns (address) {
        return address(this);
    } 
    function symbol() public view  returns (string memory) {
        return "SYM";
    }
}

File 2 (Second.sol)

// SPDX-License-Identifier: MIT
pragma solidity ^0.7.4;
contract Second {
    function totalSupply() external view returns (uint256) {
        return 7777777777;
    }
}

First.get_verification_info() output

>>> First.get_verification_info()
{
    'bytecode_len': 770,
    'compiler_version': "0.7.4+commit.3f05b770",
    'contract_name': "First",
    'flattened_source': "// SPDX-License-Identifier: MIT

pragma solidity 0.7.4;

// Part: Second

contract Second {
    function totalSupply() external view returns (uint256) {
        return 7777777777;
    }
}

// File: First.sol

contract First is Second {

    function name() public view  returns (address) {
        return address(this);
    }

    function symbol() public view  returns (string memory) {
        return "SYM";
    }

}
",
    'license_identifier': "MIT",
    'optimizer_enabled': True,
    'optimizer_runs': 200
}

pragma solidity ^0.8.4;

File 1 (First.sol)

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "./Second.sol";
contract First is Second {
    function name() public view  returns (address) {
        return address(this);
    } 
    function symbol() public view  returns (string memory) {
        return "SYM";
    }
}

File 2 (Second.sol)

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
contract Second {
    function totalSupply() external view returns (uint256) {
        return 7777777777;
    }
}

First.get_verification_info() output

Brownie environment is ready.
>>> First.get_verification_info()
{
    'bytecode_len': 602,
    'compiler_version': "0.8.4+commit.c7e474f2",
    'contract_name': "First",
    'flattened_source': "// SPDX-License-Identifier: MIT

pragma solidity 0.8.4;

// File: First.sol

contract First is Second {

    function name() public view  returns (address) {
        return address(this);
    }

    function symbol() public view  returns (string memory) {
        return "SYM";
    }

}
",
    'license_identifier': "MIT",
    'optimizer_enabled': True,
    'optimizer_runs': 200
}
iamdefinitelyahuman commented 3 years ago

I think the issue is present from 0.8.4 onward. Not sure what changed in that version, but something happened that broke everything.

maxsiz commented 3 years ago

There are a lot of changes but code compiling is OK. Only source collecting is broken https://docs.soliditylang.org/en/breaking/080-breaking-changes.html

TechNickAI commented 3 years ago

I was able to use pragma solidity 0.8.3; and get it to work - so it's something with 0.8.4+

PatrickAlphaC commented 3 years ago

It looks like it might have to do with get_verification_info. If I run get_verification_info on any contract with imports from OZ, it bugs out. Seems like it should be pretty straightforward for one of us to fix.

PatrickAlphaC commented 3 years ago

Yeah get_verification_info seems to be ignoring imports

PatrickAlphaC commented 3 years ago

https://github.com/ethereum/solidity/issues/11643

I think this is the problem

maxsiz commented 3 years ago

@iamdefinitelyahuman I have update brownie up to 1.15.1 but still cant verify code sol version >= 0.8.0. Does work in progress? May be you need some help?

iamdefinitelyahuman commented 3 years ago

is this fixed in v1.15.2 ?

maxsiz commented 3 years ago

Thank you! After brownie compile --all seems that output LockerByBlock.get_verification_info() look well. I`ll check soon on etherscan

PatrickAlphaC commented 3 years ago

https://github.com/ethereum/solidity/issues/11643#issuecomment-891887826

Not sure if this conversation was addressed, haven't had a chance to jump into the brownie code yet.