This repository has been archived by the owner on Nov 6, 2020. It is now read-only.
Node permission contract enabling leads to CPU overload and peers loosing #10121
Labels
F3-annoyance 💩
The client behaves within expectations, however this “expected behaviour” itself is at issue.
F7-optimisation 💊
An enhancement to provide better overall performance in terms of time-to-completion for a task.
M4-core ⛓
Core client code / Rust.
Milestone
After setting up the chain with node permission contract all parity nodes are loosing all peers within a couple of hours. The contract allows access only to few enode addresses and has the following logic:
While debugging this issue I found out that when parity has zero peers, one of threads eats 100% CPU, which means that parity does not have enough time to react on trying to connect nodes (which was learned here from similar issues about 0 peers).
After removing
nodePermissionContract
from the json spec - the connections get stabilized as well as CPU usage.I went further to the source code and tried to figure out what's going wrong.
I have removed the caching part from the code (LruCache) and the node started to work stable even with node permission contract enabled:
https://github.com/paritytech/parity-ethereum/blob/c077dc652d92535cff0afc9ae096c795c4cf39e3/ethcore/node-filter/src/lib.rs#L87-L90
I do not have too much experience with caching, but it seems to me that either the problem starts to appear when cache gets full or some kind of deadlock happens.
I would add a boot flag like
--disable-node-permission-caching
in order to provide a quick fix for blockchains that currently rely on this contract.What do you think about that?
P.S.: During debugging I found out that the connection allowed check happens BEFORE network ID checking, which leads to huge amount of unnecessary calls to the contract. Was this done intentionally? I would consider move the check to the place when network ID is already checked, if that is possible of course!
The text was updated successfully, but these errors were encountered: