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

rm sig check #770

Merged
merged 7 commits into from
Sep 23, 2024
Merged

Conversation

bxue-l2
Copy link
Contributor

@bxue-l2 bxue-l2 commented Sep 20, 2024

Feature addition

  • allowing users without disperser to use EigenDAClient. For rollup, rollup nodes that do not assume the batcher role do not need the ability to disperse blobs. But the current EigenDAClient necessitate a hex private keys. This PR serves to remove such restrictions. Such that anyone can read from EigenDA without a privateKey

Method

  • this PR adds a new struct that implement the interface BlobRequestSigner called LocalNoopSigner, it returns error for all methods. For a user without setting the private key, but uses the signer to send the blob. It will encounter a problem.

Test with proxy

Send without privateKey

Screenshot 2024-09-20 at 12 37 39 PM

Send with privateKey (i.e it is working)

Screenshot 2024-09-20 at 1 36 23 PM

retrieve without privatekey (working)

Screenshot 2024-09-20 at 2 43 32 PM

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

@bxue-l2 bxue-l2 marked this pull request as ready for review September 20, 2024 21:19
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.

looks good, left some comments

@@ -52,9 +52,6 @@ func (c *EigenDAClientConfig) CheckAndSetDefaults() error {
if c.ResponseTimeout == 0 {
c.ResponseTimeout = 30 * time.Second
}
if len(c.SignerPrivateKeyHex) != 64 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of removing this check, check length only when this value is not nil?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

SignerPrivateKeyHex is a string defined in the config, it cannot be nil.

Copy link
Contributor

Choose a reason for hiding this comment

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

*empty string

Copy link
Contributor Author

@bxue-l2 bxue-l2 Sep 21, 2024

Choose a reason for hiding this comment

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

https://go.dev/play/p/6gLQTyOMg5o

empty string cannot be compared with nil. Not sure what I am missing here

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh sorry what I meant was we need to keep this check when the key is non-empty.
i.e. if len(c.SignerPrivateKeyHex) > 0 && len(c.SignerPrivateKeyHex) != 64 then return 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.

got it, added

@@ -107,6 +107,28 @@ func (c *disperserClient) DisperseBlob(ctx context.Context, data []byte, quorums
}

func (c *disperserClient) DisperseBlobAuthenticated(ctx context.Context, data []byte, quorums []uint8) (*disperser.BlobStatus, []byte, error) {
// first check if signer is valid
accountId, err := c.signer.GetAccountID()
Copy link
Contributor

Choose a reason for hiding this comment

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

check if c.signer == nil?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

after some reflections, we could have just assign the signer interface as nil if privateKeyHex is not provided. This make NoopSigner impl looks like a over-do. But I kind of like noopSigner because it complies to the interface, and leave less space for 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.

my main thing about it is because the signer is a interface, if it is a struct pointer, I will fall immediately after nil check

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah shouldn't it fail immediately if c.signer is nil?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

var signer core.BlobRequestSigner
if len(config.SignerPrivateKeyHex) == 64 {
signer = auth.NewLocalBlobRequestSigner(config.SignerPrivateKeyHex)
} else {
Copy link
Contributor

Choose a reason for hiding this comment

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

only do this when config.SignerPrivateKeyHex is nil, and return error when config.SignerPrivateKeyHex is anything other than nil or has length != 64

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can add the error case, but config.SignerPrivateKeyHex is a string, what I am missing here, there is no reason to check nil

Copy link
Contributor

Choose a reason for hiding this comment

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

I want to make sure we check the key length. If this key is provided (non-empty string), it should be length 64 and error out otherwise.

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, pushed that change

// first check if signer is valid
accountId, err := c.signer.GetAccountID()
if err != nil {
return nil, nil, err
Copy link
Contributor

Choose a reason for hiding this comment

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

would it be even more clear if we add something like please configure signer key if you want to use authenticated endpoint?

@bxue-l2 bxue-l2 merged commit 4a22a7a into Layr-Labs:master Sep 23, 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