Implement retroactive IS locking of transactions first seen in blocks instead of mempool - #2770
Conversation
b397947 to
c6c27f8
Compare
PastaPastaPasta
left a comment
There was a problem hiding this comment.
utACK, I don't see anything wrong with it. As long as good testing is done, I am happy :)
|
Please wait with merging, I'd like to do a rebase first after #2774 is merged (I hope this fixes test failures here) |
f8eb94c to
72f0748
Compare
0d71f7e to
70d939d
Compare
|
Tests are finally green, ready for merge after re-ACK |
|
I'm still not sure if I like the idea tbh 🙈 Also, can we split this PR into two - one for the fixes and the other one for the actual retroactive signing implementation? |
|
Ok, I'll do some PR splitting tomorrow. |
70d939d to
598d789
Compare
|
I've also rebased this PR on top of #2779 so that the ordering and conflict resolution is already in-place. I also added a commit on top to fix an issue with NewPoWValidBlock |
The UTXO set only works for TXs in the mempool and won't work when we try to retroactively lock unlocked TXs from blocks. This is safe as ProcessTx is only called when a TX was accepted into the mempool or connected in a block, which means that all input checks were good.
… cases SyncTransaction is called from AcceptToMemoryPool and when transactions got connected in a block. So this is the time we want to run TXs through ProcessTx. This also enables retroactive signing of TXs that were unknown before a new block appeared.
NewPoWValidBlock is not guaranteed to be called when blocks come in fast. When a block is accepted in AcceptBlock, NewPoWValidBlock is only called when the new block is a successor of the currently active tip. This is not the case when after the first block a second block is accepted immediately as the first block is not connected yet. This might be a bug actually in the handling of NewPoWValidBlock, so we might need to check/fix this later, but currently I prefer to not touch that part. Instead, we now use SyncTransaction to gather TXs for blockTxs. This works because SyncTransaction is called for all transactions in a freshly connected block in one go. The call also happens before UpdatedBlockTip is called, so it's fine with the existing logic.
598d789 to
633f64b
Compare
|
Rebased on develop and force-pushed. PR now only contains commits related to the PR. |
UdjinM6
left a comment
There was a problem hiding this comment.
Looks good 👍
Just a couple small suggestions.
Also check for empty vin.
This implements "retroactive signing" of TXs which were not known before a block appears that contains the TX. This implicitly enables retroactive signing of CLSIGs when included transactions were previously considered "unsafe".
The PR also includes a few fixes for issues I encountered while implementing/testing this.