Skip to content

Conversation

Diapolo
Copy link

@Diapolo Diapolo commented Jul 3, 2015

banlist: update set dirty to be more fine grained

  • move the SetBannedSetDirty(false) call from DumpData() into DumpBanlist()
  • ensure we only set false, if the write succeeded

banlist: better handling of banlist in StartNode()

  • only start working on/with banlist data, if reading in the banlist from
    disk didn't fail
  • as CNode::setBannedIsDirty is false (default) when reading fails, we
    don't need to explicitly set it to false to prevent writing banlist.dat
    in that case either

banlist: add more banlist infos to log / add GUI signal

  • to match the peers.dat handling also supply a debug.log entry for how
    many entries were loaded from banlist.dat and how long it took
  • add a GUI init message for loading the banlist (same as with peers.dat)
  • move the same message for peers.dat upwards in the code, to be able to
    reuse the timing variable nStart and also just log, if our read from
    peers.dat didn't fail

banlist (bugfix): allow CNode::SweepBanned() to run on interval

  • allows CNode::SweepBanned() to run, even if !CNode::BannedSetIsDirty(),
    because if nBanUntil is over we want the ban to be disabled for these
    nodes

LogPrintf("Invalid or missing banlist.dat; recreating\n");
} else {
CNode::SetBanned(banmap); // thread save setter
CNode::SetBannedSetDirty(false); // no need to write down, just read data
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line CNode::SetBannedSetDirty(false); should be called even if bandb.Read(ban map) failed.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As written in the code, it is false as default, so it isn't dirty, because no functions were called that change the flag :).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it's default false (net.cppL448)? I would recommend to callCNode::SetBannedSetDirty(false);` when we start up a node. There is no case where the list can be "dirty" in this state.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO an not explicitly initialized bool defaults to false (0).
This call here (where the comment is), is necessary because we just read and didn't change anything, as the CNode::SetBanned() call sets setBannedIsDirty = true.

@jonasschnelli
Copy link
Contributor

utACK (mind the nit above).

}

//try to read stored banlist
uiInterface.InitMessage(_("Loading banned addresses..."));
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jonasschnelli Should this be ips/subnets rather than addresses?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm.... it could be _("Loading banned addresses/subnets...") but if we be particular about this: a subnet defines an amount of "addresses". But i don't care about that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Loading ban list..."

@laanwj laanwj added the P2P label Jul 3, 2015
@Diapolo
Copy link
Author

Diapolo commented Jul 3, 2015

@jonasschnelli Would be nice if you could test this pull and review commit 4, so this can get merged soon. I've got further small fixes for this but don't want to blow up this pull ;).

@Diapolo
Copy link
Author

Diapolo commented Jul 21, 2015

@jonasschnelli Ping

@Diapolo
Copy link
Author

Diapolo commented Jul 29, 2015

@jonasschnelli @laanwj Can we get this in please?

@Diapolo
Copy link
Author

Diapolo commented Aug 10, 2015

@jonasschnelli Too sad you couldn't yet ACK this, mind taking a look?

banmap.size(), GetTimeMillis() - nStart);
LogPrint("net", "Flushed %d banned node ips/subnets to banlist.dat %dms\n",
banmap.size(), GetTimeMillis() - nStart);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

General principle: Code like "if (!dirty) return;" reduces the indentation level for the standard case, and makes the code more readable.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So you would have written?

if (bandb.Write(banmap)) CNode::SetBannedSetDirty(false);

Or are you talking about:

LogPrint("net", "Flushed %d banned node ips/subnets to banlist.dat  %dms\n", banmap.size(), GetTimeMillis() - Start);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it was if (!CNode::BannedSetIsDirty()) return;

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOL, got it now ;)... thanks for that hint.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Diapolo any chance you'll do the early exit as @jgarzik suggested?

@jgarzik
Copy link
Contributor

jgarzik commented Sep 16, 2015

ut ACK

@Diapolo
Copy link
Author

Diapolo commented Sep 16, 2015

@jgarzik Thanks for review :).

@@ -555,11 +555,13 @@ void CNode::SweepBanned()
banmap_t::iterator it = setBanned.begin();
while(it != setBanned.end())
{
CSubNet subNet = (*it).first;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not used a single time currently in net.cpp with (*it), so I'll leave that. But I'm open for further comments on this.

@dcousens
Copy link
Contributor

utACK

@Diapolo
Copy link
Author

Diapolo commented Sep 19, 2015

@dcousens @jgarzik Reworked to fix your valuable nits, can you re-check and re-ACK please?

@dcousens
Copy link
Contributor

@Diapolo re-reviewed commit-by-commit. utACK / concept ACK (683275e)

@Diapolo
Copy link
Author

Diapolo commented Sep 21, 2015

Seems unrelated!?

Running 161 test cases...

No output has been received in the last 10 minutes, this potentially indicates a stalled build or something wrong with the build itself.

The build has been terminated

Philip Kaufmann added 4 commits October 2, 2015 11:38
- move the SetBannedSetDirty(false) call from DumpData() into DumpBanlist()
- ensure we only set false, if the write succeeded
- only start working on/with banlist data, if reading in the banlist from
  disk didn't fail
- as CNode::setBannedIsDirty is false (default) when reading fails, we
  don't need to explicitly set it to false to prevent writing
  banlist.dat in that case either
- to match the peers.dat handling also supply a debug.log entry for how
  many entries were loaded from banlist.dat and how long it took
- add a GUI init message for loading the banlist (same as with peers.dat)

- move the same message for peers.dat upwards in the code, to be able to
  reuse the timing variable nStart and also just log, if our read from
  peers.dat didn't fail
- allows CNode::SweepBanned() to run, even if !CNode::BannedSetIsDirty(),
  because if nBanUntil is over we want the ban to be disabled for these
  nodes
@Diapolo
Copy link
Author

Diapolo commented Oct 9, 2015

What is holding up the merge here?
@jgarzik Ping :)

@dcousens
Copy link
Contributor

utACK

luke-jr pushed a commit to luke-jr/bitcoin that referenced this pull request Oct 15, 2015
@laanwj
Copy link
Member

laanwj commented Oct 27, 2015

All utACK but I can't really see from the code changes whether it's correct. No one has tested this yet? Or is this covered by the current tests?

@Diapolo
Copy link
Author

Diapolo commented Oct 27, 2015

Well, I tested it :-D and I also was aware of these things while @jonasschnelli implemented it, but AFAIK no one was interrested in fixing/improving at that time...

@jonasschnelli
Copy link
Contributor

utACK. A unittest would be nice (or extending the rpc test with some banlist.dat checking on file basis).

@Diapolo Diapolo closed this Oct 31, 2015
@Diapolo Diapolo deleted the banlist branch October 31, 2015 11:27
@luke-jr luke-jr mentioned this pull request Jan 15, 2016
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants