From 8188fc0f9e02c241bfc4739e2a8f75bbfa763e7c Mon Sep 17 00:00:00 2001 From: Nishant Das Date: Wed, 10 Jun 2020 08:22:45 +0800 Subject: [PATCH] Use Updated Connection Manager (#6184) * introduce updated connection manager * Merge branch 'master' into removeHardLimit * remove forked connection manager * Merge branch 'removeHardLimit' of https://github.com/prysmaticlabs/geth-sharding into removeHardLimit * Merge branch 'master' into removeHardLimit * Merge branch 'master' into removeHardLimit * Merge branch 'master' of https://github.com/prysmaticlabs/geth-sharding into removeHardLimit * Merge branch 'master' of https://github.com/prysmaticlabs/geth-sharding into removeHardLimit # Conflicts: tidy up * Merge branch 'removeHardLimit' of https://github.com/prysmaticlabs/geth-sharding into removeHardLimit --- beacon-chain/p2p/BUILD.bazel | 2 +- beacon-chain/p2p/connmgr/BUILD.bazel | 32 -- beacon-chain/p2p/connmgr/connmgr.go | 514 ----------------- beacon-chain/p2p/connmgr/connmgr_test.go | 683 ----------------------- beacon-chain/p2p/handshake.go | 9 - beacon-chain/p2p/options.go | 13 +- go.mod | 7 +- go.sum | 21 - 8 files changed, 14 insertions(+), 1267 deletions(-) delete mode 100644 beacon-chain/p2p/connmgr/BUILD.bazel delete mode 100644 beacon-chain/p2p/connmgr/connmgr.go delete mode 100644 beacon-chain/p2p/connmgr/connmgr_test.go diff --git a/beacon-chain/p2p/BUILD.bazel b/beacon-chain/p2p/BUILD.bazel index 548994f556a..8ef82087611 100644 --- a/beacon-chain/p2p/BUILD.bazel +++ b/beacon-chain/p2p/BUILD.bazel @@ -37,7 +37,6 @@ go_library( "//beacon-chain/core/feed:go_default_library", "//beacon-chain/core/feed/state:go_default_library", "//beacon-chain/core/helpers:go_default_library", - "//beacon-chain/p2p/connmgr:go_default_library", "//beacon-chain/p2p/encoder:go_default_library", "//beacon-chain/p2p/peers:go_default_library", "//proto/beacon/p2p/v1:go_default_library", @@ -63,6 +62,7 @@ go_library( "@com_github_libp2p_go_libp2p//:go_default_library", "@com_github_libp2p_go_libp2p//config:go_default_library", "@com_github_libp2p_go_libp2p//p2p/host/routed:go_default_library", + "@com_github_libp2p_go_libp2p_connmgr//:go_default_library", "@com_github_libp2p_go_libp2p_core//:go_default_library", "@com_github_libp2p_go_libp2p_core//crypto:go_default_library", "@com_github_libp2p_go_libp2p_core//host:go_default_library", diff --git a/beacon-chain/p2p/connmgr/BUILD.bazel b/beacon-chain/p2p/connmgr/BUILD.bazel deleted file mode 100644 index 28933adbb5e..00000000000 --- a/beacon-chain/p2p/connmgr/BUILD.bazel +++ /dev/null @@ -1,32 +0,0 @@ -load("@prysm//tools/go:def.bzl", "go_library") -load("@io_bazel_rules_go//go:def.bzl", "go_test") - -go_library( - name = "go_default_library", - srcs = ["connmgr.go"], - importpath = "github.com/prysmaticlabs/prysm/beacon-chain/p2p/connmgr", - visibility = ["//beacon-chain:__subpackages__"], - deps = [ - "//shared/roughtime:go_default_library", - "//shared/runutil:go_default_library", - "@com_github_ipfs_go_log//:go_default_library", - "@com_github_libp2p_go_libp2p_core//connmgr:go_default_library", - "@com_github_libp2p_go_libp2p_core//network:go_default_library", - "@com_github_libp2p_go_libp2p_core//peer:go_default_library", - "@com_github_multiformats_go_multiaddr//:go_default_library", - ], -) - -go_test( - name = "go_default_test", - srcs = ["connmgr_test.go"], - embed = [":go_default_library"], - deps = [ - "//shared/roughtime:go_default_library", - "@com_github_ipfs_go_detect_race//:go_default_library", - "@com_github_libp2p_go_libp2p_core//network:go_default_library", - "@com_github_libp2p_go_libp2p_core//peer:go_default_library", - "@com_github_libp2p_go_libp2p_core//test:go_default_library", - "@com_github_multiformats_go_multiaddr//:go_default_library", - ], -) diff --git a/beacon-chain/p2p/connmgr/connmgr.go b/beacon-chain/p2p/connmgr/connmgr.go deleted file mode 100644 index cac6afab39b..00000000000 --- a/beacon-chain/p2p/connmgr/connmgr.go +++ /dev/null @@ -1,514 +0,0 @@ -/* -Copyright 2019. Protocol Labs, Inc. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - -// Package connmgr is forked from github.com/libp2p/go-libp2p-core/connmgr/connmgr.go -package connmgr - -import ( - "context" - "sort" - "sync" - "sync/atomic" - "time" - - logging "github.com/ipfs/go-log" - "github.com/libp2p/go-libp2p-core/connmgr" - "github.com/libp2p/go-libp2p-core/network" - "github.com/libp2p/go-libp2p-core/peer" - ma "github.com/multiformats/go-multiaddr" - "github.com/prysmaticlabs/prysm/shared/roughtime" - "github.com/prysmaticlabs/prysm/shared/runutil" -) - -// SilencePeriod refers to the period in which a connection is given leeway by the connection -// manager before it is handled normally. -var SilencePeriod = 5 * time.Second - -// TickerPeriod represents the frequency in which we check the number of -// open connections. -var TickerPeriod = 5 * time.Second - -var log = logging.Logger("connmgr") - -// BasicConnMgr is a ConnManager that trims connections whenever the count exceeds the -// high watermark. New connections are given a grace period before they're subject -// to trimming. Trims are automatically run on demand, only if the time from the -// previous trim is higher than 10 seconds. Furthermore, trims can be explicitly -// requested through the public interface of this struct (see TrimOpenConns). -// -// See configuration parameters in NewConnManager. -type BasicConnMgr struct { - highWater int - lowWater int - connCount int32 - gracePeriod time.Duration - segments segments - - plk sync.RWMutex - protected map[peer.ID]map[string]struct{} - - // channel-based semaphore that enforces only a single trim is in progress - trimRunningCh chan struct{} - lastTrim time.Time - silencePeriod time.Duration - - ctx context.Context - cancel func() -} - -var _ connmgr.ConnManager = (*BasicConnMgr)(nil) - -type segment struct { - sync.Mutex - peers map[peer.ID]*peerInfo -} - -type segments [256]*segment - -func (ss *segments) get(p peer.ID) *segment { - return ss[p[len(p)-1]] -} - -func (ss *segments) countPeers() (count int) { - for _, seg := range ss { - seg.Lock() - count += len(seg.peers) - seg.Unlock() - } - return count -} - -func (s *segment) tagInfoFor(p peer.ID) *peerInfo { - pi, ok := s.peers[p] - if ok { - return pi - } - // create a temporary peer to buffer early tags before the Connected notification arrives. - pi = &peerInfo{ - id: p, - firstSeen: roughtime.Now(), // this timestamp will be updated when the first Connected notification arrives. - temp: true, - tags: make(map[string]int), - conns: make(map[network.Conn]time.Time), - } - s.peers[p] = pi - return pi -} - -// NewConnManager creates a new BasicConnMgr with the provided params: -// * lo and hi are watermarks governing the number of connections that'll be maintained. -// When the peer count exceeds the 'high watermark', as many peers will be pruned (and -// their connections terminated) until 'low watermark' peers remain. -// * grace is the amount of time a newly opened connection is given before it becomes -// subject to pruning. -func NewConnManager(low, hi int, grace time.Duration) *BasicConnMgr { - ctx, cancel := context.WithCancel(context.Background()) - cm := &BasicConnMgr{ - highWater: hi, - lowWater: low, - gracePeriod: grace, - trimRunningCh: make(chan struct{}, 1), - protected: make(map[peer.ID]map[string]struct{}, 16), - silencePeriod: SilencePeriod, - ctx: ctx, - cancel: cancel, - segments: func() (ret segments) { - for i := range ret { - ret[i] = &segment{ - peers: make(map[peer.ID]*peerInfo), - } - } - return ret - }(), - } - - // Check every TickerPeriod to see if we should trim the number of active connections. - runutil.RunEvery(cm.ctx, TickerPeriod, func() { - if atomic.LoadInt32(&cm.connCount) > int32(cm.highWater) { - cm.TrimOpenConns(cm.ctx) - } - }) - - return cm -} - -// Close shutsdown the connection manager. -func (cm *BasicConnMgr) Close() error { - cm.cancel() - return nil -} - -// Protect is used to protect a peer from being pruned by the -// connection manager. -func (cm *BasicConnMgr) Protect(id peer.ID, tag string) { - cm.plk.Lock() - defer cm.plk.Unlock() - - tags, ok := cm.protected[id] - if !ok { - tags = make(map[string]struct{}, 2) - cm.protected[id] = tags - } - tags[tag] = struct{}{} -} - -// Unprotect is used to remove the protection a previously protected peer -// so that it can be normally pruned by the connection manager. -func (cm *BasicConnMgr) Unprotect(id peer.ID, tag string) (protected bool) { - cm.plk.Lock() - defer cm.plk.Unlock() - - tags, ok := cm.protected[id] - if !ok { - return false - } - if delete(tags, tag); len(tags) == 0 { - delete(cm.protected, id) - return false - } - return true -} - -// peerInfo stores metadata for a given peer. -type peerInfo struct { - id peer.ID - tags map[string]int // value for each tag - value int // cached sum of all tag values - temp bool // this is a temporary entry holding early tags, and awaiting connections - - conns map[network.Conn]time.Time // start time of each connection - - firstSeen time.Time // timestamp when we began tracking this peer. -} - -// TrimOpenConns closes the connections of as many peers as needed to make the peer count -// equal the low watermark. Peers are sorted in ascending order based on their total value, -// pruning those peers with the lowest scores first, as long as they are not within their -// grace period. -// -// (a) there's another trim in progress, or (b) the silence period is in effect. -func (cm *BasicConnMgr) TrimOpenConns(ctx context.Context) { - select { - case cm.trimRunningCh <- struct{}{}: - default: - return - } - defer func() { <-cm.trimRunningCh }() - if time.Since(cm.lastTrim) < cm.silencePeriod { - // skip this attempt to trim as the last one just took place. - return - } - - defer log.EventBegin(ctx, "connCleanup").Done() - for _, c := range cm.getConnsToClose(ctx) { - log.Info("closing conn: ", c.RemotePeer()) - log.Event(ctx, "closeConn", c.RemotePeer()) - if err := c.Close(); err != nil { - log.Errorf("Failed to close connection: %v", err) - } - } - - cm.lastTrim = roughtime.Now() -} - -// getConnsToClose runs the heuristics described in TrimOpenConns and returns the -// connections to close. -func (cm *BasicConnMgr) getConnsToClose(ctx context.Context) []network.Conn { - if cm.lowWater == 0 || cm.highWater == 0 { - // disabled - return nil - } - - nconns := int(atomic.LoadInt32(&cm.connCount)) - if nconns <= cm.lowWater { - log.Info("open connection count below limit") - return nil - } - - npeers := cm.segments.countPeers() - candidates := make([]*peerInfo, 0, npeers) - ncandidates := 0 - gracePeriodStart := roughtime.Now().Add(-cm.gracePeriod) - - cm.plk.RLock() - for _, s := range cm.segments { - s.Lock() - for id, inf := range s.peers { - if _, ok := cm.protected[id]; ok { - // skip over protected peer. - continue - } - if inf.firstSeen.After(gracePeriodStart) { - // skip peers in the grace period. - continue - } - candidates = append(candidates, inf) - ncandidates += len(inf.conns) - } - s.Unlock() - } - cm.plk.RUnlock() - - if ncandidates < cm.lowWater { - log.Info("open connection count above limit but too many are in the grace period") - // We have too many connections but fewer than lowWater - // connections out of the grace period. - // - // If we trimmed now, we'd kill potentially useful connections. - return nil - } - - // Sort peers according to their value. - sort.Slice(candidates, func(i, j int) bool { - left, right := candidates[i], candidates[j] - // temporary peers are preferred for pruning. - if left.temp != right.temp { - return left.temp - } - // otherwise, compare by value. - return left.value < right.value - }) - - target := ncandidates - cm.lowWater - - // slightly overallocate because we may have more than one conns per peer - selected := make([]network.Conn, 0, target+10) - - for _, inf := range candidates { - if target <= 0 { - break - } - - // lock this to protect from concurrent modifications from connect/disconnect events - s := cm.segments.get(inf.id) - s.Lock() - - if len(inf.conns) == 0 && inf.temp { - // handle temporary entries for early tags -- this entry has gone past the grace period - // and still holds no connections, so prune it. - delete(s.peers, inf.id) - } else { - for c := range inf.conns { - selected = append(selected, c) - } - } - target -= len(inf.conns) - s.Unlock() - } - - return selected -} - -// GetTagInfo is called to fetch the tag information associated with a given -// peer, nil is returned if p refers to an unknown peer. -func (cm *BasicConnMgr) GetTagInfo(p peer.ID) *connmgr.TagInfo { - s := cm.segments.get(p) - s.Lock() - defer s.Unlock() - - pi, ok := s.peers[p] - if !ok { - return nil - } - - out := &connmgr.TagInfo{ - FirstSeen: pi.firstSeen, - Value: pi.value, - Tags: make(map[string]int), - Conns: make(map[string]time.Time), - } - - for t, v := range pi.tags { - out.Tags[t] = v - } - for c, t := range pi.conns { - out.Conns[c.RemoteMultiaddr().String()] = t - } - - return out -} - -// TagPeer is called to associate a string and integer with a given peer. -func (cm *BasicConnMgr) TagPeer(p peer.ID, tag string, val int) { - s := cm.segments.get(p) - s.Lock() - defer s.Unlock() - - pi := s.tagInfoFor(p) - - // Update the total value of the peer. - pi.value += val - pi.tags[tag] - pi.tags[tag] = val -} - -// UntagPeer is called to disassociate a string and integer from a given peer. -func (cm *BasicConnMgr) UntagPeer(p peer.ID, tag string) { - s := cm.segments.get(p) - s.Lock() - defer s.Unlock() - - pi, ok := s.peers[p] - if !ok { - log.Info("tried to remove tag from untracked peer: ", p) - return - } - - // Update the total value of the peer. - pi.value -= pi.tags[tag] - delete(pi.tags, tag) -} - -// UpsertTag is called to insert/update a peer tag -func (cm *BasicConnMgr) UpsertTag(p peer.ID, tag string, upsert func(int) int) { - s := cm.segments.get(p) - s.Lock() - defer s.Unlock() - - pi := s.tagInfoFor(p) - - oldval := pi.tags[tag] - newval := upsert(oldval) - pi.value += newval - oldval - pi.tags[tag] = newval -} - -// CMInfo holds the configuration for BasicConnMgr, as well as status data. -type CMInfo struct { - // The low watermark, as described in NewConnManager. - LowWater int - - // The high watermark, as described in NewConnManager. - HighWater int - - // The timestamp when the last trim was triggered. - LastTrim time.Time - - // The configured grace period, as described in NewConnManager. - GracePeriod time.Duration - - // The current connection count. - ConnCount int -} - -// GetInfo returns the configuration and status data for this connection manager. -func (cm *BasicConnMgr) GetInfo() CMInfo { - return CMInfo{ - HighWater: cm.highWater, - LowWater: cm.lowWater, - LastTrim: cm.lastTrim, - GracePeriod: cm.gracePeriod, - ConnCount: int(atomic.LoadInt32(&cm.connCount)), - } -} - -// Notifee returns a sink through which Notifiers can inform the BasicConnMgr when -// events occur. Currently, the notifee only reacts upon connection events -// {Connected, Disconnected}. -func (cm *BasicConnMgr) Notifee() network.Notifiee { - return (*cmNotifee)(cm) -} - -type cmNotifee BasicConnMgr - -func (nn *cmNotifee) cm() *BasicConnMgr { - return (*BasicConnMgr)(nn) -} - -// Connected is called by notifiers to inform that a new connection has been established. -// The notifee updates the BasicConnMgr to start tracking the connection. If the new connection -// count exceeds the high watermark, a trim may be triggered. -func (nn *cmNotifee) Connected(n network.Network, c network.Conn) { - cm := nn.cm() - - p := c.RemotePeer() - s := cm.segments.get(p) - s.Lock() - defer s.Unlock() - - id := c.RemotePeer() - pinfo, ok := s.peers[id] - if !ok { - pinfo = &peerInfo{ - id: id, - firstSeen: roughtime.Now(), - tags: make(map[string]int), - conns: make(map[network.Conn]time.Time), - } - s.peers[id] = pinfo - } else if pinfo.temp { - // we had created a temporary entry for this peer to buffer early tags before the - // Connected notification arrived: flip the temporary flag, and update the firstSeen - // timestamp to the real one. - pinfo.temp = false - pinfo.firstSeen = roughtime.Now() - } - - _, ok = pinfo.conns[c] - if ok { - log.Error("received connected notification for conn we are already tracking: ", p) - return - } - - pinfo.conns[c] = roughtime.Now() - atomic.AddInt32(&cm.connCount, 1) -} - -// Disconnected is called by notifiers to inform that an existing connection has been closed or terminated. -// The notifee updates the BasicConnMgr accordingly to stop tracking the connection, and performs housekeeping. -func (nn *cmNotifee) Disconnected(n network.Network, c network.Conn) { - cm := nn.cm() - - p := c.RemotePeer() - s := cm.segments.get(p) - s.Lock() - defer s.Unlock() - - cinf, ok := s.peers[p] - if !ok { - log.Error("received disconnected notification for peer we are not tracking: ", p) - return - } - - _, ok = cinf.conns[c] - if !ok { - log.Error("received disconnected notification for conn we are not tracking: ", p) - return - } - - delete(cinf.conns, c) - if len(cinf.conns) == 0 { - delete(s.peers, p) - } - atomic.AddInt32(&cm.connCount, -1) -} - -// Listen is no-op in this implementation. -func (nn *cmNotifee) Listen(n network.Network, addr ma.Multiaddr) {} - -// ListenClose is no-op in this implementation. -func (nn *cmNotifee) ListenClose(n network.Network, addr ma.Multiaddr) {} - -// OpenedStream is no-op in this implementation. -func (nn *cmNotifee) OpenedStream(network.Network, network.Stream) {} - -// ClosedStream is no-op in this implementation. -func (nn *cmNotifee) ClosedStream(network.Network, network.Stream) {} diff --git a/beacon-chain/p2p/connmgr/connmgr_test.go b/beacon-chain/p2p/connmgr/connmgr_test.go deleted file mode 100644 index 89dd9216ff5..00000000000 --- a/beacon-chain/p2p/connmgr/connmgr_test.go +++ /dev/null @@ -1,683 +0,0 @@ -package connmgr - -import ( - "context" - "testing" - "time" - - detectrace "github.com/ipfs/go-detect-race" - "github.com/libp2p/go-libp2p-core/network" - "github.com/libp2p/go-libp2p-core/peer" - tu "github.com/libp2p/go-libp2p-core/test" - ma "github.com/multiformats/go-multiaddr" - "github.com/prysmaticlabs/prysm/shared/roughtime" -) - -type tconn struct { - network.Conn - - peer peer.ID - closed bool - disconnectNotify func(net network.Network, conn network.Conn) -} - -func (c *tconn) Close() error { - c.closed = true - if c.disconnectNotify != nil { - c.disconnectNotify(nil, c) - } - return nil -} - -func (c *tconn) RemotePeer() peer.ID { - return c.peer -} - -func (c *tconn) RemoteMultiaddr() ma.Multiaddr { - addr, err := ma.NewMultiaddr("/ip4/127.0.0.1/udp/1234") - if err != nil { - panic("cannot create multiaddr") - } - return addr -} - -func randConn(t testing.TB, discNotify func(network.Network, network.Conn)) network.Conn { - pid := tu.RandPeerIDFatal(t) - return &tconn{peer: pid, disconnectNotify: discNotify} -} - -func TestConnTrimming(t *testing.T) { - cm := NewConnManager(200, 300, 0) - not := cm.Notifee() - - var conns []network.Conn - for i := 0; i < 300; i++ { - rc := randConn(t, nil) - conns = append(conns, rc) - not.Connected(nil, rc) - } - - for _, c := range conns { - if c.(*tconn).closed { - t.Fatal("nothing should be closed yet") - } - } - - for i := 0; i < 100; i++ { - cm.TagPeer(conns[i].RemotePeer(), "foo", 10) - } - - cm.TagPeer(conns[299].RemotePeer(), "badfoo", -5) - - cm.TrimOpenConns(context.Background()) - - for i := 0; i < 100; i++ { - c := conns[i] - if c.(*tconn).closed { - t.Fatal("these shouldnt be closed") - } - } - - if !conns[299].(*tconn).closed { - t.Fatal("conn with bad tag should have gotten closed") - } -} - -func TestConnsToClose(t *testing.T) { - cm := NewConnManager(0, 10, 0) - conns := cm.getConnsToClose(context.Background()) - if conns != nil { - t.Fatal("expected no connections") - } - - cm = NewConnManager(10, 0, 0) - conns = cm.getConnsToClose(context.Background()) - if conns != nil { - t.Fatal("expected no connections") - } - - cm = NewConnManager(1, 1, 0) - conns = cm.getConnsToClose(context.Background()) - if conns != nil { - t.Fatal("expected no connections") - } - - cm = NewConnManager(1, 1, 10*time.Minute) - not := cm.Notifee() - for i := 0; i < 5; i++ { - conn := randConn(t, nil) - not.Connected(nil, conn) - } - conns = cm.getConnsToClose(context.Background()) - if len(conns) != 0 { - t.Fatal("expected no connections") - } -} - -func TestGetTagInfo(t *testing.T) { - start := roughtime.Now() - cm := NewConnManager(1, 1, 10*time.Minute) - not := cm.Notifee() - conn := randConn(t, nil) - not.Connected(nil, conn) - end := roughtime.Now() - - other := tu.RandPeerIDFatal(t) - tag := cm.GetTagInfo(other) - if tag != nil { - t.Fatal("expected no tag") - } - - tag = cm.GetTagInfo(conn.RemotePeer()) - if tag == nil { - t.Fatal("expected tag") - } - if tag.FirstSeen.Before(start) || tag.FirstSeen.After(end) { - t.Fatal("expected first seen time") - } - if tag.Value != 0 { - t.Fatal("expected zero value") - } - if len(tag.Tags) != 0 { - t.Fatal("expected no tags") - } - if len(tag.Conns) != 1 { - t.Fatal("expected one connection") - } - for s, tm := range tag.Conns { - if s != conn.RemoteMultiaddr().String() { - t.Fatal("unexpected multiaddr") - } - if tm.Before(start) || tm.After(end) { - t.Fatal("unexpected connection time") - } - } - - cm.TagPeer(conn.RemotePeer(), "tag", 5) - tag = cm.GetTagInfo(conn.RemotePeer()) - if tag == nil { - t.Fatal("expected tag") - } - if tag.FirstSeen.Before(start) || tag.FirstSeen.After(end) { - t.Fatal("expected first seen time") - } - if tag.Value != 5 { - t.Fatal("expected five value") - } - if len(tag.Tags) != 1 { - t.Fatal("expected no tags") - } - for tString, v := range tag.Tags { - if tString != "tag" || v != 5 { - t.Fatal("expected tag value") - } - } - if len(tag.Conns) != 1 { - t.Fatal("expected one connection") - } - for s, tm := range tag.Conns { - if s != conn.RemoteMultiaddr().String() { - t.Fatal("unexpected multiaddr") - } - if tm.Before(start) || tm.After(end) { - t.Fatal("unexpected connection time") - } - } -} - -func TestTagPeerNonExistant(t *testing.T) { - cm := NewConnManager(1, 1, 10*time.Minute) - - id := tu.RandPeerIDFatal(t) - cm.TagPeer(id, "test", 1) - - if !cm.segments.get(id).peers[id].temp { - t.Fatal("expected 1 temporary entry") - } -} - -func TestUntagPeer(t *testing.T) { - cm := NewConnManager(1, 1, 10*time.Minute) - not := cm.Notifee() - conn := randConn(t, nil) - not.Connected(nil, conn) - rp := conn.RemotePeer() - cm.TagPeer(rp, "tag", 5) - cm.TagPeer(rp, "tag two", 5) - - id := tu.RandPeerIDFatal(t) - cm.UntagPeer(id, "test") - if len(cm.segments.get(rp).peers[rp].tags) != 2 { - t.Fatal("expected tags to be uneffected") - } - - cm.UntagPeer(conn.RemotePeer(), "test") - if len(cm.segments.get(rp).peers[rp].tags) != 2 { - t.Fatal("expected tags to be uneffected") - } - - cm.UntagPeer(conn.RemotePeer(), "tag") - if len(cm.segments.get(rp).peers[rp].tags) != 1 { - t.Fatal("expected tag to be removed") - } - if cm.segments.get(rp).peers[rp].value != 5 { - t.Fatal("expected aggreagte tag value to be 5") - } -} - -func TestGetInfo(t *testing.T) { - start := roughtime.Now() - gp := 10 * time.Minute - cm := NewConnManager(1, 5, gp) - not := cm.Notifee() - conn := randConn(t, nil) - not.Connected(nil, conn) - cm.TrimOpenConns(context.Background()) - end := roughtime.Now() - - info := cm.GetInfo() - if info.HighWater != 5 { - t.Fatal("expected highwater to be 5") - } - if info.LowWater != 1 { - t.Fatal("expected highwater to be 1") - } - if info.LastTrim.Before(start) || info.LastTrim.After(end) { - t.Fatal("unexpected last trim time") - } - if info.GracePeriod != gp { - t.Fatal("unexpected grace period") - } - if info.ConnCount != 1 { - t.Fatal("unexpected number of connections") - } -} - -func TestDoubleConnection(t *testing.T) { - gp := 10 * time.Minute - cm := NewConnManager(1, 5, gp) - not := cm.Notifee() - conn := randConn(t, nil) - not.Connected(nil, conn) - cm.TagPeer(conn.RemotePeer(), "foo", 10) - not.Connected(nil, conn) - if cm.connCount != 1 { - t.Fatal("unexpected number of connections") - } - if cm.segments.get(conn.RemotePeer()).peers[conn.RemotePeer()].value != 10 { - t.Fatal("unexpected peer value") - } -} - -func TestDisconnected(t *testing.T) { - gp := 10 * time.Minute - cm := NewConnManager(1, 5, gp) - not := cm.Notifee() - conn := randConn(t, nil) - not.Connected(nil, conn) - cm.TagPeer(conn.RemotePeer(), "foo", 10) - - not.Disconnected(nil, randConn(t, nil)) - if cm.connCount != 1 { - t.Fatal("unexpected number of connections") - } - if cm.segments.get(conn.RemotePeer()).peers[conn.RemotePeer()].value != 10 { - t.Fatal("unexpected peer value") - } - - not.Disconnected(nil, &tconn{peer: conn.RemotePeer()}) - if cm.connCount != 1 { - t.Fatal("unexpected number of connections") - } - if cm.segments.get(conn.RemotePeer()).peers[conn.RemotePeer()].value != 10 { - t.Fatal("unexpected peer value") - } - - not.Disconnected(nil, conn) - if cm.connCount != 0 { - t.Fatal("unexpected number of connections") - } - if cm.segments.countPeers() != 0 { - t.Fatal("unexpected number of peers") - } -} - -func TestGracePeriod(t *testing.T) { - if detectrace.WithRace() { - t.Skip("race detector is unhappy with this test") - } - - SilencePeriod = 0 - cm := NewConnManager(10, 20, 100*time.Millisecond) - SilencePeriod = 10 * time.Second - - not := cm.Notifee() - - var conns []network.Conn - - // Add a connection and wait the grace period. - { - rc := randConn(t, not.Disconnected) - conns = append(conns, rc) - not.Connected(nil, rc) - - time.Sleep(200 * time.Millisecond) - - if rc.(*tconn).closed { - t.Fatal("expected conn to remain open") - } - } - - // quickly add 30 connections (sending us above the high watermark) - for i := 0; i < 30; i++ { - rc := randConn(t, not.Disconnected) - conns = append(conns, rc) - not.Connected(nil, rc) - } - - cm.TrimOpenConns(context.Background()) - - for _, c := range conns { - if c.(*tconn).closed { - t.Fatal("expected no conns to be closed") - } - } - - time.Sleep(200 * time.Millisecond) - - cm.TrimOpenConns(context.Background()) - - closed := 0 - for _, c := range conns { - if c.(*tconn).closed { - closed++ - } - } - - if closed != 21 { - t.Fatal("expected to have closed 21 connections") - } -} - -// see https://github.com/libp2p/go-libp2p-connmgr/issues/23 -func TestQuickBurstRespectsSilencePeriod(t *testing.T) { - if detectrace.WithRace() { - t.Skip("race detector is unhappy with this test") - } - - cm := NewConnManager(10, 20, 0) - not := cm.Notifee() - - var conns []network.Conn - - // quickly produce 30 connections (sending us above the high watermark) - for i := 0; i < 30; i++ { - rc := randConn(t, not.Disconnected) - conns = append(conns, rc) - not.Connected(nil, rc) - } - - // wait for a few seconds - time.Sleep(time.Second * 3) - - // only the first trim is allowed in; make sure we close at most 20 connections, not all of them. - var closed int - for _, c := range conns { - if c.(*tconn).closed { - closed++ - } - } - if closed > 20 { - t.Fatalf("should have closed at most 20 connections, closed: %d", closed) - } - if total := closed + int(cm.connCount); total != 30 { - t.Fatalf("expected closed connections + open conn count to equal 30, value: %d", total) - } -} - -func TestPeerProtectionSingleTag(t *testing.T) { - if detectrace.WithRace() { - t.Skip("race detector is unhappy with this test") - } - - SilencePeriod = 0 - cm := NewConnManager(19, 20, 0) - SilencePeriod = 10 * time.Second - - not := cm.Notifee() - - var conns []network.Conn - addConn := func(value int) { - rc := randConn(t, not.Disconnected) - conns = append(conns, rc) - not.Connected(nil, rc) - cm.TagPeer(rc.RemotePeer(), "test", value) - } - - // produce 20 connections with unique peers. - for i := 0; i < 20; i++ { - addConn(20) - } - - // protect the first 5 peers. - var protected []network.Conn - for _, c := range conns[0:5] { - cm.Protect(c.RemotePeer(), "global") - protected = append(protected, c) - // tag them negatively to make them preferred for pruning. - cm.TagPeer(c.RemotePeer(), "test", -100) - } - - // add 1 more conn, this shouldn't send us over the limit as protected conns don't count - addConn(20) - - cm.TrimOpenConns(context.Background()) - - for _, c := range conns { - if c.(*tconn).closed { - t.Error("connection was closed by connection manager") - } - } - - // add 5 more connection, sending the connection manager overboard. - for i := 0; i < 5; i++ { - addConn(20) - } - - cm.TrimOpenConns(context.Background()) - - for _, c := range protected { - if c.(*tconn).closed { - t.Error("protected connection was closed by connection manager") - } - } - - closed := 0 - for _, c := range conns { - if c.(*tconn).closed { - closed++ - } - } - if closed != 2 { - t.Errorf("expected 2 connection to be closed, found %d", closed) - } - - // unprotect the first peer. - cm.Unprotect(protected[0].RemotePeer(), "global") - - // add 2 more connections, sending the connection manager overboard again. - for i := 0; i < 2; i++ { - addConn(20) - } - - cm.TrimOpenConns(context.Background()) - - if !protected[0].(*tconn).closed { - t.Error("unprotected connection was kept open by connection manager") - } - for _, c := range protected[1:] { - if c.(*tconn).closed { - t.Error("protected connection was closed by connection manager") - } - } -} - -func TestPeerProtectionMultipleTags(t *testing.T) { - if detectrace.WithRace() { - t.Skip("race detector is unhappy with this test") - } - - SilencePeriod = 0 - cm := NewConnManager(19, 20, 0) - SilencePeriod = 10 * time.Second - - not := cm.Notifee() - - // produce 20 connections with unique peers. - var conns []network.Conn - for i := 0; i < 20; i++ { - rc := randConn(t, not.Disconnected) - conns = append(conns, rc) - not.Connected(nil, rc) - cm.TagPeer(rc.RemotePeer(), "test", 20) - } - - // protect the first 5 peers under two tags. - var protected []network.Conn - for _, c := range conns[0:5] { - cm.Protect(c.RemotePeer(), "tag1") - cm.Protect(c.RemotePeer(), "tag2") - protected = append(protected, c) - // tag them negatively to make them preferred for pruning. - cm.TagPeer(c.RemotePeer(), "test", -100) - } - - // add one more connection, sending the connection manager overboard. - not.Connected(nil, randConn(t, not.Disconnected)) - - cm.TrimOpenConns(context.Background()) - - for _, c := range protected { - if c.(*tconn).closed { - t.Error("protected connection was closed by connection manager") - } - } - - // remove the protection from one tag. - for _, c := range protected { - if !cm.Unprotect(c.RemotePeer(), "tag1") { - t.Error("peer should still be protected") - } - } - - // add 2 more connections, sending the connection manager overboard again. - for i := 0; i < 2; i++ { - rc := randConn(t, not.Disconnected) - conns = append(conns, rc) - not.Connected(nil, rc) - cm.TagPeer(rc.RemotePeer(), "test", 20) - } - - cm.TrimOpenConns(context.Background()) - - // connections should still remain open, as they were protected. - for _, c := range protected[0:] { - if c.(*tconn).closed { - t.Error("protected connection was closed by connection manager") - } - } - - // unprotect the first peer entirely. - cm.Unprotect(protected[0].RemotePeer(), "tag2") - - // add 2 more connections, sending the connection manager overboard again. - for i := 0; i < 2; i++ { - rc := randConn(t, not.Disconnected) - conns = append(conns, rc) - not.Connected(nil, rc) - cm.TagPeer(rc.RemotePeer(), "test", 20) - } - - cm.TrimOpenConns(context.Background()) - - if !protected[0].(*tconn).closed { - t.Error("unprotected connection was kept open by connection manager") - } - for _, c := range protected[1:] { - if c.(*tconn).closed { - t.Error("protected connection was closed by connection manager") - } - } - -} - -func TestPeerProtectionIdempotent(t *testing.T) { - SilencePeriod = 0 - cm := NewConnManager(10, 20, 0) - SilencePeriod = 10 * time.Second - - id, err := tu.RandPeerID() - if err != nil { - t.Error(err) - } - cm.Protect(id, "global") - cm.Protect(id, "global") - cm.Protect(id, "global") - cm.Protect(id, "global") - - if len(cm.protected[id]) > 1 { - t.Error("expected peer to be protected only once") - } - - if !cm.Unprotect(id, "unused") { - t.Error("expected peer to continue to be protected") - } - - if !cm.Unprotect(id, "unused2") { - t.Error("expected peer to continue to be protected") - } - - if cm.Unprotect(id, "global") { - t.Error("expected peer to be unprotected") - } - - if len(cm.protected) > 0 { - t.Error("expected no protections") - } -} - -func TestUpsertTag(t *testing.T) { - cm := NewConnManager(1, 1, 10*time.Minute) - not := cm.Notifee() - conn := randConn(t, nil) - rp := conn.RemotePeer() - - // this is an early tag, before the Connected notification arrived. - cm.UpsertTag(rp, "tag", func(v int) int { return v + 1 }) - if len(cm.segments.get(rp).peers[rp].tags) != 1 { - t.Fatal("expected a tag") - } - if cm.segments.get(rp).peers[rp].value != 1 { - t.Fatal("expected a tag value of 1") - } - - // now let's notify the connection. - not.Connected(nil, conn) - - cm.UpsertTag(rp, "tag", func(v int) int { return v + 1 }) - if len(cm.segments.get(rp).peers[rp].tags) != 1 { - t.Fatal("expected a tag") - } - if cm.segments.get(rp).peers[rp].value != 2 { - t.Fatal("expected a tag value of 2") - } - - cm.UpsertTag(rp, "tag", func(v int) int { return v - 1 }) - if len(cm.segments.get(rp).peers[rp].tags) != 1 { - t.Fatal("expected a tag") - } - if cm.segments.get(rp).peers[rp].value != 1 { - t.Fatal("expected a tag value of 1") - } -} - -func TestTemporaryEntriesClearedFirst(t *testing.T) { - cm := NewConnManager(1, 1, 0) - - id := tu.RandPeerIDFatal(t) - cm.TagPeer(id, "test", 20) - - if cm.GetTagInfo(id).Value != 20 { - t.Fatal("expected an early tag with value 20") - } - - not := cm.Notifee() - conn1, conn2 := randConn(t, nil), randConn(t, nil) - not.Connected(nil, conn1) - not.Connected(nil, conn2) - - cm.TrimOpenConns(context.Background()) - if cm.GetTagInfo(id) != nil { - t.Fatal("expected no temporary tags after trimming") - } -} - -func TestTemporaryEntryConvertedOnConnection(t *testing.T) { - cm := NewConnManager(1, 1, 0) - - conn := randConn(t, nil) - cm.TagPeer(conn.RemotePeer(), "test", 20) - - ti := cm.segments.get(conn.RemotePeer()).peers[conn.RemotePeer()] - - if ti.value != 20 || !ti.temp { - t.Fatal("expected a temporary tag with value 20") - } - - not := cm.Notifee() - not.Connected(nil, conn) - - if ti.value != 20 || ti.temp { - t.Fatal("expected a non-temporary tag with value 20") - } -} diff --git a/beacon-chain/p2p/handshake.go b/beacon-chain/p2p/handshake.go index 7339d9fc1b5..1f43c4c7934 100644 --- a/beacon-chain/p2p/handshake.go +++ b/beacon-chain/p2p/handshake.go @@ -78,21 +78,12 @@ func (s *Service) AddConnectionHandler(reqFunc func(ctx context.Context, id peer return } s.peers.Add(nil /* ENR */, remotePeer, conn.RemoteMultiaddr(), conn.Stat().Direction) - if len(s.peers.Active()) >= int(s.cfg.MaxPeers) { - log.WithField("reason", "at peer limit").Trace("Ignoring connection request") - if err := goodbyeFunc(context.Background(), remotePeer); err != nil { - log.WithError(err).Trace("Unable to send goodbye message to peer") - } - disconnectFromPeer() - return - } if s.peers.IsBad(remotePeer) { log.WithField("reason", "bad peer").Trace("Ignoring connection request") disconnectFromPeer() return } validPeerConnection := func() { - s.host.ConnManager().Protect(conn.RemotePeer(), "protocol") s.peers.SetConnectionState(conn.RemotePeer(), peers.PeerConnected) // Go through the handshake process. multiAddr := fmt.Sprintf("%s/p2p/%s", conn.RemoteMultiaddr().String(), conn.RemotePeer().String()) diff --git a/beacon-chain/p2p/options.go b/beacon-chain/p2p/options.go index a6ec7ee9d61..73ad5611658 100644 --- a/beacon-chain/p2p/options.go +++ b/beacon-chain/p2p/options.go @@ -7,14 +7,23 @@ import ( "time" "github.com/libp2p/go-libp2p" + connmgr "github.com/libp2p/go-libp2p-connmgr" noise "github.com/libp2p/go-libp2p-noise" filter "github.com/multiformats/go-multiaddr" ma "github.com/multiformats/go-multiaddr" "github.com/pkg/errors" - "github.com/prysmaticlabs/prysm/beacon-chain/p2p/connmgr" "github.com/prysmaticlabs/prysm/shared/featureconfig" ) +const ( + // Period that we allocate each new peer before we mark them as valid + // for trimming. + gracePeriod = 2 * time.Minute + // Buffer for the number of peers allowed to connect above max peers before the + // connection manager begins trimming them. + peerBuffer = 5 +) + // buildOptions for the libp2p host. func buildOptions(cfg *Config, ip net.IP, priKey *ecdsa.PrivateKey) []libp2p.Option { listen, err := multiAddressBuilder(ip.String(), cfg.TCPPort) @@ -29,7 +38,7 @@ func buildOptions(cfg *Config, ip net.IP, priKey *ecdsa.PrivateKey) []libp2p.Opt denyListSubnets(cfg.DenyListCIDR), // Add one for the boot node and another for the relay, otherwise when we are close to maxPeers we will be above the high // water mark and continually trigger pruning. - libp2p.ConnectionManager(connmgr.NewConnManager(int(cfg.MaxPeers+2), int(cfg.MaxPeers+2), 1*time.Second)), + libp2p.ConnectionManager(connmgr.NewConnManager(int(cfg.MaxPeers), int(cfg.MaxPeers+peerBuffer), gracePeriod)), } if featureconfig.Get().EnableNoise { // Enable NOISE for the beacon node diff --git a/go.mod b/go.mod index 40786730c7c..862e41255ce 100644 --- a/go.mod +++ b/go.mod @@ -41,9 +41,7 @@ require ( github.com/influxdata/influxdb v1.8.0 // indirect github.com/ipfs/go-cid v0.0.6 // indirect github.com/ipfs/go-datastore v0.4.4 - github.com/ipfs/go-detect-race v0.0.1 github.com/ipfs/go-ipfs-addr v0.0.1 - github.com/ipfs/go-ipns v0.0.2 // indirect github.com/ipfs/go-log v1.0.4 github.com/ipfs/go-log/v2 v2.1.1 github.com/joonix/log v0.0.0-20200409080653-9c1d2ceb5f1d @@ -54,6 +52,7 @@ require ( github.com/libp2p/go-libp2p v0.9.2 github.com/libp2p/go-libp2p-blankhost v0.1.6 github.com/libp2p/go-libp2p-circuit v0.2.3 + github.com/libp2p/go-libp2p-connmgr v0.2.3 github.com/libp2p/go-libp2p-core v0.5.6 github.com/libp2p/go-libp2p-crypto v0.1.0 github.com/libp2p/go-libp2p-host v0.1.0 @@ -64,7 +63,7 @@ require ( github.com/libp2p/go-libp2p-peer v0.2.0 github.com/libp2p/go-libp2p-peerstore v0.2.4 github.com/libp2p/go-libp2p-pubsub v0.3.1 - github.com/libp2p/go-libp2p-routing-helpers v0.2.3 // indirect + github.com/libp2p/go-libp2p-record v0.1.2 // indirect github.com/libp2p/go-libp2p-swarm v0.2.5 github.com/libp2p/go-libp2p-tls v0.1.4-0.20200421131144-8a8ad624a291 // indirect github.com/libp2p/go-libp2p-yamux v0.2.8 // indirect @@ -92,7 +91,6 @@ require ( github.com/status-im/keycard-go v0.0.0-20200402102358-957c09536969 // indirect github.com/tyler-smith/go-bip39 v1.0.2 // indirect github.com/urfave/cli/v2 v2.2.0 - github.com/wangjia184/sortedset v0.0.0-20160527075905-f5d03557ba30 // indirect github.com/wealdtech/eth2-signer-api v1.3.0 github.com/wealdtech/go-bytesutil v1.1.1 github.com/wealdtech/go-eth2-wallet v1.9.4 @@ -111,7 +109,6 @@ require ( golang.org/x/tools v0.0.0-20200528185414-6be401e3f76e google.golang.org/genproto v0.0.0-20200528191852-705c0b31589b google.golang.org/grpc v1.29.1 - google.golang.org/protobuf v1.24.0 gopkg.in/confluentinc/confluent-kafka-go.v1 v1.4.2 gopkg.in/d4l3k/messagediff.v1 v1.2.1 gopkg.in/yaml.v2 v2.2.8 diff --git a/go.sum b/go.sum index 1e7f07df199..7eea5465741 100644 --- a/go.sum +++ b/go.sum @@ -355,10 +355,6 @@ github.com/grpc-ecosystem/grpc-gateway v1.14.6 h1:8ERzHx8aj1Sc47mu9n/AksaKCSWrMc github.com/grpc-ecosystem/grpc-gateway v1.14.6/go.mod h1:zdiPV4Yse/1gnckTHtghG4GkDEdKCRJduHpTxT3/jcw= github.com/gxed/hashland/keccakpg v0.0.1/go.mod h1:kRzw3HkwxFU1mpmPP8v1WyQzwdGfmKFJ6tItnhQ67kU= github.com/gxed/hashland/murmur3 v0.0.1/go.mod h1:KjXop02n4/ckmZSnY2+HKcLud/tcmvhST0bie/0lS48= -github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA= -github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= -github.com/hashicorp/go-multierror v1.1.0 h1:B9UzwGQJehnUY1yNrnwREHc3fGbC2xefo8g4TbElacI= -github.com/hashicorp/go-multierror v1.1.0/go.mod h1:spPvp8C1qA32ftKqdAHm4hHTbPw+vmowP0z+KUhOZdA= github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= @@ -423,8 +419,6 @@ github.com/ipfs/go-ipfs-addr v0.0.1/go.mod h1:uKTDljHT3Q3SUWzDLp3aYUi8MrY32fgNgo github.com/ipfs/go-ipfs-delay v0.0.0-20181109222059-70721b86a9a8/go.mod h1:8SP1YXK1M1kXuc4KJZINY3TQQ03J2rwBG9QfXmbRPrw= github.com/ipfs/go-ipfs-util v0.0.1 h1:Wz9bL2wB2YBJqggkA4dD7oSmqB4cAnpNbGrlHJulv50= github.com/ipfs/go-ipfs-util v0.0.1/go.mod h1:spsl5z8KUnrve+73pOhSVZND1SIxPW5RyBCNzQxlJBc= -github.com/ipfs/go-ipns v0.0.2 h1:oq4ErrV4hNQ2Eim257RTYRgfOSV/s8BDaf9iIl4NwFs= -github.com/ipfs/go-ipns v0.0.2/go.mod h1:WChil4e0/m9cIINWLxZe1Jtf77oz5L05rO2ei/uKJ5U= github.com/ipfs/go-log v0.0.1/go.mod h1:kL1d2/hzSpI0thNYjiKfjanbVNU+IIGA/WnNESY9leM= github.com/ipfs/go-log v1.0.2/go.mod h1:1MNjMxe0u6xvJZgeqbJ8vdo2TKaGwZ1a0Bpza+sr2Sk= github.com/ipfs/go-log v1.0.3/go.mod h1:OsLySYkwIbiSUR/yBTdv1qPtcE4FW3WPWk/ewz9Ru+A= @@ -528,7 +522,6 @@ github.com/libp2p/go-libp2p v0.6.1/go.mod h1:CTFnWXogryAHjXAKEbOf1OWY+VeAP3lDMZk github.com/libp2p/go-libp2p v0.7.0/go.mod h1:hZJf8txWeCduQRDC/WSqBGMxaTHCOYHt2xSU1ivxn0k= github.com/libp2p/go-libp2p v0.7.4/go.mod h1:oXsBlTLF1q7pxr+9w6lqzS1ILpyHsaBPniVO7zIHGMw= github.com/libp2p/go-libp2p v0.8.1/go.mod h1:QRNH9pwdbEBpx5DTJYg+qxcVaDMAz3Ee/qDKwXujH5o= -github.com/libp2p/go-libp2p v0.8.2/go.mod h1:NQDA/F/qArMHGe0J7sDScaKjW8Jh4y/ozQqBbYJ+BnA= github.com/libp2p/go-libp2p v0.8.3/go.mod h1:EsH1A+8yoWK+L4iKcbPYu6MPluZ+CHWI9El8cTaefiM= github.com/libp2p/go-libp2p v0.9.2 h1:5rViLwtjkaEWcIBbk6oII39cVjPTElo3F78SSLf9yho= github.com/libp2p/go-libp2p v0.9.2/go.mod h1:cunHNLDVus66Ct9iXXcjKRLdmHdFdHVe1TAnbubJQqQ= @@ -582,13 +575,9 @@ github.com/libp2p/go-libp2p-host v0.1.0 h1:OZwENiFm6JOK3YR5PZJxkXlJE8a5u8g4YvAUr github.com/libp2p/go-libp2p-host v0.1.0/go.mod h1:5+fWuLbDn8OxoxPN3CV0vsLe1hAKScSMbT84qRfxum8= github.com/libp2p/go-libp2p-kad-dht v0.2.1 h1:+pb1DCkV/6oNQjTZVXl+Y++eV0rnelx/L8y1t4J+Rnw= github.com/libp2p/go-libp2p-kad-dht v0.2.1/go.mod h1:k7ONOlup7HKzQ68dE6lSnp07cdxdkmnRa+6B4Fh9/w0= -github.com/libp2p/go-libp2p-kad-dht v0.8.1 h1:PS/mgLSzFqH5lS3PnnxcqsIrHy+qbQ5GkhzcrT12LyA= -github.com/libp2p/go-libp2p-kad-dht v0.8.1/go.mod h1:u3rbYbp3CSraAHD5s81CJ3hHozKTud/UOXfAgh93Gek= github.com/libp2p/go-libp2p-kbucket v0.2.1/go.mod h1:/Rtu8tqbJ4WQ2KTCOMJhggMukOLNLNPY1EtEWWLxUvc= github.com/libp2p/go-libp2p-kbucket v0.2.3 h1:XtNfN4WUy0cfeJoJgWCf1lor4Pp3kBkFJ9vQ+Zs+VUM= github.com/libp2p/go-libp2p-kbucket v0.2.3/go.mod h1:opWrBZSWnBYPc315q497huxY3sz1t488X6OiXUEYWKA= -github.com/libp2p/go-libp2p-kbucket v0.4.2 h1:wg+VPpCtY61bCasGRexCuXOmEmdKjN+k1w+JtTwu9gA= -github.com/libp2p/go-libp2p-kbucket v0.4.2/go.mod h1:7sCeZx2GkNK1S6lQnGUW5JYZCFPnXzAZCCBBS70lytY= github.com/libp2p/go-libp2p-loggables v0.1.0 h1:h3w8QFfCt2UJl/0/NW4K829HX/0S4KD31PQ7m8UXXO8= github.com/libp2p/go-libp2p-loggables v0.1.0/go.mod h1:EyumB2Y6PrYjr55Q3/tiJ/o3xoDasoRYM7nOzEpoa90= github.com/libp2p/go-libp2p-mplex v0.2.0/go.mod h1:Ejl9IyjvXJ0T9iqUTE1jpYATQ9NM3g+OtR+EMMODbKo= @@ -629,7 +618,6 @@ github.com/libp2p/go-libp2p-record v0.1.2 h1:M50VKzWnmUrk/M5/Dz99qO9Xh4vs8ijsK+7 github.com/libp2p/go-libp2p-record v0.1.2/go.mod h1:pal0eNcT5nqZaTV7UGhqeGqxFgGdsU/9W//C8dqjQDk= github.com/libp2p/go-libp2p-routing v0.1.0 h1:hFnj3WR3E2tOcKaGpyzfP4gvFZ3t8JkQmbapN0Ct+oU= github.com/libp2p/go-libp2p-routing v0.1.0/go.mod h1:zfLhI1RI8RLEzmEaaPwzonRvXeeSHddONWkcTcB54nE= -github.com/libp2p/go-libp2p-routing-helpers v0.2.3/go.mod h1:795bh+9YeoFl99rMASoiVgHdi5bjack0N1+AFAdbvBw= github.com/libp2p/go-libp2p-secio v0.1.0/go.mod h1:tMJo2w7h3+wN4pgU2LSYeiKPrfqBgkOsdiKK77hE7c8= github.com/libp2p/go-libp2p-secio v0.2.0/go.mod h1:2JdZepB8J5V9mBp79BmwsaPQhRPNN2NrnB2lKQcdy6g= github.com/libp2p/go-libp2p-secio v0.2.1/go.mod h1:cWtZpILJqkqrSkiYcDBh5lA3wbT2Q+hz3rJQq3iftD8= @@ -938,12 +926,6 @@ github.com/protolambda/zssz v0.1.4 h1:4jkt8sqwhOVR8B1JebREU/gVX0Ply4GypsV8+RWrDu github.com/protolambda/zssz v0.1.4/go.mod h1:a4iwOX5FE7/JkKA+J/PH0Mjo9oXftN6P8NZyL28gpag= github.com/prysmaticlabs/bazel-go-ethereum v0.0.0-20200530091827-df74fa9e9621 h1:HcfxALO2N5aiK20b9GmfP/ZQKcjnaRlY8qvFWgSqq0c= github.com/prysmaticlabs/bazel-go-ethereum v0.0.0-20200530091827-df74fa9e9621/go.mod h1:oP8FC5+TbICUyftkTWs+8JryntjIJLJvWvApK3z2AYw= -github.com/prysmaticlabs/ethereumapis v0.0.0-20200529200550-337049017365 h1:WYx4msKthEtN21Vr/T1RXaCLQHnTOuP5ccAgcygBODc= -github.com/prysmaticlabs/ethereumapis v0.0.0-20200529200550-337049017365/go.mod h1:rs05kpTfWKl0KflsBWzBQFstoyPFMTWQTbxSAyGHe78= -github.com/prysmaticlabs/ethereumapis v0.0.0-20200603034020-fd7b2d1fe13f h1:+FPJ/5X39h+Jk9Ny16tVH315TzsDCUdfF9U8UWSzY1Q= -github.com/prysmaticlabs/ethereumapis v0.0.0-20200603034020-fd7b2d1fe13f/go.mod h1:rs05kpTfWKl0KflsBWzBQFstoyPFMTWQTbxSAyGHe78= -github.com/prysmaticlabs/ethereumapis v0.0.0-20200606010748-e78ac6918bf5 h1:XfsjGmygBsjmY7FcEZPxxHrsRwYyYEhROdDKWn3QWXg= -github.com/prysmaticlabs/ethereumapis v0.0.0-20200606010748-e78ac6918bf5/go.mod h1:rs05kpTfWKl0KflsBWzBQFstoyPFMTWQTbxSAyGHe78= github.com/prysmaticlabs/ethereumapis v0.0.0-20200608211251-7dafd77461b5 h1:9igaafiIE223IAcWdw7LyFOzAh4okr1/b4JtvfDMI9A= github.com/prysmaticlabs/ethereumapis v0.0.0-20200608211251-7dafd77461b5/go.mod h1:rs05kpTfWKl0KflsBWzBQFstoyPFMTWQTbxSAyGHe78= github.com/prysmaticlabs/go-bitfield v0.0.0-20191017011753-53b773adde52/go.mod h1:hCwmef+4qXWjv0jLDbQdWnL0Ol7cS7/lCSS26WR+u6s= @@ -1069,7 +1051,6 @@ github.com/urfave/cli/v2 v2.2.0 h1:JTTnM6wKzdA0Jqodd966MVj4vWbbquZykeX1sKbe2C4= github.com/urfave/cli/v2 v2.2.0/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ= github.com/viant/assertly v0.4.8/go.mod h1:aGifi++jvCrUaklKEKT0BU95igDNaqkvz+49uaYMPRU= github.com/viant/toolbox v0.24.0/go.mod h1:OxMCG57V0PXuIP2HNQrtJf2CjqdmbrOx5EkMILuUhzM= -github.com/wangjia184/sortedset v0.0.0-20160527075905-f5d03557ba30/go.mod h1:YkocrP2K2tcw938x9gCOmT5G5eCD6jsTz0SZuyAqwIE= github.com/wealdtech/eth2-signer-api v1.3.0 h1:Fs0GfrdhboBKW7zaMvIvUHJaOB1ibpAmRG3lkB53in4= github.com/wealdtech/eth2-signer-api v1.3.0/go.mod h1:H8OpAoTBl6CaBvZEnhxWDjjWXNc3kwVFKWMAZd6sHlk= github.com/wealdtech/go-bytesutil v1.0.0/go.mod h1:jENeMqeTEU8FNZyDFRVc7KqBdRKSnJ9CCh26TcuNb9s= @@ -1382,8 +1363,6 @@ golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapK golang.org/x/tools v0.0.0-20200221224223-e1da425f72fd/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200528185414-6be401e3f76e h1:jTL1CJ2kmavapMVdBKy6oVrhBHByRCMfykS45+lEFQk= golang.org/x/tools v0.0.0-20200528185414-6be401e3f76e/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200530233709-52effbd89c51 h1:Wec8/IO8hAraBf0it7/dPQYOslIrgM938wZYNkLnOYc= -golang.org/x/tools v0.0.0-20200530233709-52effbd89c51/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=