p2p: peer store and dialing changes

(cherry picked from commit 9dbb135152)
This commit is contained in:
tycho garen
2022-06-10 07:27:08 -04:00
parent 28c38522e0
commit cee254e695
4 changed files with 194 additions and 63 deletions
+109 -21
View File
@@ -39,10 +39,11 @@ const (
)
// PeerScore is a numeric score assigned to a peer (higher is better).
type PeerScore uint8
type PeerScore int
const (
PeerScorePersistent PeerScore = math.MaxUint8 // persistent peers
PeerScorePersistent PeerScore = math.MaxInt // persistent peers
MaxPeerScoreNotPersistent PeerScore = PeerScorePersistent - 1
)
// PeerUpdate is a peer update event sent via PeerUpdates.
@@ -427,6 +428,9 @@ func (m *PeerManager) Add(address NodeAddress) (bool, error) {
if ok {
return false, nil
}
if peer.Inactive {
return false, nil
}
// else add the new address
peer.AddressInfo[address] = &peerAddressInfo{Address: address}
@@ -600,8 +604,7 @@ func (m *PeerManager) Dialed(address NodeAddress) error {
return fmt.Errorf("peer %v is already connected", address.NodeID)
}
if m.options.MaxConnected > 0 && len(m.connected) >= int(m.options.MaxConnected) {
if upgradeFromPeer == "" || len(m.connected) >=
int(m.options.MaxConnected)+int(m.options.MaxConnectedUpgrade) {
if upgradeFromPeer == "" || len(m.connected) >= int(m.options.MaxConnected)+int(m.options.MaxConnectedUpgrade) {
return fmt.Errorf("already connected to maximum number of peers")
}
}
@@ -611,6 +614,7 @@ func (m *PeerManager) Dialed(address NodeAddress) error {
return fmt.Errorf("peer %q was removed while dialing", address.NodeID)
}
now := time.Now().UTC()
peer.Inactive = false
peer.LastConnected = now
if addressInfo, ok := peer.AddressInfo[address]; ok {
addressInfo.DialFailures = 0
@@ -666,8 +670,7 @@ func (m *PeerManager) Accepted(peerID types.NodeID) error {
if m.connected[peerID] {
return fmt.Errorf("peer %q is already connected", peerID)
}
if m.options.MaxConnected > 0 &&
len(m.connected) >= int(m.options.MaxConnected)+int(m.options.MaxConnectedUpgrade) {
if m.options.MaxConnected > 0 && len(m.connected) >= int(m.options.MaxConnected)+int(m.options.MaxConnectedUpgrade) {
return fmt.Errorf("already connected to maximum number of peers")
}
@@ -692,6 +695,7 @@ func (m *PeerManager) Accepted(peerID types.NodeID) error {
}
}
peer.Inactive = false
peer.LastConnected = time.Now().UTC()
if err := m.store.Set(peer); err != nil {
return err
@@ -821,15 +825,27 @@ func (m *PeerManager) Errored(peerID types.NodeID, err error) {
m.evictWaker.Wake()
}
func (m *PeerManager) Inactivate(peerID types.NodeID) error {
m.mtx.Lock()
defer m.mtx.Unlock()
peer := m.store.peers[peerID]
peer.Inactive = true
return m.store.Set(*peer)
}
// Advertise returns a list of peer addresses to advertise to a peer.
//
// FIXME: This is fairly naïve and only returns the addresses of the
// highest-ranked peers.
// It finds twice as many peers as the limit specifies, shuffles this
// list, and then returns the limit. The goal of this is to gossip the
// "best" peers but also ensure that more fresh peers also have a
// chance.
func (m *PeerManager) Advertise(peerID types.NodeID, limit uint16) []NodeAddress {
m.mtx.Lock()
defer m.mtx.Unlock()
addresses := make([]NodeAddress, 0, limit)
addresses := make([]NodeAddress, 0, 2*limit)
// advertise ourselves, to let everyone know how to dial us back
// and enable mutual address discovery
@@ -843,6 +859,7 @@ func (m *PeerManager) Advertise(peerID types.NodeID, limit uint16) []NodeAddress
}
for nodeAddr, addressInfo := range peer.AddressInfo {
if len(addresses) >= int(limit) {
return addresses
}
@@ -853,8 +870,11 @@ func (m *PeerManager) Advertise(peerID types.NodeID, limit uint16) []NodeAddress
}
}
}
rand.Shuffle(len(addresses), func(i, j int) {
addresses[i], addresses[j] = addresses[j], addresses[i]
})
return addresses
return addresses[:limit-1]
}
// Subscribe subscribes to peer updates. The caller must consume the peer
@@ -1203,9 +1223,47 @@ func (s *peerStore) Ranked() []*peerInfo {
s.ranked = append(s.ranked, peer)
}
sort.Slice(s.ranked, func(i, j int) bool {
// FIXME: If necessary, consider precomputing scores before sorting,
// to reduce the number of Score() calls.
return s.ranked[i].Score() > s.ranked[j].Score()
// sort inactive peers after active peers
if s.ranked[i].Inactive && !s.ranked[j].Inactive {
return false
} else if !s.ranked[i].Inactive && s.ranked[j].Inactive {
return true
}
iLastDialed, iLastDialSuccess := s.ranked[i].LastDialed()
jLastDialed, jLastDialSuccess := s.ranked[j].LastDialed()
// sort peers who our most recent dialing attempt was
// successful ahead of peers with recent dialing
// failures
switch {
case iLastDialSuccess && jLastDialSuccess:
// if both peers were (are?) successfully
// connected, convey their score, but give the
// one we dialed successfully most recently a bonus
iScore := s.ranked[i].Score()
jScore := s.ranked[j].Score()
if jLastDialed.Before(iLastDialed) {
jScore++
} else {
iScore++
}
return iScore > jScore
case iLastDialSuccess:
return true
case jLastDialSuccess:
return false
default:
// if both peers were not successful in their
// most recent dialing attempt, fall back to
// peer score.
// FIXME: If necessary, consider precomputing scores before sorting,
// to reduce the number of Score() calls.
return s.ranked[i].Score() > s.ranked[j].Score()
}
})
return s.ranked
}
@@ -1228,6 +1286,8 @@ type peerInfo struct {
FixedScore PeerScore // mainly for tests
MutableScore int64 // updated by router
Inactive bool
DialFailures int64
}
// peerInfoFromProto converts a Protobuf PeerInfo message to a peerInfo,
@@ -1236,6 +1296,7 @@ func peerInfoFromProto(msg *p2pproto.PeerInfo) (*peerInfo, error) {
p := &peerInfo{
ID: types.NodeID(msg.ID),
AddressInfo: map[NodeAddress]*peerAddressInfo{},
Inactive: msg.Inactive,
}
if msg.LastConnected != nil {
p.LastConnected = *msg.LastConnected
@@ -1259,6 +1320,7 @@ func (p *peerInfo) ToProto() *p2pproto.PeerInfo {
msg := &p2pproto.PeerInfo{
ID: string(p.ID),
LastConnected: &p.LastConnected,
Inactive: p.Inactive,
}
for _, addressInfo := range p.AddressInfo {
msg.AddressInfo = append(msg.AddressInfo, addressInfo.ToProto())
@@ -1282,6 +1344,40 @@ func (p *peerInfo) Copy() peerInfo {
return c
}
// LastDialed returns when the peer was last dialed, and if that dial
// attempt was successful.
func (p *peerInfo) LastDialed() (time.Time, bool) {
var (
last time.Time
success bool
)
last = last.Add(-1) // so it's after the epoch
for _, addr := range p.AddressInfo {
if addr.LastDialFailure.Equal(addr.LastDialSuccess) {
if addr.LastDialFailure.IsZero() {
continue
}
if last.Before(addr.LastDialSuccess) {
last = addr.LastDialSuccess
success = true
}
}
if addr.LastDialFailure.Before(addr.LastDialSuccess) {
if last.Before(addr.LastDialFailure) {
continue
}
last = addr.LastDialFailure
success = false
}
}
if last.Add(1).IsZero() {
last = last.Add(1)
}
return last, success
}
// Score calculates a score for the peer. Higher-scored peers will be
// preferred over lower scores.
func (p *peerInfo) Score() PeerScore {
@@ -1300,14 +1396,6 @@ func (p *peerInfo) Score() PeerScore {
score -= int64(addr.DialFailures)
}
if score <= 0 {
return 0
}
if score >= math.MaxUint8 {
return PeerScore(math.MaxUint8)
}
return PeerScore(score)
}
+3 -2
View File
@@ -555,7 +555,7 @@ func (r *Router) filterPeersID(ctx context.Context, id types.NodeID) error {
func (r *Router) dialSleep(ctx context.Context) {
if r.options.DialSleep == nil {
// nolint:gosec // G404: Use of weak random number generator
timer := time.NewTimer(time.Duration(rand.Int63n(dialRandomizerIntervalMilliseconds)) * time.Millisecond)
timer := time.NewTimer(time.Duration(rand.Int63n(500)) * time.Millisecond)
defer timer.Stop()
select {
@@ -811,6 +811,7 @@ func (r *Router) dialPeer(ctx context.Context, address NodeAddress) (Connection,
return conn, nil
}
}
return nil, errors.New("all endpoints failed")
}
@@ -837,7 +838,7 @@ func (r *Router) handshakePeer(
}
if peerInfo.Network != r.nodeInfo.Network {
if err := r.peerManager.store.Delete(peerInfo.NodeID); err != nil {
if err := r.peerManager.Inactivate(peerInfo.NodeID); err != nil {
return peerInfo, peerKey, fmt.Errorf("problem removing peer from store from incorrect network [%s]: %w", peerInfo.Network, err)
}
+81 -40
View File
@@ -243,6 +243,7 @@ type PeerInfo struct {
ID string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
AddressInfo []*PeerAddressInfo `protobuf:"bytes,2,rep,name=address_info,json=addressInfo,proto3" json:"address_info,omitempty"`
LastConnected *time.Time `protobuf:"bytes,3,opt,name=last_connected,json=lastConnected,proto3,stdtime" json:"last_connected,omitempty"`
Inactive bool `protobuf:"varint,4,opt,name=inactive,proto3" json:"inactive,omitempty"`
}
func (m *PeerInfo) Reset() { *m = PeerInfo{} }
@@ -299,6 +300,13 @@ func (m *PeerInfo) GetLastConnected() *time.Time {
return nil
}
func (m *PeerInfo) GetInactive() bool {
if m != nil {
return m.Inactive
}
return false
}
type PeerAddressInfo struct {
Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"`
LastDialSuccess *time.Time `protobuf:"bytes,2,opt,name=last_dial_success,json=lastDialSuccess,proto3,stdtime" json:"last_dial_success,omitempty"`
@@ -378,46 +386,46 @@ func init() {
func init() { proto.RegisterFile("tendermint/p2p/types.proto", fileDescriptor_c8a29e659aeca578) }
var fileDescriptor_c8a29e659aeca578 = []byte{
// 610 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0xcd, 0x4e, 0x1b, 0x3d,
0x14, 0xcd, 0x24, 0x21, 0x09, 0x37, 0x84, 0xf0, 0x59, 0xe8, 0xd3, 0x10, 0xa9, 0x19, 0x14, 0x36,
0xac, 0x26, 0x52, 0xaa, 0x2e, 0xba, 0x64, 0x40, 0xad, 0x22, 0x55, 0x25, 0x9a, 0xa2, 0x2e, 0xda,
0xc5, 0x68, 0x32, 0x76, 0x82, 0xc5, 0xc4, 0xb6, 0x3c, 0x4e, 0x4b, 0xdf, 0x82, 0x37, 0xe9, 0x63,
0x94, 0x25, 0xcb, 0xae, 0xd2, 0x6a, 0xd8, 0xf6, 0x21, 0x2a, 0xdb, 0x33, 0x40, 0xa2, 0x2e, 0xd8,
0xf9, 0xdc, 0xe3, 0x73, 0xee, 0x8f, 0xad, 0x0b, 0x3d, 0x45, 0x18, 0x26, 0x72, 0x41, 0x99, 0x1a,
0x8a, 0x91, 0x18, 0xaa, 0x6f, 0x82, 0x64, 0xbe, 0x90, 0x5c, 0x71, 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xd6, 0x9d, 0x96, 0xb2,
0xc1, 0x1f, 0x07, 0xba, 0x1b, 0x99, 0xf4, 0xdc, 0xcb, 0x96, 0x8b, 0x81, 0x14, 0x10, 0xbd, 0x83,
0xff, 0x4c, 0x5a, 0x4c, 0xe3, 0x34, 0xca, 0x96, 0x49, 0x52, 0x8e, 0xe5, 0x39, 0x99, 0xbb, 0x5a,
0x7a, 0x46, 0xe3, 0xf4, 0x83, 0x15, 0xae, 0xbb, 0xcd, 0x62, 0x9a, 0x2e, 0x25, 0x79, 0x76, 0x1f,
0x0f, 0x6e, 0x6f, 0xac, 0x10, 0x1d, 0x41, 0xe7, 0xa9, 0x51, 0x66, 0xfe, 0x60, 0x27, 0xdc, 0xc1,
0x8f, 0x77, 0xb2, 0xe0, 0xfc, 0x36, 0xef, 0x3b, 0x77, 0x79, 0xdf, 0xf9, 0x9d, 0xf7, 0x9d, 0x9b,
0xfb, 0x7e, 0xe5, 0xee, 0xbe, 0x5f, 0xf9, 0x79, 0xdf, 0xaf, 0x7c, 0x7a, 0x35, 0xa7, 0xea, 0x72,
0x39, 0xf5, 0x13, 0xbe, 0x18, 0x3e, 0xd9, 0x12, 0x4f, 0x17, 0x86, 0xd9, 0x05, 0xeb, 0x1b, 0x64,
0xda, 0x30, 0xd1, 0x97, 0x7f, 0x03, 0x00, 0x00, 0xff, 0xff, 0x0b, 0xe9, 0x56, 0xd3, 0x5a, 0x04,
0x00, 0x00,
// 621 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0x41, 0x4f, 0xdb, 0x30,
0x14, 0x6e, 0xda, 0xd2, 0x96, 0x57, 0x4a, 0x99, 0x85, 0xa6, 0x50, 0x69, 0x0d, 0x2a, 0x17, 0x4e,
0x89, 0xd4, 0x69, 0x87, 0x1d, 0x09, 0x68, 0x53, 0xa5, 0x69, 0x54, 0x1e, 0xda, 0x61, 0x3b, 0x44,
0x69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 0x9e, 0x58, 0xdf, 0x2e, 0x93, 0x86, 0x89, 0xbe, 0xfe,
0x17, 0x00, 0x00, 0xff, 0xff, 0x42, 0xcb, 0x37, 0x26, 0x76, 0x04, 0x00, 0x00,
}
func (m *ProtocolVersion) Marshal() (dAtA []byte, err error) {
@@ -600,6 +608,16 @@ func (m *PeerInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) {
_ = i
var l int
_ = l
if m.Inactive {
i--
if m.Inactive {
dAtA[i] = 1
} else {
dAtA[i] = 0
}
i--
dAtA[i] = 0x20
}
if m.LastConnected != nil {
n3, err3 := github_com_gogo_protobuf_types.StdTimeMarshalTo(*m.LastConnected, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(*m.LastConnected):])
if err3 != nil {
@@ -792,6 +810,9 @@ func (m *PeerInfo) Size() (n int) {
l = github_com_gogo_protobuf_types.SizeOfStdTime(*m.LastConnected)
n += 1 + l + sovTypes(uint64(l))
}
if m.Inactive {
n += 2
}
return n
}
@@ -1487,6 +1508,26 @@ func (m *PeerInfo) Unmarshal(dAtA []byte) error {
return err
}
iNdEx = postIndex
case 4:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Inactive", wireType)
}
var v int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowTypes
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
v |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
m.Inactive = bool(v != 0)
default:
iNdEx = preIndex
skippy, err := skipTypes(dAtA[iNdEx:])
+1
View File
@@ -32,6 +32,7 @@ message PeerInfo {
string id = 1 [(gogoproto.customname) = "ID"];
repeated PeerAddressInfo address_info = 2;
google.protobuf.Timestamp last_connected = 3 [(gogoproto.stdtime) = true];
bool inactive = 4;
}
message PeerAddressInfo {