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

feat: Proxy client #33

Merged
merged 6 commits into from
Jun 9, 2024
Merged

feat: Proxy client #33

merged 6 commits into from
Jun 9, 2024

Conversation

epociask
Copy link
Collaborator

@epociask epociask commented Jun 8, 2024

@epociask epociask requested a review from teddyknox June 8, 2024 18:39
}

// client is the implementation of ProxyClient
type client struct {
Copy link
Collaborator

Choose a reason for hiding this comment

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

  • Why not expose the concrete type?
  • Naming-wise, I think "eigenda" should either be in the package name or in the struct/interface name.

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 client specific to OP stack or general?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

general

httpClient *http.Client
}

func New(cfg *Config) ProxyClient {
Copy link
Collaborator

Choose a reason for hiding this comment

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

i.e. why not return a client type? (may need to make it a public type)

return err
}

if resp.StatusCode != http.StatusOK {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would be nice to add a protocol for including error messages from the response body in the error output here.


// ProxyClient is an interface for communicating with the EigenDA proxy server
type ProxyClient interface {
Health() error
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 part of the OP plasma interface? I figured this endpoint was for docker healthchecks.

}

// encode prefix bytes
b = eigenda.GenericPrefix(eigenda.Commitment(b).Encode())
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: not terribly ergonomic to have Commitment(b) do nothing to b without a corresponding call to .Encode(). What if it looked more like

type genericPrefix String
type commitment String
b = eigenda.NewGenericPrefix(eigenda.NewCommitment(b))

where these are functions and not type casting operators and b

Copy link
Collaborator

Choose a reason for hiding this comment

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

Update:

I'm now seeing that GenericPrefix() is already a function, but Commitment() is not. So my suggestion would be to make Commitment() into a simple function so the Encode() part can be dropped.

client/client.go Outdated
return nil, fmt.Errorf("read certificate is of invalid length: %d", len(b))
}

var blob *common.Certificate
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: rename blob var to cert

common/common.go Outdated
@@ -93,3 +110,26 @@ func ParseBytesAmount(s string) (uint64, error) {
return 0, fmt.Errorf("unsupported unit: %s", unit)
}
}

func SubsetExists[P comparable](arr, sub []P) bool {
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 this being used?

operator-setup Outdated Show resolved Hide resolved
Comment on lines +159 to +166
wait.For(ts.ctx, time.Second*1, func() (bool, error) {
err := daClient.Health()
if err != nil {
return false, nil
}

return true, nil
})
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe that createTestSuite() is already waiting for the server to come up.

// verify that the server comes up

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this just does a time wait and verifies that no error is generated within 10 ms. Feel like doing the await gurantees client <-> server communication is ready versus instantiation the server construct

@@ -165,3 +221,55 @@ func TestE2EPutGetLogicForMemoryStore(t *testing.T) {
require.NoError(t, err)
require.Equal(t, testPreimage, preimage)
}

func TestMemStoreWithProxyClient(t *testing.T) {
Copy link
Collaborator

@teddyknox teddyknox Jun 9, 2024

Choose a reason for hiding this comment

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

nit: Theoretically it should be possible to dry up these tests with a loop + test configuration array. Not necessary to do manually but maybe chatgpt can do.

Copy link
Collaborator

@teddyknox teddyknox left a comment

Choose a reason for hiding this comment

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

So the idea here is that we have different versions of the proxy conform to the effective plasma interface of different versions of optimism, but then we maintain this client to hold a certain idealized interface constant through those changes. And this client can be used in Orbit, ZK Sync, CDK. Do I have that right?

Approving with comments.

@epociask epociask merged commit cfac6cc into main Jun 9, 2024
3 of 4 checks passed
@epociask epociask deleted the epociask--feat-proxy-client branch August 22, 2024 03:06
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