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.65k stars 553 forks source link

Infinite loop fetching source from etherscan #669

Closed BlinkyStitt closed 4 years ago

BlinkyStitt commented 4 years ago

Environment information

What was wrong?

$ brownie console --network mainnet 
Brownie v1.9.7 - Python development framework for Ethereum

AppProject is the active project.
Brownie environment is ready.
>>> Contract.from_explorer("0x080bf510FCbF18b91105470639e9561022937712")                                                                                         
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
Fetching source of 0x080bf510FCbF18b91105470639e9561022937712 from api.etherscan.io...
^C  File "<console>", line 1, in <module>
  File "brownie/network/contract.py", line 650, in from_explorer
    implementation_contract = Contract.from_explorer(as_proxy_for)
  File "brownie/network/contract.py", line 650, in from_explorer
    implementation_contract = Contract.from_explorer(as_proxy_for)
  File "brownie/network/contract.py", line 650, in from_explorer
    implementation_contract = Contract.from_explorer(as_proxy_for)
  File line, line 31, in times]
  File "brownie/network/contract.py", line 624, in from_explorer
    data = _fetch_from_explorer(address, "getsourcecode", silent)
  File "brownie/network/contract.py", line 1242, in _fetch_from_explorer
    response = requests.get(url, params=params, headers=REQUEST_HEADERS)
  File "requests/api.py", line 76, in get
    return request('get', url, params=params, **kwargs)
  File "requests/api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "requests/sessions.py", line 530, in request
    resp = self.send(prep, **send_kwargs)
  File "requests/sessions.py", line 685, in send
    r.content
  File "requests/models.py", line 829, in content
    self._content = b''.join(self.iter_content(CONTENT_CHUNK_SIZE)) or b''
  File "requests/models.py", line 751, in generate
    for chunk in self.raw.stream(chunk_size, decode_content=True):
  File "urllib3/response.py", line 576, in stream
    data = self.read(amt=amt, decode_content=decode_content)
  File "urllib3/response.py", line 519, in read
    data = self._fp.read(amt) if not fp_closed else b""
  File "/usr/lib/python3.8/http/client.py", line 454, in read
    n = self.readinto(b)
  File "/usr/lib/python3.8/http/client.py", line 498, in readinto
    n = self.fp.readinto(b)
  File "/usr/lib/python3.8/socket.py", line 669, in readinto
    return self._sock.recv_into(b)
  File "/usr/lib/python3.8/ssl.py", line 1241, in recv_into
    return self.read(nbytes, buffer)
  File "/usr/lib/python3.8/ssl.py", line 1099, in read
    return self._sslobj.read(len, buffer)
KeyboardInterrupt: 
>>>          

This is one of 0x's contracts: https://etherscan.io/address/0x080bf510FCbF18b91105470639e9561022937712#code

iamdefinitelyahuman commented 4 years ago

Oh interesting... in the API, 0x080bf510fcbf18b91105470639e9561022937712 is listed as the implementation contract for 0x080bf510fcbf18b91105470639e9561022937712. Must be a bug in etherscan's automatic proxy verification. I hadn't considered that possibility.

Easy fix at least :)