ethereum / web3.py

A python interface for interacting with the Ethereum blockchain and ecosystem.
http://web3py.readthedocs.io
MIT License
5k stars 1.7k forks source link

Getting the symbol of 0x9f8F72aA9304c8B593d555F12eF6589cC3A579A2 (MKR) fails #1874

Closed randomshinichi closed 3 years ago

randomshinichi commented 3 years ago
argon2-cffi==20.1.0
asn1crypto==1.4.0
async-generator==1.10
attrdict==2.0.1
attrs==20.3.0
autopep8==1.5.4
backcall==0.2.0
base58==2.1.0
bcrypt==3.2.0
bigquery==0.0.8
bleach==3.2.1
cachetools==4.2.1
cadCAD==0.4.23
certifi==2020.12.5
cffi==1.14.4
chardet==4.0.0
Click==7.0
colorama==0.4.4
cryptography==3.3.1
cycler==0.10.0
cytoolz==0.11.0
dacktool==0.0.7
dataclasses==0.6
dataclasses-json==0.5.2
dbstream==0.0.30
decorator==4.4.2
defusedxml==0.6.0
dill==0.3.3
entrypoints==0.3
eth-abi==1.3.0
eth-account==0.3.0
eth-hash==0.3.1
eth-keyfile==0.5.1
eth-keys==0.2.4
eth-rlp==0.2.1
eth-typing==2.2.2
eth-utils==1.8.4
ethereum-dasm==0.1.4
ethereum-etl==1.6.1
evmdasm==0.1.8
fn==0.4.3
funcy==1.15
google-api-core==1.25.1
google-api-python-client==1.7.11
google-auth==1.24.0
google-auth-httplib2==0.0.3
google-auth-oauthlib==0.4.2
google-cloud-bigquery==2.7.0
google-cloud-bigquery-storage==2.2.1
google-cloud-core==1.5.0
google-crc32c==1.1.2
google-resumable-media==1.2.0
googleapis-common-protos==1.52.0
googleauthentication==0.0.14
grpcio==1.35.0
hexbytes==0.2.1
httplib2==0.18.1
idna==2.10
iniconfig==1.1.1
ipdb==0.13.4
ipykernel==5.4.3
ipython==7.19.0
ipython-genutils==0.2.0
ipywidgets==7.6.3
jedi==0.18.0
jeepney==0.6.0
Jinja2==2.11.2
jsonschema==3.2.0
jupyter==1.0.0
jupyter-client==6.1.11
jupyter-console==6.2.0
jupyter-core==4.7.0
jupyterlab-pygments==0.1.2
jupyterlab-widgets==1.0.0
jupyterthemes==0.20.0
keyring==10.6.0
kiwisolver==1.3.1
lesscpy==0.14.0
libcst==0.3.16
lru-dict==1.1.6
lxml==4.5.2
MarkupSafe==1.1.1
marshmallow==3.10.0
marshmallow-enum==1.5.1
matplotlib==3.3.3
mistune==0.8.4
multiprocess==0.70.11.1
mypy-extensions==0.4.3
nbclient==0.5.1
nbconvert==6.0.7
nbformat==5.1.2
nest-asyncio==1.4.3
notebook==6.2.0
numpy==1.20.0
oauthlib==3.1.0
packaging==20.8
pandas==1.2.1
pandocfilters==1.4.3
paramiko==2.7.2
parsimonious==0.8.1
parso==0.8.1
pathos==0.2.7
pexpect==4.8.0
pickleshare==0.7.5
Pillow==8.1.0
pluggy==0.13.1
ply==3.11
pox==0.2.9
ppft==1.6.6.3
prometheus-client==0.9.0
prompt-toolkit==3.0.10
proto-plus==1.13.0
protobuf==3.14.0
ptyprocess==0.7.0
py==1.9.0
pyarrow==3.0.0
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycodestyle==2.6.0
pycparser==2.20
pycryptodome==3.9.9
Pygments==2.7.4
PyNaCl==1.4.0
pyparsing==2.4.7
pyrsistent==0.17.3
pytest==6.1.2
python-dateutil==2.8.1
pytz==2021.1
PyYAML==5.4.1
pyzmq==21.0.1
qtconsole==5.0.1
QtPy==1.9.0
requests==2.25.1
requests-oauthlib==1.3.0
rlp==2.0.1
rope==0.18.0
rsa==4.7
SecretStorage==3.3.0
Send2Trash==1.5.0
six==1.15.0
sshtunnel==0.1.5
stringcase==1.2.0
tabulate==0.8.7
terminado==0.9.2
testpath==0.4.4
toml==0.10.2
toolz==0.11.1
tornado==6.1
traitlets==5.0.5
typing-extensions==3.7.4.3
typing-inspect==0.6.0
uritemplate==3.0.1
urllib3==1.26.3
wcwidth==0.1.9
web3==4.7.2
webencodings==0.5.1
websockets==6.0
widgetsnbextension==3.5.1
zipp==3.1.0

What was wrong?

In https://github.com/TokenEngineeringCommunity/BalancerAMM_Model/blob/cf4210443b7c6780b1f6d74f86d63b996c517784/data/w3_utils.py#L63 for address = 0x9f8F72aA9304c8B593d555F12eF6589cC3A579A2 (Maker MKR token), looking up the symbol on Infura fails with:

OverflowError('Python int too large to convert to C ssize_t')
> /home/shinichi/.virtualenvs/balancer/lib/python3.9/site-packages/eth_abi/decoding.py(82)seek_in_frame()
     81         """
---> 82         super().seek(self._total_offset + pos, *args, **kwargs)
     83 

ipdb> u
> /home/shinichi/.virtualenvs/balancer/lib/python3.9/site-packages/eth_abi/decoding.py(93)push_frame()
     92 
---> 93         self.seek_in_frame(0)
     94 

ipdb> u
> /home/shinichi/.virtualenvs/balancer/lib/python3.9/site-packages/eth_abi/decoding.py(135)decode()
    134 
--> 135         stream.push_frame(start_pos)
    136         value = self.tail_decoder(stream)

ipdb> u
> /home/shinichi/.virtualenvs/balancer/lib/python3.9/site-packages/eth_abi/decoding.py(118)__call__()
    117     def __call__(self, stream):
--> 118         return self.decode(stream)
    119 

ipdb> u
> /home/shinichi/.virtualenvs/balancer/lib/python3.9/site-packages/eth_abi/decoding.py(164)decode()
    163         for decoder in self.decoders:
--> 164             yield decoder(stream)
    165 

ipdb> u
> /home/shinichi/.virtualenvs/balancer/lib/python3.9/site-packages/eth_utils/functional.py(45)inner()
     44         def inner(*args, **kwargs) -> T:  # type: ignore
---> 45             return callback(fn(*args, **kwargs))
     46 

ipdb> u
> /home/shinichi/.virtualenvs/balancer/lib/python3.9/site-packages/eth_abi/decoding.py(118)__call__()
    117     def __call__(self, stream):
--> 118         return self.decode(stream)
    119 

ipdb> u
> /home/shinichi/.virtualenvs/balancer/lib/python3.9/site-packages/eth_abi/abi.py(96)decode_abi()
     94     stream = ContextFramesBytesIO(data)
     95 
---> 96     return decoder(stream)

ipdb> u
> /home/shinichi/.virtualenvs/balancer/lib/python3.9/site-packages/web3/contract.py(1377)call_contract_function()
   1376     try:
-> 1377         output_data = decode_abi(output_types, return_data)
   1378     except DecodingError as e:

ipdb> u
> /home/shinichi/.virtualenvs/balancer/lib/python3.9/site-packages/web3/contract.py(1110)call()
   1109 
-> 1110         return call_contract_function(
   1111             self.web3,

ipdb> u
> /home/shinichi/source/work/BalancerModel/data/w3_utils.py(63)get_token_symbol()
     62         contract = self.get_contract_for(address)
---> 63         symbol = contract.functions.symbol().call()
     64         self.token_mapping[address] = {'symbol': symbol}

ipdb> address
'0x9f8F72aA9304c8B593d555F12eF6589cC3A579A2'
kclowes commented 3 years ago

It looks like the ABI you have in your utils file isn't quite right for the maker contract. The ABI for maker is:

{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"bytes32"}]

I'm going to close because this isn't a web3 bug. If it comes up again though, I'll add an issue for a better error message.