Skip to content

Commit

Permalink
state sync: prefer external if available (#12239)
Browse files Browse the repository at this point in the history
Reverts state sync to the old behavior: if an external parts source is
available, it will be used without making any p2p requests.

Alternative would be to set the default `peer_attempts_threshold` to 0,
but I'd rather hard disable this since we do not intend to officially
release it pending further testing and tuning.
  • Loading branch information
saketh-are authored Oct 17, 2024
1 parent 827aab9 commit 8b6c751
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions chain/client/src/sync/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ struct StateSyncExternal {
semaphore: Arc<tokio::sync::Semaphore>,
/// A node with external storage configured first tries to obtain state parts from peers.
/// For each part, it will make this many attempts before getting it from external storage.
peer_attempts_threshold: u64,
_peer_attempts_threshold: u64,
/// Connection to the external storage.
external: ExternalConnection,
}
Expand Down Expand Up @@ -186,7 +186,7 @@ impl StateSync {
Some(StateSyncExternal {
chain_id: chain_id.to_string(),
semaphore: Arc::new(tokio::sync::Semaphore::new(num_permits)),
peer_attempts_threshold: *external_storage_fallback_threshold,
_peer_attempts_threshold: *external_storage_fallback_threshold,
external,
})
}
Expand Down Expand Up @@ -592,10 +592,10 @@ impl StateSync {
let mut peer_requests_sent = 0;
let mut state_root_and_part_count: Option<(CryptoHash, u64)> = None;
for (part_id, download) in parts_to_fetch(new_shard_sync_download) {
if self
.external
.as_ref()
.is_some_and(|ext| download.state_requests_count >= ext.peer_attempts_threshold)
if self.external.is_some()
// TODO(saketh): enable after p2p state sync is ready
//.as_ref()
//.is_some_and(|ext| download.state_requests_count >= ext.peer_attempts_threshold)
{
// TODO(saketh): After we have sufficient confidence that requesting state parts
// from peers is working well, we will eliminate the external storage entirely.
Expand Down

0 comments on commit 8b6c751

Please sign in to comment.