Skip to content

"filter not found" in Web3.py 4.2.0 #923

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

Closed
alex-murashkin opened this issue Jun 22, 2018 · 4 comments
Closed

"filter not found" in Web3.py 4.2.0 #923

alex-murashkin opened this issue Jun 22, 2018 · 4 comments

Comments

@alex-murashkin
Copy link

  • Version: 4.2.0
  • Python: 3.6.4
  • OS: osx

What was wrong?

"Filter not found" exception was unexpectedly thrown in about 45 mins after the filter was created.

Please include any of the following that are applicable:

  • The code which produced the error

Anonymized code:


self.__my_contract = self.web3_client.eth.contract(
                address=self.my_contract_address,
                abi=abi_json,
            )
...

self.__run_audit_evt_thread(
            "MyGreatEvent",
            self.__my_contract.events.MyGreatEvent.createFilter(fromBlock=start_block),
            self.__on_my_great_event,
        )
  • The full output of the error
Exception in thread MyGreatEvent thread:
Traceback (most recent call last):
  File "/Users/myusername/.pyenv/versions/3.6.4/lib/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/Users/myusername/.pyenv/versions/3.6.4/lib/python3.6/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/myusername/projects/myproject/main_file.py", line 67, in exec
    for evt in evt_filter.get_new_entries():
  File "/Users/myusername/.pyenv/versions/3.6.4/lib/python3.6/site-packages/web3/utils/filters.py", line 105, in get_new_entries
    log_entries = self._filter_valid_entries(self.web3.eth.getFilterChanges(self.filter_id))
  File "/Users/myusername/.pyenv/versions/3.6.4/lib/python3.6/site-packages/web3/eth.py", line 320, in getFilterChanges
    "eth_getFilterChanges", [filter_id],
  File "/Users/myusername/.pyenv/versions/3.6.4/lib/python3.6/site-packages/web3/manager.py", line 106, in request_blocking
    raise ValueError(response["error"])
ValueError: {'code': -32000, 'message': 'filter not found'}
  • What type of node you were connecting to.
    Geth/v1.8.6-stable-12683fec/linux-amd64/go1.10

How can it be fixed?

I don't have any concrete suggestions.

@dylanjw
Copy link
Contributor

dylanjw commented Jun 22, 2018

Node managed filters have a way of disappearing. There is a pull request open for a drop in replacement for node managed filters with a web3 managed filter that will leverage the stateless getLogs rpc method: #732.

The web3 managed filter will solve a lot of problems that the node based filters suffer from: filters getting lost by the client, inability to use filters on infura, unable to use filters across multiple load balanced nodes.

@dylanjw dylanjw closed this as completed Jun 22, 2018
@carver
Copy link
Collaborator

carver commented Jun 22, 2018

Node managed filters have a way of disappearing.

To expand on this a bit: it's expected behavior for the node to delete installed filters at any time. In the current API, one must always check if the filter is gone and reinstall it, on every data pull.

(Hence, Dylan's work on a better solution)

@DragonDmoney
Copy link

DragonDmoney commented Feb 17, 2022

I am getting this same error. How can I fix it? I am using latest version of web3.py

@kclowes
Copy link
Collaborator

kclowes commented Feb 18, 2022

@DragonDmoney Nodes consistently drop filters. You may just have to make the filter again. Also, usage questions are better asked in the discord channel.

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

5 participants