Implement admin_peerEvents for rpc module#7999
Merged
damian-orzechowski merged 29 commits intomasterfrom Feb 11, 2025
Merged
Conversation
LukaszRozmej
requested changes
Jan 6, 2025
Member
LukaszRozmej
left a comment
There was a problem hiding this comment.
Potentially we also need msgsend and msgrecv subscriptions, but they will be a bit harder to add as I believe we don't expose events yet.
Member
LukaszRozmej
left a comment
There was a problem hiding this comment.
Almost done - what do you think about moving subscription registrations from SubscriptionManager to be close to actual modules themselves?
added 10 commits
January 22, 2025 09:43
Allow real time pub-sub through websocket on peer_added and peer_removed events.
+ Move admin_subscribe and admin_unsubsribe methods into the AdminRpcModule. + Move relevant tests to AdminModuleTest + Deal with other comments in PR review.
Removed `JsonPropertyName`, changed variable name.
a433375 to
2c1ea99
Compare
LukaszRozmej
requested changes
Feb 10, 2025
Member
LukaszRozmej
left a comment
There was a problem hiding this comment.
Please don't update submodules!
src/bench_precompiles
src/tests
a840b0d to
db42c6a
Compare
LukaszRozmej
approved these changes
Feb 10, 2025
Comment on lines
+111
to
+114
| [JsonRpcMethod(Description = "Starts a subscription (on WebSockets/Sockets) to a particular event. For every event that matches the subscription a JSON-RPC notification with event details and subscription ID will be sent to a client.", IsImplemented = true, IsSharable = false, Availability = RpcEndpoint.All & ~RpcEndpoint.Http)] | ||
| ResultWrapper<string> admin_subscribe(string subscriptionName, string? args = null); | ||
| [JsonRpcMethod(Description = "Unsubscribes from a subscription.", IsImplemented = true, IsSharable = false, Availability = RpcEndpoint.All & ~RpcEndpoint.Http)] | ||
| ResultWrapper<bool> admin_unsubscribe(string subscriptionId); |
rubo
reviewed
Feb 11, 2025
…Subscription.cs Co-authored-by: Ruben Buniatyan <rubo@users.noreply.github.com>
…e.cs Co-authored-by: Ruben Buniatyan <rubo@users.noreply.github.com>
…dRecvResponse.cs Co-authored-by: Ruben Buniatyan <rubo@users.noreply.github.com>
…esponse.cs Co-authored-by: Ruben Buniatyan <rubo@users.noreply.github.com>
…pResponse.cs Co-authored-by: Ruben Buniatyan <rubo@users.noreply.github.com>
damian-orzechowski
approved these changes
Feb 11, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
These changes allow real time pub-sub through websocket on peer-related events (
peerEvents), specifically,peerAddedandpeerRemovedevents. Once a client subscribes forpeerEvents, A JSON-RPC notification with event payload and subscription id is sent to this client for every event matching the subscription topic (peerAddedorpeerRemoved).Users subscribe to peerEvents by sending a request as such:
{"jsonrpc": "2.0", "id": 1, "method": "admin_subscribe", "params": ["peerEvents"]}Resolves #7816
Changes
peerEvents.IPeerPool.peerAddedandIPeerPool.peerRemovedevents when requested.eth_subscribeandadmin_subscribeinJsonRpcSubscriptionResponseclass.Types of changes
What types of changes does your code introduce?
Testing
Requires testing
If yes, did you write tests?