gridcoin-community / Gridcoin-Research

Gridcoin-Research
MIT License
585 stars 172 forks source link

beacon, registry: Fix beacon history stall #2731

Closed jamescowens closed 7 months ago

jamescowens commented 8 months ago

We have had some problems with beacon history causing the wallet to get stuck. The symptoms are the wallet stops syncing and one thread is constantly running. This is cleared by having the users start the wallet with -clearbeaconhistory, which clears out the leveldb beacon registry area and rebuilds it from a contract replay. This would indicate that the beacon chainlets are somehow corrupted and causing an infinite loop during the chainlet walkback that is done in several consensus critical areas.

This PR corrects some flaws found in the beacon contract handling code, refactors chainlet walkbacks that were in several places in the code into one BeaconRegistry::GetBeaconChainletRoot, which also has corruption detection, and also expands the logging in the beacon test harness to help with troubleshooting. Code comments have also been corrected and updated.

martini1992 commented 8 months ago

Had this bug on my server for a couple of weeks had no idea how to clear it, then I found this PR, adding -clearbeaconhistory fixed the issue, added it commented to my docker-compose file for future reference. Thank you 🙂

jamescowens commented 8 months ago

Clearing the entire chain history and resyncing from zero also fixes it, but that is applying a sledgehammer to hammer a nail... :)

martini1992 commented 8 months ago

That was going to be my next move, but thank you for saving me the bandwidth 😄