shermand100 / PiNodeXMR

Monero Node for Single Board Computers with Web Interface and additional tools pre-configured. Self Installing.
GNU General Public License v3.0
213 stars 40 forks source link

execScripts/p2pool.sh does not account for monerod's RPC password #105

Closed alicedb2 closed 9 months ago

alicedb2 commented 11 months ago

I run a private monero node together with a p2pool node. I had to modify execScripts/p2pool.sh because p2pool was complaining about rpc authentication errors. I was getting a constant stream of the following two lines in p2pool.log :

2023-09-21 19:01:06.7918 P2Pool get_info RPC request to 192.168.0.13:18081:ZMQ:18083 failed: error HTTP error 401, trying again in 1 second
WARNING 2023-09-21 19:01:06.7918 P2Pool get_info RPC request to 192.168.0.13:18081:ZMQ:18083 failed: error HTTP error 401, trying again in 1 second
2023-09-21 19:01:06.7918 P2Pool get_info RPC request to 192.168.0.13:18081:ZMQ:18083 failed: error HTTP error 401, trying again in 1 second
WARNING 2023-09-21 19:01:06.7918 P2Pool get_info RPC request to 192.168.0.13:18081:ZMQ:18083 failed: error HTTP error 401, trying again in 1 second
[...]

and p2pool was failing to synchronize complaining about invalid shares and a p2pool block height of 0.

I added the following lines at the beginning of execScripts/p2pool.sh

        #Import RPC username
        . /home/pinodexmr/variables/RPCu.sh
        #Import RPC password
        . /home/pinodexmr/variables/RPCp.sh

and appended --rpc-login to the command

./p2pool --host $DEVICE_IP --wallet $MINING_ADDRESS --rpc-login $RPCu:$RPCp 
         --no-color --light-mode --no-cache --loglevel 2 --mini

For reference, the private monero node is running under the following command

./monerod --rpc-bind-ip=192.168.0.13 --zmq-pub tcp://192.168.0.13:18083 --rpc-bind-port=18081 
          --confirm-external-bind --rpc-login=rpcuser:rpcpassword --rpc-ssl disabled
          --in-peers=32 --out-peers=32 --limit-rate-up=1024 --limit-rate-down=4096 --max-log-file-size=10485760
          --log-level=1 --max-log-files=1 --pidfile /home/pinodexmr/monero/build/release/bin/monerod.pid 
          --enable-dns-blocklist --detach
shermand100 commented 11 months ago

https://github.com/monero-ecosystem/PiNode-XMR/commit/29b438f7698c80b7362f52abc87d4d447802bb7f

Thanks for flagging this. I'm currently testing a fix which applies our start method for the OnionBlockExplorer to P2Pool. It uses the variable bootstatus.sh which is set 1 - 7 by Monerod starting to flag what Monerod RPC port or RPC login credentials may be required.

Open to other ideas?

alicedb2 commented 11 months ago

Great!

Speaking of BOOT_STATUS, could we list them somewhere? Only way I could figure out their meaning was to grep all scripts:

pinodexmr@PiNodeXMR:~$ grep -R "BOOT_STATUS=" *
bootStatusSetIdle.sh:BOOT_STATUS=2" > /home/pinodexmr/bootstatus.sh
bootstatus.sh:BOOT_STATUS=3
execScripts/moneroTorPrivate.sh:BOOT_STATUS=4" > /home/pinodexmr/bootstatus.sh
execScripts/moneroMiningNode.sh:BOOT_STATUS=5" > /home/pinodexmr/bootstatus.sh
execScripts/moneroPrivate.sh:BOOT_STATUS=3" > /home/pinodexmr/bootstatus.sh
execScripts/moneroPublicRPCPay.sh:BOOT_STATUS=6" > /home/pinodexmr/bootstatus.sh
execScripts/moneroTorPublic.sh:BOOT_STATUS=9" > /home/pinodexmr/bootstatus.sh
execScripts/moneroPublicFree.sh:BOOT_STATUS=7" > /home/pinodexmr/bootstatus.sh
execScripts/moneroI2PPrivate.sh:BOOT_STATUS=8" > /home/pinodexmr/bootstatus.sh

Would it make sense to maybe use a bit/hexmask instead of a sequential integer so that we can also keep track of the configuration state of other things like p2pool/standalone tor/atomic swaps and so on?

(sorry, off-topic, maybe that's something to be discussed elsewhere)

shermand100 commented 9 months ago

Commit https://github.com/monero-ecosystem/PiNode-XMR/commit/481b2ef7dcf0dfbae17902bc1af6ae1ab6caaa2b has merged the upgraded P2Pool start file and included key for index numbers for Monerod configuration for what's going on.

Tested with: tor Public and Private Clearnet Public and Private Monerod Idle - Now gives systemd failure (auto-restart), with "Error: Monerod not running" printed in P2Pool log

Going forwards, I see why on the face of it a hex key rather than integers may make sense but the BOOT_STATUS number index is entirely driven by the configuration status of Monerod. Monerod sets the BOOT_STATUS number and the other integrated projects - blockexplorer, P2Pool etc - use that reference number to know how and with what parameters to talk to Monerod. There are currently only 7 major configurations, and internal minor configurations are handled by options flags sourced at time of script execution by pulling in variables from the /home/pinodexmr/variables directory, for if a user has set a custom RPC/P2P port etc.

2 = Idle, Monero not running (Set whenever ANY stop button is pressed)

3 = private node 4 = tor private 5 = solo mining 6 = Public RPC pay 7 = Public free 8 = I2P 9 = tor public

I'll add the above key to the other files in which it's used to hopefully clarify what's going on. As always though I'm open to changing it if there is a better method.

Closing this particular issue but can re-open for P2Pool.sh related problems. BOOT_STATUS discussion could be a new issue.