This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Switch to new light client protocol#5472
Merged
gavofyork merged 5 commits intoparitytech:masterfrom Apr 1, 2020
Merged
Conversation
twittner
reviewed
Mar 31, 2020
client/network/src/protocol.rs
Outdated
| who: PeerId, | ||
| response: message::RemoteCallResponse | ||
| _: PeerId, | ||
| _: message::RemoteCallResponse |
Contributor
There was a problem hiding this comment.
Why not removing this and the other empty methods?
client/network/src/service.rs
Outdated
| while let Poll::Ready(Some(rq)) = light_client_rqs.poll_next_unpin(cx) { | ||
| this.network_service.user_protocol_mut().add_light_client_request(rq); | ||
| // This can error if there are too many queued requests already. | ||
| let _ = this.network_service.light_client_request(rq); |
Contributor
There was a problem hiding this comment.
Should we not log a message here if an error has been returned? Are there plans to replace those unbounded channels with something that can exercise back pressure?
Contributor
Author
There was a problem hiding this comment.
Are there plans to replace those unbounded channels with something that can exercise back pressure?
That would be #3230
twittner
approved these changes
Apr 1, 2020
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
(built on top of #5461)
In #3520, we introduced a second light client protocol with the intent of replacing the current one.
This PR switches to this new protocol by default for all light client requests.
Summary of the changes:
Removes the
light_dispatchmodule entirely, as it was responsible for the old protocol. Also removes the code paths inprotocol.rsthat handles receiving responses on the old protocol. Note that we still answer requests, so this doesn't break backwards compatibility.The code in
on_demand_layernow generateslight_client_handler::Requests instead oflight_dispatch::RequestDatas for the network service to pick up. These two types are equivalent except that the new one uses the new protocol.When the code in
protocol.rsdetects a new best block for a peer, it reports it as aCustomMessageOutcome::PeerNewBestevent so that we can update the state of theLightClientHandler. This is mandatory for it to know who to dispatch requests to.Here's probably the biggest change: lights nodes must also be able to perform block requests, and block requests are done on the wire through the regular sync-ing protocol. Unfortunately the
LightClientHandlerbefore this PR cannot handle these queries, as it is not "its" protocol. After discussion with @twittner, I changedlight_client_handlerto also be able to emitBlockRequests and receive backBlockResponses. While this is not a great solution, it is in my opinion the cleanest thing to do.Moves
light_dispatch::AlwaysBadCheckerto theon_demandmodule andlight_dispatch::TIMEOUT_REPUTATION_CHANGEtolight_client_handler.Adds a Prometheus counter to the number of light requests that have been issued out.
Compatibility
After this PR, light clients will no longer be able to make queries to nodes that don't include #3520 (which was merged on February 12th).
Considering that this concerns the light client I don't think that this is a serious problem to anyone, but let me know if I'm wrong.