Skip to content

Commit

Permalink
[DataApi] Handle Deregisterd operator errors (#260)
Browse files Browse the repository at this point in the history
Co-authored-by: Siddharth More <Siddhi More>
  • Loading branch information
siddimore authored Feb 28, 2024
1 parent 6147d85 commit b8f296b
Show file tree
Hide file tree
Showing 8 changed files with 421 additions and 25 deletions.
3 changes: 3 additions & 0 deletions disperser/dataapi/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,9 @@ const docTemplate = `{
"operator_id": {
"type": "string"
},
"operator_process_error": {
"type": "string"
},
"socket": {
"type": "string"
}
Expand Down
3 changes: 3 additions & 0 deletions disperser/dataapi/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,9 @@
"operator_id": {
"type": "string"
},
"operator_process_error": {
"type": "string"
},
"socket": {
"type": "string"
}
Expand Down
2 changes: 2 additions & 0 deletions disperser/dataapi/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ definitions:
type: boolean
operator_id:
type: string
operator_process_error:
type: string
socket:
type: string
type: object
Expand Down
28 changes: 18 additions & 10 deletions disperser/dataapi/operators_info_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ import (
)

type OperatorOnlineStatus struct {
OperatorInfo *Operator
IndexedOperatorInfo *core.IndexedOperatorInfo
OperatorInfo *Operator
IndexedOperatorInfo *core.IndexedOperatorInfo
OperatorProcessError string
}

var (
Expand Down Expand Up @@ -60,8 +61,9 @@ func processOperatorOnlineCheck(deregisteredOperatorState *IndexedDeregisteredOp

for _, operatorInfo := range operators {
operatorStatus := OperatorOnlineStatus{
OperatorInfo: operatorInfo.Metadata,
IndexedOperatorInfo: operatorInfo.IndexedOperatorInfo,
OperatorInfo: operatorInfo.Metadata,
IndexedOperatorInfo: operatorInfo.IndexedOperatorInfo,
OperatorProcessError: operatorInfo.OperatorProcessError,
}

// Submit each operator status check to the worker pool
Expand All @@ -74,8 +76,13 @@ func processOperatorOnlineCheck(deregisteredOperatorState *IndexedDeregisteredOp
}

func checkIsOnlineAndProcessOperator(operatorStatus OperatorOnlineStatus, operatorOnlineStatusresultsChan chan<- *DeregisteredOperatorMetadata, logger common.Logger) {
socket := core.OperatorSocket(operatorStatus.IndexedOperatorInfo.Socket).GetRetrievalSocket()
isOnline := checkIsOperatorOnline(socket)
var isOnline bool
var socket string
if operatorStatus.IndexedOperatorInfo != nil {
logger.Error("IndexedOperatorInfo is nil for operator %v", operatorStatus.OperatorInfo)
socket = core.OperatorSocket(operatorStatus.IndexedOperatorInfo.Socket).GetRetrievalSocket()
isOnline = checkIsOperatorOnline(socket)
}

// Log the online status
if isOnline {
Expand All @@ -86,10 +93,11 @@ func checkIsOnlineAndProcessOperator(operatorStatus OperatorOnlineStatus, operat

// Create the metadata regardless of online status
metadata := &DeregisteredOperatorMetadata{
OperatorId: string(operatorStatus.OperatorInfo.OperatorId[:]),
BlockNumber: uint(operatorStatus.OperatorInfo.BlockNumber),
Socket: socket,
IsOnline: isOnline,
OperatorId: string(operatorStatus.OperatorInfo.OperatorId[:]),
BlockNumber: uint(operatorStatus.OperatorInfo.BlockNumber),
Socket: socket,
IsOnline: isOnline,
OperatorProcessError: operatorStatus.OperatorProcessError,
}

// Send the metadata to the results channel
Expand Down
10 changes: 5 additions & 5 deletions disperser/dataapi/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,11 @@ type (
}

DeregisteredOperatorMetadata struct {
OperatorId string `json:"operator_id"`
BlockNumber uint `json:"block_number"`
Socket string `json:"socket"`
IsOnline bool `json:"is_online"`
OperatorId string `json:"operator_id"`
BlockNumber uint `json:"block_number"`
Socket string `json:"socket"`
IsOnline bool `json:"is_online"`
OperatorProcessError string `json:"operator_process_error"`
}

DeregisteredOperatorsResponse struct {
Expand Down Expand Up @@ -165,7 +166,6 @@ func (s *server) Start() error {
metrics.GET("/throughput", s.FetchMetricsTroughputHandler)
metrics.GET("/non-signers", s.FetchNonSigners)
metrics.GET("/operator-nonsigning-percentage", s.FetchOperatorsNonsigningPercentageHandler)
metrics.GET("/deregistered-operators", s.FetchDeregisteredOperators)
}
swagger := v1.Group("/swagger")
{
Expand Down
Loading

0 comments on commit b8f296b

Please sign in to comment.