From 72c8b7961a1ac612b725673f3801119fc37ddbfb Mon Sep 17 00:00:00 2001 From: gop Date: Tue, 2 Jan 2024 07:21:45 -0600 Subject: [PATCH] Fix the crash related to the hard-fork change in the peer --- eth/protocols/eth/protocol.go | 2 +- p2p/peer.go | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/eth/protocols/eth/protocol.go b/eth/protocols/eth/protocol.go index 373166ed33..ecded03ec0 100644 --- a/eth/protocols/eth/protocol.go +++ b/eth/protocols/eth/protocol.go @@ -39,7 +39,7 @@ const c_ProtocolName = "quai" // ProtocolVersions are the supported versions of the `eth` protocol (first // is primary). -var ProtocolVersions = []uint{QUAI1, QUAI2} +var ProtocolVersions = []uint{QUAI2} // protocolLengths are the number of implemented message corresponding to // different protocol versions. diff --git a/p2p/peer.go b/p2p/peer.go index d2f0f06692..77eef1e182 100644 --- a/p2p/peer.go +++ b/p2p/peer.go @@ -397,6 +397,9 @@ outer: func (p *Peer) startProtocols(writeStart <-chan struct{}, writeErr chan<- error) { p.wg.Add(len(p.running)) for _, proto := range p.running { + if proto == nil { + continue + } proto := proto proto.closed = p.closed proto.wstart = writeStart @@ -408,6 +411,9 @@ func (p *Peer) startProtocols(writeStart <-chan struct{}, writeErr chan<- error) p.log.Trace(fmt.Sprintf("Starting protocol %s/%d", proto.Name, proto.Version)) go func() { defer p.wg.Done() + if proto == nil { + return + } err := proto.Run(p, rw) if err == nil { p.log.Trace(fmt.Sprintf("Protocol %s/%d returned", proto.Name, proto.Version))