Skip to content

Commit

Permalink
fix: remove all dynamic peer discovery
Browse files Browse the repository at this point in the history
  • Loading branch information
gartnera committed Dec 12, 2024
1 parent 462fcea commit edcd2d7
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 38 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -371,5 +371,5 @@ replace (
github.com/bnb-chain/tss-lib => github.com/zeta-chain/tss-lib v0.0.0-20240916163010-2e6b438bd901
github.com/ethereum/go-ethereum => github.com/zeta-chain/go-ethereum v1.13.16-0.20241022183758-422c6ef93ccc
github.com/libp2p/go-libp2p => github.com/zeta-chain/go-libp2p v0.0.0-20240710192637-567fbaacc2b4
gitlab.com/thorchain/tss/go-tss => github.com/zeta-chain/go-tss v0.0.0-20241115165301-8535262eb16f
gitlab.com/thorchain/tss/go-tss => github.com/zeta-chain/go-tss v0.0.0-20241211022951-f486d1f8425c
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1526,8 +1526,8 @@ github.com/zeta-chain/go-ethereum v1.13.16-0.20241022183758-422c6ef93ccc h1:FVOt
github.com/zeta-chain/go-ethereum v1.13.16-0.20241022183758-422c6ef93ccc/go.mod h1:MgO2/CmxFnj6W7v/5hrz3ypco3kHkb8856pRnFkY4xQ=
github.com/zeta-chain/go-libp2p v0.0.0-20240710192637-567fbaacc2b4 h1:FmO3HfVdZ7LzxBUfg6sVzV7ilKElQU2DZm8PxJ7KcYI=
github.com/zeta-chain/go-libp2p v0.0.0-20240710192637-567fbaacc2b4/go.mod h1:TBv5NY/CqWYIfUstXO1fDWrt4bDoqgCw79yihqBspg8=
github.com/zeta-chain/go-tss v0.0.0-20241115165301-8535262eb16f h1:zKBTanf2jf/oyr3f27GgvibSdVThmCdcV9sc5/6uOyQ=
github.com/zeta-chain/go-tss v0.0.0-20241115165301-8535262eb16f/go.mod h1:nqelgf4HKkqlXaVg8X38a61WfyYB+ivCt6nnjoTIgCc=
github.com/zeta-chain/go-tss v0.0.0-20241211022951-f486d1f8425c h1:Fb++MnF1ls/A0wjlh8cYRROvTHZ773BdhUzAHDN+Ja0=
github.com/zeta-chain/go-tss v0.0.0-20241211022951-f486d1f8425c/go.mod h1:nqelgf4HKkqlXaVg8X38a61WfyYB+ivCt6nnjoTIgCc=
github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20241021075719-d40d2e28467c h1:ZoFxMMZtivRLquXVq1sEVlT45UnTPMO1MSXtc88nDv4=
github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20241021075719-d40d2e28467c/go.mod h1:SjT7QirtJE8stnAe1SlNOanxtfSfijJm3MGJ+Ax7w7w=
github.com/zeta-chain/protocol-contracts-solana/go-idl v0.0.0-20241108171442-e48d82f94892 h1:oI5qCrw2SXDf2a2UYAn0tpaKHbKpJcR+XDtceyY00wE=
Expand Down
27 changes: 0 additions & 27 deletions zetaclient/metrics/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ type TelemetryServer struct {
status types.Status
ipAddress string
HotKeyBurnRate *BurnRate
knownPeers []peer.AddrInfo
connectedPeers []peer.AddrInfo
rtt map[peer.ID]int64
}
Expand All @@ -43,7 +42,6 @@ func NewTelemetryServer() *TelemetryServer {
lastScannedBlockNumber: make(map[int64]uint64),
lastStartTimestamp: time.Now(),
HotKeyBurnRate: NewBurnRate(100),
knownPeers: make([]peer.AddrInfo, 0),
connectedPeers: make([]peer.AddrInfo, 0),
rtt: make(map[peer.ID]int64),
}
Expand All @@ -69,18 +67,6 @@ func (t *TelemetryServer) GetPingRTT() map[peer.ID]int64 {
return t.rtt
}

func (t *TelemetryServer) SetKnownPeers(peers []peer.AddrInfo) {
t.mu.Lock()
defer t.mu.Unlock()
t.knownPeers = peers
}

func (t *TelemetryServer) GetKnownPeers() []peer.AddrInfo {
t.mu.Lock()
defer t.mu.Unlock()
return t.knownPeers
}

func (t *TelemetryServer) SetConnectedPeers(peers []peer.AddrInfo) {
t.mu.Lock()
defer t.mu.Unlock()
Expand Down Expand Up @@ -189,7 +175,6 @@ func (t *TelemetryServer) Handlers() http.Handler {
router.Handle("/ip", http.HandlerFunc(t.ipHandler)).Methods(http.MethodGet)
router.Handle("/hotkeyburnrate", http.HandlerFunc(t.hotKeyFeeBurnRate)).Methods(http.MethodGet)
router.Handle("/connectedpeers", http.HandlerFunc(t.connectedPeersHandler)).Methods(http.MethodGet)
router.Handle("/knownpeers", http.HandlerFunc(t.knownPeersHandler)).Methods(http.MethodGet)
router.Handle("/pingrtt", http.HandlerFunc(t.pingRTTHandler)).Methods(http.MethodGet)
router.Handle("/systemtime", http.HandlerFunc(systemTimeHandler)).Methods(http.MethodGet)
router.Use(logMiddleware())
Expand Down Expand Up @@ -306,18 +291,6 @@ func (t *TelemetryServer) connectedPeersHandler(w http.ResponseWriter, _ *http.R
fmt.Fprintf(w, "%s", string(data))
}

func (t *TelemetryServer) knownPeersHandler(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusOK)
peers := t.GetKnownPeers()
data, err := json.Marshal(peers)
if err != nil {
t.logger.Error().Err(err).Msg("Failed to marshal known peers")
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
fmt.Fprintf(w, "%s", string(data))
}

func (t *TelemetryServer) pingRTTHandler(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusOK)
rtt := t.GetPingRTT()
Expand Down
7 changes: 0 additions & 7 deletions zetaclient/tss/healthcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,6 @@ func HealthcheckWorker(ctx context.Context, server *tss.TssServer, p Healthcheck
return nil
}

knownPeersCounter := func(_ context.Context, _ *ticker.Ticker) error {
peers := server.GetKnownPeers()
p.Telemetry.SetKnownPeers(peers)
return nil
}

connectedPeersCounter := func(_ context.Context, _ *ticker.Ticker) error {
p2pHost := server.GetP2PHost()
connectedPeers := lo.Map(p2pHost.Network().Conns(), func(conn libp2p_network.Conn, _ int) peer.AddrInfo {
Expand All @@ -112,7 +106,6 @@ func HealthcheckWorker(ctx context.Context, server *tss.TssServer, p Healthcheck
}

runBackgroundTicker(ctx, pinger, p.Interval, "TSSHealthcheckPeersPing", logger)
runBackgroundTicker(ctx, knownPeersCounter, p.Interval, "TSSHealthcheckKnownPeersCounter", logger)
runBackgroundTicker(ctx, connectedPeersCounter, p.Interval, "TSSHealthcheckConnectedPeersCounter", logger)

return nil
Expand Down
1 change: 0 additions & 1 deletion zetaclient/tss/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ type Zetacore interface {
type Telemetry interface {
SetP2PID(id string)
SetConnectedPeers(peers []peer.AddrInfo)
SetKnownPeers(peers []peer.AddrInfo)
SetPingRTT(peers map[peer.ID]int64)
}

Expand Down

0 comments on commit edcd2d7

Please sign in to comment.