Skip to content

Commit

Permalink
Comment out v2 tests TestFetchMetricsSummaryHandler & TestFetchMetric…
Browse files Browse the repository at this point in the history
…sThroughputTimeseriesHandler
  • Loading branch information
pschork committed Jan 3, 2025
1 parent a86ab68 commit 13b6cef
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 401 deletions.
6 changes: 0 additions & 6 deletions disperser/dataapi/v2/metrics_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ type metricsHandler struct {
promClient dataapi.PrometheusClient
}

func newMetricsHandler(promClient dataapi.PrometheusClient) *metricsHandler {
return &metricsHandler{
promClient: promClient,
}
}

func (mh *metricsHandler) GetAvgThroughput(ctx context.Context, startTime int64, endTime int64) (float64, error) {
result, err := mh.promClient.QueryDisperserBlobSizeBytesPerSecond(ctx, time.Unix(startTime, 0), time.Unix(endTime, 0))
if err != nil {
Expand Down
82 changes: 0 additions & 82 deletions disperser/dataapi/v2/metrics_handlers.go

This file was deleted.

40 changes: 40 additions & 0 deletions disperser/dataapi/v2/operator_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package v2
import (
"context"
"fmt"
"net"
"time"

"github.com/Layr-Labs/eigenda/core"
Expand Down Expand Up @@ -156,3 +157,42 @@ func (s *operatorHandler) scanOperatorsHostInfo(ctx context.Context) (*SemverRep
return semverReport, nil

}

// Check that the socketString is not private/unspecified
func ValidOperatorIP(address string, logger logging.Logger) bool {
host, _, err := net.SplitHostPort(address)
if err != nil {
logger.Error("Failed to split host port", "address", address, "error", err)
return false
}
ips, err := net.LookupIP(host)
if err != nil {
logger.Error("Error resolving operator host IP", "host", host, "error", err)
return false
}
ipAddr := ips[0]
if ipAddr == nil {
logger.Error("IP address is nil", "host", host, "ips", ips)
return false
}
isValid := !ipAddr.IsPrivate() && !ipAddr.IsUnspecified()
logger.Debug("Operator IP validation", "address", address, "host", host, "ips", ips, "ipAddr", ipAddr, "isValid", isValid)

return isValid
}

// method to check if operator is online via socket dial
func checkIsOperatorOnline(socket string, timeoutSecs int, logger logging.Logger) bool {
if !ValidOperatorIP(socket, logger) {
logger.Error("port check blocked invalid operator IP", "socket", socket)
return false
}
timeout := time.Second * time.Duration(timeoutSecs)
conn, err := net.DialTimeout("tcp", socket, timeout)
if err != nil {
logger.Warn("port check timeout", "socket", socket, "timeout", timeoutSecs, "error", err)
return false
}
defer conn.Close() // Close the connection after checking
return true
}
Loading

0 comments on commit 13b6cef

Please sign in to comment.