Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: Gabrics on January 10, 2020, 08:26:16 PM



Title: Chain reorg question
Post by: Gabrics on January 10, 2020, 08:26:16 PM
Hi,

What happens after chain reorg with the transactions confirmed on the shorter chain (lets assume a somewhat possible 3 blocks reorg), but not included in the longer chain? I believe those are not in the mempool anymore as they were included in a block earlier.
Does Bitcoin core re-queues the transactions from the overwritten blocks?
Does it x-reference which transactions were included in the loosing but not he winning fork?

Can someone please someone enlighten me? ;)

Thanks


Title: Re: Chain reorg question
Post by: HeRetiK on January 10, 2020, 08:38:13 PM
Does it x-reference which transactions were included in the loosing but not he winning fork?

No. Orphaned blocks and their transactions are not stored and referenced. Some blockchain explorers may store the orphaned blocks that they received in their database for public viewing, but that's unrelated to how the Bitcoin protocol works.


What happens after chain reorg with the transactions confirmed on the shorter chain (lets assume a somewhat possible 3 blocks reorg), but not included in the longer chain? I believe those are not in the mempool anymore as they were included in a block earlier.
Does Bitcoin core re-queues the transactions from the overwritten blocks?

"The" mempool does not exist. Every node has their own mempool. That means while nodes that followed the "losing" fork will have removed the transaction from their mempool, other nodes that have been following the "winning" fork all along will still have the transactions in their mempool -- given, of course, the transactions have not yet been included in the "winning" chain as well.


Title: Re: Chain reorg question
Post by: jackg on January 10, 2020, 08:43:18 PM
If a block is orphaned most of the transactions will normally appear in the unorphaned block anyway (especially is consensus rules aren't changed).

In addition, I'm not sure about whether they'd be recycled back into the mempool but my instinct tells me they would... I know they're recycled the other way around so the signature doesn't have to be verified twice (once entering the mempool and once entering the block) so blocks can be added a lot faster.


Title: Re: Chain reorg question
Post by: Gabrics on January 11, 2020, 06:37:07 AM
Thanks for the inputs.
So I conclude:
The winning fork has its own version of pending transactions (mempool) which will still have the transactions not included in the overtaking chain. The nodes which followed the shorter version for a while will not have these, but will get to know about them when these pending transactions eventually will be included in a block.

Pretty smart IMHO :)


Title: Re: Chain reorg question
Post by: nc50lc on January 11, 2020, 07:14:55 AM
Thanks for the inputs.
So I conclude:
The winning fork has its own version of pending transactions (mempool) which will still have the transactions not included in the overtaking chain. The nodes which followed the shorter version for a while will not have these, but will get to know about them when these pending transactions eventually will be included in a block.
They won't wait for those transaction to get included in a block in order to "know" them.
The transactions from the orphaned block that weren't included to the latest block(s) of the longest will be added to their mempool again.

The book: Mastering bitcoin used the term "queued up again" that lightly indicates that the node will move them from the orphaned block back to mempool.