Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
[net] listbanned RPC and QT should show correct banned subnets #10234
Conversation
|
Nice find. Though I can't think of a good reason why we'd ever want a stale list coming out of GetBanned(). Why not just sweep there? |
|
utACK ea2c925 |
Right. If you think that's ok, then calling sweep from with |
fanquake
added
the
P2P
label
Apr 19, 2017
added a commit
to bitcoinknots/bitcoin
that referenced
this pull request
Apr 21, 2017
added a commit
to bitcoinknots/bitcoin
that referenced
this pull request
Apr 21, 2017
|
Needs rebase |
|
Discussion on IRC: the |
|
rebased with fix to disconnect_ban.py test suite. |
|
@jnewbery Yea, I'd prefer to see this moved to GetBanned(). Otherwise correct usage just isn't obvious enough (as evidenced by this bug). Ideally the sweep would be a static function operating on a banlist_t rather than this, but I don't think it's worth worrying about. Looks like the only other change needed would be: @@ -496,10 +499,9 @@ void CConnman::DumpBanlist()
CBanDB bandb;
banmap_t banmap;
- SetBannedSetDirty(false);
GetBanned(banmap);
- if (!bandb.Write(banmap))
- SetBannedSetDirty(true);
+ if (bandb.Write(banmap))
+ SetBannedSetDirty(false);Note that this code is pretty racy either way. We should fix that as a follow-up. |
jnewbery
added some commits
Apr 19, 2017
|
thanks @theuni - that's definitely cleaner. I've changed this PR to use your fix. |
|
It fails locally here (every time, not just intermittently):
|
|
@laanwj that's very strange. The test passes for me consistently, and also passes on travis. Can you try rebuilding and clearing the functional test cache. If it's still failing, can you send me the test logs? |
|
Seems to work now. Strange. |
jnewbery commentedApr 19, 2017
The listbanned RPC and QT show entries in the connman.setBanned set, even if the entry has expired. Expired entries in the set are only swept in the following circumstances:
That means that the list of banned subnets returned by listbanned is inconsistent. If the node has been stop-started or the setban/clearbanned RPC has been called, then stale entries won't be shown. If the node hasn't been stop-started and those RPCs haven't been called, then stale entries will be shown.
This PR calls SweepBanned() before GetBanned() in the listbanned RPC and QT, so all calls to GetBanned() return an up-to-date list of banned subnets.
This PR also adds a test to nodehandling to test the behaviour.
@jonasschnelli @sdaftuar