Skip to content

Commit

Permalink
Operator signing computing (#1206)
Browse files Browse the repository at this point in the history
  • Loading branch information
jianoaix authored Feb 4, 2025
1 parent af073be commit cd790e8
Show file tree
Hide file tree
Showing 9 changed files with 1,370 additions and 12 deletions.
12 changes: 12 additions & 0 deletions core/mock/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ func (t *MockWriter) GetOperatorStakes(ctx context.Context, operatorId core.Oper
func (t *MockWriter) GetOperatorStakesForQuorums(ctx context.Context, quorums []core.QuorumID, blockNumber uint32) (core.OperatorStakes, error) {
args := t.Called()
result := args.Get(0)
if fn, ok := result.(func([]core.QuorumID, uint32) core.OperatorStakes); ok {
return fn(quorums, blockNumber), args.Error(1)
}
return result.(core.OperatorStakes), args.Error(1)
}

Expand Down Expand Up @@ -128,18 +131,27 @@ func (t *MockWriter) OperatorAddressToID(ctx context.Context, address gethcommon
func (t *MockWriter) BatchOperatorIDToAddress(ctx context.Context, operatorIds []core.OperatorID) ([]gethcommon.Address, error) {
args := t.Called()
result := args.Get(0)
if fn, ok := result.(func([]core.OperatorID) []gethcommon.Address); ok {
return fn(operatorIds), args.Error(1)
}
return result.([]gethcommon.Address), args.Error(1)
}

func (t *MockWriter) BatchOperatorAddressToID(ctx context.Context, addresses []gethcommon.Address) ([]core.OperatorID, error) {
args := t.Called()
result := args.Get(0)
if fn, ok := result.(func([]gethcommon.Address) []core.OperatorID); ok {
return fn(addresses), args.Error(1)
}
return result.([]core.OperatorID), args.Error(1)
}

func (t *MockWriter) GetQuorumBitmapForOperatorsAtBlockNumber(ctx context.Context, operatorIds []core.OperatorID, blockNumber uint32) ([]*big.Int, error) {
args := t.Called()
result := args.Get(0)
if fn, ok := result.(func([]core.OperatorID, uint32) []*big.Int); ok {
return fn(operatorIds, blockNumber), args.Error(1)
}
return result.([]*big.Int), args.Error(1)
}

Expand Down
103 changes: 103 additions & 0 deletions disperser/dataapi/docs/v2/V2_docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,69 @@ const docTemplateV2 = `{
}
}
},
"/operators/signing-info": {
"get": {
"produces": [
"application/json"
],
"tags": [
"Operators"
],
"summary": "Fetch operators signing info",
"parameters": [
{
"type": "string",
"description": "Fetch operators signing info up to the end time (ISO 8601 format: 2006-01-02T15:04:05Z) [default: now]",
"name": "end",
"in": "query"
},
{
"type": "integer",
"description": "Fetch operators signing info starting from an interval (in seconds) before the end time [default: 3600]",
"name": "interval",
"in": "query"
},
{
"type": "string",
"description": "Comma separated list of quorum IDs to fetch signing info for [default: 0,1]",
"name": "quorums",
"in": "query"
},
{
"type": "boolean",
"description": "Whether to only return operators with signing rate less than 100% [default: false]",
"name": "nonsigner_only",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/v2.OperatorsSigningInfoResponse"
}
},
"400": {
"description": "error: Bad request",
"schema": {
"$ref": "#/definitions/v2.ErrorResponse"
}
},
"404": {
"description": "error: Not found",
"schema": {
"$ref": "#/definitions/v2.ErrorResponse"
}
},
"500": {
"description": "error: Server error",
"schema": {
"$ref": "#/definitions/v2.ErrorResponse"
}
}
}
}
},
"/operators/stake": {
"get": {
"produces": [
Expand Down Expand Up @@ -1251,6 +1314,35 @@ const docTemplateV2 = `{
}
}
},
"v2.OperatorSigningInfo": {
"type": "object",
"properties": {
"operator_address": {
"type": "string"
},
"operator_id": {
"type": "string"
},
"quorum_id": {
"type": "integer"
},
"signing_percentage": {
"type": "number"
},
"stake_percentage": {
"type": "number"
},
"total_batches": {
"type": "integer"
},
"total_responsible_batches": {
"type": "integer"
},
"total_unsigned_batches": {
"type": "integer"
}
}
},
"v2.OperatorStake": {
"type": "object",
"properties": {
Expand All @@ -1268,6 +1360,17 @@ const docTemplateV2 = `{
}
}
},
"v2.OperatorsSigningInfoResponse": {
"type": "object",
"properties": {
"operator_signing_info": {
"type": "array",
"items": {
"$ref": "#/definitions/v2.OperatorSigningInfo"
}
}
}
},
"v2.OperatorsStakeResponse": {
"type": "object",
"properties": {
Expand Down
103 changes: 103 additions & 0 deletions disperser/dataapi/docs/v2/V2_swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,69 @@
}
}
},
"/operators/signing-info": {
"get": {
"produces": [
"application/json"
],
"tags": [
"Operators"
],
"summary": "Fetch operators signing info",
"parameters": [
{
"type": "string",
"description": "Fetch operators signing info up to the end time (ISO 8601 format: 2006-01-02T15:04:05Z) [default: now]",
"name": "end",
"in": "query"
},
{
"type": "integer",
"description": "Fetch operators signing info starting from an interval (in seconds) before the end time [default: 3600]",
"name": "interval",
"in": "query"
},
{
"type": "string",
"description": "Comma separated list of quorum IDs to fetch signing info for [default: 0,1]",
"name": "quorums",
"in": "query"
},
{
"type": "boolean",
"description": "Whether to only return operators with signing rate less than 100% [default: false]",
"name": "nonsigner_only",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/v2.OperatorsSigningInfoResponse"
}
},
"400": {
"description": "error: Bad request",
"schema": {
"$ref": "#/definitions/v2.ErrorResponse"
}
},
"404": {
"description": "error: Not found",
"schema": {
"$ref": "#/definitions/v2.ErrorResponse"
}
},
"500": {
"description": "error: Server error",
"schema": {
"$ref": "#/definitions/v2.ErrorResponse"
}
}
}
}
},
"/operators/stake": {
"get": {
"produces": [
Expand Down Expand Up @@ -1248,6 +1311,35 @@
}
}
},
"v2.OperatorSigningInfo": {
"type": "object",
"properties": {
"operator_address": {
"type": "string"
},
"operator_id": {
"type": "string"
},
"quorum_id": {
"type": "integer"
},
"signing_percentage": {
"type": "number"
},
"stake_percentage": {
"type": "number"
},
"total_batches": {
"type": "integer"
},
"total_responsible_batches": {
"type": "integer"
},
"total_unsigned_batches": {
"type": "integer"
}
}
},
"v2.OperatorStake": {
"type": "object",
"properties": {
Expand All @@ -1265,6 +1357,17 @@
}
}
},
"v2.OperatorsSigningInfoResponse": {
"type": "object",
"properties": {
"operator_signing_info": {
"type": "array",
"items": {
"$ref": "#/definitions/v2.OperatorSigningInfo"
}
}
}
},
"v2.OperatorsStakeResponse": {
"type": "object",
"properties": {
Expand Down
71 changes: 71 additions & 0 deletions disperser/dataapi/docs/v2/V2_swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,25 @@ definitions:
v2_dispersal_status:
type: string
type: object
v2.OperatorSigningInfo:
properties:
operator_address:
type: string
operator_id:
type: string
quorum_id:
type: integer
signing_percentage:
type: number
stake_percentage:
type: number
total_batches:
type: integer
total_responsible_batches:
type: integer
total_unsigned_batches:
type: integer
type: object
v2.OperatorStake:
properties:
operator_id:
Expand All @@ -460,6 +479,13 @@ definitions:
stake_percentage:
type: number
type: object
v2.OperatorsSigningInfoResponse:
properties:
operator_signing_info:
items:
$ref: '#/definitions/v2.OperatorSigningInfo'
type: array
type: object
v2.OperatorsStakeResponse:
properties:
stake_ranked_operators:
Expand Down Expand Up @@ -846,6 +872,51 @@ paths:
summary: Operator node reachability check
tags:
- Operators
/operators/signing-info:
get:
parameters:
- description: 'Fetch operators signing info up to the end time (ISO 8601 format:
2006-01-02T15:04:05Z) [default: now]'
in: query
name: end
type: string
- description: 'Fetch operators signing info starting from an interval (in seconds)
before the end time [default: 3600]'
in: query
name: interval
type: integer
- description: 'Comma separated list of quorum IDs to fetch signing info for
[default: 0,1]'
in: query
name: quorums
type: string
- description: 'Whether to only return operators with signing rate less than
100% [default: false]'
in: query
name: nonsigner_only
type: boolean
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/v2.OperatorsSigningInfoResponse'
"400":
description: 'error: Bad request'
schema:
$ref: '#/definitions/v2.ErrorResponse'
"404":
description: 'error: Not found'
schema:
$ref: '#/definitions/v2.ErrorResponse'
"500":
description: 'error: Server error'
schema:
$ref: '#/definitions/v2.ErrorResponse'
summary: Fetch operators signing info
tags:
- Operators
/operators/stake:
get:
parameters:
Expand Down
Loading

0 comments on commit cd790e8

Please sign in to comment.