lightninglabs / neutrino

Privacy-Preserving Bitcoin Light Client
MIT License
894 stars 182 forks source link

rescan: use batch filter fetching #275

Closed ellemouton closed 1 year ago

ellemouton commented 1 year ago

With this PR, we ensure that rescan can make use of batch filter fetching by waiting until the header chain is either current or until it is ahead of the specified end height before starting the scan. This greatly improves the speed of a rescan because before this commit, the filters would be fetched one-by-one.

The first few commits of this PR are just refactor commits that clean-up the rescan function and then the actual behaviour change is added in the final commit.

Fixes https://github.com/lightninglabs/neutrino/issues/68 Replaces https://github.com/lightninglabs/neutrino/pull/236

Performance Improvement

On current master branch, syncing 3200 filters on my local regtest network takes 4m25s With this PR, syncing the same number of filters takes 653ms

LND CI

https://github.com/lightningnetwork/lnd/pull/7788

lightninglabs-deploy commented 1 year ago

@roasbeef: review reminder

saubyk commented 1 year ago

cc @ProofOfKeags for review request

ProofOfKeags commented 1 year ago

post merge ACK b38fa7f

It took me a sec to realize most of the diff was just nesting some values under the state structure. Seems like the only major change was blocking on waiting for the header chain to get far enough ahead to maximize the benefits of batching.