Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds operator ejections dataapi endpoint #810

Merged
merged 12 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 94 additions & 0 deletions disperser/dataapi/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,69 @@ const docTemplate = `{
}
}
},
"/operators-info/operator-ejections": {
"get": {
"produces": [
"application/json"
],
"tags": [
"OperatorsInfo"
],
"summary": "Fetch list of operator ejections over last N days.",
"parameters": [
{
"type": "integer",
"description": "Lookback in days [default: 1]",
"name": "days",
"in": "query"
},
{
"type": "string",
"description": "Operator ID filter [default: all operators]",
"name": "operator_id",
"in": "query"
},
{
"type": "integer",
"description": "Return first N ejections [default: 1000]",
"name": "first",
"in": "query"
},
{
"type": "integer",
"description": "Skip first N ejections [default: 0]",
"name": "skip",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/dataapi.QueriedOperatorEjectionsResponse"
}
},
"400": {
"description": "error: Bad request",
"schema": {
"$ref": "#/definitions/dataapi.ErrorResponse"
}
},
"404": {
"description": "error: Not found",
"schema": {
"$ref": "#/definitions/dataapi.ErrorResponse"
}
},
"500": {
"description": "error: Server error",
"schema": {
"$ref": "#/definitions/dataapi.ErrorResponse"
}
}
}
}
},
"/operators-info/operators-stake": {
"get": {
"produces": [
Expand Down Expand Up @@ -920,6 +983,37 @@ const docTemplate = `{
}
}
},
"dataapi.QueriedOperatorEjections": {
"type": "object",
"properties": {
"block_number": {
"type": "integer"
},
"block_timestamp": {
"type": "string"
},
"operator_id": {
"type": "string"
},
"quorum": {
"type": "integer"
},
"transaction_hash": {
"type": "string"
}
}
},
"dataapi.QueriedOperatorEjectionsResponse": {
"type": "object",
"properties": {
"ejections": {
"type": "array",
"items": {
"$ref": "#/definitions/dataapi.QueriedOperatorEjections"
}
}
}
},
"dataapi.QueriedStateOperatorMetadata": {
"type": "object",
"properties": {
Expand Down
94 changes: 94 additions & 0 deletions disperser/dataapi/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,69 @@
}
}
},
"/operators-info/operator-ejections": {
"get": {
"produces": [
"application/json"
],
"tags": [
"OperatorsInfo"
],
"summary": "Fetch list of operator ejections over last N days.",
"parameters": [
{
"type": "integer",
"description": "Lookback in days [default: 1]",
"name": "days",
"in": "query"
},
{
"type": "string",
"description": "Operator ID filter [default: all operators]",
"name": "operator_id",
"in": "query"
},
{
"type": "integer",
"description": "Return first N ejections [default: 1000]",
"name": "first",
"in": "query"
},
{
"type": "integer",
"description": "Skip first N ejections [default: 0]",
"name": "skip",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/dataapi.QueriedOperatorEjectionsResponse"
}
},
"400": {
"description": "error: Bad request",
"schema": {
"$ref": "#/definitions/dataapi.ErrorResponse"
}
},
"404": {
"description": "error: Not found",
"schema": {
"$ref": "#/definitions/dataapi.ErrorResponse"
}
},
"500": {
"description": "error: Server error",
"schema": {
"$ref": "#/definitions/dataapi.ErrorResponse"
}
}
}
}
},
"/operators-info/operators-stake": {
"get": {
"produces": [
Expand Down Expand Up @@ -916,6 +979,37 @@
}
}
},
"dataapi.QueriedOperatorEjections": {
"type": "object",
"properties": {
"block_number": {
"type": "integer"
},
"block_timestamp": {
"type": "string"
},
"operator_id": {
"type": "string"
},
"quorum": {
"type": "integer"
},
"transaction_hash": {
"type": "string"
}
}
},
"dataapi.QueriedOperatorEjectionsResponse": {
"type": "object",
"properties": {
"ejections": {
"type": "array",
"items": {
"$ref": "#/definitions/dataapi.QueriedOperatorEjections"
}
}
}
},
"dataapi.QueriedStateOperatorMetadata": {
"type": "object",
"properties": {
Expand Down
61 changes: 61 additions & 0 deletions disperser/dataapi/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,26 @@ definitions:
type: array
type: object
type: object
dataapi.QueriedOperatorEjections:
properties:
block_number:
type: integer
block_timestamp:
type: string
operator_id:
type: string
quorum:
type: integer
transaction_hash:
type: string
type: object
dataapi.QueriedOperatorEjectionsResponse:
properties:
ejections:
items:
$ref: '#/definitions/dataapi.QueriedOperatorEjections'
type: array
type: object
dataapi.QueriedStateOperatorMetadata:
properties:
block_number:
Expand Down Expand Up @@ -605,6 +625,47 @@ paths:
is a query parameter with a default value of 14 and max value of 30.
tags:
- OperatorsInfo
/operators-info/operator-ejections:
get:
parameters:
- description: 'Lookback in days [default: 1]'
in: query
name: days
type: integer
- description: 'Operator ID filter [default: all operators]'
in: query
name: operator_id
type: string
- description: 'Return first N ejections [default: 1000]'
in: query
name: first
type: integer
- description: 'Skip first N ejections [default: 0]'
in: query
name: skip
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/dataapi.QueriedOperatorEjectionsResponse'
"400":
description: 'error: Bad request'
schema:
$ref: '#/definitions/dataapi.ErrorResponse'
"404":
description: 'error: Not found'
schema:
$ref: '#/definitions/dataapi.ErrorResponse'
"500":
description: 'error: Server error'
schema:
$ref: '#/definitions/dataapi.ErrorResponse'
summary: Fetch list of operator ejections over last N days.
tags:
- OperatorsInfo
/operators-info/operators-stake:
get:
parameters:
Expand Down
14 changes: 14 additions & 0 deletions disperser/dataapi/queried_operators_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,20 @@ func (s *server) getRegisteredOperatorForDays(ctx context.Context, days int32) (
return RegisteredOperatorMetadata, nil
}

// Function to get operator ejection over last N days
// Returns list of Ejections with operatorId, quorum, block number, txn and timestemp if ejection
func (s *server) getOperatorEjections(ctx context.Context, days int32, operatorId string, first uint, skip uint) ([]*QueriedOperatorEjections, error) {
startTime := time.Now()

operatorEjections, err := s.subgraphClient.QueryOperatorEjectionsForTimeWindow(ctx, days, operatorId, first, skip)
if err != nil {
return nil, err
}

s.logger.Info("Get operator ejections", "days", days, "operatorId", operatorId, "len", len(operatorEjections), "duration", time.Since(startTime))
return operatorEjections, nil
}

func processOperatorOnlineCheck(queriedOperatorsInfo *IndexedQueriedOperatorInfo, operatorOnlineStatusresultsChan chan<- *QueriedStateOperatorMetadata, logger logging.Logger) {
operators := queriedOperatorsInfo.Operators
wp := workerpool.New(poolSize)
Expand Down
Loading
Loading