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

[v2] Blob Metadata Store #818

Merged
merged 3 commits into from
Oct 28, 2024
Merged

Conversation

ian-shim
Copy link
Contributor

Why are these changes needed?

Set up v2 blob metadata store. Only implements few basic methods for now.

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

core/data.go Outdated Show resolved Hide resolved
@ian-shim ian-shim marked this pull request as ready for review October 18, 2024 06:13
return &dynamodb.CreateTableInput{
AttributeDefinitions: []types.AttributeDefinition{
{
AttributeName: aws.String("PK"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you document the tables that are abbreviations? It's not obvious to me what PK and SK stand for.


blobKeyPrefix = "BlobKey#"
dispersalIDPrefix = "DispersalID#"
blobMetadataSK = "BlobMetadata"
Copy link
Contributor

@pschork pschork Oct 18, 2024

Choose a reason for hiding this comment

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

So we're not using immutable design where blob metadata updates create a new unique sortable item via compound SK like BlobMetadata#UUID7 or BlobMetadata#EpochSeconds?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah as discussed offline, some fields (BlobStatus) will be updated

disperser/common/v2/blob.go Outdated Show resolved Hide resolved
disperser/common/v2/blobstore/blob_metadata_store.go Outdated Show resolved Hide resolved
return &dynamodb.CreateTableInput{
AttributeDefinitions: []types.AttributeDefinition{
{
AttributeName: aws.String("PK"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you document the tables that are abbreviations? It's not obvious to me what PK and SK stand for.

disperser/common/v2/blob.go Outdated Show resolved Hide resolved
data = append(data, paymentBytes...)

return crypto.Keccak256(data)
func (pm *PaymentMetadata) Hash() ([32]byte, 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.

updated this hash function to make it compatible with solidity
cc @hopeyen

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.

looks good!

OperatorResponseIndexName = "OperatorResponseIndex"

blobKeyPrefix = "BlobKey#"
dispersalIDPrefix = "DispersalID#"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's used in a follow up PR, removed for now


// GetBlobMetadataByStatus returns all the metadata with the given status
// Because this function scans the entire index, it should only be used for status with a limited number of items.
func (s *blobMetadataStore) GetBlobMetadataByStatus(ctx context.Context, status v2.BlobStatus) ([]*v2.BlobMetadata, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would there ever be a need for a batched version of this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do you mean by a batched version?

// Existing fields
AccountID string
// AccountID is the ETH account address for the payer
AccountID string `json:"account_id"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

Where is the json serialization used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's used when we marshal/unmarshal the struct to/from json, i.e. in dataapi.
I've removed these for now

return hash, nil
}

func (pm *PaymentMetadata) MarshalDynamoDBAttributeValue() (types.AttributeValue, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this belong in core? Is there any way to have this code in the blobstore?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They need to belong in the same package as where the type is defined. We can wrap and clone these types in blobstore but not sure if that's worth it

@@ -59,7 +81,153 @@ func (b *BlobHeader) GetEncodingParams() (encoding.EncodingParams, error) {
NumChunks: uint64(params.NumChunks),
ChunkLength: uint64(length),
}, nil
}

func (b *BlobHeader) BlobKey() (BlobKey, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice!

@ian-shim ian-shim force-pushed the v2-blob-metadata branch 2 times, most recently from 0dbb4c9 to 1b63aee Compare October 24, 2024 23:38
@ian-shim ian-shim merged commit 4d1352c into Layr-Labs:master Oct 28, 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.

4 participants