From 2699b91b81a32e48c5a6e9a952f4b2438a822fff Mon Sep 17 00:00:00 2001 From: Jian Xiao <99709935+jianoaix@users.noreply.github.com> Date: Thu, 9 Jan 2025 19:31:45 -0800 Subject: [PATCH] Fix: add blobkey in blob response (#1087) --- disperser/dataapi/docs/v2/V2_docs.go | 3 +++ disperser/dataapi/docs/v2/V2_swagger.json | 3 +++ disperser/dataapi/docs/v2/V2_swagger.yaml | 2 ++ disperser/dataapi/v2/server_v2.go | 8 ++++++++ 4 files changed, 16 insertions(+) diff --git a/disperser/dataapi/docs/v2/V2_docs.go b/disperser/dataapi/docs/v2/V2_docs.go index 9df5d7464..194e1f9f5 100644 --- a/disperser/dataapi/docs/v2/V2_docs.go +++ b/disperser/dataapi/docs/v2/V2_docs.go @@ -817,6 +817,9 @@ const docTemplateV2 = `{ "blob_header": { "$ref": "#/definitions/github_com_Layr-Labs_eigenda_core_v2.BlobHeader" }, + "blob_key": { + "type": "string" + }, "blob_size_bytes": { "type": "integer" }, diff --git a/disperser/dataapi/docs/v2/V2_swagger.json b/disperser/dataapi/docs/v2/V2_swagger.json index 3323d8512..acd088d1e 100644 --- a/disperser/dataapi/docs/v2/V2_swagger.json +++ b/disperser/dataapi/docs/v2/V2_swagger.json @@ -814,6 +814,9 @@ "blob_header": { "$ref": "#/definitions/github_com_Layr-Labs_eigenda_core_v2.BlobHeader" }, + "blob_key": { + "type": "string" + }, "blob_size_bytes": { "type": "integer" }, diff --git a/disperser/dataapi/docs/v2/V2_swagger.yaml b/disperser/dataapi/docs/v2/V2_swagger.yaml index 8d0b91824..1fa5ac575 100644 --- a/disperser/dataapi/docs/v2/V2_swagger.yaml +++ b/disperser/dataapi/docs/v2/V2_swagger.yaml @@ -232,6 +232,8 @@ definitions: properties: blob_header: $ref: '#/definitions/github_com_Layr-Labs_eigenda_core_v2.BlobHeader' + blob_key: + type: string blob_size_bytes: type: integer dispersed_at: diff --git a/disperser/dataapi/v2/server_v2.go b/disperser/dataapi/v2/server_v2.go index 1b1258656..59e7d5a99 100644 --- a/disperser/dataapi/v2/server_v2.go +++ b/disperser/dataapi/v2/server_v2.go @@ -51,6 +51,7 @@ type ( } BlobResponse struct { + BlobKey string `json:"blob_key"` BlobHeader *corev2.BlobHeader `json:"blob_header"` Status string `json:"status"` DispersedAt uint64 `json:"dispersed_at"` @@ -321,7 +322,14 @@ func (s *ServerV2) FetchBlobHandler(c *gin.Context) { errorResponse(c, err) return } + bk, err := metadata.BlobHeader.BlobKey() + if err != nil || bk != blobKey { + s.metrics.IncrementFailedRequestNum("FetchBlob") + errorResponse(c, err) + return + } response := &BlobResponse{ + BlobKey: bk.Hex(), BlobHeader: metadata.BlobHeader, Status: metadata.BlobStatus.String(), DispersedAt: metadata.RequestedAt,