Reduced number of addresses per NodeID in peermanager to 1#2990
Reduced number of addresses per NodeID in peermanager to 1#2990
Conversation
|
The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2990 +/- ##
===========================================
+ Coverage 58.08% 71.76% +13.67%
===========================================
Files 2109 22 -2087
Lines 173234 1948 -171286
===========================================
- Hits 100626 1398 -99228
+ Misses 63664 450 -63214
+ Partials 8944 100 -8844
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
| for id, old := range p.addrs { | ||
| if old.lastFail.IsPresent() { | ||
| delete(p.addrs, id) | ||
| p.addrs[pa.addr.NodeID] = pa | ||
| return nil | ||
| } | ||
| } |
Check warning
Code scanning / CodeQL
Iteration over map Warning
| if _, ok := peerAddrs.addrs[addr]; ok { | ||
| peerAddrs.fails[addr] = now | ||
| if peerAddr, ok := p.addrs[addr.NodeID]; ok && peerAddr.addr == addr { | ||
| peerAddr.lastFail = utils.Some(time.Now()) |
Check warning
Code scanning / CodeQL
Calling the system time Warning
| p.addrs[pa.addr.NodeID] = pa | ||
| return nil | ||
| } | ||
| // Otherwise, do not replace |
There was a problem hiding this comment.
Hmm, what if my legitimate peer is moving to a new data center and i do want to replace it? I need to shut down the old one and wait for the address to be valid?
| return nil | ||
| } | ||
| } | ||
| // If the new address is public, find a private address to prune. |
There was a problem hiding this comment.
could it be the private address is actually a high staked validator I don't want to lose?
With 6.3 upgrade, invalid/outdated addresses are no longer gossiped by honest nodes (malicious nodes can poison the addresses buffer anyway). With that we can simplify the logic to handle just 1 address per peer. I've also added an additional mechanism to prefer public ips over private ips, to account for nodes gossiping private addresses (that they have configured as persistent peers for example).