Skip to content

Commit 75dd1dc

Browse files
committed
Reduce syncing and shutdown timeouts considerably
Previously, we had to configure enormous syncing timeouts as the BDK wallet syncing would hold a central mutex that could lead to large parts of event handling and syncing locking up. Here, we drop the configured timeouts considerably across the board, since such huge values are hopefully not required anymore.
1 parent 201217f commit 75dd1dc

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

src/chain/electrum.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ use std::time::{Duration, Instant};
4040

4141
const BDK_ELECTRUM_CLIENT_BATCH_SIZE: usize = 5;
4242
const ELECTRUM_CLIENT_NUM_RETRIES: u8 = 3;
43-
const ELECTRUM_CLIENT_TIMEOUT_SECS: u8 = 20;
43+
const ELECTRUM_CLIENT_TIMEOUT_SECS: u8 = 10;
4444

4545
pub(crate) struct ElectrumRuntimeClient {
4646
electrum_client: Arc<ElectrumClient>,

src/config.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,13 @@ pub(crate) const NODE_ANN_BCAST_INTERVAL: Duration = Duration::from_secs(60 * 60
6565
pub(crate) const WALLET_SYNC_INTERVAL_MINIMUM_SECS: u64 = 10;
6666

6767
// The timeout after which we abort a wallet syncing operation.
68-
pub(crate) const BDK_WALLET_SYNC_TIMEOUT_SECS: u64 = 90;
68+
pub(crate) const BDK_WALLET_SYNC_TIMEOUT_SECS: u64 = 20;
6969

7070
// The timeout after which we abort a wallet syncing operation.
71-
pub(crate) const LDK_WALLET_SYNC_TIMEOUT_SECS: u64 = 30;
71+
pub(crate) const LDK_WALLET_SYNC_TIMEOUT_SECS: u64 = 10;
72+
73+
// The timeout after which we give up waiting on LDK's event handler to exit on shutdown.
74+
pub(crate) const LDK_EVENT_HANDLER_SHUTDOWN_TIMEOUT_SECS: u64 = 30;
7275

7376
// The timeout after which we abort a fee rate cache update operation.
7477
pub(crate) const FEE_RATE_CACHE_UPDATE_TIMEOUT_SECS: u64 = 5;

src/lib.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,9 @@ pub use builder::NodeBuilder as Builder;
127127

128128
use chain::ChainSource;
129129
use config::{
130-
default_user_config, may_announce_channel, ChannelConfig, Config, NODE_ANN_BCAST_INTERVAL,
131-
PEER_RECONNECTION_INTERVAL, RGS_SYNC_INTERVAL,
130+
default_user_config, may_announce_channel, ChannelConfig, Config,
131+
LDK_EVENT_HANDLER_SHUTDOWN_TIMEOUT_SECS, NODE_ANN_BCAST_INTERVAL, PEER_RECONNECTION_INTERVAL,
132+
RGS_SYNC_INTERVAL,
132133
};
133134
use connection::ConnectionManager;
134135
use event::{EventHandler, EventQueue};
@@ -672,13 +673,10 @@ impl Node {
672673
let event_handling_stopped_logger = Arc::clone(&self.logger);
673674
let mut event_handling_stopped_receiver = self.event_handling_stopped_sender.subscribe();
674675

675-
// FIXME: For now, we wait up to 100 secs (BDK_WALLET_SYNC_TIMEOUT_SECS + 10) to allow
676-
// event handling to exit gracefully even if it was blocked on the BDK wallet syncing. We
677-
// should drop this considerably post upgrading to BDK 1.0.
678676
let timeout_res = tokio::task::block_in_place(move || {
679677
runtime.block_on(async {
680678
tokio::time::timeout(
681-
Duration::from_secs(100),
679+
Duration::from_secs(LDK_EVENT_HANDLER_SHUTDOWN_TIMEOUT_SECS),
682680
event_handling_stopped_receiver.changed(),
683681
)
684682
.await

0 commit comments

Comments
 (0)