-
Notifications
You must be signed in to change notification settings - Fork 73
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
Conversation
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 |
There was a problem hiding this comment.
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
lib/ethereumex/ipc_server.ex
Outdated
end | ||
|
||
def handle_call({:request, request}, _from, %{socket: socket} = state) do | ||
:ok = :gen_tcp.send(socket, request) |
There was a problem hiding this comment.
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?
There was a problem hiding this 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.
@hswick Some thoughts on |
Hi @ayrat555, I made the changes you recommended. |
lib/ethereumex/client/base_client.ex
Outdated
|
||
@spec single_request(map(), []) :: {:ok, any() | [any()]} | error | ||
def single_request(payload, opts \\ []) do | ||
payload |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
lib/ethereumex/config.ex
Outdated
@@ -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)) |
There was a problem hiding this comment.
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?
lib/ethereumex/ipc_client.ex
Outdated
defmodule Ethereumex.IpcClient do | ||
use Ethereumex.Client.Macro | ||
use Ethereumex.Client.BaseClient | ||
# import Ethereumex.Config |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unused import
config/config.exs
Outdated
@@ -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" |
There was a problem hiding this comment.
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?
@hswick Thanks again. Tomorrow I will test these changes locally, will look into |
@ayrat555 you are very welcome! Thanks for all of the quick feedback. Excited to use this with ExW3. Best of luck with debugging! |
@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 |
.circleci/config.yml
Outdated
@@ -11,7 +11,7 @@ jobs: | |||
- run: echo > passfile | |||
- run: ./parity --chain 2>&1 & |
There was a problem hiding this comment.
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
`
b62fe70
to
c21712a
Compare
bbbac21
to
df91c02
Compare
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to set?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep... good catch
I ran manually compiled parity from the latest master branch. And it seems to work fine. |
@hswick 🔥 Amazing work! |
I found a neat way to do #8 using no dependencies, just :gen_tcp.