Closed BinaryQuasar closed 6 years ago
@BinaryQuasar ganache-core v2.1.4 fixes filter.address to work with a single value or an array, in compliance with the JSON RPC wiki.
Can you check which version you are using and update ganache-core if it is less than 2.1.4?
@dylanjw I'm running ganache-core 2.2.1, ganache-cli 6.1.8.
> ganache-cli --version
Ganache CLI v6.1.8 (ganache-core: 2.2.1)
@BinaryQuasar ganache-core forwards eth_newFilter
to provider-engine
which is missing support for address arrays. I opened a pull request with that project to get that fixed: https://github.com/MetaMask/provider-engine/pull/280. Im closing this issue because it is not a web3 bug.
While you wait for the fix, you could give the rpc endpoint eth_getLogs
a try.
@dylanjw Thanks for tracking down the issue and providing a fix!
What was wrong?
In version 4.6.0, filtering on contract events returns no logs when the contract address is set (using ganache-cli). It still fails after updating eth-abi to the alpha 2.0 version. Version 4.5.0 works.
The following code fails to return logs in 4.6.0:
The same code works fine in 4.5.0, returning an array of event dicts as expected.
Event logs are also returned in 4.6.0 when initializing the contract without an address:
How can it be fixed?
I have identified the issue is caused by the changes made in f1e8e915. Specifically these two lines:
https://github.com/ethereum/web3.py/commit/f1e8e91503153c9942db570ac88752fd63d0a278#diff-f1ec2154438a2971d779c561901b6591R27 https://github.com/ethereum/web3.py/commit/f1e8e91503153c9942db570ac88752fd63d0a278#diff-480e77d839a1bfb9e5557e00f9b9c7aeR16
Changing
https://github.com/ethereum/web3.py/blob/master/web3/utils/rpc_abi.py#L27
back to
'address': 'address'
, andhttps://github.com/ethereum/web3.py/blob/master/web3/middleware/normalize_request_parameters.py#L16
to
'address': apply_formatter_if(is_string, lambda x: x)})
solves the issue, though this is probably not the desired fix.