-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
Background
We noticed that new nodes were taking forever to sync even under ideal environmental conditions. We have correlated this to when the timing of createwallet comes before headers have sync'd.
Our deployments use neutrino to our own colocated servers.
We've long used this deployment flow without issue, but just discovered this after testing greenfield deployments for the first time in awhile.
Your environment
Encountered this on 19.3, reproduced on 19.1
Confirmed that issue is not present in 18.3
(Also tested 19.0 and 19.2 but they have separate issues when attempting to repro, rpc hangs and crashes respectively.)
Tests were run on an Debian 13/amd64 VM with ample memory, bandwidth, and nvme storage
We reproduced this with our two separate neutrino nodes in disparate datacenters, one using btcd 24.2 and the other using Core 26.1.
Steps to reproduce
Start lnd and run create wallet before headers complete sync, observe that syncing then crawls block by block.

A restart of LND then clears this issue.
Expected behaviour
Lnd should report it sync'd to chain once headers sync is complete since the wallet is new and not be delayed by what appears to be a block-level rescan.
Actual behaviour
Seems that because the wallet is created before headers lnd does not know its age and therefore triggers the much slower rescan.
Upon restart (unlock) the situation clears itself, presumably this is because the wallet exists while lnd is at the headers tip and thus no rescan is triggered.
Other thoughts
We've always used walletunlocker to create the wallet once that rpc made itself available, afaik this is the only rpc available before createwallet.
A workaround to this issue for us would be to delay createwallet until after header sync is complete, but we would need to come up with some sketchy log parsing that may not work well in many environments to do so.