greenaddress / elements

Feature experiments to advance the art of Bitcoin
MIT License
2 stars 1 forks source link

Non-deterministic block validity state cached #17

Open luke-jr opened 5 years ago

luke-jr commented 5 years ago

IsValidPeginWitness is used from at least GetTransactionSigOpCost and CheckTxInputs to determine block validity, the result of which can cause a block to be marked invalid permanently, and never reconsidered later.

But this is a problem because it calls IsConfirmedBitcoinBlock which can return true or false depending on the state of the linked Bitcoin node. The Bitcoin node might be behind, causing the block to be marked as invalid, and never reconsidered later when the Bitcoin node catches up. (Or an actually-invalid block might become valid as the Bitcoin blockchain grows, but this shouldn't happen in reality.)

instagibbs commented 5 years ago

These blocks are re-evaluated ever N seconds(2 minute default). see qa/rpc-tests/feature_fedpeg.py for the test case covering this by setting it to 15 seconds and making sure it recovers.

-recheckpeginblockinterval=15