From 680b2c9db57acab02c3401ddfcf341b691794588 Mon Sep 17 00:00:00 2001 From: Barry Plunkett Date: Wed, 21 Sep 2022 11:46:31 -0400 Subject: [PATCH] [Bug Fix] Allow empty relayer ID for Validators (#37) * initializing side car broadcast only for sidecar peers * fixing relayer initialization in switch to allow empty relayer ID --- mempool/reactor.go | 10 ++++++++-- node/node.go | 8 ++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/mempool/reactor.go b/mempool/reactor.go index cb01d9d2a..96c5bc274 100644 --- a/mempool/reactor.go +++ b/mempool/reactor.go @@ -164,7 +164,12 @@ func (memR *Reactor) GetChannels() []*p2p.ChannelDescriptor { func (memR *Reactor) AddPeer(peer p2p.Peer) { if memR.config.Broadcast { go memR.broadcastMempoolTxRoutine(peer) - go memR.broadcastSidecarTxRoutine(peer) + fmt.Println("[mev-tendermint] Starting mempool tx broadcast routine for ", peer.ID()) + // go memR.broadcastSidecarTxRoutine(peer) + if peer.IsSidecarPeer() { + fmt.Println("[mev-tendermint] Starting sidecar tx broadcast routine for ", peer.ID()) + go memR.broadcastSidecarTxRoutine(peer) + } } } @@ -185,7 +190,7 @@ func (memR *Reactor) Receive(chID byte, src p2p.Peer, msgBytes []byte) { memR.Switch.StopPeerForError(src, err) return } - memR.Logger.Debug("Receive Mempool Tx", "src", src, "chId", chID, "msg", msg) + memR.Logger.Info("Received Mempool Tx", "src ", src.ID, "chId", chID, "msg", msg) txInfo := TxInfo{SenderID: memR.ids.GetForPeer(src)} if src != nil { txInfo.SenderP2PID = src.ID() @@ -206,6 +211,7 @@ func (memR *Reactor) Receive(chID byte, src p2p.Peer, msgBytes []byte) { memR.Switch.StopPeerForError(src, err) return } + fmt.Println("[mev-tendermint] Reactor (receive) RECEIVED TX FROM ", src.ID()) // memR.Logger.Debug("Receive Sidecar Tx", "src", src, "chId", chID, "msg", msg) txInfo := TxInfo{SenderID: memR.ids.GetForPeer(src), DesiredHeight: msg.DesiredHeight, BundleId: msg.BundleId, BundleOrder: msg.BundleOrder, BundleSize: msg.BundleSize} if src != nil { diff --git a/node/node.go b/node/node.go index f8564df0f..5e7f5d641 100644 --- a/node/node.go +++ b/node/node.go @@ -550,12 +550,13 @@ func createSwitch(config *cfg.Config, nodeKey *p2p.NodeKey, p2pLogger log.Logger) *p2p.Switch { peerList := splitAndTrimEmpty(config.Sidecar.PersonalPeerIDs, ",", " ") - if !contains(peerList, config.Sidecar.RelayerID) { + + if !contains(peerList, config.Sidecar.RelayerID) && config.Sidecar.RelayerID != "" { peerList = append(peerList, config.Sidecar.RelayerID) } sidecarPeers, err := p2p.NewSidecarPeers(peerList) if err != nil { - panic("Problem with peer initialization") + p2pLogger.Error(fmt.Sprintf("Error initializing sidecar peers: %s", err)) } sw := p2p.NewSwitch( @@ -833,6 +834,9 @@ func NewNode(config *cfg.Config, transport, peerFilters := createTransport(config, nodeInfo, nodeKey, proxyApp) // Setup Switch. + if config.Sidecar.RelayerID == "" { + logger.Error("Relayer ID not set -- Will not participate in mev auctions") + } p2pLogger := logger.With("module", "p2p") sw := createSwitch( config, transport, p2pMetrics, peerFilters, mempoolReactor, bcReactor,