-
Notifications
You must be signed in to change notification settings - Fork 200
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
Disperser api audit #1170
Disperser api audit #1170
Conversation
@@ -32,6 +33,11 @@ func (s *DispersalServerV2) DisperseBlob(ctx context.Context, req *pb.DisperseBl | |||
return nil, err | |||
} | |||
|
|||
// Check against payment meter to make sure there is quota remaining | |||
if err := s.checkPaymentMeter(ctx, req); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Separate out rate limiting checking and place it after the param validation, because this will make external RPC calls
@@ -40,7 +46,7 @@ func (s *DispersalServerV2) DisperseBlob(ctx context.Context, req *pb.DisperseBl | |||
blob := req.GetBlob() | |||
blobHeader, err := corev2.BlobHeaderFromProtobuf(req.GetBlobHeader()) | |||
if err != nil { | |||
return nil, api.NewErrorInternal(err.Error()) | |||
return nil, api.NewErrorInvalidArg(fmt.Sprintf("failed to parse the blob header proto: %w", err)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't internal error
@@ -20,12 +20,12 @@ func (s *DispersalServerV2) GetBlobStatus(ctx context.Context, req *pb.BlobStatu | |||
}() | |||
|
|||
if req.GetBlobKey() == nil || len(req.GetBlobKey()) != 32 { | |||
return nil, api.NewErrorInvalidArg("invalid blob key") | |||
return nil, api.NewErrorInvalidArg("blob key must be present and with 32 bytes") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Informative error messages here and below
@@ -32,6 +33,11 @@ func (s *DispersalServerV2) DisperseBlob(ctx context.Context, req *pb.DisperseBl | |||
return nil, err | |||
} | |||
|
|||
// Check against payment meter to make sure there is quota remaining | |||
if err := s.checkPaymentMeter(ctx, req); err != nil { | |||
return nil, err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we be using api.NewErrorX for this return. Also noticed there are some other areas that aren't doing that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it already wrapped inside the function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see, seems like one level of indirection though. I was thinking the top level would handle that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea the implementation here had chosen to let low level functions to classify the errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually like moving it up to have less redundant code. validateDispersalRequest should be homogeneous and all its errors are (and should be) invalid requests.
Why are these changes needed?
A pass of audit of the disperser/apiserver
Checks