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

decoding events fails for indexed bytes #351

Open
cyberthirst opened this issue Nov 27, 2024 · 0 comments
Open

decoding events fails for indexed bytes #351

cyberthirst opened this issue Nov 27, 2024 · 0 comments

Comments

@cyberthirst
Copy link

boa version: 0.2.5

import boa

def test():
    loggy_code = """

a: Bytes[3]

event MyLog:
    arg1: indexed(Bytes[3])

@external
def foo():
    self.a = b"bar"
    log MyLog(self.a)
    """

    c = boa.loads(loggy_code)
    c.foo()
    c.get_logs()

test()

yields:

File "proj/titanoboa/boa/contracts/vyper/vyper_contract.py", line 739, in get_logs
    ret.append(c.decode_log(e))
               ^^^^^^^^^^^^^^^
  File "proj/titanoboa/boa/contracts/vyper/vyper_contract.py", line 769, in decode_log
    abi_decode(typ.abi_type.selector_name(), encoded_topic)
  File "proj/titanoboa/boa/util/abi.py", line 86, in abi_decode
    return _ABIDecoder.decode(_get_parser(schema), data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "proj/titanoboa/venv/lib/python3.11/site-packages/eth/codecs/abi/decoder.py", line 58, in decode
    return node.accept(cls, value, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "proj/titanoboa/venv/lib/python3.11/site-packages/eth/codecs/abi/nodes.py", line 44, in accept
    return fn(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "proj/titanoboa/venv/lib/python3.11/site-packages/eth/codecs/abi/decoder.py", line 204, in visit_BytesNode
    raise DecodeError("bytes", value, e.args[0])
eth.codecs.abi.exceptions.DecodeError: Error decoding '0x435cd288e3694b535549c3af56ad805c149f92961bf84a1c647f7d86fc2431b4' as 'bytes' - Data section is not the correct size

i think the decoding of topics might be messed up because we hash the bytestrings when used as indexed event args

@cyberthirst cyberthirst changed the title decoding events fails for bytesm decoding events fails for indexed bytes Nov 27, 2024
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

No branches or pull requests

1 participant