eth-brownie / brownie

A Python-based development and testing framework for smart contracts targeting the Ethereum Virtual Machine.

Home Page:https://eth-brownie.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Verification does not work in case of dependency from 2 same-name files

vsmelov opened this issue · comments

Environment information

  • brownie Version: 1.19.3
  • ganache-cli Version: Ganache CLI v6.12.2 (ganache-core: 2.13.2)
  • solc Version: 0.8.6
  • Python Version: 3.9.7
  • OS: macos m1

How to reproduce

git clone git@github.com:vsmelov/brownie_fail_verification.git
cd brownie_fail_verification
virtualenv venv -p python3.9
. venv/bin/activate
pip install -r requirements.txt
brownie compile
export BRAVE_MAIN_PASS='xxx'
brownie run scripts/deploy_and_verify_ok.py --network polygon-main
brownie run scripts/deploy_and_verify_fail.py --network polygon-main

What was wrong?

Contract verification with dependency on the file that imports the file with the same name does not work.

e.g.

https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.3.3/contracts/interfaces/IERC165.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../utils/introspection/IERC165.sol";
  • what command you ran

brownie run scripts/deploy_and_verify_fail.py --network polygon-main

  • full output of the error you received
brownie run scripts/deploy_and_verify_fail.py --network polygon-main

#Running 'scripts/deploy_and_verify_fail.py::main'...
#Transaction sent: 0xd3cbb5004acd636cb14738034f091afd98d74d1b7e4f2d8ae1e954b3d9a9beb2
#  Gas price: 114.379120423 gwei   Gas limit: 108170   Nonce: 141
#  VerificationFail.constructor confirmed   Block: 40759442   Gas used: 98337 (90.91%)
#  VerificationFail deployed at: 0x1AF0b97581d883B9260182d00f8619e5B3a4f7d4
#
#Verification submitted successfully. Waiting for result...
#Verification complete. Result: Fail - Unable to verify

How can it be fixed?

If you go into function publish_source and check what is inside

    contract_info = self.get_verification_info()

you will see IERC165 from contracts/interfaces/IERC165.sol which refers to itself from "../utils/introspection/IERC165.sol"

First, I'm sure brownie should give a warning in case if file with some filename imports the same filename from inside. I spent 2 days trying to realize what is going on!

I see a way how to fix it:

  • automatically attach uniq prefix to every same-name files like "utils_introspection_IERC165.sol" and "interfaces_IERC165.sol"

Take a look on this verified smart on etherscan - https://etherscan.io/address/0x7358182024c9f1B2e6b0153e60bf6156B7eF4906#code

it has both contracts IERC165.sol
Screenshot 2023-03-26 at 00 39 09