Skip to content

Commit

Permalink
temp fix: only accept valid erigon peers
Browse files Browse the repository at this point in the history
# Conflicts:
#	p2p/server.go
  • Loading branch information
weiihann committed Dec 4, 2023
1 parent 636b91e commit df449c2
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions p2p/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"errors"
"fmt"
"net"
"strings"
"sync"
"sync/atomic"
"time"
Expand Down Expand Up @@ -889,11 +890,29 @@ func (srv *Server) addPeerChecks(peers map[enode.ID]*Peer, inboundCount int, c *
if len(srv.Protocols) > 0 && countMatchingProtocols(srv.Protocols, c.caps) == 0 {
return DiscUselessPeer
}

if !checkValidErigonNodes(c.name) {
return errors.New("only connect to Erigon peers with version 1.1.9-dev-d0bc870b or 1.1.9-dev-86fc9ec3")
}

// Repeat the post-handshake checks because the
// peer set might have changed since those checks were performed.
return srv.postHandshakeChecks(peers, inboundCount, c)
}

// TEMP FIX: If the node is running erigon, only support the following version:
// 1.1.9-dev-d0bc870b
// 1.1.9-dev-86fc9ec3
func checkValidErigonNodes(name string) bool {
name = strings.ToLower(name)
if strings.Contains(name, "erigon") {
if !strings.Contains(name, "d0bc870b") && !strings.Contains(name, "86fc9ec3") {
return false
}
}
return true
}

// listenLoop runs in its own goroutine and accepts
// inbound connections.
func (srv *Server) listenLoop() {
Expand Down

0 comments on commit df449c2

Please sign in to comment.