Skip to content

Commit

Permalink
Update dataapi response to include stake %
Browse files Browse the repository at this point in the history
  • Loading branch information
pschork committed Oct 31, 2024
1 parent f42ecf2 commit 807b43e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion disperser/common/semver/semver.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func GetSemverInfo(ctx context.Context, socket string, userRetrievalClient bool,

// local node source compiles without semver
if reply.Semver == "" {
reply.Semver = "src-compile"
reply.Semver = "0.8.4"
}

logger.Info("NodeInfo", "operatorId", operatorId.Hex(), "socket", socket, "userRetrievalClient", userRetrievalClient, "semver", reply.Semver, "os", reply.Os, "arch", reply.Arch, "numCpu", reply.NumCpu, "memBytes", reply.MemBytes)
Expand Down
7 changes: 4 additions & 3 deletions disperser/dataapi/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/Layr-Labs/eigenda/disperser"
"github.com/Layr-Labs/eigenda/disperser/common/blobstore"
"github.com/Layr-Labs/eigenda/disperser/common/semver"
"github.com/Layr-Labs/eigenda/operators"
"github.com/Layr-Labs/eigensdk-go/logging"
"github.com/prometheus/client_golang/prometheus"
Expand Down Expand Up @@ -110,9 +111,9 @@ func (g *Metrics) IncrementNotFoundRequestNum(method string) {
}

// UpdateSemverMetrics updates the semver metrics
func (g *Metrics) UpdateSemverCounts(semverData map[string]int) {
for semver, count := range semverData {
g.Semvers.WithLabelValues(semver).Set(float64(count))
func (g *Metrics) UpdateSemverCounts(semverData map[string]*semver.SemverMetrics) {
for semver, metrics := range semverData {
g.Semvers.WithLabelValues(semver).Set(float64(metrics.Operators))
}
}

Expand Down
6 changes: 5 additions & 1 deletion disperser/dataapi/queried_operators_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,11 +296,15 @@ func (s *server) scanOperatorsHostInfo(ctx context.Context) (*SemverReportRespon
return nil, fmt.Errorf("failed to fetch indexed operator info - %s", err)
}
s.logger.Info("Queried indexed operators", "operators", len(operators), "block", currentBlock)
operatorState, err := s.chainState.GetOperatorState(context.Background(), currentBlock, []core.QuorumID{0, 1, 2})
if err != nil {
return nil, fmt.Errorf("failed to fetch operator state - %s", err)
}

nodeInfoWorkers := 20
nodeInfoTimeout := time.Duration(1 * time.Second)
useRetrievalClient := false
semvers := semver.ScanOperators(operators, useRetrievalClient, nodeInfoWorkers, nodeInfoTimeout, s.logger)
semvers := semver.ScanOperators(operators, operatorState, useRetrievalClient, nodeInfoWorkers, nodeInfoTimeout, s.logger)

// Create HostInfoReportResponse instance
semverReport := &SemverReportResponse{
Expand Down
3 changes: 2 additions & 1 deletion disperser/dataapi/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"google.golang.org/grpc/health/grpc_health_v1"

"github.com/Layr-Labs/eigenda/disperser"
"github.com/Layr-Labs/eigenda/disperser/common/semver"
"github.com/Layr-Labs/eigenda/disperser/dataapi/docs"
"github.com/gin-contrib/cors"
"github.com/gin-contrib/logger"
Expand Down Expand Up @@ -181,7 +182,7 @@ type (
RetrievalOnline bool `json:"retrieval_online"`
}
SemverReportResponse struct {
Semver map[string]int `json:"semver"`
Semver map[string]*semver.SemverMetrics `json:"semver"`
}

ErrorResponse struct {
Expand Down
5 changes: 4 additions & 1 deletion tools/semverscan/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,12 @@ func RunScan(ctx *cli.Context) error {
return fmt.Errorf("failed to fetch current block number - %s", err)
}
operatorState, err := chainState.GetOperatorState(context.Background(), currentBlock, []core.QuorumID{0, 1, 2})
if err != nil {
return fmt.Errorf("failed to fetch operator state - %s", err)
}
operators, err := ics.GetIndexedOperators(context.Background(), currentBlock)
if err != nil {
return fmt.Errorf("failed to fetch indexed operator state - %s", err)
return fmt.Errorf("failed to fetch indexed operators info - %s", err)
}
if config.OperatorId != "" {
operatorId, err := core.OperatorIDFromHex(config.OperatorId)
Expand Down

0 comments on commit 807b43e

Please sign in to comment.