Skip to content

Commit

Permalink
Fix panic when receiving a response after GrandPa warp sync has finis…
Browse files Browse the repository at this point in the history
…hed (#650)
  • Loading branch information
tomaka authored Jun 1, 2023
1 parent 929a68a commit fee7735
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions lib/src/sync/all.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1722,6 +1722,20 @@ impl<TRq, TSrc, TBl> AllSync<TRq, TSrc, TBl> {

(user_data.user_data, ResponseOutcome::Queued)
}
(
AllSyncInner::GrandpaWarpSync {
inner: warp_sync::WarpSync::Finished(sync),
},
RequestMapping::WarpSync(request_id),
) => {
let pos = sync
.in_progress_requests
.iter()
.position(|(_, id, ..)| *id == request_id)
.unwrap();
let (_, _, user_data, _) = sync.in_progress_requests.remove(pos);
(user_data.user_data, ResponseOutcome::Outdated)
}

// Only the GrandPa warp syncing ever starts GrandPa warp sync requests.
(_, RequestMapping::Inline(_, _, user_data)) => {
Expand Down Expand Up @@ -1781,6 +1795,21 @@ impl<TRq, TSrc, TBl> AllSync<TRq, TSrc, TBl> {
};
(user_data, ResponseOutcome::Queued)
}
(
AllSyncInner::GrandpaWarpSync {
inner: warp_sync::WarpSync::Finished(mut sync),
},
_,
RequestMapping::WarpSync(request_id),
) => {
let pos = sync
.in_progress_requests
.iter()
.position(|(_, id, ..)| *id == request_id)
.unwrap();
let (_, _, user_data, _) = sync.in_progress_requests.remove(pos);
(user_data.user_data, ResponseOutcome::Outdated)
}
// Only the GrandPa warp syncing ever starts GrandPa warp sync requests.
(other, _, RequestMapping::Inline(_, _, user_data)) => {
self.inner = other;
Expand Down Expand Up @@ -1843,6 +1872,21 @@ impl<TRq, TSrc, TBl> AllSync<TRq, TSrc, TBl> {
};
(user_data.user_data, ResponseOutcome::Queued)
}
(
AllSyncInner::GrandpaWarpSync {
inner: warp_sync::WarpSync::Finished(mut sync),
},
_,
RequestMapping::WarpSync(request_id),
) => {
let pos = sync
.in_progress_requests
.iter()
.position(|(_, id, ..)| *id == request_id)
.unwrap();
let (_, _, user_data, _) = sync.in_progress_requests.remove(pos);
(user_data.user_data, ResponseOutcome::Outdated)
}
// Only the GrandPa warp syncing ever starts call proof requests.
(other, _, RequestMapping::Inline(_, _, user_data)) => {
self.inner = other;
Expand Down

0 comments on commit fee7735

Please sign in to comment.