greenaddress / elements

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

ApplyTxInUndo probably shouldn't check IsConfirmedBitcoinBlock #18

Open luke-jr opened 5 years ago

luke-jr commented 5 years ago

ApplyTxInUndo is used to disconnect a block being reorganised out. When undoing peg-ins, it checks IsConfirmedBitcoinBlock via IsValidPeginWitness. But if such a reorg were to happen, it would likely be because a peg-in is no longer valid on the Bitcoin side, and this failure would be fatal to Liquid nodes trying to sync to the new best chain.

Maybe a non-issue if Liquid functionaries are expected never to reorg. But at the very least, there is no apparent reason to re-check here, and it only has the potential to create unnecessary problems. Even if there are no problems, it can slow down the reorg.

instagibbs commented 5 years ago

mm true

instagibbs commented 5 years ago

And even if there was a re-org(1 block reorgs are possible!) this means you'd need a buried Bitcoin transaction to get reorged, which means the functionary network should immediately halt anyways. Currently the functionary network will stop what it's doing if it sees a 50+ block reorg in Liquid.

instagibbs commented 5 years ago

This is probably worth an issue in the main repo regardless