mynodebtc / mynode

The easiest way to run Bitcoin and Lightning!
Other
650 stars 148 forks source link

Chainstate not being saved #807

Open goodluck456 opened 1 year ago

goodluck456 commented 1 year ago

Describe the bug Chainstate not being saved

Expected behavior So myNode is doing this weird thing where if I try to go to the power button and do a reboot or shutdown, it shuts down, but when I try to boot back and login, the last up to date chainstate doesn't seem to be saving. Or even if I go do sudo mynode-stop-services and sudo reboot from ssh, reconnect the power cord and boot back up and login, the chainstate isn't being saved. Instead of it going back to the most recent blocks like 801433, it keeps saying the nBestHeight was 801045, so it ends up syncing the blocks all over again. How do I get this to stop and make it save the chainstate upon reboot? I'm currently on myNode version 0.3.18

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information): Viewing it on Chrome in Ubuntu 22.04.2 LTS

MyNode hardware (please complete the following information): It's the Model 1 on Raspberry Pi 4 using a 1TB external SSD and 32gb microSD card. myNode version 0.3.18

Additional context And lately, when I check the log for Tor, I've been getting a lot of lines that say certain things: [WARN] Proxy Client: unable to connect to :50002 ("general SOCKS server failure") [NOTICE] DisableNetwork is set. Tor will not make or accept non-control network connections. Shutting down all existing connections. I have tried deleting the DisableNetwork in torrc and I also added some obfs4 bridges in the torrc file. I'm still getting the [WARN] Proxy Client: unable to connect to :50002 ("general SOCKS server failure") error. I'm assuming this can be ignored and Tor is still running as usual. Think it has something to do with the Tor network itself being DDOSed and guard nodes failing.

babikpatient6 commented 1 year ago

I have the same issue on every LN node I run. Its bug in bitcoin core 25.0 and should be fixed in 25.1. https://github.com/bitcoin/bitcoin/issues/27722 Hopefully it will be soon, this is quite high priority imho.

Until then idk about easy fix, and I have tried few things. Keep node / bitcoin reboots to minimum for now. Some things (typically changing lnd.conf) can be done in cli without full reboot (unlike in web UI)..

Edit: Regarding TOR, I have seen something similar when I couldnt reconnect to any TOR peer (bitcoin or lnd). I've solved it by resetting TOR connections on settings page.

tehelsper commented 1 year ago

I agree. If the chain does catch up, I would try to avoid reboots. If not, it can be due to blockchain corruption which could require resetting the blockchain, but the bitcoin log can help confirm that.

goodluck456 commented 1 year ago

I have the same issue on every LN node I run. Its bug in bitcoin core 25.0 and should be fixed in 25.1. bitcoin/bitcoin#27722 Hopefully it will be soon, this is quite high priority imho.

Until then idk about easy fix, and I have tried few things. Keep node / bitcoin reboots to minimum for now. Some things (typically changing lnd.conf) can be done in cli without full reboot (unlike in web UI)..

Edit: Regarding TOR, I have seen something similar when I couldnt reconnect to any TOR peer (bitcoin or lnd). I've solved it by resetting TOR connections on settings page.

I keep getting stuff like this in my Tor log:

[warn] Proxy Client: unable to connect OR connection (handshaking (proxy)) with <ip> ("general SOCKS server failure")
[notice] Delaying directory fetches: No running bridges
[notice] We now have enough directory information to build circuits.
[notice] Tried for 120 seconds to get a connection to [scrubbed]:5222. Giving up. (waiting for circuit)
[notice] Application request when we haven't used client functionality lately. Optimistically trying known bridges again.
[notice] Our directory information is no longer up-to-date enough to build circuits: We're missing descriptors for 2/4 of our primary entry guards (total microdescriptors: 7286/7286). That's ok. We will try to fetch missing descriptors soon.
[notice] Delaying directory fetches: No running bridges
[warn] Proxy Client: unable to connect OR connection (handshaking (proxy)) with <ip> ("general SOCKS server failure")
[notice] Your network connection speed appears to have changed. Resetting timeout to 60000ms after 18 timeouts and 1000 buildtimes.
[notice] Delaying directory fetches: No running bridges
[notice] Closed 1 streams for service [scrubbed].onion for reason resolve failed. Fetch status: No more HSDir available to query.

I don't know if maybe this has something to do with the Tor network itself being DDOSed. I have tried adding bridges to Tor and it doesn't seem to be fixing the issue. Or if I don't use any bridges, I still have this issue. I tried to reset Tor connections and I tried resetting Tor data and they didn't seem to do anything.

I'm also getting this when I edited the torrc file back to normal and restarted Tor:

[warn] Guard <guard> is failing a very large amount of circuits. Most likely this means the Tor network is overloaded, but it could also mean an attack against you or potentially the guard itself. Success counts are 73/151. 
[warn] Guard <guard> is failing a very large amount of circuits. Most likely this means the Tor network is overloaded, but it could also mean an attack against you or potentially the guard itself. Success counts are 66/151. 
[warn] Guard <guard> is failing a very large amount of circuits. Most likely this means the Tor network is overloaded, but it could also mean an attack against you or potentially the guard itself. Success counts are 67/151.

Not sure why I'm getting this stuff.

I tried to upgrade myNode one time and when I did that, it messed up my Bitcoin blockchain and/or the microSD got corrupted. So I had to get a new microSD card, flash myNode to it and insert it, and then I had to download the entire Bitcoin blockchain again. That took me like a month to download. I'm kinda hesitant to do another upgrade until I figure out what's going on. I have 0.3.18 myNode and it's asking me to upgrade to 0.3.19, so I'm kinda hesitant at the moment because I'm afraid it'll corrupt the Bitcoin blockchain again. Which commands do you use via SSH to gracefully shut down myNode? I have also noticed that if I keep myNode running for a while, every once in a while, I end up losing the connection to myNode. If I try to go to the IP address, it says it can't connect or connection not found. So I have to unplug the power and plug it in again. I'm not sure why that happens.

Edit: myNode did it again. I had it running for a little bit for like an hour or two. And then it lost the connection and I couldn't connect to it. So I unplugged the power, reconnected the power, I went back in and it said it was looking for drive to mount. I went to the status to see what was going on with Bitcoin and it said "MISSING FILE". I thought the blockchain or the directory in the SSD got screwed up. So I waited the next day, then I reflashed the microSD and now it boots back up again and got back the chainstate of 801629. So all I had to do was reflash the microSD card instead of redownloading the entire blockchaiin again.

tehelsper commented 1 year ago

Losing the connection can be caused by running out of RAM or bad hardware. To reboot, just run sudo mynode-reboot. Re-flashing won't cause the blockchain data to be lost. It sounds like power outages or bad hardware are causing SD card corruption and possibly SSD corruption in the blockchain data.

goodluck456 commented 1 year ago

Well, it looks like i tried to reboot it and it looked like it was going to start the syncing process again, but it just keeps dropping out and losing the connection and it keeps repeating this. That would suck if I have to buy another myNode. Or maybe something is using too much RAM.