HomePhabricator

Use rolling bloom filter of recent block tx's for AlreadyHave() check

Description

Use rolling bloom filter of recent block tx's for AlreadyHave() check

Summary:

In order to determine whether to download or process a relayed transaction, we
try to determine if we already have the transaction, either in the mempool, in
our recently rejected filter, in our orphan pool, or already confirmed in the
chain itself.

Prior to this commit, the heuristic for checking the chain is based on whether
there's an output corresponding to the 0- or 1-index vout in our coin cache.
While that is a quick check, it is very imprecise (say if those outputs were
already spent in a block) -- we can do better by just keeping a rolling bloom
filter of the transactions in recent blocks, which will capture the case of a
transaction which has been confirmed and then fully spent already.

To avoid relay problems for transactions which have been included in a recent
block but then reorged out of the chain, we clear the bloom filter whenever a
block is disconnected.

This is a backport of PR17951

Test Plan: ninja all check-all

Reviewers: #bitcoin_abc, majcosta, deadalnix

Reviewed By: #bitcoin_abc, majcosta, deadalnix

Subscribers: deadalnix, majcosta

Differential Revision: https://reviews.bitcoinabc.org/D8695

Details

Provenance
Suhas Daftuar <sdaftuar@gmail.com>Authored on Dec 23 2020, 09:32
PiRKCommitted on Dec 23 2020, 09:32
abc-botPushed on Dec 23 2020, 09:36
Reviewer
Restricted Project
Differential Revision
D8695: Use rolling bloom filter of recent block tx's for AlreadyHave() check
Parents
rABCbf384a3c4786: Qt: pass clientmodel changes from walletframe to walletviews
Branches
Unknown
Tags
Unknown