Skip to content

Commit 84d2123

Browse files
authored
Shuffle validator order in download_missing_sender_blocks (#4724)
## Motivation Right now we're going through the validators always in the same order, which is not ideal ## Proposal Shuffle the validator order ## Test Plan CI ## Release Plan - These changes should be backported to the latest `testnet` branch, then - be released in a validator hotfix.
1 parent 16d29ff commit 84d2123

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

linera-core/src/client/mod.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ use linera_execution::{
5757
};
5858
use linera_storage::{Clock as _, ResultReadCertificates, Storage as _};
5959
use linera_views::ViewError;
60-
use rand::distributions::{Distribution, WeightedIndex};
60+
use rand::{
61+
distributions::{Distribution, WeightedIndex},
62+
seq::SliceRandom,
63+
};
6164
use serde::{Deserialize, Serialize};
6265
use thiserror::Error;
6366
use tokio::sync::{mpsc, OwnedRwLockReadGuard};
@@ -2323,14 +2326,15 @@ impl<Env: Environment> ChainClient<Env> {
23232326
stream::iter(missing_blocks.into_iter())
23242327
.map(|(sender_chain_id, heights)| {
23252328
let height = heights.into_iter().max();
2326-
let nodes = nodes.clone();
23272329
let this = self.clone();
2330+
let mut shuffled_nodes = nodes.clone();
2331+
shuffled_nodes.shuffle(&mut rand::thread_rng());
23282332
async move {
23292333
let Some(height) = height else {
23302334
return Ok(());
23312335
};
23322336
// Try to download from any node.
2333-
for node in &nodes {
2337+
for node in &shuffled_nodes {
23342338
if let Err(err) = this
23352339
.download_sender_block_with_sending_ancestors(
23362340
sender_chain_id,

0 commit comments

Comments
 (0)