Skip to content

network/sync: Extra justification response might be lost when peer disconnects #5414

@dmitry-markin

Description

@dmitry-markin

In justification_requests.rs active_requests are moved to pending_requests when sync peer disconnects:

pub(crate) fn peer_disconnected(&mut self, who: &PeerId) {
if let Some(request) = self.active_requests.remove(who) {
self.pending_requests.push_front(request);
}
}

When receiving a response the code relies on the request being present in active_requests:

if let Some(request) = self.active_requests.remove(&who) {
if let Some(r) = resp {
trace!(target: LOG_TARGET,
"Queuing import of {} from {:?} for {:?}",
self.request_type_name, who, request,
);
self.importing_requests.insert(request);
return Some((who, request.0, request.1, r))

We can hit a race condition if the response from the request-response protocol is delivered after the sync peer disconnect event from the notifications protocol.

Metadata

Metadata

Assignees

No one assigned

    Labels

    D0-easyCan be fixed primarily by duplicating and adapting code by an intermediate coder.I2-bugThe node fails to follow expected behavior.T0-nodeThis PR/Issue is related to the topic “node”.

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions