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

Maybe make EndpointAPI.connect_to APIs more forgiving. #92

Open
pipermerriam opened this issue May 25, 2019 · 0 comments
Open

Maybe make EndpointAPI.connect_to APIs more forgiving. #92

pipermerriam opened this issue May 25, 2019 · 0 comments

Comments

@pipermerriam
Copy link
Member

What was wrong?

Right now, if you try to connect to an endpoint you are already connected to lahja throws an error:

https://github.com/ethereum/lahja/blob/master/lahja/asyncio/endpoint.py#L484

This is likely good behavior since a name match does not definitively identify an endpoint since two endpoints could have the same name but be fundamentally different. Situations I could see this legitimately occuring would be.

  1. Two servers accidentally named the same but with different IPC paths
  2. Two clients accidentally named the same (both establishing a connection to the same server)

How can it be fixed?

Ideally, it would be nice for connect_to_endpoint to not error in the case where you are already connected to the requested endpoint.

In the client -> server case this is relatively trivial. We just need to store the whole ConnectionConfig or its contents (name, ipc_path) and return as if the connection were successful if they match, try to connect if there is no name conflict, and throw an error if the name matches but the IPC path does not.

In the server -> client case it's trickier and not clear how we would correctly identify if the client is indeed the same one. We can potentially divide this up into two cases for clarity but I believe they both pose the same challenge.

  1. two same named clients connect to a server
  2. a server has an existing client with the name and then tries to establish a connection to another serving endpoint with that name.

One potential way to reconcile this would be to define client identity as something like (process-id, name).

However, we probably still must keep the invariant that an endpoint may only ever have a unique set of endpoint names that it is connected to, since allowing multiple same named clients would change the assumptions about broadcasts which are specifically routed to an endpoint having a single recipient, and introduce things like race conditions in a request/response scenario.

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

No branches or pull requests

1 participant