Skip to content

Commit

Permalink
[Bug Fix] Allow empty relayer ID for Validators (#37)
Browse files Browse the repository at this point in the history
* initializing side car broadcast only for sidecar peers

* fixing relayer initialization in switch to allow empty relayer ID
  • Loading branch information
bpiv400 authored Sep 21, 2022
1 parent e786ae9 commit 680b2c9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
10 changes: 8 additions & 2 deletions mempool/reactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}

Expand All @@ -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()
Expand All @@ -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 {
Expand Down
8 changes: 6 additions & 2 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 680b2c9

Please sign in to comment.