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

Improve blobs Beacon API endpoint #14845

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft

Improve blobs Beacon API endpoint #14845

wants to merge 2 commits into from

Conversation

rkapka
Copy link
Contributor

@rkapka rkapka commented Jan 30, 2025

What type of PR is this?

Other

What does this PR do? Why is it needed?

  • Currently we return an 500 InternalServerError when a blob for a requested index is not found. It would be more useful to return a 404 instead, letting the user know that we don't have the blob, not that something went wrong when trying to fetch it.
  • Additional information in some errors, such as block root or slot number

Acknowledgements

@rkapka rkapka added the API Api related tasks label Jan 30, 2025
@rkapka rkapka requested a review from a team as a code owner January 30, 2025 08:36
Comment on lines +246 to 264
for k, v := range m {
if v {
if k >= len(commitments) {
return nil, &core.RpcError{
Err: fmt.Errorf("blob index %d is more than blob kzg commitment count %d for block %#x", k, len(commitments), root),
Reason: core.Internal,
}
}
if !indicesRequested {
indices = append(indices, uint64(k))
}
} else if indicesRequested {
for _, ix := range indices {
if uint64(k) == ix {
return nil, &core.RpcError{Err: fmt.Errorf("no blob at index %d found for block %#x", k, root), Reason: core.NotFound}
}
}
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestions for making this more straightforward/readable welcome

blobs := make([]*blocks.VerifiedROBlob, len(indices))
for i, index := range indices {
vblob, err := p.BlobStorage.Get(bytesutil.ToBytes32(root), index)
if err != nil {
log.WithFields(log.Fields{
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed this log and one more log because I don't see the point of logging out one specific thing from the whole function. As a matter of fact, I don't think we log out anything else from the whole Beacon API (note that this file is in beacon-chain/rpc, so it's limited to APIs). In my opinion if we find such logs useful, we should write a middleware that will log out every error from httputil.HandleError (most likely on the Debug level)

@rkapka rkapka marked this pull request as draft January 31, 2025 03:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Api related tasks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant