Backport net.py
Summary:
This is a backport of core's PR10077, PR10264 and PR10224
Depends on D956
Test Plan:
make check ./test/functional/test_runner.py net.py
Reviewers: #bitcoin_abc, schancel
Reviewed By: #bitcoin_abc, schancel
Differential Revision: https://reviews.bitcoinabc.org/D965