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

[node] Add StoreBlobs endpoint for minibatch streaming #671

Merged
merged 3 commits into from
Aug 7, 2024

Conversation

ian-shim
Copy link
Contributor

Why are these changes needed?

This PR adds StoreBlobs endpoint to DA node.
This method can be used to disperse blobs and have signatures for each blob returned, instead of a batch containing those blobs.

Checks

  • I've made sure the lint is passing in this PR.
  • 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.
  • Testing Strategy
    • Unit tests
    • Integration tests
    • This PR is not tested :(

start := time.Now()

// Validate the request
if in.GetReferenceBlockNumber() == 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we put some of this in a validation function?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we generalize the validateStoreChunksRequest and reuse in both places?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If this method is getting too long, I'd prefer creating another method validateStoreBlobsRequest instead of generalizing validateStoreChunksRequest and using it in both places.
After the migration, StoreChunks method will be deprecated. I think it's better to make two codepaths somewhat independent and clear for each use case, so that eventually when one codepath is removed, what's left is clear for those without context.

node/store.go Outdated

numDeleted, err = s.deleteNBatches(currentTimeUnixSec, numBatchesToDeleteAtomically)
if err != nil {
return numBatchesDeleted, numBlobsDeleted, err
}
// When there is no error and we didn't delete any batch, it means we have
// no obsolete batches to delete, so we can return.
if numDeleted == 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems like it will return if there are no more batches to delete even if there are still blobs to delete.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for catching this!

rawChunks := make(map[core.QuorumID][][]byte)
for i, bundle := range rawBlob.GetBundles() {
quorumID := uint8(rawBlob.GetHeader().GetQuorumHeaders()[i].GetQuorumId())
if format == core.GnarkBundleEncodingFormat {
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems unideal that we are processing the chunk format both here at when we process the raw blobs in GetBlobMessages of utils.go. I'd prefer it if GetBlobMessages or some other utility function did all of this processing and then returned all formats of the chunks needed by validation and storage, so that the storage functions can be format agnostic.

Copy link
Contributor Author

@ian-shim ian-shim Aug 5, 2024

Choose a reason for hiding this comment

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

Agree it's a bit ugly. I was mostly leaving the implementation same as StoreBatch to minimize risk
On the bright side, this branching based on encoding format will also go away soon when all blobs are encoded with gnark

Copy link
Collaborator

@mooselumph mooselumph left a comment

Choose a reason for hiding this comment

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

A few comments

@ian-shim ian-shim merged commit f76f995 into Layr-Labs:master Aug 7, 2024
6 checks passed
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.

2 participants