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 #2992 +/- ##
==========================================
- Coverage 58.22% 58.16% -0.06%
==========================================
Files 2113 2110 -3
Lines 173671 173413 -258
==========================================
- Hits 101115 100866 -249
- Misses 63540 63608 +68
+ Partials 9016 8939 -77
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
| // NOTE: amplification factor! | ||
| // small request results in up to maxMsgSize response | ||
| maxMsgSize = maxAddressSize * maxGetSelection | ||
| maxMsgSize = 1000 + maxAddressSize*p2p.MaxPexAddrs |
There was a problem hiding this comment.
How big is the average msg now? Where does the constant 1000 come from?
There was a problem hiding this comment.
let's say 50 addresses * (42B for NodeID and ~20B for ip/dns address + 6B of protobuf overhead) = 3.5kB. This 1kB extra is arbitrary for whatever constant overhead. This estimation is not very precise.
| Encode: func(m *handshakeMsg) *pb.Handshake { | ||
| var selfAddr *string | ||
| if addr, ok := m.SelfAddr.Get(); ok { | ||
| selfAddr = utils.Alloc(addr.String()) |
There was a problem hiding this comment.
When would it happen that you can't get selfAddr here?
There was a problem hiding this comment.
node doesn't have to configure an external (public) address in case it doesn't have one.
| if p.SelfAddr != nil { | ||
| addr, err := ParseNodeAddress(*p.SelfAddr) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("SelfAddr: %w", err) |
There was a problem hiding this comment.
Would this ever happen during normal operations? DNS failures?
There was a problem hiding this comment.
Adversary node can send broken data. This is just a proto converter though, it doesn't assume the proto to be valid in any sense, other than specified by the proto message definiton
| for i, addrString := range p.PexAddrs { | ||
| addr, err := ParseNodeAddress(addrString) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("PexAddrs[%v]: %w", i, err) |
There was a problem hiding this comment.
If this may happen on a valid address, should we just ignore that one address and keep the others?
There was a problem hiding this comment.
wdym? Valid address is parseable. This is not a dynamic property.
There was a problem hiding this comment.
Ah okay, if this is a static parser this should be safe.
| if err != nil { | ||
| return nil, fmt.Errorf("NodeAuthKey: %w", err) | ||
| } | ||
| nodeAuthSig, err := ed25519.SignatureFromBytes(p.NodeAuthSig) |
There was a problem hiding this comment.
Can anyone with zero stake send us address updates?
There was a problem hiding this comment.
yes, node keys do not have stake assigned. They are not validator keys
| func (r *Router) Advertise(maxAddrs int) []NodeAddress { | ||
| return r.peerManager.Advertise(maxAddrs) | ||
| addrs := r.peerManager.Advertise() | ||
| return addrs[:min(len(addrs), maxAddrs)] |
There was a problem hiding this comment.
nit: would we ever want randomly pick instead of always the front?
There was a problem hiding this comment.
We might want to. Currently the earlier addresses are of outbound connections, and they are preferred rn (by a rather weak argument that these are valid because we dialed them, while addresses of inbound connections are self-declared, and therefore potentially misconfigured). We can revisit later.
This PR allows nodes to learn more node addresses, even if the peer they dial is out of capacity for new connections. This works by making listener node send pex batch as part of the handshake (it might discard the connection just after handshake, in case it decides it does not have capacity for this connection).
This new "pex in handshake" is enabled only if reactor pex is enabled in the node - disabling pex reactor prevents a node from learning new addresses and is currently mainly used to prevent node from connecting to random peers (which is misleading indirect use of pex flag), and this pr maintains this semantics to avoid distruptions. I think we should change this semantics and require people to just set MaxConnected to 0 instead (which is a direct way to say: connect only to persistent peers).
Additionally a SelfAddress is added to the handshake message: nodes advertise addresses of nodes they are connected to. Until now they could only advertise the addresses of outbound connections (i.e. verified addresses), but with this PR also SelfAddress of inbound connections is included (each node declares just their own up to date address, so it is fine to gossip it).
Note that SelfAddress could have been also be extracted from the pex response (it is always included), but I wanted to make it more explicit that it is special.