Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Temporarily ban peers after failing to connect to them #2747

Merged
merged 5 commits into from
Sep 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 9 additions & 0 deletions bin/full-node/src/run/network_service/tasks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ pub(super) async fn opening_connection_task(
let mut guarded = inner.guarded.lock().await;
guarded.num_pending_out_attempts -= 1;
guarded.network.pending_outcome_err(start_connect.id, true);
for chain_index in 0..guarded.network.num_chains() {
guarded.unassign_slot_and_ban(chain_index, start_connect.expected_peer_id.clone());
}
inner.wake_up_main_background_task.notify(1);
return;
}
Expand All @@ -83,6 +86,9 @@ pub(super) async fn opening_connection_task(
let mut guarded = inner.guarded.lock().await;
guarded.num_pending_out_attempts -= 1;
guarded.network.pending_outcome_err(start_connect.id, false);
for chain_index in 0..guarded.network.num_chains() {
guarded.unassign_slot_and_ban(chain_index, start_connect.expected_peer_id.clone());
}
inner.wake_up_main_background_task.notify(1);
return;
}
Expand All @@ -93,6 +99,9 @@ pub(super) async fn opening_connection_task(
let mut guarded = inner.guarded.lock().await;
guarded.num_pending_out_attempts -= 1;
guarded.network.pending_outcome_err(start_connect.id, true);
for chain_index in 0..guarded.network.num_chains() {
guarded.unassign_slot_and_ban(chain_index, start_connect.expected_peer_id.clone());
}
inner.wake_up_main_background_task.notify(1);
return;
}
Expand Down
5 changes: 5 additions & 0 deletions bin/light-base/src/network_service/tasks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ pub(super) async fn connection_task<TPlat: Platform>(
err.map_or(false, |err| err.is_bad_addr),
); // TODO: should pass a proper value for `is_unreachable`, but an error is sometimes returned despite a timeout https://github.com/paritytech/smoldot/issues/1531

for chain_index in 0..guarded.network.num_chains() {
guarded
.unassign_slot_and_ban(chain_index, start_connect.expected_peer_id.clone());
}

// We wake up the background task so that the slot can potentially be
// assigned to a different peer.
shared.wake_up_main_background_task.notify(1);
Expand Down
4 changes: 4 additions & 0 deletions bin/wasm-node/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Changed

- No longer try to connect to a peer for 20 seconds after failing to connect to it. This prevents loops where we keep trying to connect to the same address(es) over and over again ([#2747](https://github.com/paritytech/smoldot/pull/2747)).

### Added

- Add support for the `chainHead_unstable_finalizedDatabase` JSON-RPC method. This JSON-RPC method aims to be a replacement for the `databaseContent` method of the `Chain` and is expected to remain a permanently unstable smoldot-specific function. ([#2749](https://github.com/paritytech/smoldot/pull/2749))
Expand Down