Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't support content hash (EIP1577) for ENS domains #1397

Closed
filips123 opened this issue Jul 22, 2019 · 1 comment
Closed

Doesn't support content hash (EIP1577) for ENS domains #1397

filips123 opened this issue Jul 22, 2019 · 1 comment

Comments

@filips123
Copy link

filips123 commented Jul 22, 2019

  • Version: 4.9.2
  • Python: 3.7
  • OS: win

What was wrong?

There is no way to get a content record of ENS domain.

Based on the source code, I should be able to get the content record with ns.resolve('domain.eth', 'content'). This is because there are two types of records. One is addr which is already aliased to address methods and other is content which currently doesn't have any alias. But even if it doesn't have alias, I should be able to get content record "the long way".

However, when I do this, it throws exceptions:

>>> from web3 import HTTPProvider
>>> from ens import ENS

>>> provider = HTTPProvider('https://cloudflare-eth.com')
>>> ns = ENS(provider)

>>> ns.resolve('pricefeed.doracle.eth', 'content')

Traceback (most recent call last):
  File "D:\Users\filips\Downloads\ZeroNet\venv\lib\site-packages\web3\contract.py", line 1372, in call_contract_function
    output_data = decode_abi(output_types, return_data)
  File "D:\Users\filips\Downloads\ZeroNet\venv\lib\site-packages\eth_abi\abi.py", line 96, in decode_abi
    return decoder(stream)
  File "D:\Users\filips\Downloads\ZeroNet\venv\lib\site-packages\eth_abi\decoding.py", line 118, in __call__
    return self.decode(stream)
  File "D:\Users\filips\Downloads\ZeroNet\venv\lib\site-packages\eth_utils\functional.py", line 46, in inner
    return callback(fn(*args, **kwargs))
  File "D:\Users\filips\Downloads\ZeroNet\venv\lib\site-packages\eth_abi\decoding.py", line 164, in decode
    yield decoder(stream)
  File "D:\Users\filips\Downloads\ZeroNet\venv\lib\site-packages\eth_abi\decoding.py", line 118, in __call__
    return self.decode(stream)
  File "D:\Users\filips\Downloads\ZeroNet\venv\lib\site-packages\eth_abi\decoding.py", line 186, in decode
    raw_data = self.read_data_from_stream(stream)
  File "D:\Users\filips\Downloads\ZeroNet\venv\lib\site-packages\eth_abi\decoding.py", line 296, in read_data_from_stream
    len(data),
eth_abi.exceptions.InsufficientDataBytes: Tried to read 32 bytes.  Only got 0 bytes

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\Users\filips\Downloads\ZeroNet\venv\lib\site-packages\ens\main.py", line 187, in resolve
    return lookup_function(namehash)
  File "D:\Users\filips\Downloads\ZeroNet\venv\lib\site-packages\web3\contract.py", line 887, in __call__
    return self.__prepared_function(*args, **kwargs)
  File "D:\Users\filips\Downloads\ZeroNet\venv\lib\site-packages\web3\contract.py", line 900, in __prepared_function
    return getattr(self._function(*args), modifier)(modifier_dict)
  File "D:\Users\filips\Downloads\ZeroNet\venv\lib\site-packages\web3\contract.py", line 1115, in call
    **self.kwargs
  File "D:\Users\filips\Downloads\ZeroNet\venv\lib\site-packages\web3\contract.py", line 1394, in call_contract_function
    raise BadFunctionCallOutput(msg) from e
web3.exceptions.BadFunctionCallOutput: Could not decode contract function call content return data b'' for output_types ['bytes32']

I also tested this with other mainnet providers and other ENS domains.

Here is a list of some ENS domains that don't work (all of them have correct content record):

  • almonit.eth
  • pepesza.eth
  • digitallyrare.eth
  • pricefeed.doracle.eth

How can it be fixed?

First, you should somehow fix this bug. Additionally, you should also add content method as alias for content record type.

I investigated this a little bit and I found out that it only doesn't work for domains that use new resolver contract (0xD3ddcCDD3b25A8a7423B5bEe360a42146eb4Baf3) with a content record in format type://address (like ipfs://QmaA1TM7CnsGPLQvf27zB4DaGaDkncNDqh5vBzVymECkCk).

I investigated this a bit more and I found that new resolver now uses contenthash instead of content. However, Web3py still uses old resolver's ABI so it is not able to call it. Additionally, there are some differences between old content and new contenthash as it now uses EIP1577.

Also, I'm currently making content-hash library for Python (inspired by pldespaigne/content-hash). You can use it to add support for content hash in Web3. Update: It is available here. Update 2: I'm currently also creating support for content hash.

@filips123 filips123 changed the title Can't get ENS domain content Doesn't support content hash (EIP1577) for ENS domains Jul 22, 2019
@fselmo
Copy link
Collaborator

fselmo commented Jul 11, 2023

closed by #2700

Using the right libraries to generate a content hash, such as content-hash mentioned here, a user can interact with an ENS resolver that supports setting and getting the contenthash since the ABI is updated to match the ENS Public Resolver 2.

@fselmo fselmo closed this as completed Jul 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants