Skip to content

Commit

Permalink
Remove dead code
Browse files Browse the repository at this point in the history
Force dispersal socker for all node info scans
  • Loading branch information
pschork committed Sep 26, 2024
1 parent ac9e1d0 commit 18ccf9b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 43 deletions.
19 changes: 8 additions & 11 deletions disperser/common/semver/semver.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ func ScanOperators(operators map[core.OperatorID]*core.IndexedOperatorInfo, numW
worker := func() {
for operatorId := range operatorChan {
operatorSocket := core.OperatorSocket(operators[operatorId].Socket)
retrievalSocket := operatorSocket.GetRetrievalSocket()
semver := GetSemverInfo(context.Background(), retrievalSocket, operatorId, true, logger, nodeInfoTimeout)
dispersalSocket := operatorSocket.GetDispersalSocket()
semver := GetSemverInfo(context.Background(), dispersalSocket, operatorId, logger, nodeInfoTimeout)

mu.Lock()
semvers[semver]++
Expand All @@ -49,7 +49,7 @@ func ScanOperators(operators map[core.OperatorID]*core.IndexedOperatorInfo, numW
}

// query operator host info endpoint if available
func GetSemverInfo(ctx context.Context, socket string, operatorId core.OperatorID, useRetrievalSocket bool, logger logging.Logger, timeout time.Duration) string {
func GetSemverInfo(ctx context.Context, socket string, operatorId core.OperatorID, logger logging.Logger, timeout time.Duration) string {
conn, err := grpc.Dial(socket, grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
return "unreachable"
Expand All @@ -58,17 +58,14 @@ func GetSemverInfo(ctx context.Context, socket string, operatorId core.OperatorI
ctxWithTimeout, cancel := context.WithTimeout(ctx, timeout)
defer cancel()
reply := &node.NodeInfoReply{}

Check failure on line 60 in disperser/common/semver/semver.go

View workflow job for this annotation

GitHub Actions / Linter

ineffectual assignment to reply (ineffassign)
if useRetrievalSocket {
client := node.NewRetrievalClient(conn)
reply, err = client.NodeInfo(ctxWithTimeout, &node.NodeInfoRequest{})
} else {
client := node.NewDispersalClient(conn)
reply, err = client.NodeInfo(ctxWithTimeout, &node.NodeInfoRequest{})
}
client := node.NewDispersalClient(conn)
reply, err = client.NodeInfo(ctxWithTimeout, &node.NodeInfoRequest{})
if err != nil {
var semver string
if strings.Contains(err.Error(), "Unimplemented") {
if strings.Contains(err.Error(), "unknown method NodeInfo") {
semver = "<0.8.0"
} else if strings.Contains(err.Error(), "unknown service") {
semver = "filtered"
} else if strings.Contains(err.Error(), "DeadlineExceeded") {
semver = "timeout"
} else if strings.Contains(err.Error(), "Unavailable") {
Expand Down
1 change: 1 addition & 0 deletions disperser/dataapi/queried_operators_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ func (s *server) scanOperatorsHostInfo(ctx context.Context) (*SemverReportRespon
// Publish semver report metrics
s.metrics.UpdateSemverCounts(semvers)

s.logger.Info("Semver scan completed", "semverReport", semverReport)
return semverReport, nil
}

Expand Down
14 changes: 0 additions & 14 deletions disperser/dataapi/subgraph/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ type (
QueryOperatorInfoByOperatorIdAtBlockNumber(ctx context.Context, operatorId string, blockNumber uint32) (*IndexedOperatorInfo, error)
QueryOperatorAddedToQuorum(ctx context.Context, startBlock, endBlock uint32) ([]*OperatorQuorum, error)
QueryOperatorRemovedFromQuorum(ctx context.Context, startBlock, endBlock uint32) ([]*OperatorQuorum, error)
QueryOperatorsDeregistered(ctx context.Context, first int) ([]*Operator, error)
}

api struct {
Expand Down Expand Up @@ -111,19 +110,6 @@ func (a *api) QueryOperators(ctx context.Context, first int) ([]*Operator, error
return result.OperatorRegistereds, nil
}

func (a *api) QueryOperatorsDeregistered(ctx context.Context, first int) ([]*Operator, error) {
variables := map[string]any{
"first": graphql.Int(first),
}
result := new(queryOperatorDeregistereds)
err := a.operatorStateGql.Query(ctx, result, variables)
if err != nil {
return nil, err
}

return result.OperatorDeregistereds, nil
}

func (a *api) QueryBatchNonSigningInfo(ctx context.Context, startTime, endTime int64) ([]*BatchNonSigningInfo, error) {

variables := map[string]any{
Expand Down
18 changes: 0 additions & 18 deletions disperser/dataapi/subgraph_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ type (
QueryOperatorQuorumEvent(ctx context.Context, startBlock, endBlock uint32) (*OperatorQuorumEvents, error)
QueryIndexedOperatorsWithStateForTimeWindow(ctx context.Context, days int32, state OperatorState) (*IndexedQueriedOperatorInfo, error)
QueryOperatorInfoByOperatorId(ctx context.Context, operatorId string) (*core.IndexedOperatorInfo, error)
QueryOperatorDeregistrations(ctx context.Context, limit int) ([]*Operator, error)
}
Batch struct {
Id []byte
Expand Down Expand Up @@ -108,23 +107,6 @@ func NewSubgraphClient(api subgraph.Api, logger logging.Logger) *subgraphClient
return &subgraphClient{api: api, logger: logger.With("component", "SubgraphClient")}
}

func (sc *subgraphClient) QueryOperatorDeregistrations(ctx context.Context, limit int) ([]*Operator, error) {
// Implement the logic to query operator deregistrations
operatorsGql, err := sc.api.QueryOperatorsDeregistered(ctx, limit)
if err != nil {
return nil, err
}
operators := make([]*Operator, len(operatorsGql))
for i, operatorGql := range operatorsGql {
operator, err := convertOperator(operatorGql)
if err != nil {
return nil, err
}
operators[i] = operator
}
return operators, nil
}

func (sc *subgraphClient) QueryBatchesWithLimit(ctx context.Context, limit, skip int) ([]*Batch, error) {
subgraphBatches, err := sc.api.QueryBatches(ctx, true, "blockTimestamp", limit, skip)
if err != nil {
Expand Down

0 comments on commit 18ccf9b

Please sign in to comment.