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

Add eth accounts to allowlist #175

Merged
merged 9 commits into from
Jan 17, 2024

Conversation

mooselumph
Copy link
Contributor

Why are these changes needed?

Adds ETH accounts to the allowlist so we can provision throughput to authenticated requests based on the corresponding ETH account.

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

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.

disperser/apiserver/rate_config.go Outdated Show resolved Hide resolved
disperser/apiserver/server.go Outdated Show resolved Hide resolved
disperser/apiserver/server.go Outdated Show resolved Hide resolved
@mooselumph
Copy link
Contributor Author

lgtm, can we add a test like https://github.com/Layr-Labs/eigenda/blob/master/disperser/apiserver/server_test.go#L282?

Yeah, we can, but it will take mocking the GRPC stream so it will be a bit more work. I'll add it later.

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, left couple questions

Comment on lines 133 to 143
// Get the ethereum address associated with the public key. This is just for convenience so we can put addresses instead of public keys in the allowlist.
// Decode public key
publicKeyBytes, err := hexutil.Decode(blob.RequestHeader.AccountID)
if err != nil {
return fmt.Errorf("failed to decode public key (%v): %v", blob.RequestHeader.AccountID, err)
}

pubKey, err := crypto.UnmarshalPubkey(publicKeyBytes)
if err != nil {
return fmt.Errorf("failed to decode public key (%v): %v", blob.RequestHeader.AccountID, err)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

should we move this validation at the beginning of this method so that we return immediately when AccountID is not something that's expected?

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

@@ -257,45 +273,73 @@ func (s *DispersalServer) disperseBlob(ctx context.Context, blob *core.Blob) (*p
}, nil
}

func (s *DispersalServer) getAccountRate(origin string, quorumID core.QuorumID) (*PerUserRateInfo, error) {
type RateKeys 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 we expect to have two different types of the allowlisted account for the same request?
i.e. for one account that has IP A and eth address B, can they specify throughput limit with A and blob limit with B?
for simplicity, why don't we consolidate it so that it has to be from the same type?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a good point. I think it makes sense to always prefer the authenticatedAddress if it is in the allowlist, and only check the ip address if no authenticatedAddress was provided or it was not found in the allowlist.

@@ -128,8 +130,22 @@ func (s *DispersalServer) DisperseBlobAuthenticated(stream pb.Disperser_Disperse
return fmt.Errorf("failed to authenticate blob request: %v", err)
}

// Get the ethereum address associated with the public key. This is just for convenience so we can put addresses instead of public keys in the allowlist.
// Decode public key
publicKeyBytes, err := hexutil.Decode(blob.RequestHeader.AccountID)
Copy link
Contributor

Choose a reason for hiding this comment

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

The check here and below assume the account id is in hex format ethereum. address. It'd be helpful to make this assumption clear at the interface: https://github.com/Layr-Labs/eigenda/blob/master/api/proto/disperser/disperser.proto#L83

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.


if rateInfo.BlobRate > rates.BlobRate {
rates.BlobRate = rateInfo.BlobRate
keys.BlobRateKey = "address:" + authenticatedAddress
Copy link
Contributor

Choose a reason for hiding this comment

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

Can the key just be authenticatedAddress for both throughput and blob rates? They look the same.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I'm going to make this change.

@mooselumph mooselumph merged commit 669be3d into Layr-Labs:master Jan 17, 2024
4 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