AleoNet / snarkOS

A Decentralized Operating System for ZK Applications
http://snarkos.org
Apache License 2.0
4.32k stars 2.62k forks source link

fix(tcp): fix outbound tcp requests not respecting --node bind port #3318

Closed Meshiest closed 3 months ago

Meshiest commented 3 months ago

Motivation

These changes force outgoing TCP connections to respect the address configured by the --node flag. When not properly bound, peers of multi-home/multi-address hosts are broadcasting incorrect socket addresses, which can increase load on unrelated nodes.

Example scenario (based off of our canary nodes, all 3 nodes running on the same server):

  1. client 1 bound on 6.5.4.100
  2. client 2 bound on 6.5.4.101
  3. client 3 bound on 6.5.4.102
  4. clients 2 and 3 make outgoing connection requests on 6.5.4.100, rather than .101 or .102
  5. the wrong socket address is extrapolated for successive peer requests

Side-effects of not binding the correct address:

Test Plan

We are successfully running this on canary, and this is a minimal change based on tokio's documentation

apruden2008 commented 3 months ago

@zosorock this is good to merge pending CI passing