Repository navigation
banlist: log post-swept banlist size at startup - #19470
Conversation
We are currently logging the size of the banlist before SweepBanned() has been called, meaning the value may be incorrect.
|
Code review ACK 0b8ba84 |
|
Code review ACK 0b8ba84 Now that the local |
jonatack
left a comment
There was a problem hiding this comment.
Code review ACK 0b8ba84 m_banned is set in SetBanned and is updated by SweepBanned before the logging.
In a couple of manual checks, both master and this branch logged the correct number with 0 and 1 banned peers using setban/clearbanned, so I didn't hit the timing to produce a wrong count.
| @@ -26,7 +26,7 @@ BanMan::BanMan(fs::path ban_file, CClientUIInterface* client_interface, int64_t | |||
| SweepBanned(); // sweep out unused entries | |||
|
|
|||
| LogPrint(BCLog::NET, "Loaded %d banned node ips/subnets from banlist.dat %dms\n", | |||
There was a problem hiding this comment.
FWIW I would find this logging handy as a regular debug log LogPrintf, like the other ones in this function.
You can observe the issue on master by just setting a short ban, and restarting bitcoind. i.e: src/bitcoind -regtest
# set a short-lived ban
src/bitcoin-cli -regtest setban "2001:4d48:ac57:400:cacf:e9ff:fe1d:1" "add" "10"
# shutdown bitcoind, wait 11 seconds, restart bitcoind
....
2020-07-09T12:06:54.944698Z [init] SweepBanned: Removed banned node ip/subnet from banlist.dat: 2001:4d48:ac57:400:cacf:e9ff:fe1d:1/128
2020-07-09T12:06:54.944731Z [init] Loaded 1 banned node ips/subnets from banlist.dat 0msThe loaded count is logged as |
|
Ok, reproduced on mainnet. I wasn't shutting down bitcoind fast enough before it expired. |
Summary: We are currently logging the size of the banlist before SweepBanned() has been called, meaning the value may be incorrect. This is a backport of [[bitcoin/bitcoin#19470 | core#19470]] Test Plan: `ninja all check-all` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D9583
0b8ba84 banlist: log post-swept banlist size at startup (fanquake) Pull request description: We are currently logging the size of the banlist from before `SweepBanned()` has been called, meaning the value may be incorrect. i.e banlist.dat had `1`ban. That ban is swept on startup. We log "loaded 1 banned node..". Actual banlist size is `0`. ACKs for top commit: jonatack: Code review ACK 0b8ba84 `m_banned` is set in SetBanned and is updated by SweepBanned before the logging. laanwj: Code review ACK 0b8ba84 jnewbery: Code review ACK 0b8ba84 Tree-SHA512: 1d6e363d6c68d7cc214dd685df3d2d27572f6a58a4c0e43c03cfbb03bc01badb6a10ecae403d137094bb316d27f33feb6be15b4e23ef1e9496cd0b3c23c21698
We are currently logging the size of the banlist from before
SweepBanned()has been called, meaning the value may be incorrect.i.e banlist.dat had
1ban. That ban is swept on startup. We log "loaded 1 banned node..". Actual banlist size is0.