JoinMarket-Org / joinmarket-clientserver

Bitcoin CoinJoin implementation with incentive structure to convince people to take part
GNU General Public License v3.0
733 stars 179 forks source link

Troubleshooting Directory Service Node Setup #1456

Closed CohibAA closed 1 year ago

CohibAA commented 1 year ago

I am trying to get a directory node up, but have run into a couple issues. Please consider this low priority, as I may just need more clarity on syntax or something simple. It's been quite a while since I've dove into the inner workings of JoinMarket, so forgive my ignorance! Eventually, I'd like to help resolve this issue and contribute to the stopgap list / default nodes if I can get past this. Maybe try to smash some bugs here and there.

I have reviewed and understand the start-dn.py script for the most part, and have setup joinmarket.cfg after a fresh install on a new virtual server running ubuntu 22, command line only, with tor, for backround. The server is dedicated to this project only, with only minimal services installed.

My joinmarket.cfg has these relevant lines:

blockchain_source = no-blockchain

[MESSAGING:onion]
type = onion
socks5_host = localhost
socks5_port = 9050
tor_control_host = localhost
tor_control_port = 9051
onion_serving_host = 127.0.0.1
onion_serving_port = 8080
hidden_service_dir = /home/dirnode/jm-service-dir

directory_nodes is default currently, as this is where I am stuck.

When I run start-dn.py to generate the onion for my node, this is the output:

(jmvenv) dirnode:~/joinmarket-clientserver/scripts$ python start-dn.py Greetings
User data location: /home/dirnode/.joinmarket/
2023-03-02 05:07:14,185 [INFO]  starting directory node
2023-03-02 05:07:14,186 [INFO]  Joinmarket daemon listening on port 27183
2023-03-02 05:07:14,191 [DEBUG]  connection was made, starting client.
2023-03-02 05:07:14,192 [INFO]  Attempting to start onion service on port: 5222 ...

This will go on for at least 10 minutes, probably more, but I didn't let it keep running for longer. I then Ctrl-C out and get this:

^CUnhandled error in Deferred:

Traceback (most recent call last):
--- <exception caught here> ---
  File "/home/dirnode/joinmarket-clientserver/jmvenv/lib/python3.10/site-packages/txtorcon/endpoints.py", line 651, in listen
    self.hiddenservice = yield create_d
  File "/home/dirnode/joinmarket-clientserver/jmvenv/lib/python3.10/site-packages/txtorcon/onion.py", line 253, in create
    yield config.save()
txtorcon.torcontrolprotocol.TorProtocolError: 513 Unacceptable option value: Failed to configure rendezvous options. See logs for details.

I don't see anything in tor logs or joinmarket logs that is helping me narrow down the issue. I looked through the txtorcon scripts, but couldn't resolve much about this error/code. Any insight is appreciated!

Thanks for everyone's contributions to JoinMarket! BTW, is this the best place to discuss and ask questions about contributions, or do you all still have an IRC or Discord channel or something now days for this type of thing? I hope to contribute more often over the next year if possible.

update: I'm more confused now. I fiddled with some tor settings and directory locations and I managed to generate the genesis node.

2023-03-03 02:49:25,461 [MainThread  ] [INFO ]  setting onion hostname to : xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.onion
2023-03-03 02:49:25,717 [MainThread  ] [INFO ]  This is the genesis node: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.onion
2023-03-03 02:49:25,719 [MainThread  ] [INFO ]  All message channels connected, starting execution.
2023-03-03 02:49:25,724 [MainThread  ] [INFO ]  JM daemon setup complete

I changed nothing afterwards, just closed the script, and put the genesis onion into joinmarket.cfg as directory_nodes. When I run the script I now get this error:

(jmvenv) dirnode:~/joinmarket-clientserver/scripts$ ./start-dn.py 'Greetings'
User data location: /home/dirnode/.joinmarket/
2023-03-03 02:51:40,551 [INFO]  starting directory node
2023-03-03 02:51:40,552 [INFO]  Joinmarket daemon listening on port 27183
2023-03-03 02:51:40,557 [INFO]  Attempting to start onion service on port: 5222 ...
Unhandled Error
Traceback (most recent call last):
Failure: twisted.internet.error.ConnectError: An error occurred while connecting: 2: No such file or directory.

I'll keep playing around and update accordingly. Any suggestions are appreciated.

FINAL UPDATE:

tor is very particular, as it should be. The solution boiled down to conflicting settings in /etc/tor/torrc vs /usr/share/tor/tor-service-defaults-torrc and the directory node. I won't post all my settings here, but I'm happy to help others having similar issues. The directory node is now running, tested to communicate properly with an outside maker bot. I will unhide and publish the onion to the issues referenced in the first paragraph, once I'm confident the server is stable.

User data location: /home/dirnode/.joinmarket/
2023-03-03 04:27:11,289 [INFO]  starting directory node
2023-03-03 04:27:11,290 [INFO]  Joinmarket daemon listening on port 
2023-03-03 04:27:11,293 [DEBUG]  connection was made, starting client.
2023-03-03 04:27:11,294 [INFO]  Attempting to start onion service on port: 5222 ...
2023-03-03 04:27:23,970 [INFO]  setting onion hostname to : xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.onion
2023-03-03 04:27:24,356 [INFO]  This is the genesis node: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.onion
2023-03-03 04:27:24,357 [INFO]  All message channels connected, starting execution.
2023-03-03 04:27:24,361 [INFO]  JM daemon setup complete
2023-03-03 04:29:52,117 [DEBUG]  received message as directory: b'{"type": 797, "line": "127.0.0.1:"}'
2023-03-03 04:29:52,118 [INFO]  Updating status of peer: 127.0.0.1: to connected.
2023-03-03 04:29:52,118 [INFO]  We, xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.onion:5222, are calling the handshake callback as client.
2023-03-03 04:29:52,119 [DEBUG]  Not sending client handshake to 127.0.0.1: because we are directory.
2023-03-03 04:29:53,084 [DEBUG]  received message as directory: b'{"type": 793, "line": "{\\"app-name\\": \\"joinmarket\\", \\"directory\\": false, \\"location-string\\": \\"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.onion:5222\\", \\"proto-ver\\": 5, \\"features\\": {}, \\"nick\\": \\"xxxxxxxxxxxxxxxxxx\\", \\"network\\": \\"mainnet\\"}"}'
2023-03-03 04:29:53,119 [INFO]  Sending this handshake as directory: {"app-name": "joinmarket", "directory": true, "proto-ver-min": 5, "proto-ver-max": 5, "features": {}, "accepted": true, "nick": "xxxxxxxxxxxxxxxx", "network": "mainnet", "motd": "DIRECTORY NODE: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.onion:5222\nJOINMARKET VERSION: 0.9.10dev\nGreetings"}
2023-03-03 04:30:47,729 [DEBUG]  received message as directory: b'{"type": 687, "line": "xxxxxxxxxx!PUBLIC!sw0reloffer 0 xxxx xxxx x x.xxxxxx"}'
AdamISZ commented 1 year ago

So: (1) you have a directory node running and (2) you had to edit certain tor config settings, presumably something different from what's written here?

Just checking I follow exactly where you are with this. On the second point, let us know if there's something we should add to that section of the documentation.

AdamISZ commented 1 year ago

Thanks for everyone's contributions to JoinMarket! BTW, is this the best place to discuss and ask questions about contributions, or do you all still have an IRC or Discord channel or something now days for this type of thing?

Afaik the most active place is the Telegram group: https://t.me/joinmarketorg

CohibAA commented 1 year ago

So: (1) you have a directory node running and (2) you had to edit certain tor config settings, presumably something different from what's written here?

Just checking I follow exactly where you are with this. On the second point, let us know if there's something we should add to that section of the documentation.

(1) Yes, the new directory node is running now and stable for the last two weeks. The only downtime has been for server maintenance. (2) Honestly, I am still not sure why I was geting some errors. At some point I'll do the setup process again and document my steps better in case documentation should be updated. If I remember correctly, the only difference was adding the default ubuntu user to tor config, in addition to adding them to the linux user group for tor, but that might not be complete/accurate. I have not yet experience any failure of the directory node, nor any failure of connection to the node from maker bots.

Unhandled Error
Traceback (most recent call last):
Failure: twisted.internet.error.ConnectError: An error occurred while connecting: 2: No such file or directory.

The "No such file or directory" error still haunts startup of my directory node. It seems that turning off tor service, then restarting tor service allows the script to start successfully, as I can reproduce the error consistently by rebooting the server and trying to launch the node without stopping/starting tor. If the script is started immediately after restarting tor, it works correctly for me.

roshii commented 1 year ago

When I run start-dn.py to generate the onion for my node, this is the output:

(jmvenv) dirnode:~/joinmarket-clientserver/scripts$ python start-dn.py Greetings
User data location: /home/dirnode/.joinmarket/
2023-03-02 05:07:14,185 [INFO]  starting directory node
2023-03-02 05:07:14,186 [INFO]  Joinmarket daemon listening on port 27183
2023-03-02 05:07:14,191 [DEBUG]  connection was made, starting client.
2023-03-02 05:07:14,192 [INFO]  Attempting to start onion service on port: 5222 ...

I encountered the very same issue. It turned out it was (at my end) related to hidden service directory permission which must be set to 700

8alr0g commented 8 months ago

``

When I run start-dn.py to generate the onion for my node, this is the output:

(jmvenv) dirnode:~/joinmarket-clientserver/scripts$ python start-dn.py Greetings
User data location: /home/dirnode/.joinmarket/
2023-03-02 05:07:14,185 [INFO]  starting directory node
2023-03-02 05:07:14,186 [INFO]  Joinmarket daemon listening on port 27183
2023-03-02 05:07:14,191 [DEBUG]  connection was made, starting client.
2023-03-02 05:07:14,192 [INFO]  Attempting to start onion service on port: 5222 ...

I encountered the very same issue. It turned out it was (at my end) related to hidden service directory permission which must be set to 700

Hi! As you can see here: https://github.com/JoinMarket-Org/joinmarket-clientserver/issues/1687 Ive the same error. How have you solved this? What hidden service directory are you talking about? Tnx!

roshii commented 7 months ago

What hidden service directory are you talking about?

See https://github.com/JoinMarket-Org/joinmarket-clientserver/blob/master/docs%2Fonion-message-channels.md#joinmarket-specific-configuration

techy2 commented 2 months ago

Having difficulty setting up directory node joinmarket.cfg [DAEMON] no_daemon = 1 daemon_port = 27183 daemon_host = localhost use_ssl = false

[BLOCKCHAIN] blockchain_source = no-blockchain network = mainnet

[MESSAGING:onion] type = onion socks5_host = localhost socks5_port = 9050 tor_control_host = localhost tor_control_port = 9051 onion_serving_host = 127.0.0.1 onion_serving_port = 8080 hidden_service_dir = /home/johndoe/dirnode directory_nodes =

regtest_count = 0,0

[LOGGING] console_log_level = INFO color = true

[TIMEOUT] maker_timeout_sec = 60 unconfirm_timeout_sec = 180 confirm_timeout_hours = 6

accept_commitment_broadcasts = 1 commit_file_location = cmtdata/commitments.json commitment_list_location = cmtdata/commitmentlist ################ torrc SocksPort 9050 # Default: Bind to localhost:9050 for local connections. ControlPort 9051 CookieAuthentication 1 HiddenServiceDir /home/johndoe/dirnode HiddenServicePort 443 127.0.0.1:27183

permissions on "dirnode" 700

when I start start-dn.py in the jmvenv environment, this is the resulting output ser data location: /home/johndoe/dirnode 2024-09-16 11:09:49,601 [INFO] starting directory node 2024-09-16 11:09:49,602 [INFO] Joinmarket daemon listening on port 27183 2024-09-16 11:09:49,638 [ERROR] Failed to load directory nodes: InvalidLocationStringError('')

techy2 commented 2 months ago

port 443 is open on firewall and directed back to the host for this process

techy2 commented 2 months ago

so the issue appear to be that tor can not create the hidden service directory in the users directory tree. Yes, the user belongs to group debian-tor creating the directory manually with permission 700 does not fix the permission issue. If I use /var/lib/tor/hidden_service, then the directory is created and filled with the appropriate sutff, however the user daemon gets a permission denied when attempting to access that directory even though it belongs to the debian-tor group. I don't know how to resolve this and there is no documentation or chats that address this particular issue. I know tor is fussy, Still working on it