Skip to content

bug: node start takes up to a minute since ldk-node rc.82 #2219

Done

Description

@jvsena42

What happened

Found in mainnet QA of 3.2.0 RC2 (build 199, Android 17). Starting the node takes much longer on 3.2.0 than on 3.1.1 on the same phone and network, also after the only channel was closed. Until it starts, the Send sheet shows "Connecting to network".

The step that grew is LDK persisting the channel monitor while the node is built, which writes to VSS:

Build Got new ChannelMonitor → Persistence … completed
3.1.1 (10 starts, 2026-11-15 to 2026-11-30) 0.3–0.4 s every time
3.2.0 (16 starts, 2026-11-30 to 2026-12-01) 0.8, 1.0, 1.8, 3.3, 3.6, 8.6, 8.7, 8.7, 16.4, 41.4, 49.0, 62.2 s; the last session (after the channel was closed) had not finished after 49 s

Building the node (before this step) also loads five extra on-chain wallet accounts at about 2 s each; that cost is the same on 3.1.1 and is not the regression.

Logs

3.1.1:

2026-11-30 09:44:22.841 VERBOSE [LightningService.kt:366] Building node with vssUrl: 'https://bitkit.to/vss_rs_auth' lnurlAuthServerUrl: 'https://bitkit.to/lnurl_auth/auth'
2026-11-30 09:44:45.253 TRACE [lightning::chain::chainmonitor:1373] Got new ChannelMonitor for channel 22996d62f741…
2026-11-30 09:44:45.550 INFO [lightning::chain::chainmonitor:1387] Persistence of new ChannelMonitor for channel 22996d62f741… completed
2026-11-30 09:44:45.837 DEBUG [LightningService.kt:421] Starting node… - LightningService

3.2.0:

2026-12-01 10:18:27.308 VERBOSE [LightningService.kt:459] Building node with vssUrl: 'https://api.bitkit.to/vss_rs_auth' lnurlAuthServerUrl: 'https://api.bitkit.to/lnurl_auth/auth' keyDomain: 'bitkit.to'
2026-12-01 10:18:45.622 INFO [ldk_node::builder:1679] Loaded configured wallet for OnchainWalletAccount { address_type: NativeSegwit, account_index: 6 }
2026-12-01 10:18:49.694 TRACE [lightning::chain::chainmonitor:1373] Got new ChannelMonitor for channel 22996d62f741…
2026-12-01 10:19:38.722 INFO [lightning::chain::chainmonitor:1387] Persistence of new ChannelMonitor for channel 22996d62f741… completed
2026-12-01 10:19:39.030 DEBUG [LightningService.kt:538] Starting node… - LightningService

After the channel was closed cooperatively at 10:37, the next start also force-closed the closed channel's monitor and tried to rebroadcast its commitment:

2026-12-01 11:44:08.134 [lightning::ln::channelmanager:17197] Queueing monitor update to ensure missing channel 22996d62f741… is force closed
2026-12-01 11:44:13.651 ERROR [ldk_node::chain::electrum:1051] Failed to broadcast transaction 68182f5db3c6…: Made one or multiple attempts, all errored: - invalid type: null, expected an ASCII hex string …
2026-12-01 11:44:48.758 VERBOSE [LightningService.kt:459] Building node with vssUrl: 'https://api.bitkit.to/vss_rs_auth' …
2026-12-01 11:45:10.621 TRACE [lightning::chain::chainmonitor:1373] Got new ChannelMonitor for channel 22996d62f741…
(no "Persistence … completed" or "Starting node…" by the time logs were exported at 11:45:59; support snapshot lifecycle 'Starting')

What changed between the two builds

Likely cause: ldk-node 9ab24d5 ("fence a replaced vss store's writes", released in rc.82). At rc.84, src/io/vss_store.rs:348-354 adds separate blocking_write_client / async_write_client with no_retry_policy(), retried through fenced_retry with WRITE_ATTEMPT_TIMEOUT = 30 s (:79). rc.80 had only the read clients. The build's first monitor write now opens a fresh TLS connection instead of reusing the read client's warm one, and a slow or rejected new connect costs a full request timeout before the retry. App side, LightningService.setup() (LightningService.kt:357-382) holds lifecycleMutex (LightningRepo.kt:487) for the whole build, so every node operation waits on it.

Not yet confirmed: the same start on rc.80 vs rc.84 on one network, timing Got new ChannelMonitor → Persistence … completed. This likely also needs an upstream issue in synonymdev/ldk-node.

Expected

The node starts in about the time 3.1.1 took. A closed channel's monitor is not force-closed and re-persisted on every start.

Activity

  1. added
    bug
    on Dec 1, 2026
  2. added this to the 3.2.0 milestone on Dec 1, 2026
  3. ovitrif commented on Dec 1, 2026

    @ovitrif
    Collaborator

    Placing this in the 3.2.0 milestone as an RC blocker candidate: it is a regression from the release's own ldk-node bump (rc.80 → rc.84, #2197), visible on every node start, with "Connecting to network" for up to a minute. iOS ships the same ldk-node rc.84 (synonymdev/bitkit-ios#1550), so it likely starts slowly too. The rc.80 vs rc.84 timing on one network would confirm the cause.

  4. self-assigned this
    on Dec 1, 2026
  5. ovitrif commented on Dec 1, 2026

    @ovitrif
    Collaborator

    First timings: the slow write doesn't reproduce from a desktop network, on any host.

    Store level (ldk-node rc.84, fresh store, 150 KB write to monitors/, attempts counted):

    VSS Auth First monitor write Later writes Attempts
    staging upstream LNURL-auth 0.31–0.42 s 0.19–0.28 s 1 each
    api.bitkit.to key domain bitkit.to, 60 reads first 0.43–0.45 s 0.22–0.27 s 1 each
    bitkit.to 60 reads first 0.44–0.46 s 0.22–0.28 s 1 each

    Full node (rc.84, regtest, staging VSS with LNURL-auth, one channel, 3 restarts): Got new ChannelMonitor → Persistence … completed took 0.12–0.13 s; build took 1.1–1.3 s.

    • bitkit.to and api.bitkit.to resolve to the same IP, with about 0.1 s TLS each, so the host move alone doesn't explain it.
    • The span is a single call: watch_channel → MonitorUpdatingPersister::persist_new_channel → one VSS putObjects of the full monitor.
    • What changed since rc.80 is how that write reaches the network. Since rc.82 writes have their own reqwest pool (blocking_write_client / async_write_client), so the first monitor write pays a new DNS lookup, TCP connect and TLS handshake that rc.80 skipped by reusing the reads' warm connection. Its retries also run in fenced_retry: 10 ms doubling backoff, 30 s per attempt. That fits the 0.8 s floor on a phone. If the new connection fails a few times, it also fits the long tail: 41 s is about 12 failed attempts of doubling backoff. Not confirmed: rc.84 doesn't log failed write attempts.
    • It predicts RC1 (rc.82) is as slow as RC2, which Piotr's RC1-vs-RC2 comparison would show.
    • iOS release-3.2.0 pins the same rc.84.

    Closed channel force-closed on start: LDK 0.2.8 queues ChannelForceClosed { should_broadcast: true } on load for a monitor with no channel in the manager that hasn't seen the funding spend (no_further_updates_allowed() false), which rebroadcasts its commitment. So the 11:44 start loaded a monitor that never persisted the closing tx's confirmation: either no block was processed before the stop, or the monitor writes after the close didn't land.

    Next: rc.80 vs rc.84 through a proxy that makes new connections slow or fail. If rc.84 alone slows down, the fix is to share one connection pool between reads and writes, keeping fenced_retry.

  6. ovitrif commented on Dec 1, 2026

    @ovitrif
    Collaborator

    Cause confirmed on rc.84; fix in synonymdev/ldk-node#147.

    A local proxy that makes new connections slow or fail separates the versions:

    2 s added to each new connection First 4 new connections fail
    rc.80 first monitor write 0.21–0.37 s no failed attempts
    rc.84 2.33–2.41 s 5 attempts, 0.63–0.92 s
    synonymdev/ldk-node#147 0.38 s no failed attempts

    rc.80 writes over the connection the reads just opened. rc.84 opens a new one for the first write, so every start pays that connect, and on a phone any failed connect adds a retry. synonymdev/ldk-node#147 shares one HTTP client between each side's reads and writes and keeps fenced_retry as is. It doesn't roll anything back from rc.82–rc.84, so the shutdown crash fix and the stale-write protection stay.

    Once it's approved: release 0.7.0-rc.85, then bump both apps on release-3.2.0. Phone start times on that build still need checking against 3.1.1's 0.3–0.4 s.

  7. ovitrif commented on Dec 1, 2026

    @ovitrif
    Collaborator

    Same A/B on rc.82 (RC1): the first monitor write takes 2.30–2.50 s with 2 s added per new connection, and needs 5 attempts when the first 4 connects fail, as on rc.84. So RC1 is affected too, and rc.83's LNURL-auth key domain isn't the cause.

    iOS release-3.2.0 builds the node the same way (buildWithVssStoreAndLnurlAuthKeyDomain on rc.84), so it goes through the same write path. An iOS device start timing still needs a tester.

    synonymdev/ldk-node#147 doesn't touch the closed-channel force-close on start. That one is LDK's load path for a monitor that never persisted the closing tx's confirmation, so this issue stays open for it after the bumps.

  8. ovitrif commented on Dec 1, 2026

    @ovitrif
    Collaborator

    Slow restore on 3.2.0 (Pixel 10 Pro, mainnet, no channels): it isn't the VSS monitor write. synonymdev/ldk-node#147 doesn't change it.

    This wallet has no channels, so there's no Got new ChannelMonitor line and no monitor write. The restore took 3 min 16 s. About 178 s of that went to five keychain passes over the WALLET backup, around 35 s each:

    Pass Keychain call Time
    1 restoreUsdtRecovery: upsert USDT_PENDING_BACKUP_RESTORE 35.6 s
    2 restoreUsdtRecovery: upsert PAYKIT_PENDING_BACKUP_RESTORE 35.4 s
    3 performFullRestoreFromLatestBackup: load PAYKIT_PENDING_BACKUP_RESTORE 34.7 s
    4 restoreWalletBackup: upsert PAYKIT_PENDING_BACKUP_RESTORE 35.9 s
    5 retainRecoveryBackup: upsert PAYKIT_RECOVERY_BACKUP 36.0 s
    • The stored PAYKIT_RECOVERY_BACKUP is 3.04 MB of base64, about 2.3 MB of data. Every other keychain entry is under 1.2 KB.
    • Small upserts in the same restore took 0.12–0.16 s with the 3 MB entry already in the file. So the time goes to encrypting or decrypting the large value, not to rewriting the DataStore file.
    • About 65 KB/s is consistent with the StrongBox-backed key AndroidKeyStore creates when the device has one (this phone does).

    The node start was slow because of this:

    • AndroidKeyStore.encrypt and decrypt are @Synchronized, so every keychain read waits behind a large pass.
    • LightningService.buildNode loads BIP39_MNEMONIC and waited 19.6 s, until pass 1 finished.
    • Then VssBackupClientLdk.setup loads it again and waited 35.4 s, until pass 2 finished.
    • So the node build waited about 55 s on the keychain. At the same point, regular starts on this phone take 0.1–0.4 s.

    The same keychain passes are already in v3.1.1; 3.2.0 only adds the small PAYKIT_ALLOWANCE_RESTORE_PAUSE write. The time grows with the size of the WALLET backup, so this needs its own issue rather than a place in RC3. Fix options:

    • Hold the retained backup outside the StrongBox keychain.
    • Encrypt and decrypt it once per restore instead of five times.
  9. ovitrif commented on Dec 1, 2026

    @ovitrif
    Collaborator

    @jvsena42's RC2 export agrees with the cause fixed in synonymdev/ldk-node#147.

    First monitor write per node start, 3.2.0 (Got new ChannelMonitor → Persistence … completed), against other requests in the app that failed to connect meanwhile (transport_error, error sending request):

    Write Failed requests elsewhere meanwhile
    0.8 s (×4), 1.0 s, 1.8 s 0
    3.3 s, 3.6 s 0, 1
    8.6–8.7 s (×3), 16.4 s 0–1
    41.4 s 1
    49.0 s 4
    62.2 s 17
    unfinished (the app went to the background 23 s in) 35 after it began
    • In the 49 s and unfinished starts, the store's reads (wallets, monitors) succeed seconds before the write. Only the write is stuck.
    • rc.84 opens a new connection for that first write, so a network that drops new connects sends it through fenced_retry's backoff. That is the case the proxy A/B reproduced, and rc.85 writes over the reads' connection instead.
    • The 0.8 s floor, against 0.3 s on 3.1.1, is that extra TLS connect.
    • rc.84 logs no failed write attempts, so the attempt count per start can't be read from these logs.
  10. ovitrif commented on Dec 1, 2026

    @ovitrif
    Collaborator

    #2224 closes this issue with the start-time fix (ldk-node 0.7.0-rc.85, also in #2222 for RC3). The rest is split out:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions