Skip to content

Commit

Permalink
Provide signer and nonsigner operator IDs in blob attestation-info API (
Browse files Browse the repository at this point in the history
  • Loading branch information
jianoaix authored Feb 13, 2025
1 parent 5ae24bc commit 5f38d42
Show file tree
Hide file tree
Showing 6 changed files with 247 additions and 17 deletions.
30 changes: 28 additions & 2 deletions disperser/dataapi/docs/v2/V2_docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -979,6 +979,32 @@ const docTemplateV2 = `{
}
}
},
"v2.AttestationInfo": {
"type": "object",
"properties": {
"attestation": {
"$ref": "#/definitions/github_com_Layr-Labs_eigenda_core_v2.Attestation"
},
"nonsigning_operator_ids": {
"type": "object",
"additionalProperties": {
"type": "array",
"items": {
"type": "string"
}
}
},
"signing_operator_ids": {
"type": "object",
"additionalProperties": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
},
"v2.BatchFeedResponse": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -1039,8 +1065,8 @@ const docTemplateV2 = `{
"v2.BlobAttestationInfoResponse": {
"type": "object",
"properties": {
"attestation": {
"$ref": "#/definitions/github_com_Layr-Labs_eigenda_core_v2.Attestation"
"attestation_info": {
"$ref": "#/definitions/v2.AttestationInfo"
},
"batch_header_hash": {
"type": "string"
Expand Down
30 changes: 28 additions & 2 deletions disperser/dataapi/docs/v2/V2_swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -976,6 +976,32 @@
}
}
},
"v2.AttestationInfo": {
"type": "object",
"properties": {
"attestation": {
"$ref": "#/definitions/github_com_Layr-Labs_eigenda_core_v2.Attestation"
},
"nonsigning_operator_ids": {
"type": "object",
"additionalProperties": {
"type": "array",
"items": {
"type": "string"
}
}
},
"signing_operator_ids": {
"type": "object",
"additionalProperties": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
},
"v2.BatchFeedResponse": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -1036,8 +1062,8 @@
"v2.BlobAttestationInfoResponse": {
"type": "object",
"properties": {
"attestation": {
"$ref": "#/definitions/github_com_Layr-Labs_eigenda_core_v2.Attestation"
"attestation_info": {
"$ref": "#/definitions/v2.AttestationInfo"
},
"batch_header_hash": {
"type": "string"
Expand Down
21 changes: 19 additions & 2 deletions disperser/dataapi/docs/v2/V2_swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,23 @@ definitions:
type: number
type: object
type: object
v2.AttestationInfo:
properties:
attestation:
$ref: '#/definitions/github_com_Layr-Labs_eigenda_core_v2.Attestation'
nonsigning_operator_ids:
additionalProperties:
items:
type: string
type: array
type: object
signing_operator_ids:
additionalProperties:
items:
type: string
type: array
type: object
type: object
v2.BatchFeedResponse:
properties:
batches:
Expand Down Expand Up @@ -266,8 +283,8 @@ definitions:
type: object
v2.BlobAttestationInfoResponse:
properties:
attestation:
$ref: '#/definitions/github_com_Layr-Labs_eigenda_core_v2.Attestation'
attestation_info:
$ref: '#/definitions/v2.AttestationInfo'
batch_header_hash:
type: string
blob_inclusion_info:
Expand Down
54 changes: 53 additions & 1 deletion disperser/dataapi/v2/blobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"strconv"
"time"

"github.com/Layr-Labs/eigenda/core"
corev2 "github.com/Layr-Labs/eigenda/core/v2"
"github.com/Layr-Labs/eigenda/disperser/common/v2/blobstore"
"github.com/gin-gonic/gin"
Expand Down Expand Up @@ -225,6 +226,8 @@ func (s *ServerV2) FetchBlobCertificate(c *gin.Context) {
// @Router /blobs/{blob_key}/attestation-info [get]
func (s *ServerV2) FetchBlobAttestationInfo(c *gin.Context) {
handlerStart := time.Now()

ctx := c.Request.Context()
blobKey, err := corev2.HexToBlobKey(c.Param("blob_key"))
if err != nil {
s.metrics.IncrementInvalidArgRequestNum("FetchBlobAttestationInfo")
Expand All @@ -246,11 +249,60 @@ func (s *ServerV2) FetchBlobAttestationInfo(c *gin.Context) {
return
}

// Get quorums that this blob was dispersed to
metadata, err := s.blobMetadataStore.GetBlobMetadata(ctx, blobKey)
if err != nil {
s.metrics.IncrementFailedRequestNum("FetchBlobAttestationInfo")
errorResponse(c, fmt.Errorf("failed to fetch blob metadata: %w", err))
return
}
blobQuorums := make(map[uint8]struct{}, 0)
for _, q := range metadata.BlobHeader.QuorumNumbers {
blobQuorums[q] = struct{}{}
}

// Get all nonsigners (of the batch that this blob is part of)
nonsigners := make(map[core.OperatorID]struct{}, 0)
for i := 0; i < len(attestationInfo.Attestation.NonSignerPubKeys); i++ {
opId := attestationInfo.Attestation.NonSignerPubKeys[i].GetOperatorID()
nonsigners[opId] = struct{}{}
}

// Get all operators at the reference block number
rbn := attestationInfo.Attestation.ReferenceBlockNumber
operatorsByQuorum, err := s.chainReader.GetOperatorStakesForQuorums(ctx, attestationInfo.Attestation.QuorumNumbers, uint32(rbn))
if err != nil {
s.metrics.IncrementFailedRequestNum("FetchBlobAttestationInfo")
errorResponse(c, fmt.Errorf("failed to fetch operators at reference block number: %w", err))
return
}

// Compute the signers and nonsigners for the blob, for each quorum that the blob was dispersed to
signerIds := make(map[uint8][]string, 0)
nonsignerIds := make(map[uint8][]string, 0)
for q, innerMap := range operatorsByQuorum {
// Make sure the blob was dispersed to the quorum
if _, exist := blobQuorums[q]; !exist {
continue
}
for _, op := range innerMap {
if _, exist := nonsigners[op.OperatorID]; exist {
nonsignerIds[q] = append(nonsignerIds[q], op.OperatorID.Hex())
} else {
signerIds[q] = append(signerIds[q], op.OperatorID.Hex())
}
}
}

response := &BlobAttestationInfoResponse{
BlobKey: blobKey.Hex(),
BatchHeaderHash: hex.EncodeToString(batchHeaderHash[:]),
InclusionInfo: attestationInfo.InclusionInfo,
Attestation: attestationInfo.Attestation,
AttestationInfo: &AttestationInfo{
Attestation: attestationInfo.Attestation,
SigningOperatorIds: signerIds,
NonsigningOperatorIds: nonsignerIds,
},
}

s.metrics.IncrementSuccessfulRequestNum("FetchBlobAttestationInfo")
Expand Down
7 changes: 6 additions & 1 deletion disperser/dataapi/v2/server_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,16 @@ type (
Certificate *corev2.BlobCertificate `json:"blob_certificate"`
}

AttestationInfo struct {
Attestation *corev2.Attestation `json:"attestation"`
NonsigningOperatorIds map[uint8][]string `json:"nonsigning_operator_ids"`
SigningOperatorIds map[uint8][]string `json:"signing_operator_ids"`
}
BlobAttestationInfoResponse struct {
BlobKey string `json:"blob_key"`
BatchHeaderHash string `json:"batch_header_hash"`
InclusionInfo *corev2.BlobInclusionInfo `json:"blob_inclusion_info"`
Attestation *corev2.Attestation `json:"attestation"`
AttestationInfo *AttestationInfo `json:"attestation_info"`
}

BlobInfo struct {
Expand Down
Loading

0 comments on commit 5f38d42

Please sign in to comment.