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

Possible regresssion when fetching contract #963

Closed poolpitako closed 3 years ago

poolpitako commented 3 years ago

Environment information

What was wrong?

Running emp = Contract("0xEAA081a9fad4607CdF046fEA7D4BF3DfEf533282") in the console fails with:

  File "<console>", line 1, in <module>
  File "eth_brownie-1.13.1-py3.8.egg/brownie/network/contract.py", line 923, in __init__
    contract = self.from_explorer(address, owner=owner, silent=True)
  File "eth_brownie-1.13.1-py3.8.egg/brownie/network/contract.py", line 1177, in from_explorer
    build_json = compiler.generate_build_json(input_json, output_json)
  File "eth_brownie-1.13.1-py3.8.egg/brownie/project/compiler/__init__.py", line 313, in generate_build_json
    build_json[contract_alias] = solidity._get_unique_build_json(
  File "eth_brownie-1.13.1-py3.8.egg/brownie/project/compiler/solidity.py", line 260, in _get_unique_build_json
    pc_map, statement_map, branch_map = _generate_coverage_data(
  File "eth_brownie-1.13.1-py3.8.egg/brownie/project/compiler/solidity.py", line 353, in _generate_coverage_data
    pc_list.append({"op": opcodes.popleft(), "pc": pc})
IndexError: pop from an empty deque

Older versions of brownie 1.11.8 get:

>>> emp = Contract.from_explorer("0xEAA081a9fad4607CdF046fEA7D4BF3DfEf533282")
Fetching source of 0xEAA081a9fad4607CdF046fEA7D4BF3DfEf533282 from api.etherscan.io...
  File "<console>", line 1, in <module>
  File "brownie/network/contract.py", line 770, in from_explorer
    build_json = compiler.generate_build_json(input_json, output_json)
  File "brownie/project/compiler/__init__.py", line 309, in generate_build_json
    build_json[contract_name] = solidity._get_unique_build_json(
  File "brownie/project/compiler/solidity.py", line 246, in _get_unique_build_json
    pc_map, statement_map, branch_map = _generate_coverage_data(
  File "brownie/project/compiler/solidity.py", line 349, in _generate_coverage_data
    pc += int(pc_list[-1]["op"][4:])
ValueError: invalid literal for int() with base 10: 'AK256'
poolpitako commented 3 years ago

A possible change in etherscan?

Another weird issue I was not having before:

Contract("0x7d2768dE32b0b80b7a3454c06BdAc94A69DDc7A9")
  File "<console>", line 1, in <module>
  File "eth_brownie-1.13.1-py3.8.egg/brownie/network/contract.py", line 923, in __init__
    contract = self.from_explorer(address, owner=owner, silent=True)
  File "eth_brownie-1.13.1-py3.8.egg/brownie/network/contract.py", line 1103, in from_explorer
    as_proxy_for = _resolve_address(implementation_eip1967[12:])
  File "eth_brownie-1.13.1-py3.8.egg/brownie/network/web3.py", line 192, in _resolve_address
    return to_address(domain)
  File "eth_brownie-1.13.1-py3.8.egg/brownie/convert/main.py", line 43, in to_address
    return str(EthAddress(value))
  File "eth_brownie-1.13.1-py3.8.egg/brownie/convert/datatypes.py", line 204, in __new__
    raise ValueError(f"'{value}' is not a valid ETH address") from None
ValueError: 'b'\x92xw\xef\xdaB[\xaf'' is not a valid ETH address
poolpitako commented 3 years ago

More info:

Contract.from_explorer("0x0b8f12b1788BFdE65Aa1ca52E3e9F3Ba401be16D")

works in v1.11.8 but fails in master.

poolpitako commented 3 years ago

I just bisect the versions. Last working version: 1.12.1, on 1.12.2 Contract.from_explorer("0x0b8f12b1788BFdE65Aa1ca52E3e9F3Ba401be16D") starts failing.

poolpitako commented 3 years ago

So based on the changes in 1.12.2 (https://github.com/eth-brownie/brownie/releases/tag/v1.12.2) Possible culprits:

iamdefinitelyahuman commented 3 years ago

https://github.com/eth-brownie/brownie/compare/v1.12.1...v1.12.2