This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Switch to new light client protocol #5472
Merged
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.