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

Check blob key from disperser against actual key #1109

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

litt3
Copy link
Contributor

@litt3 litt3 commented Jan 14, 2025

Why are these changes needed?

Checks

  • I've made sure the tests are passing. Note that there might be a few flaky tests, in that case, please comment that they are not relevant.
  • I've checked the new test coverage and the coverage percentage didn't drop.
  • Testing Strategy
    • Unit tests
    • Integration tests
    • This PR is not tested :(

@litt3 litt3 self-assigned this Jan 14, 2025
@litt3 litt3 marked this pull request as ready for review January 14, 2025 21:35
Copy link
Contributor

@samlaf samlaf left a 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.

@litt3
Copy link
Contributor Author

litt3 commented Jan 15, 2025

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

@litt3 litt3 requested a review from samlaf January 15, 2025 15:17
Copy link
Contributor

@samlaf samlaf left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

api/clients/v2/disperser_client.go Outdated Show resolved Hide resolved
Comment on lines +230 to +235
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 {
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@litt3 litt3 requested review from cody-littley and samlaf January 17, 2025 21:15
// 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,
Copy link
Contributor

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?

Copy link
Contributor Author

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)
Copy link
Contributor

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..?

Copy link
Contributor Author

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

@litt3 litt3 requested a review from ian-shim January 23, 2025 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Verify that the blob key returned in DisperseBlob matches what was sent
4 participants