-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
eth_subscribe and eth_unsubscribe support #1402
Comments
We do not have any plans yet, but will leave this ticket open to indicate that there is interest! |
As of Nov-2019, Infura keeps promoting eth_subscribe to an extreme extent that they are not trying to fix any other websocket issues for web3.py Here's a week-long agonizing talk I had with them -- https://community.infura.io/t/ropsten-websocket-event-timeout-with-web3-py/1078 Given Infura's direction, could the discussion to support Thanks. |
We are trying to keep our multiple off-chain backends in sync with the blockchain but are having a hard time doing that. We currently have the polling interval set to 300 seconds, maybe we could adjust that a bit. However there are still cases where we could only "afford" a few seconds lag between on-chain and off-chain states. Being able to subscribe to blockchain events will likely make things simpler for us. It will also enable us to simplify our blockchain monitoring code largely. |
Hi, thank you for developing this project. This issue was opened two years ago, has anything been done to implement subscriptions? Thanks. |
@tgdn Nope, not yet, but it's fairly high priority at this point. If anyone has the time to put up a PR, I'd be happy to review/help out. That's probably the fastest way to get something in! |
Do you have any idea how you would like this to be built? |
I'd like to get some feedback from @pipermerriam because I'm not super familiar with python pub/sub paradigms. One naive implementation might be to add the /cc @marcgarreau |
Also unsure of the most pythonic approach. Web3.js uses the event emitter pattern, e.g.,
Looks like a python port exists here. Maybe a different flavor of observer pattern is preferred, though. I yield the remainder of my time to Piper or Carver. |
im curious if anyone has figured out a way to get eth_subscribe to work with web3py? I just ported a project from web3js because I wanted to work with scikit, only to find that I can't subscribe. I'd love to see this feature implemented, or if someone has an idea of a workaround, that would be great too! |
here are two examples of pub sub. python-binance-chain has a subscribe feature and an auto reconnect for their websockets connection. |
can't something similar to this be used? |
I'm not usually one to give tricks but here's a small snippet you can use to subscribe with autobahn/twisted under python
You would have to manage the response under the onMessage, probably with a json.loads(payload) thingy. I'll let you all discover the rest. Also this is twisted which is similar but different to asyncio so you would have to manage it as such but it's a good start |
any updates on the implementation of subscriptions? |
I looked into doing this a while back, and there wasn't really a straightforward way to do it within our existing architecture. It's not on our immediate roadmap but it will probably move up in priority once async gets off the ground since there is so much interest! If anyone wants to take a crack at it, I'd be happy to review/keep things moving! |
Let me know if this is out of place but in case someone want an idea on how to implement this I've made a subscription client for JSON-RPC for python. |
this answer helped me do eth_subscribe in python. might be a good solution while we wait for eth_subscribe to be supported by web3.py |
Greetings, I've made subscription work for websockets using the link below: But does anyone know how to go about doing the same thing for IPC? |
Hello, |
On a related note, Infura made a guide to listen to pendong transactions using web3.py: |
Thanks for the update @pacrob, this is great news 💪 I ended up implementing my own solution in web3client. I think we took a similar approach: https://github.com/coccoinomane/web3client/blob/master/src/web3client/base_client.py#L451-L673 Will test the web3.py implementation at the next occasion. Cheers, |
Great, thanks! I'm going to close this issue, but please let us know if you have any further suggestions/request. |
Hi,
Are there any plans on implementing
eth_subscribe/eth_unsubscribe
RPC calls similarly how it's done in web3js?eth_getFilterChanges
consumes a lot of traffic as you need to always poll the node for the changes. Witheth_subscribe
node will push the updates upon arrival.The text was updated successfully, but these errors were encountered: