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

feat(taiko-client): switching from blobstorage server to blobscan-api #17244

Merged
merged 2 commits into from
May 21, 2024
Merged
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
27 changes: 19 additions & 8 deletions packages/taiko-client/pkg/rpc/blob_datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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").
Expand All @@ -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
}