HomePhabricator

net: limit BIP37 filter lifespan (active between 'filterload'..'filterclear')

Description

net: limit BIP37 filter lifespan (active between 'filterload'..'filterclear')

Summary:

net: limit BIP37 filter lifespan (active between 'filterload' and 'filterclear')
Previously, a default match-everything bloom filter was set for every peer,
i.e. even before receiving a 'filterload' message and after receiving a
'filterclear' message code branches checking for the existence of the filter
by testing the pointer "pfilter" were _always_ executed.

test: add more inactive filter tests to p2p_filter.py
check the following expected behaviors if no filter is set:
-> filtered block requests are ignored by the node
-> sending a 'filteradd' message is treated as misbehavior

also fixes a bug in the on_inv() callback method, which
directly modified the type from BLOCK to FILTERED_BLOCK
in the received 'inv' message rather than just for the reply

Co-authored-by: MarcoFalke <falke.marco@gmail.com>

This is a backport of Core PR18544

I had to change the last test to use a different way to detect misbehavior, because banscore was deprecated in D8798 (this would have been applied in PR18672, if the backports had been done in sequential order)

Test Plan: ninja all check-all

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

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

Details

Provenance
Sebastian Falbesoner <sebastian.falbesoner@gmail.com>Authored on Apr 6 2020, 15:34
PiRKCommitted on Jan 19 2021, 08:57
PiRKPushed on Jan 19 2021, 08:57
Reviewer
Restricted Project
Differential Revision
D8949: net: limit BIP37 filter lifespan (active between 'filterload'..'filterclear')
Parents
rABC616dff33486e: [Cashtab] More clarity and tests for address parsing
Branches
Unknown
Tags
Unknown