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

IpcClient Implementation #40

Merged
merged 33 commits into from
Oct 7, 2018
Merged

IpcClient Implementation #40

merged 33 commits into from
Oct 7, 2018

Conversation

hswick
Copy link
Collaborator

@hswick hswick commented Oct 4, 2018

I found a neat way to do #8 using no dependencies, just :gen_tcp.

@hswick
Copy link
Collaborator Author

hswick commented Oct 4, 2018

Looks like it isn't finding the IPC socket path in the CircleCI build.

Perhaps this may be a solution https://serverfault.com/questions/881875/expose-a-unix-socket-to-the-host-system-from-inside-from-a-docker-container

@@ -0,0 +1,55 @@
defmodule Ethereumex.IpcClient do
Copy link
Member

Choose a reason for hiding this comment

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

There seems to be a lot of duplication in Ethereumex.IpcClient and Ethereumex.HttpClient. Can we get rid of this duplication? Maybe we can move common logic to separate module

end

def handle_call({:request, request}, _from, %{socket: socket} = state) do
:ok = :gen_tcp.send(socket, request)
Copy link
Member

Choose a reason for hiding this comment

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

Can we somehow handle socket/request errors here? Maybe we can pass those errors to Ethereumex.IpcClient.post_request/2 and return them to a user. What do you think about it?

Copy link
Member

@ayrat555 ayrat555 left a comment

Choose a reason for hiding this comment

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

@hswick great work! A couple of comments, otherwise this LGTM.

@ayrat555
Copy link
Member

ayrat555 commented Oct 5, 2018

@hswick There is a bounty for this issue on gitcoin. You should submit your PR (I don't know the details, never used it).

@ayrat555
Copy link
Member

ayrat555 commented Oct 5, 2018

@hswick Some thoughts on IpcServer. In the current implementation, HttpClient is started by default. I think we can configure which client to start (or both of them) using configuration parameters. IpcServer and IpcClient can be started together on the same level of the supervision tree

@hswick
Copy link
Collaborator Author

hswick commented Oct 6, 2018

Hi @ayrat555, I made the changes you recommended.


@spec single_request(map(), []) :: {:ok, any() | [any()]} | error
def single_request(payload, opts \\ []) do
payload
Copy link
Member

Choose a reason for hiding this comment

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

something's wrong with formatting

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oops. I always forget to run format

@hswick hswick mentioned this pull request Oct 6, 2018
@@ -25,4 +25,25 @@ defmodule Ethereumex.Config do
def request_timeout do
Application.get_env(:ethereumex, :request_timeout, 5000)
end

def setup_children do
setup_children(Application.get_env(:ethereumex, :client, :http))
Copy link
Member

Choose a reason for hiding this comment

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

What do you think about setting up children directly in Ethereumex module and using Config module only for getting configuration params?

defmodule Ethereumex.IpcClient do
use Ethereumex.Client.Macro
use Ethereumex.Client.BaseClient
# import Ethereumex.Config
Copy link
Member

Choose a reason for hiding this comment

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

unused import

@@ -2,4 +2,8 @@ use Mix.Config

config :ethereumex, request_timeout: 5000

config :ethereumex, :client, :ipc

config :ethereumex, :ipc_path, "/.local/share/io.parity.ethereum/jsonrpc.ipc"
Copy link
Member

Choose a reason for hiding this comment

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

I think this value is used for testing?

@ayrat555
Copy link
Member

ayrat555 commented Oct 6, 2018

@hswick Thanks again. Tomorrow I will test these changes locally, will look into eth_get_block_by_number (it's one of the most used API methods). I want this PR to get merged as soon as possible

@hswick
Copy link
Collaborator Author

hswick commented Oct 6, 2018

@ayrat555 you are very welcome! Thanks for all of the quick feedback. Excited to use this with ExW3. Best of luck with debugging!

@ayrat555
Copy link
Member

ayrat555 commented Oct 7, 2018

@hswick Can you add me to your fork? I think I found the solution to the truncated json problem. I want to push changes to your branch

@@ -11,7 +11,7 @@ jobs:
- run: echo > passfile
- run: ./parity --chain 2>&1 &
Copy link
Member

Choose a reason for hiding this comment

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

@hswick you can start parity with /parity --jsonrpc-interface all --no-warp. It starts ipc and http servers
`

CHANGELOG.md Outdated Show resolved Hide resolved
@hswick
Copy link
Collaborator Author

hswick commented Oct 7, 2018

Good news is I got the build working.

Bad news any version of parity above 1.10 makes the tests fail, but I think that should be created on a separate issue.

README.md Outdated
@@ -37,6 +37,24 @@ config :ethereumex,
request_timeout: 10_000 # default is 5000 ms
```

If you want to use IPC you will need to a few things in your config.
Copy link
Member

Choose a reason for hiding this comment

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

need to set?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yep... good catch

@ayrat555
Copy link
Member

ayrat555 commented Oct 7, 2018

Bad news any version of parity above 1.10 makes the tests fail, but I think that should be created on a separate issue.

I ran manually compiled parity from the latest master branch. And it seems to work fine.
@hswick Can you create a separate issue?

@hswick
Copy link
Collaborator Author

hswick commented Oct 7, 2018

Bad news any version of parity above 1.10 makes the tests fail, but I think that should be created on a separate issue.

I ran manually compiled parity from the latest master branch. And it seems to work fine.
@hswick Can you create a separate issue?

#43

@ayrat555
Copy link
Member

ayrat555 commented Oct 7, 2018

@hswick 🔥 Amazing work!

@ayrat555 ayrat555 merged commit cfc2732 into mana-ethereum:master Oct 7, 2018
@ayrat555
Copy link
Member

ayrat555 commented Oct 7, 2018

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