-
Notifications
You must be signed in to change notification settings - Fork 198
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
Check blob key from disperser against actual key #1109
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: litt3 <[email protected]>
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.
Changes LGTM, but the DisperseBlob function is getting big and unweildy. Might be good to refactor at some point, create some functions to abstract some of the stuff out. Would need to think through best way to do this.
Your code here could clearly fit in a function though, for eg.
@samlaf Good point. Split the blob key check into a separate function 617cbd5b |
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.
LGTM, thanks!
Signed-off-by: litt3 <[email protected]>
func verifyReceivedBlobKey( | ||
// the blob header which was constructed locally and sent to the disperser | ||
blobHeader *corev2.BlobHeader, | ||
// the reply received back from the disperser | ||
disperserReply *disperser_rpc.DisperseBlobReply, | ||
) error { |
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.
nit, would a simple unit test be possible? i.e. check both a valid and invalid header
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.
Done
Signed-off-by: litt3 <[email protected]>
// the blob header which was constructed locally and sent to the disperser | ||
blobHeader *corev2.BlobHeader, | ||
// the reply received back from the disperser | ||
disperserReply *disperser_rpc.DisperseBlobReply, |
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.
why don't we just take the received blob key instead of full reply?
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.
The idea was that we don't immediately have either blob key (computed or received) in the correct form: they need to be constructed and error checked. Moving the logic to the helper method was intended to keep DisperseBlob
as clean as possible
I don't feel super strongly about this, I can remove the helper method if you would like
@@ -213,9 +213,47 @@ func (c *disperserClient) DisperseBlob( | |||
return nil, [32]byte{}, err | |||
} | |||
|
|||
if verifyReceivedBlobKey(blobHeader, reply) != nil { | |||
return nil, [32]byte{}, fmt.Errorf("verify received blob key: %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.
nit: "failed to verify that the reply contains locally computed blob key" or something like 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.
The helper method does contains more specific details about what specifically failed, e.g. "blob key returned by disperser (%v) doesn't match blob which was dispersed (%v)"
(Also, this message is attempting to follow this standard that @samlaf has been rallying support behind. It prescribes omitting the "failed to..." prefix)
Happy to still make an update here if you'd like, just pointing out the rationale of the current message
Why are these changes needed?
DisperseBlob
matches what was sent #1100Checks