From 491b24e075da03193c7df7a7bd2d4ab0e3a9b95f Mon Sep 17 00:00:00 2001 From: qima Date: Mon, 16 Dec 2024 19:21:17 +0800 Subject: [PATCH] fix(client): wait a short while before startup quoting/upload tasks --- .github/workflows/merge.yml | 4 ++-- ant-node/src/node.rs | 6 ++++-- autonomi/src/client/mod.rs | 6 ++++++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml index 1d59de2431..aebccee63f 100644 --- a/.github/workflows/merge.yml +++ b/.github/workflows/merge.yml @@ -408,7 +408,7 @@ jobs: if: matrix.os != 'windows-latest' run: | set -e - for i in {1..100}; do + for i in {1..50}; do dd if=/dev/urandom of=random_file_$i.bin bs=1M count=1 status=none ./target/release/ant --log-output-dest data-dir file upload random_file_$i.bin --public ./target/release/ant --log-output-dest data-dir file upload random_file_$i.bin @@ -423,7 +423,7 @@ jobs: shell: pwsh run: | $ErrorActionPreference = "Stop" - for ($i = 1; $i -le 100; $i++) { + for ($i = 1; $i -le 50; $i++) { $fileName = "random_file_$i.bin" $byteArray = [byte[]]@(0xFF) * (1MB) # Create a 1 MB array filled with 0xFF [System.IO.File]::WriteAllBytes($fileName, $byteArray) diff --git a/ant-node/src/node.rs b/ant-node/src/node.rs index 4908c0bc23..2515af6344 100644 --- a/ant-node/src/node.rs +++ b/ant-node/src/node.rs @@ -16,7 +16,9 @@ use ant_bootstrap::BootstrapCacheStore; use ant_evm::RewardsAddress; #[cfg(feature = "open-metrics")] use ant_networking::MetricsRegistries; -use ant_networking::{Instant, Network, NetworkBuilder, NetworkEvent, NodeIssue, SwarmDriver}; +use ant_networking::{ + target_arch::sleep, Instant, Network, NetworkBuilder, NetworkEvent, NodeIssue, SwarmDriver, +}; use ant_protocol::{ convert_distance_to_u256, error::Error as ProtocolError, @@ -969,7 +971,7 @@ impl Node { } } // Sleep a short while to avoid causing a spike on resource usage. - std::thread::sleep(std::time::Duration::from_secs(10)); + sleep(std::time::Duration::from_secs(10)).await; } } } diff --git a/autonomi/src/client/mod.rs b/autonomi/src/client/mod.rs index f245833b91..d118a5f065 100644 --- a/autonomi/src/client/mod.rs +++ b/autonomi/src/client/mod.rs @@ -251,6 +251,12 @@ impl Client { receiver.await.expect("sender should not close")?; debug!("Client is connected to the network"); + // With the switch to the new bootstrap cache scheme, + // Seems the too many `initial dial`s could result in failure, + // when startup quoting/upload tasks got started up immediatly. + // Hence, put in a forced wait to allow `initial network discovery` to be completed. + ant_networking::target_arch::sleep(Duration::from_secs(5)).await; + Ok(Self { network, client_event_sender: Arc::new(None),