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

sapphire-localnet: expose internal.sock #423

Closed
CedarMist opened this issue Aug 29, 2023 · 6 comments · Fixed by #626
Closed

sapphire-localnet: expose internal.sock #423

CedarMist opened this issue Aug 29, 2023 · 6 comments · Fixed by #626
Assignees

Comments

@CedarMist
Copy link
Member

CedarMist commented Aug 29, 2023

This will allow Go client and Oasis CLI can connect from outside docker.

One option would be to do a bind-mount to expose the client-0 directory:

OASIS_NODE_SOCKET=${OASIS_NODE_DATADIR}/net-runner/network/client-0/internal.sock

Another cleaner option would be to expose over TCP.

Or, may be able to link two containers together and directly expose the socket from one to another?

@matevz
Copy link
Member

matevz commented Aug 29, 2023

Some reading https://docs.oasis.io/core/oasis-node/rpc

I think we use https://www.npmjs.com/package/envoy-node in production.

@matevz
Copy link
Member

matevz commented Aug 29, 2023

The following works, but it's not pretty, acrobatics with docker's permissions...

mkdir serverdir
docker run -it -p8545:8545 -p8546:8546 -v /home/user/serverdir:/serverdir ghcr.io/oasisprotocol/sapphire-dev
# wait for sapphire-dev to spin up

# fix permissions
sudo chmod a+x serverdir/node/net-runner
sudo chmod a+x serverdir/node/net-runner/network
sudo chmod a+x serverdir/node/net-runner/network/client-0
sudo chmod a+rwx serverdir/node/net-runner/network/client-0/internal.sock

# now we can use Oasis CLI on internal.sock, for example
oasis net add-local docker unix:/home/user/serverdir/node/net-runner/network/client-0/internal.sock
oasis pt add docker sapphire 8000000000000000000000000000000000000000000000000000000000000000
oasis acc show test:cory --network docker

Another useful thing is that the serverdir is persistent after Docker is closed, so you can examine logs etc. oasis-net-runner purges serverdir the next time you run it though.

@CedarMist
Copy link
Member Author

CedarMist commented Aug 29, 2023

Another way of doing it would be just adding the oasis-cli to the container, and having a shell script which either starts the node or executes oasis-cli within the current node?

That would avoid a lot of bind mounting weirdness and permissions, although wouldn't let you do development of the CLI against a sapphire-dev node.

Is there any reason we can't just connect over TCP? Then you can expose it via -p

@aefhm
Copy link
Contributor

aefhm commented Sep 2, 2023

adding the oasis-cli to the container

@matevz matevz changed the title sapphire-dev: expose internal.sock sapphire-localnet: expose internal.sock Jul 1, 2024
@CedarMist
Copy link
Member Author

I'm using bind mounts to expose the serverdir in /tmp:

-v /tmp/eth-runtime-test:/serverdir/node

This has been working well for me for a few months.

@matevz matevz self-assigned this Sep 10, 2024
@aefhm
Copy link
Contributor

aefhm commented Sep 11, 2024

Adding the requirement that this should ideally work for Mac as well.

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 a pull request may close this issue.

4 participants