ApeWorX / ApeWorX/web3.py

Erroneous code in web3._utils.encoding

Open
#1,252 0 comments 0 reactions 0 assignees View on GitHub
Pending Clarification priority: p3 nice to have Work in Progress
Dominant language
Python
Stars
5.5k
Forks
1.7k
Avg merge
3d 10h
Merged PRs (30d)
2

Description

### What was wrong?

Found some erroneous code in `web3._utils.encoding`: https://github.com/ethereum/web3.py/blob/2271ba22be00dabc3eb8ba08a4d2ccc0dda1b93b/web3/_utils/encoding.py#L309

The problem with the above code is that the `arrlist` property on `ABIType` instances is *always* a tuple of tuples or `None` if no array dimension list was encountered when parsing a type string. So `arrlist[-1]` will never equal `1`.

I tried swapping out the enclosing function (which appears to implement an experimental packed encoder before one was available in eth-abi) for the packed encoder that is now available in eth-abi. This caused tests to fail in `tests/core/filtering/test_contract_topic_filters.py`.

I didn't have time to dig into things and really diagnose the problem. It seems like it could take a bit of time to do that. My sense is that some of the filtering features were built upon incorrect assumptions about packed encodings.

### How can it be fixed?

Not sure yet. Will need to dig into this more deeply.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.