fix(webrtc): warp sync slow initialization and webrtc handshake bug#3256
fix(webrtc): warp sync slow initialization and webrtc handshake bug#3256gab8i wants to merge 3 commits into
Conversation
Initialize warp sync source finalized_block_height with best_block_number from gossip handshake instead of 0, so warp sync triggers immediately without waiting for a GrandPa neighbor packet.
dmitry-markin
left a comment
There was a problem hiding this comment.
Substream waking in WebRTC looks good.
The idea behind optimistically targeting warp sync at the best block and not finalized one is also good, but we need to rename finalized_block_height to something like optimistic_finalized_block_height, or a better name, so future code doesn't rely on this value as actually being finalized.
Also, the comment at warp_sync.rs:768 likely needs updating and the corresponding logic checked for correctness.
| // Wait for either platform data or a coordinator write | ||
| // notification (e.g. after AcceptInNotifications queues a | ||
| // handshake response that needs to be flushed). | ||
| let write_listener = write_ready.listen(); |
There was a problem hiding this comment.
Should we move the write_ready.listen() outside the Box::pin future?
Currently, the write listener is registered once the the when_substreams_rw_ready is firstly polled.
This means we could arrive in a situation where .notify(usize::MAX); is called before registering the listener call.
For this to happen we need to:
- receive WakeUpReason::CoordinatorMessage(message)
message_sending.as_ref().as_pin_ref().is_none()should have some data to effectively take theNonepath and ignore thewhen_substreams_rw_ready.select_next_some()
Moving the listener above Box::pin solves this regardless of which states call when_substreams_rw_ready.poll_next and avoids the problem entirely
The following PR just extract work already done within paritytech/smoldot-archive#2222.
The fixes are: