Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix tests
Verify that both peers have a connection now that the validation goes
through `SyncingEngine`. Depending on how the tasks are scheduled,
one of them might not have the peer registered in `SyncingEngine` at which
point the test won't make any progress because block announcement received
from an unknown peer is discarded.

Move polling of `ChainSync` at the end of the function so that if a block
announcement causes a block request to be sent, that can be sent in the
same call to `SyncingEngine::poll()`.
  • Loading branch information
altonen committed Mar 29, 2023
commit 3724745e9df912525fc39dc3bc9a3c0c6dac8ce0
11 changes: 7 additions & 4 deletions client/network/sync/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -590,10 +590,6 @@ where
self.tick_timeout.reset(TICK_TIMEOUT);
}

while let Poll::Ready(result) = self.chain_sync.poll(cx) {
self.process_block_announce_validation_result(result);
}

while let Poll::Ready(Some(event)) = self.service_rx.poll_next_unpin(cx) {
match event {
ToServiceCommand::SetSyncForkRequest(peers, hash, number) => {
Expand Down Expand Up @@ -728,6 +724,13 @@ where
}
}

// poll `ChainSync` last because of a block announcement was received through the
// event stream between `SyncingEngine` and `Protocol` and the validation finished
// right after it as queued, the resulting block request (if any) can be sent right away.
while let Poll::Ready(result) = self.chain_sync.poll(cx) {
self.process_block_announce_validation_result(result);
}

Poll::Pending
}

Expand Down
2 changes: 1 addition & 1 deletion client/network/test/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ async fn can_sync_small_non_best_forks() {
// poll until the two nodes connect, otherwise announcing the block will not work
futures::future::poll_fn::<(), _>(|cx| {
net.poll(cx);
if net.peer(0).num_peers() == 0 {
if net.peer(0).num_peers() == 0 || net.peer(1).num_peers() == 0 {
Poll::Pending
} else {
Poll::Ready(())
Expand Down