Skip to content

fix node.sock detection from docker#147

Merged
GitGab19 merged 4 commits into
stratum-mining:mainfrom
GitGab19:fix-node-sock-detection-from-docker
May 7, 2026
Merged

fix node.sock detection from docker#147
GitGab19 merged 4 commits into
stratum-mining:mainfrom
GitGab19:fix-node-sock-detection-from-docker

Conversation

@GitGab19
Copy link
Copy Markdown
Member

@GitGab19 GitGab19 commented May 7, 2026

In #90 we introduced a validation process during Bitcoin Core setup.

The problem is that while it's working when running sv2-ui with npm run dev (because it has access to the host), it doesn't work when launching sv2-ui inside docker (what our users are doing as suggested on our website).

And the reason is that the container in that case doesn't have access to the host, so it's not able to find the node.sock file, even though the node is running and the socket file exists in reality:

image

This PR addresses that by validating the socket path from the Docker runtime instead of from the sv2-ui container filesystem.

Implementation notes:

  • The validator starts a short-lived helper container and bind-mounts the Bitcoin data directory containing node.sock.
  • It retries with Docker Binds, matching how the JDC container mounts the same socket at runtime.
  • On Linux, validation succeeds only when the helper can connect to the socket.
  • On macOS Docker Desktop, helper connect()/stat() calls can return ENOTSUP for host-mounted Unix sockets. In that case, the validator falls back to a short-lived probe using the selected JDC image, a temporary JDC config, and the same socket bind path JDC uses at runtime.
  • The JDC probe waits for JDC's own Bitcoin Core IPC bootstrap success log, so a stale node.sock file left behind after Bitcoin Core stops is rejected instead of treated as valid.

In case the socket is not active, the setup UI shows an error and automatically retries retryable failures every 5s.

Screencast.From.2026-05-07.10-40-55.mp4

@GitGab19 GitGab19 requested review from lucasbalieiro and pavlenex May 7, 2026 08:51
@GitGab19
Copy link
Copy Markdown
Member Author

GitGab19 commented May 7, 2026

I strongly believe we should push a PATCH release today with this fix, since it's a problem which has been already signaled by some users.

@GitGab19
Copy link
Copy Markdown
Member Author

GitGab19 commented May 7, 2026

To test this PR, you have to do the following:

  • checkout this PR and enter it
  • launch docker build -t sv2-ui:pr-test .
  • run the built image with the usual command, specifying that: docker run --rm \ --name sv2-ui \ -p 8080:8080 \ -e HOST_HOME="$HOME" \ -v /var/run/docker.sock:/var/run/docker.sock \ -v sv2-config:/app/data/config \ sv2-ui:pr-test
  • play with it

@GitGab19 GitGab19 force-pushed the fix-node-sock-detection-from-docker branch 3 times, most recently from fde96d0 to fe9bfd8 Compare May 7, 2026 11:00
Copy link
Copy Markdown
Member

@Shourya742 Shourya742 left a comment

Choose a reason for hiding this comment

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

Tested locally, works fine with the current changes. It is able to pick up the socket path on the host.

@GitGab19
Copy link
Copy Markdown
Member Author

GitGab19 commented May 7, 2026

@Shourya742 you're also on Linux, right?

It seems we're having issues on macOS though..

@Shourya742
Copy link
Copy Markdown
Member

@Shourya742 you're also on Linux, right?

It seems we're having issues on macOS though..

Yup on linux... worked fine

@GitGab19 GitGab19 force-pushed the fix-node-sock-detection-from-docker branch from fe9bfd8 to a14d8c0 Compare May 7, 2026 11:53
GitGab19 added 2 commits May 7, 2026 13:56
Validate configured Bitcoin Core IPC sockets from inside Docker by probing through a short-lived helper container with the host socket bind-mounted.

Also revalidate the socket before setup, config update, and restart so a node crash between wizard validation and stack startup fails cleanly instead of starting a broken JDC container.
Add retry support for transient Bitcoin socket validation failures and surface Open Bitcoin Setup actions from setup, settings, and dashboard error states.

Centralize Bitcoin socket error matching so recovery UI and retry behavior use the same predicates.
@GitGab19 GitGab19 force-pushed the fix-node-sock-detection-from-docker branch 4 times, most recently from 64d8f0c to f58ebbe Compare May 7, 2026 12:48
@lucasbalieiro
Copy link
Copy Markdown
Collaborator

Works on my mac

@GitGab19
Copy link
Copy Markdown
Member Author

GitGab19 commented May 7, 2026

@lucasbalieiro I just pushed 70cd24b which is able to get if the socket is listening for real (Bitcoin Core is running) without having to run JDC in a temporary container as done by f58ebbe.

I tested multiple times and it works like a charm, please let me know if it's the same on your side.

If you agree, I would simply drop f58ebbe in favor of this last 70cd24b which is way simpler.

@lucasbalieiro
Copy link
Copy Markdown
Collaborator

I tested multiple times and it works like a charm, please let me know if it's the same on your side.

yeah, it is also working for me on a Mac. With version 30.2 and 31

If you agree, I would simply drop f58ebbe in favor of this last 70cd24b which is way simpler.

Ok

GitGab19 added 2 commits May 7, 2026 20:05
When sv2-ui runs in Docker, attaching the container to sv2-network during setup
can briefly interrupt the in-flight /api/setup request even though the backend
successfully starts JDC and Translator.

After a fetch, network, or timeout error on the final setup step, check
/api/status and show the success screen if the stack is already configured and
running.
@GitGab19 GitGab19 force-pushed the fix-node-sock-detection-from-docker branch from 64ae58e to d1bfaa5 Compare May 7, 2026 18:09
@GitGab19
Copy link
Copy Markdown
Member Author

GitGab19 commented May 7, 2026

@lucasbalieiro now the PR is in its final shape, I tested multiple times on both macOS and Linux, and everything works perfectly.

If you approve it, I'll proceed with the PATCH release.

Copy link
Copy Markdown
Collaborator

@lucasbalieiro lucasbalieiro left a comment

Choose a reason for hiding this comment

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

tACK d1bfaa5

Did a final build/test to see if nothing went wrong during the rebase and drop of the prevous commit. It worked

@GitGab19 GitGab19 merged commit b8e48dd into stratum-mining:main May 7, 2026
5 checks passed
@GitGab19 GitGab19 deleted the fix-node-sock-detection-from-docker branch May 7, 2026 18:56
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.

3 participants