-
Notifications
You must be signed in to change notification settings - Fork 995
feat: Add eth_subscribe and eth_unsubscribe support to IPC service #9504
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
feat: Add eth_subscribe and eth_unsubscribe support to IPC service #9504
Conversation
macfarla
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MqllR Thanks for the PR - can you add a changelog entry please, think this is worth including in the release notes
| besuController.getProtocolManager().ethContext().getScheduler()); | ||
|
|
||
| final WebSocketMethodsFactory ipcMethodsFactory = | ||
| new WebSocketMethodsFactory(subscriptionManager, ipcMethods); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this change necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tried without, but it turns out that this is what:
- enables the 2 methods for the service https://github.com/hyperledger/besu/blob/main/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/websocket/methods/WebSocketMethodsFactory.java#L36
- bind the subscription manager with the methods.
So unless we want to manage it in another way, I'd answer yes, it's necessary !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tagging this as #techdebt for later investigation, you've found a code smell: reactive methods are bound to a transport type, which is excessive coupling.
Signed-off-by: Mael Regnery <mael@mqli.fr>
56846d5 to
2cb9523
Compare
Signed-off-by: Mael Regnery <mael@mqli.fr>
3ee2f96 to
bf58fa7
Compare
…yperledger#9504) * feat: Add eth_subscribe and eth_unsubscribe support to IPC service Signed-off-by: Mael Regnery <mael@mqli.fr> * add changelog note for subscription over IPC Signed-off-by: Mael Regnery <mael@mqli.fr> --------- Signed-off-by: Mael Regnery <mael@mqli.fr> Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com> Signed-off-by: Ali Zhagparov <alijakparov.kz@gmail.com>
…yperledger#9504) * feat: Add eth_subscribe and eth_unsubscribe support to IPC service Signed-off-by: Mael Regnery <mael@mqli.fr> * add changelog note for subscription over IPC Signed-off-by: Mael Regnery <mael@mqli.fr> --------- Signed-off-by: Mael Regnery <mael@mqli.fr> Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com> Signed-off-by: stefan.pingel@consensys.net <stefan.pingel@consensys.net>
Add eth_subscribe and eth_unsubscribe support to IPC service
Description
This PR adds subscription support (
eth_subscribeandeth_unsubscribe) to the IPC service, enabling applications to subscribe to blockchain events over Unix domain sockets without requiring WebSocket connections.Motivation
Currently, subscription methods are only available through the WebSocket service. Applications using IPC sockets cannot subscribe to events like new block headers, logs, pending transactions, or syncing status. This limitation forces applications to maintain both IPC and WebSocket connections when they prefer IPC for security and performance reasons.
Changes
Core Implementation
JsonRpcIpcService.java:SubscriptionManagerparameter (backward compatible)JsonRpcRequesttoWebSocketRpcRequestwith connection ID for single requestsRunnerBuilder.java:eth_subscribe,eth_unsubscribe) to IPC usingWebSocketMethodsFactorySubscriptionManagerto IPC service when enabledjsonRpcIpcConfigurationTesting
JsonRpcIpcServiceTest.java:eth_subscriberequestseth_unsubscriberequestsUsage Example
Benefits
Testing
Related Issues
Closes #9503