Skip to content

Conversation

@jamescowens
Copy link
Member

@jamescowens jamescowens commented Sep 29, 2019

The design is a sparse map keyed by CAddress, where no entry means a misbehavior of zero.
If a node is banned, the misbehavior entry is left in place. It is erased (meaning zeroed...) when the node is unbanned, or the banlist is cleared. This is done by match to sub_net, because manual bans can be placed on individual addresses or entire subnets. Automatic bans are always on individual addresses (subnets with /32 mask) and misbehaviors are also on individual addresses and the service port number (CAddress).

I have debated whether the banlist should be indexed by CNetAddr rather than CAddress, and have decided CAddress (which includes the remote port number) is the right one. Someone could have several nodes running on the same address through port forwarding/NAT, and if we use CNetAddr only, if one node misbhehaves, it would result in banning all nodes behind the address. The disadvantage of CAddress is that a node that disconnects and reconnects using different port numbers can evade banning for moderate misbehavior by spreading out the misbehavior to multiple CAddress entries corresponding to different ports with the same IP.

misbehavior also decays linearly by default banscore (100) / 86400 every second.

This also implements the peers tab on the debug console, which allows GUI users to interact with the nodes and ban/unban by right-clicking.

Also implement misbehavior increment check.
@jamescowens jamescowens self-assigned this Sep 29, 2019
@jamescowens jamescowens added this to the Fern milestone Sep 29, 2019
@jamescowens
Copy link
Member Author

Note that I have tested this on testnet and a crippled node on mainnet with good results. The DoS BOOST unit tests have also been expanded to cover the new functionality.

Copy link
Member

@cyrossignol cyrossignol left a comment

Choose a reason for hiding this comment

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

This looks great so far. Will do some more in-depth testing tomorrow.

@jamescowens
Copy link
Member Author

I wonder if the default decay rate is too rapid? I should probably put a tunable in there for the rate, with a default value.

@jamescowens jamescowens changed the title New banning misbehavior handling New banning misbehavior handling and Peers Tab on Debug Console Sep 30, 2019
@jamescowens jamescowens force-pushed the new_banning_system_time_decay branch from c8ff963 to f2ce505 Compare September 30, 2019 01:59
@iFoggz
Copy link
Member

iFoggz commented Sep 30, 2019

Would like to see this for more testing and testing on a heavy node.

@jamescowens jamescowens force-pushed the new_banning_system_time_decay branch from f2ce505 to 30eb261 Compare September 30, 2019 04:49
@jamescowens
Copy link
Member Author

jamescowens commented Sep 30, 2019

The latest force push looks really good to me. Compiles and runs well on all my devices...
OpenSuSE x86_64
Ubuntu 18.04
Windows 64-bit and 32-bit
Ubuntu 18.04 Odroid XU4 (ARM)

I don't have a Mac to check that.

I am running on my scraper node for mainnet with good results.

@jamescowens
Copy link
Member Author

Here is a screenshot of this running on my Windows testnet node...
image
Notice there is an IPv6 address in there!

@iFoggz
Copy link
Member

iFoggz commented Sep 30, 2019

yup ipv6 is a growing in usage. my big node has ipv6 as well. ipv6 also reduces nat issues and also ipv6 is preferred over ipv4 if both available.

Copy link
Member

@cyrossignol cyrossignol left a comment

Choose a reason for hiding this comment

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

Seems like everything is working and the new tab looks great 🙂

src/net.cpp Outdated
// Allow newbies to connect easily
int64_t nTime = GetAdjustedTime();
if (nTime - pnode->nTimeConnected > 24)
if (nTime - pnode->nTimeConnected > 45)
Copy link
Member

Choose a reason for hiding this comment

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

Just curious... what's the reason for this change?

Copy link
Member Author

Choose a reason for hiding this comment

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

due to our older net code, bignodes sometimes do not send a version message within that period of connecting, so I upped it. #1548 optimizes this portion of net processing and actually gets rid of that setting altogether.

@jamescowens
Copy link
Member Author

This is to prevent conflicts with #1538.

@jamescowens jamescowens merged commit c4bd55a into gridcoin-community:development Oct 1, 2019
jamescowens added a commit that referenced this pull request Oct 22, 2019
Added
 - Add testnet desktop launcher action for Linux #1516 (@caraka)
 - Shuffle vSideStakeAlloc if necessary to support sidestaking to more than 6 destinations #1532 (@jamescowens)
 - New Superblock format preparations for Fern #1526, #1542 (@jamescowens, @cyrossignol)
 - Multisigtools
   - Consolidate multisig unspent #1529 (@iFoggz)
   - Scanforunspent #1547 (@iFoggz)
   - consolidatemsunspent and scanforunspent bug fix #1561 (@iFoggz)
 - New banning misbehavior handling and Peers Tab on Debug Console #1537 (@jamescowens)
 - Reimplement getunconfirmedbalance rpc #1548 (@jamescowens)
 - Add CLI switch to display binary version #1553 (@cyrossignol)

Changed
 - Select smallest coins for contracts #1519 (@iFoggz)
 - Move some functionality from miner to SelectCoinsForStaking + Respect the coin reserve setting + Randomize UTXO order #1525 (@iFoggz)
 - For voting - if url does not contain http then add it #1531 (@iFoggz)
 - Backport newer serialization facilities from Bitcoin #1535 (@cyrossignol)
 - Refactor ThreadSocketHandler2() Inactivity checks #1538 (@iFoggz)
 - Update outdated checkpoints #1539 (@barton2526)
 - Change needed to build Gridcoin for OSX using homebrew #1540 (@Git-Jiro)
 - Optimize scraper traffic for expiring manifests #1542 (@jamescowens)
 - Move legacy neural vote warnings to debug log level #1560 (@cyrossignol)
 - Change banlist save interval to 5 minutes #1564 (@jamescowens)
 - Change default rpcconsole.ui window size to better support new Peers tab #1566 (@jamescowens)

Removed
 - Remove deprecated RSA weight and legacy kernel #1507 (@cyrossignol)

Fixed
 - Clean up compiler warnings #1521 (@cyrossignol)
 - Handle missing external CPID in client_state.xml #1530 (@cyrossignol)
 - Support boost 1.70+ #1533 (@iFoggz)
 - Fix diagnostics failed to make connection to NTP server #1545 (@Git-Jiro)
 - Install manpages in correct system location #1546 (@Git-Jiro)
 - Fix ability to show help and version without a config file #1553 (@cyrossignol)
 - Refactor QT UI variable names to be more consistent, Fix Difficulty default #1563 (@barton2526)
 - Fix two regressions in previous UI refactor #1565 (@barton2526)
 - Fix "Owed" amount in output of "magnitude" RPC method #1569 (@cyrossignol)
@jamescowens jamescowens deleted the new_banning_system_time_decay branch November 21, 2019 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants