You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With normal single value arguments, if you want to filter against multiple options, you pass those options in as a list. For single values, they should be passed in singularly. For example, to filter against a single uint you would do filters={'arg_X': 1234} and to filter against multiple options for field arg_X, filters={'arg_X', [1234, 4321]}.
In the linked code in the events.py utils, it assumes that anything that is_list_like has already been wrapped in a list, which will result in an error either during execution, or an incorrectly constructed regex.
3. dynamic sized types.
This one I'm not very sure of at all. however,
The data filter regex is constructed using encode_single, and then all of the values are joined together to form the regex. However, this is not how ABI encoding works... as dynamic sized things are actually shoved to a later offset in the encoded data. if events encode their data field the same way, the regex won't match.
How can we fix this.
All three of these issues deal with regex issues....
So, lets get rid of the regex. Rather than regexing the data, lets instead just try decoding it using the event ABI, and then matching against the provided arguments in their native python form.
The text was updated successfully, but these errors were encountered:
What is wrong?
There are probably (almost definitely) bugs lurking in contract event filters that filter on data values.
1. Variable length data elements.
suppose the log data has an ABI with a variable length value before other values.
MyEvent(string,bytes32)
The code which constructs the regex here: https://github.com/ethereum/web3.py/blob/master/web3/utils/filters.py#L138 assumes fixed length placeholders for all variable length data elements which I don't believe is correct.
2. List types
suppose my event has a list type in it like
MyEvent(bytes2[])
To filter on this value, one might pass in arguments like
filters={'arg_a': [b'aa', b'xx']}
.However, when the data filters are constructed: https://github.com/ethereum/web3.py/blob/master/web3/utils/events.py#L99
With normal single value arguments, if you want to filter against multiple options, you pass those options in as a list. For single values, they should be passed in singularly. For example, to filter against a single
uint
you would dofilters={'arg_X': 1234}
and to filter against multiple options for fieldarg_X
,filters={'arg_X', [1234, 4321]}
.In the linked code in the
events.py
utils, it assumes that anything thatis_list_like
has already been wrapped in a list, which will result in an error either during execution, or an incorrectly constructed regex.3. dynamic sized types.
This one I'm not very sure of at all. however,
The data filter regex is constructed using
encode_single
, and then all of the values are joined together to form the regex. However, this is not how ABI encoding works... as dynamic sized things are actually shoved to a later offset in the encoded data. if events encode their data field the same way, the regex won't match.How can we fix this.
All three of these issues deal with regex issues....
https://blog.codinghorror.com/regular-expressions-now-you-have-two-problems/
So, lets get rid of the regex. Rather than regexing the data, lets instead just try decoding it using the event ABI, and then matching against the provided arguments in their native python form.
The text was updated successfully, but these errors were encountered: