From fbdb7c078e738cb2c170299ac2bee0f72ec3601b Mon Sep 17 00:00:00 2001 From: K-KAD <54041472+k-kaddal@users.noreply.github.com> Date: Tue, 21 May 2024 02:25:43 +0100 Subject: [PATCH] feat(taiko-client): switching from blobstorage server to blobscan-api (#17244) Co-authored-by: jeff <113397187+cyberhorsey@users.noreply.github.com> --- .../taiko-client/pkg/rpc/blob_datasource.go | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/packages/taiko-client/pkg/rpc/blob_datasource.go b/packages/taiko-client/pkg/rpc/blob_datasource.go index 8757081637..0bff5a4ed9 100644 --- a/packages/taiko-client/pkg/rpc/blob_datasource.go +++ b/packages/taiko-client/pkg/rpc/blob_datasource.go @@ -30,6 +30,12 @@ type BlobDataSeq struct { Data []*BlobData `json:"data"` } +type BlobServerResponse struct { + Commitment string `json:"commitment"` + Data string `json:"data"` + VersionedHash string `json:"versionedHash"` +} + func NewBlobDataSource( ctx context.Context, client *Client, @@ -83,17 +89,13 @@ func (ds *BlobDataSource) GetBlobs( // getBlobFromServer get blob data from server path `/getBlob`. func (ds *BlobDataSource) getBlobFromServer(ctx context.Context, blobHash common.Hash) (*BlobDataSeq, error) { - var ( - route = "/getBlob" - param = map[string]string{"blobHash": blobHash.String()} - ) + route := "/blobs/" + blobHash.String() requestURL, err := url.JoinPath(ds.blobServerEndpoint.String(), route) if err != nil { return nil, err } resp, err := resty.New().R(). - SetResult(BlobDataSeq{}). - SetQueryParams(param). + SetResult(BlobServerResponse{}). SetContext(ctx). SetHeader("Content-Type", "application/json"). SetHeader("Accept", "application/json"). @@ -103,9 +105,18 @@ func (ds *BlobDataSource) getBlobFromServer(ctx context.Context, blobHash common } if !resp.IsSuccess() { return nil, fmt.Errorf( - "unable to connect blob server endpoint, status code: %v", + "unable to connect blobscan endpoint, status code: %v", resp.StatusCode(), ) } - return resp.Result().(*BlobDataSeq), nil + response := resp.Result().(*BlobServerResponse) + + return &BlobDataSeq{ + Data: []*BlobData{ + { + BlobHash: response.VersionedHash, + KzgCommitment: response.Commitment, + Blob: response.Data, + }, + }}, nil }