diff --git a/p2p/dial.go b/p2p/dial.go index 3e5bedeee7b752cb56dd3edabfee608a1ef16835..ce1a6e4ebd28bbae9d5d44c01e41b78ad13ba6fb 100644 --- a/p2p/dial.go +++ b/p2p/dial.go @@ -42,8 +42,8 @@ const ( dialHistoryExpiration = inboundThrottleTime + 5*time.Second // Config for the "Looking for peers" message. - dialStatsLogInterval = 10 * time.Second // printed at most this often - dialStatsPeerLimit = 3 // but not if more than this many dialed peers + dialStatsLogInterval = 60 * time.Second // printed at most this often + dialStatsPeerLimit = 20 // but not if more than this many dialed peers // Endpoint resolution is throttled with bounded backoff. initialResolveDelay = 60 * time.Second @@ -106,6 +106,8 @@ type dialScheduler struct { addPeerCh chan *conn remPeerCh chan *conn + subProtocolVersion uint + // Everything below here belongs to loop and // should only be accessed by code on the loop goroutine. dialing map[enode.ID]*dialTask // active tasks @@ -164,7 +166,7 @@ func (cfg dialConfig) withDefaults() dialConfig { return cfg } -func newDialScheduler(config dialConfig, it enode.Iterator, setupFunc dialSetupFunc) *dialScheduler { +func newDialScheduler(config dialConfig, it enode.Iterator, setupFunc dialSetupFunc, subProtocolVersion uint) *dialScheduler { d := &dialScheduler{ dialConfig: config.withDefaults(), setupFunc: setupFunc, @@ -177,6 +179,8 @@ func newDialScheduler(config dialConfig, it enode.Iterator, setupFunc dialSetupF remStaticCh: make(chan *enode.Node), addPeerCh: make(chan *conn), remPeerCh: make(chan *conn), + + subProtocolVersion: subProtocolVersion, } d.lastStatsLog = d.clock.Now() d.ctx, d.cancel = context.WithCancel(context.Background()) @@ -343,7 +347,7 @@ func (d *dialScheduler) logStats() { return } if d.dialPeers < dialStatsPeerLimit && d.dialPeers < d.maxDialPeers { - d.log.Debug("Looking for peers", "peercount", len(d.peers), "tried", d.doneSinceLastLog, "static", len(d.static)) + d.log.Info("[p2p] Looking for peers", "protocol", d.subProtocolVersion, "peers", fmt.Sprintf("%d/%d", len(d.peers), d.maxDialPeers), "tried", d.doneSinceLastLog, "static", len(d.static)) } d.doneSinceLastLog = 0 d.lastStatsLog = now diff --git a/p2p/peer.go b/p2p/peer.go index 434a9e28e0c485fbed4e4520f67bc963672043e2..a3b1434c837f81b741efe4961a8dd3693fa9e7b3 100644 --- a/p2p/peer.go +++ b/p2p/peer.go @@ -317,7 +317,7 @@ func (p *Peer) handle(msg Msg) error { // This is the last message. We don't need to discard or // check errors because, the connection will be closed after it. _ = rlp.Decode(msg.Payload, &reason) - return reason[0] + return fmt.Errorf("peer has: %w", reason[0]) case msg.Code < baseProtocolLength: // ignore other base protocol messages msg.Discard() diff --git a/p2p/server.go b/p2p/server.go index ae2495a43e2912641a211e94dfba25b51d63e081..3883f763e608a69dfcb6d68e0e8f1e18c4156596 100644 --- a/p2p/server.go +++ b/p2p/server.go @@ -649,7 +649,11 @@ func (srv *Server) setupDialScheduler() { if config.dialer == nil { config.dialer = tcpDialer{&net.Dialer{Timeout: defaultDialTimeout}} } - srv.dialsched = newDialScheduler(config, srv.discmix, srv.SetupConn) + var subProtocolVersion uint + if len(srv.Protocols) > 0 { + subProtocolVersion = srv.Protocols[0].Version + } + srv.dialsched = newDialScheduler(config, srv.discmix, srv.SetupConn, subProtocolVersion) for _, n := range srv.StaticNodes { srv.dialsched.addStatic(n) }