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

Cannot get_logs filtered by block hash #182

Open
cducrest opened this issue Mar 31, 2020 · 0 comments
Open

Cannot get_logs filtered by block hash #182

cducrest opened this issue Mar 31, 2020 · 0 comments

Comments

@cducrest
Copy link

cducrest commented Mar 31, 2020

  • Version: 0.4.0b1
  • Python: 3.6.9
  • OS: linux

What was wrong?

Cannot get logs filtered by blockHash:
web3.eth.getLogs({"blockHash": block_hash})
gets error:
TypeError: get_logs() got an unexpected keyword argument 'blockHash'

tests/chain_integration/test_event_information.py:215: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
venvrelay/lib/python3.6/site-packages/web3/eth.py:412: in getLogs
    "eth_getLogs", [filter_params],
venvrelay/lib/python3.6/site-packages/web3/manager.py:94: in request_blocking
    response = self._make_request(method, params)
venvrelay/lib/python3.6/site-packages/web3/manager.py:81: in _make_request
    return request_func(method, params)
cytoolz/functoolz.pyx:254: in cytoolz.functoolz.curry.__call__
    ???
cytoolz/functoolz.pyx:250: in cytoolz.functoolz.curry.__call__
    ???
venvrelay/lib/python3.6/site-packages/web3/middleware/formatting.py:48: in apply_formatters
    response = make_request(method, formatted_params)
venvrelay/lib/python3.6/site-packages/web3/middleware/gas_price_strategy.py:18: in middleware
    return make_request(method, params)
cytoolz/functoolz.pyx:254: in cytoolz.functoolz.curry.__call__
    ???
cytoolz/functoolz.pyx:250: in cytoolz.functoolz.curry.__call__
    ???
venvrelay/lib/python3.6/site-packages/web3/middleware/formatting.py:48: in apply_formatters
    response = make_request(method, formatted_params)
venvrelay/lib/python3.6/site-packages/web3/middleware/attrdict.py:18: in middleware
    response = make_request(method, params)
cytoolz/functoolz.pyx:254: in cytoolz.functoolz.curry.__call__
    ???
cytoolz/functoolz.pyx:250: in cytoolz.functoolz.curry.__call__
    ???
venvrelay/lib/python3.6/site-packages/web3/middleware/formatting.py:48: in apply_formatters
    response = make_request(method, formatted_params)
venvrelay/lib/python3.6/site-packages/web3/middleware/normalize_errors.py:9: in middleware
    result = make_request(method, params)
cytoolz/functoolz.pyx:254: in cytoolz.functoolz.curry.__call__
    ???
cytoolz/functoolz.pyx:250: in cytoolz.functoolz.curry.__call__
    ???
venvrelay/lib/python3.6/site-packages/web3/middleware/formatting.py:50: in apply_formatters
    response = make_request(method, params)
cytoolz/functoolz.pyx:254: in cytoolz.functoolz.curry.__call__
    ???
cytoolz/functoolz.pyx:250: in cytoolz.functoolz.curry.__call__
    ???
venvrelay/lib/python3.6/site-packages/web3/middleware/formatting.py:48: in apply_formatters
    response = make_request(method, formatted_params)
venvrelay/lib/python3.6/site-packages/web3/providers/eth_tester/middleware.py:311: in middleware
    return make_request(method, params)
cytoolz/functoolz.pyx:254: in cytoolz.functoolz.curry.__call__
    ???
cytoolz/functoolz.pyx:250: in cytoolz.functoolz.curry.__call__
    ???
venvrelay/lib/python3.6/site-packages/web3/middleware/formatting.py:48: in apply_formatters
    response = make_request(method, formatted_params)
venvrelay/lib/python3.6/site-packages/web3/providers/eth_tester/main.py:68: in make_request
    response = delegator(self.ethereum_tester, params)
venvrelay/lib/python3.6/site-packages/web3/providers/eth_tester/defaults.py:117: in get_logs
    logs = eth_tester.get_logs(**filter_params)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

args = (<eth_tester.main.EthereumTester object at 0x7fc138d122b0>,), kwargs = {'blockHash': HexBytes('0xf2b94dcd62c7926e72a2acdd48b20de19875b24f51055b4b85ab06aeaf2b9048')}

    @functools.wraps(fn)
    def inner(*args, **kwargs) -> T:  # type: ignore
>       return callback(fn(*args, **kwargs))
E       TypeError: get_logs() got an unexpected keyword argument 'blockHash'

venvrelay/lib/python3.6/site-packages/eth_utils/functional.py:45: TypeError

How can it be fixed?

Add parameter block_hash to get_logs and create_log_filter method.
I attempted to write a fix here: #183

I believe to make it work with web3, this will need to be updated: https://github.com/ethereum/web3.py/blob/06c194913e7736076f7d3f6f68c128c6d47c8559/web3/providers/eth_tester/middleware.py#L149
to map parameter blockHash to block_hash, but I am not fully confident in my knowledge about the code.

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