Please describe the feature you’d like to see added.
Currently, we process messages to/from all peers in a loop where every peer is processed once (has the same weight). The list of peers is shuffled before every loop.
Considering a scenario where we spend considerably more CPU time for some peers compared to others, does it make sense to de-prioritize CPU-hungry peers? This might be happening deliberately (a CPU DoS attack) or not.
For example: if we spent 5 CPU seconds to process each one of the peers Bad
and Demanding
and 1 CPU second to process peers Normal
and Light
. Then on the next loop, we can process just Normal
and Light
so they now account to 2 CPU seconds each and skip Bad
and Demanding
. Do a few loops like this until everybody is around 5 CPU seconds and then process all of them again.
I am not sure how much sense this makes, but at least it seems worthy of brainstorming.
Is your feature related to a problem, if so please describe it.
#30572 aims to address a problem of peers sending a lot of costly-to-validate-but-invalid transactions in an attempt to CPU DoS a node. To me it seems that whether those transactions are requested by the victim or are sent unsolicited is secondary. More importantly, willingly or not, some peers are eating the CPU and some not, so this is a broader issue.
Describe the solution you’d like
Aim to spend approximately the same amount of CPU time for every peer. Or, within some reasonable margin, e.g. if the difference between the lightest and the heaviest peer is more than 10x, then trigger some protective mechanism.
Describe any alternatives you’ve considered
Drop unsolicited transactions. IMO that would not really resolve the DoS.
Please leave any additional context
I got this idea while reading https://delvingbitcoin.org/t/cpu-usage-of-peers/196/2