5

In BIP157, under "Client Operation", we have the following paragraph:

Starting from the first block in the desired range, the client now MAY download the filters. The client SHOULD test that each filter links to its corresponding filter header and ban peers that send incorrect filters. The client MAY download multiple filters at once to increase throughput, though it SHOULD test the filters sequentially. [...]

I'm wondering about the bolded part: why should the client test the filters in sequence? Why can't it test them as it receives them? I'm having a hard time coming up with a good reason to test them sequentially. Anyone knows?

1 Answer 1

4

A HD wallet doesn’t know what indexes of a seed to scan for until the ones prior have been used, which can’t be discovered out of order. To allow for out of order scanning the address gap limit would need to be prohibitively large, and might still result in re-scanning filters if the wallet is particularly active.

4
  • Hmm, but I was under the impression that the wallet would have to scan up to the gap-limit anyway, in case some of the indexes end up being "skipped", eg. 3 addresses are generated, but only the 3rd ends up being used.
    – cloudhead
    Commented Dec 29, 2020 at 10:32
  • Thinking about this more, it makes sense if what you mean is that we need to scan up to highest_used_index + gap_limit, such that everytime a higher index is used, we scan further. Is that the idea?
    – cloudhead
    Commented Dec 29, 2020 at 10:53
  • 2
    Yes, that's exactly the point: the address body is expanded as time progresses and you might not have derived sufficient addresses to find all your transactions if you start with later blocks. On the other hand, if you just set an enormous gap limit, scanning the blocks for matches will take forever.
    – Murch
    Commented Dec 29, 2020 at 11:30
  • 1
    Especially in the case of systems like BIP157, having a large gap limit just reduces inefficiency as the filters get dirtier unnecessarily. Scanning them only sequentially isn't of particular concern regardless as they tend to be processed rather quickly once received (or cached).
    – Claris
    Commented Dec 29, 2020 at 11:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.