Skip to content

Commit d76160d

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 5a521c1 commit d76160d

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
@@ -126,8 +126,9 @@ pub use builder::NodeBuilder as Builder;
126126

127127
use chain::ChainSource;
128128
use config::{
129-
default_user_config, may_announce_channel, ChannelConfig, Config, NODE_ANN_BCAST_INTERVAL,
130-
PEER_RECONNECTION_INTERVAL, RGS_SYNC_INTERVAL,
129+
default_user_config, may_announce_channel, ChannelConfig, Config,
130+
LDK_EVENT_HANDLER_SHUTDOWN_TIMEOUT_SECS, NODE_ANN_BCAST_INTERVAL, PEER_RECONNECTION_INTERVAL,
131+
RGS_SYNC_INTERVAL,
131132
};
132133
use connection::ConnectionManager;
133134
use event::{EventHandler, EventQueue};
@@ -677,13 +678,10 @@ impl Node {
677678
let event_handling_stopped_logger = Arc::clone(&self.logger);
678679
let mut event_handling_stopped_receiver = self.event_handling_stopped_sender.subscribe();
679680

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

0 commit comments

Comments
 (0)