rpc v2: backpressure `chainhead_v1_follow` (#6058)
closes #5871 > The chainHead_v1_follow is using unbounded channels to send out messages on the JSON-RPC connection which may use lots of memory if the client is slow and can't really keep up with server i.e, substrate may keep lots of message in memory This PR changes the outgoing stream to abort and send a `Stop` event downstream in the case that client doesn't keep up with the producer. *In depth notes about how this PR should be integrated by downstream projects. This part is mandatory, and should be reviewed by reviewers, if the PR does NOT have the `R0-Silent` label. In case of a `R0-Silent`, it can be ignored.* - `rpc::Subscription::pipe_from_stream` - now takes `Self` param by reference, change was made to allow sending events to the `Subscription` after calls to `pipe_from_stream`. - `chainhead_follow::submit_events` - now uses `Abortable` stream to end it early in case - connection was closed by the client - signal received that subscription should stop - error has occured when processing the events - client can't keep up with the events produced - TODO: - make the abort logic less hacky --------- Co-authored-by: Niklas Adolfsson <[email protected]> Co-authored-by: Alexandru Vasile <[email protected]> (cherry picked from commit a0aefc6b ) Signed-off-by: Pavlo Khrystenko <[email protected]>
parent
fc627930
Pipeline
#502068
waiting for manual action
with stages
in
1 hour, 17 minutes, and 17 seconds
Please register or sign in to comment