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] AttestBatch endpoint #676

Merged
merged 2 commits into from
Aug 15, 2024
Merged

Conversation

ian-shim
Copy link
Contributor

@ian-shim ian-shim commented Jul 31, 2024

Why are these changes needed?

This PR adds AttestBatch endpoint to DA node.
This endpoint can be used to attest to a batch of blobs represented by a list of blob header hashes that the node had previously received.

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 :(

@ian-shim ian-shim force-pushed the node-attest-batch branch 3 times, most recently from bb1a565 to d5513cf Compare August 5, 2024 17:56
core/validator.go Outdated Show resolved Hide resolved
// GetBatchHeader constructs a core.BatchHeader from a proto of pb.StoreChunksRequest.
// Note the StoreChunksRequest is validated as soon as it enters the node gRPC
// interface, see grpc.Server.validateStoreChunkRequest.
func GetBatchHeader(in *pb.BatchHeader) (*core.BatchHeader, error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

moving a bunch of util methods from node/grpc/utils.go to prevent circular dependency

@ian-shim ian-shim marked this pull request as ready for review August 5, 2024 21:25
@ian-shim ian-shim force-pushed the node-attest-batch branch from d5513cf to 20665f3 Compare August 7, 2024 05:24
)

const (
Copy link
Contributor Author

Choose a reason for hiding this comment

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

store related utils are moved to store_utils.go

node/node.go Outdated Show resolved Hide resolved
node/node.go Outdated Show resolved Hide resolved
node/store.go Outdated
@@ -223,6 +223,13 @@ func (s *Store) deleteNBatches(currentTimeUnixSec int64, numBatches int) (int, e
size += int64(len(blobIter.Value()))
}
blobIter.Release()

// Blob index.
blobIndexIter := s.db.NewIterator(EncodeBlobIndexKeyPrefix(batchHeaderHash))
Copy link
Collaborator

Choose a reason for hiding this comment

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

If the intent is to mostly deprecate this function, should we put this code somewhere else?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Which function are you referring to? deleteNBatches or EncodeBlobIndexKeyPrefix?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Referring to deleteNBatches. It's currently handling both "Batches" which will be deprecated and "Batch Mappings" which won't be?

Copy link
Contributor Author

@ian-shim ian-shim Aug 9, 2024

Choose a reason for hiding this comment

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

Sure, agree having a separate method would make it easier to deprecate the functionality in the future.

node/store.go Outdated
values := make([][]byte, 0)

expirationTime := s.expirationTime()
expirationKey := EncodeBatchExpirationKey(expirationTime)
Copy link
Collaborator

Choose a reason for hiding this comment

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

We allow multiple blobs to have the same expiration time, but not for batches. Is this correct? Esp. if we were to allow multiple dispersers?

Copy link
Contributor Author

@ian-shim ian-shim Aug 9, 2024

Choose a reason for hiding this comment

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

Yes, a blob has its own expiration time. This would just expire the batch <-> blob mapping.

Copy link
Collaborator

Choose a reason for hiding this comment

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

What if there happen to be two batches that get created with the same expiration time? It seems like we're worrying about that case for blobs but not for batch mappings.

Copy link
Contributor Author

@ian-shim ian-shim Aug 9, 2024

Choose a reason for hiding this comment

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

I see what you mean. That's a valid edge case.
In fact, the existing StoreChunks endpoint would have this issue as well.

I also see an issue with how we're adding expirations for blobs - there could be a concurrency issue that can void a write without a lock.
I'll refactor the expiration key such that the expiration key is in format:

  • _EXPIRATION_<EXPIRATION_TIME><BATCH_HEADER_HASH> -> batch header hash
  • _BLOBEXPIRATION_<EXPIRATION_TIME><BLOB_HEADER_HASH> -> blob header hash

This way we can still query expirations by expiration time, but each batch/blob gets its own record. Wdyt?

cc @jianoaix

@ian-shim ian-shim force-pushed the node-attest-batch branch from 20665f3 to 219fc21 Compare August 9, 2024 05:42
@ian-shim ian-shim mentioned this pull request Aug 9, 2024
5 tasks
@ian-shim ian-shim requested a review from mooselumph August 13, 2024 01:11
@ian-shim ian-shim requested a review from pschork August 13, 2024 17:01
@ian-shim ian-shim merged commit 12f1a6f into Layr-Labs:master Aug 15, 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.

3 participants