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] Encoder server with EncodeBlob method #866

Merged
merged 9 commits into from
Nov 8, 2024
Merged

Conversation

dmanc
Copy link
Contributor

@dmanc dmanc commented Nov 6, 2024

Why are these changes needed?

Implements V2 server with the EncodeBlob method.

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

case s.requestPool <- struct{}{}:
default:
// TODO: Now that we no longer pass the data directly, should we pass in blob size as part of the request?
s.metrics.IncrementRateLimitedBlobRequestNum(1)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Previously we were passing blobSize, not sure if we want to keep that behavior.

logger.Info("Blob store", "bucket", blobStoreBucketName)

chunkStoreBucketName := config.ChunkStoreConfig.BucketName
chunkWriter := chunkstore.NewChunkWriter(logger, s3Client, chunkStoreBucketName, 4*1024*1024) // TODO(dmanc): make fragment size configurable?
Copy link
Contributor

Choose a reason for hiding this comment

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

Not a bad thing to make configurable. That being said, this is unlikely to be something we change often (if ever)... so possibly acceptable to hard code it in the short term.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good, I'll leave it hardcoded and update the comment.


"github.com/Layr-Labs/eigenda/common/aws/s3"
v2 "github.com/Layr-Labs/eigenda/core/v2"
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the v2 alias necessary? Isn't the package name already v2?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Going to alias it to corev2 for clarity.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For some reason the linter didn't like changing it for one specific file types_test.go https://github.com/Layr-Labs/eigenda/actions/runs/11711503781/job/32620653412

@ian-shim ian-shim requested a review from mooselumph November 6, 2024 17:50
Copy link
Contributor

@ian-shim ian-shim left a comment

Choose a reason for hiding this comment

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

lgtm

disperser/api/proto/encoder/v2/encoder.proto Show resolved Hide resolved
disperser/encoder/server_v2.go Outdated Show resolved Hide resolved
disperser/encoder/server_v2.go Outdated Show resolved Hide resolved
@@ -15,20 +15,36 @@ type DisperserVars struct {

Copy link
Contributor

Choose a reason for hiding this comment

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

🙇


// Rate limit
select {
case s.requestPool <- struct{}{}:
Copy link
Contributor

Choose a reason for hiding this comment

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

do you think this is still a good way to rate limit requests?

Copy link
Contributor Author

@dmanc dmanc Nov 7, 2024

Choose a reason for hiding this comment

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

I'll discuss with @jianoaix when he gets back but leaving it as is for now.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sg to keep it for now.

@@ -23,3 +23,25 @@ func NextPowerOf2[T constraints.Integer](d T) T {
nextPower := math.Ceil(math.Log2(float64(d)))
return T(math.Pow(2.0, nextPower))
}

// PadToPowerOf2 pads a byte slice to the nearest power of 2 length by appending zeros
func PadToPowerOf2(data []byte) []byte {
Copy link
Contributor

Choose a reason for hiding this comment

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

@mooselumph can you confirm if this is the correct way to enforce the number of chunks to be power of 2?

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is enforcing the number of bytes being a power of two rather than the number of chunks, which isn't what we would want.

I'm also not sure that such a function should be needed. We just need to make sure that the Length claimed by the client in the BlobHeader is appropriately rounded up to the next power of two.

package encoder.v2;

service Encoder {
rpc EncodeBlobToChunkStore(EncodeBlobToChunkStoreRequest) returns (EncodeBlobToChunkStoreReply) {}
Copy link
Contributor

Choose a reason for hiding this comment

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

Describe what does this API do?

Also should it be just EncodeBlob? Is storing the results to chunk store an important thing to call out in the name?

Copy link
Contributor Author

@dmanc dmanc Nov 7, 2024

Choose a reason for hiding this comment

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

Changed it back to EncodeBlob. I think if we ever have a desire to have an endpoint that immediately returns the encoded data then we would need to add more information in the name.

disperser/api/proto/encoder/v2/encoder.proto Outdated Show resolved Hide resolved
disperser/encoder/server_v2.go Outdated Show resolved Hide resolved
disperser/encoder/server_v2.go Outdated Show resolved Hide resolved
disperser/encoder/server_v2.go Outdated Show resolved Hide resolved

// Rate limit
select {
case s.requestPool <- struct{}{}:
Copy link
Contributor

Choose a reason for hiding this comment

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

Sg to keep it for now.

@dmanc dmanc changed the title [v2] Encoder server with EncodeBlobToChunkStore method [v2] Encoder server with EncodeBlob method Nov 7, 2024
@ian-shim ian-shim mentioned this pull request Nov 8, 2024
6 tasks
@dmanc dmanc merged commit 8f6b812 into Layr-Labs:master Nov 8, 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.

5 participants