elements icon indicating copy to clipboard operation
elements copied to clipboard

elementsd stuck syncing at block 2137819

Open philippem opened this issue 3 years ago • 6 comments

A elementsd built from master commit 29e62db gets stuck at block 2137819 and reports block with hash 02089a9de58601bf89ddfa80780a0adc6133a99e3d622f2c76a7c4fdeeb3feff as invalid.

This is reported by Pablof7z on twitter:

https://mobile.twitter.com/pablof7z/status/1603082516621324288

image

philippem avatar Dec 14 '22 21:12 philippem

Filed on behalf of @heelhook

psgreco avatar Dec 15 '22 11:12 psgreco

looks like my bitcoind was syncing at the same time that issue occurred; it'd seem like elementsd marked the block 02089a9de58601bf89ddfa80780a0adc6133a99e3d622f2c76a7c4fdeeb3feff as invalid too soon just because my bitcoind didn't have enough confirmations for49fdef3b803e3f201a2a798bbb2772e3cc77d3b8f689d24a44f2844125916776?

pablof7z avatar Dec 15 '22 11:12 pablof7z

Were you able to unstick it without doing anything drastic?

apoelstra avatar Dec 15 '22 14:12 apoelstra

yeah @apoelstra; I reconsiderblocked the block's hash it was complaining about and it continued syncing just fine.

pablof7z avatar Dec 15 '22 14:12 pablof7z

Ok. This is still a bug -- it should be able to recover automatically -- but that's not too bad.

apoelstra avatar Dec 15 '22 15:12 apoelstra

@apoelstra the problem seems to be that bitcoin went down between the initial checks and the final block validation. So @gwillen 's fix to "stall" didn't apply, but then the check to see if the pegins were ripe enough failed (2022-11-24T22:13:31Z WARNING: Lost connection to mainchain daemon RPC; will retry.), which returned an error and made the whole block invalid. My theory is that something like this would have fixed the issue

diff --git a/src/validation.cpp b/src/validation.cpp
index c96515f3d..82a1f4375 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -2118,7 +2118,9 @@ bool CChainState::ConnectBlock(const CBlock& block, BlockValidationState& state,
                         setPeginsSpent == NULL ? setPeginsSpentDummy : *setPeginsSpent,
                         g_parallel_script_checks ? &vChecks : NULL, fCacheResults, fScriptChecks, fedpegscripts)) {
                 // Any transaction validation failure in ConnectBlock is a block consensus failure
-                state.Invalid(BlockValidationResult::BLOCK_CONSENSUS,
+                // except for "Needs more confirmations"
+                state.Invalid((tx_state.GetDebugMessage() == "Needs more confirmations")?
+                        BlockValidationResult::BLOCK_MUTATED:BlockValidationResult::BLOCK_CONSENSUS,
                         tx_state.GetRejectReason(), tx_state.GetDebugMessage());
                 return error("%s: Consensus::CheckTxInputs: %s, %s", __func__, tx.GetHash().ToString(), state.ToString());
             }

Obviously needs better handling, but that's the idea

psgreco avatar Dec 15 '22 16:12 psgreco