CBloomFilter: Missing updateemptyfull? #16886
issue alexzk1 openend this issue on September 16, 2019-
alexzk1 commented at 4:31 pm on September 16, 2019: noneOn processing command filteradd (if (strCommand == NetMsgType::FILTERADD)) in net_processing.cpp it does not call pfilter->UpdateEmptyFull() while command filterload do that. Is it bug?
-
alexzk1 added the label Bug on Sep 16, 2019
-
fanquake added the label P2P on Sep 16, 2019
-
theStack commented at 12:51 pm on September 19, 2019: memberIt’s not a bug, but rather a missed performance improvement: the purpose of
CBloomFilter::UpdateEmptyFull()
is to set the flagsisEmpty
(filter is all zero-bits) andisFull
(filter is all one-bits) which in turn are checked in the in-set functionCBloomFilter::contains()
to avoid unnecessarily wasting time for those two corner-cases. Since theCBloomFilter::insert()
operation could lead to a full bloom filter, it makes in my opinion perfect sense to update theisFull
flag after via callingUpdateEmptyFull()
. -
MarcoFalke removed the label Bug on Sep 19, 2019
-
MarcoFalke renamed this:
Missing updateemptyfull?
CBloomFilter: Missing updateemptyfull?
on Sep 19, 2019 -
theStack referenced this in commit 9a2eee9082 on Sep 19, 2019
-
alexzk1 commented at 6:39 pm on September 20, 2019: noneGuess, UpdateEmptyFull must be private method and called from insert/add/copy filter from inside class CBloomFilter. That could make impossible such “forgot”.
-
alexzk1 commented at 7:35 pm on September 22, 2019: none
@alexzk1 note that
insert()
is called in a loop soUpdateEmptyFull
would be called unnecessarily.Shouldn’t it be for each insert ? As I recall inserting into full filter is invalid, so any way must check if full prior next insert. But I can be wrong about.
-
theStack commented at 9:01 pm on September 22, 2019: member
@alexzk1 note that
insert()
is called in a loop soUpdateEmptyFull
would be called unnecessarily.Shouldn’t it be for each insert ? As I recall inserting into full filter is invalid, so any way must check if full prior next insert. But I can be wrong about.
Note that explicitely keeping track of whether a filter is full or empty is not necessary for correctness, but is only an optimization (“to avoid wasting cpu”, as the comment for the update function in
bloom.h
puts it), introduced with commit 37c6389c5a0ca63ae3573440ecdfe95d28ad8f07. Inserting into a full filter is not invalid, but rather a waste of time – since all bits are already set, setting any bit again doesn’t change the state. -
theStack referenced this in commit b1dcc89084 on Oct 10, 2019
-
theStack commented at 3:04 pm on April 28, 2020: memberConsidering that the primary point of introducing those empty/full-flags was not optimization, but a covert fix for CVE-2013-5700 (see gmaxwells comments about commit 37c6389: #18483 (comment) and #9060 (comment)), I think this issue can be closed.
-
MarcoFalke closed this on Apr 28, 2020
-
fanquake referenced this in commit 551dc7f664 on May 6, 2020
-
sidhujag referenced this in commit e9d4768e75 on May 12, 2020
-
MarcoFalke locked this on Feb 15, 2022
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-10-30 00:12 UTC
More mirrored repositories can be found on mirror.b10c.me