You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This came to my attention when a user opened bcoin-org/bcoin#915, as an amazing coincidence I was also studying the Bitcoin Core BIP68 test which shed some important light on the subject.
The issue arises when a block is disconnected (either by a reorg, or locally with rpc invalidateblock) and there are two relevant places in the code.
First: when a block is removed, if the mempool is empty, all the TXs in the block are discarded:
Second, if a 'reorganize' event is caught by mempool, the mempool is "sterilized" by _handleReorg() but this function is a little brutal, it removes all CSV transactions and all coinbase-spends.
The effect of these two snippets is to simplify mempool processing after a reorg (the BIP68 rules get stupid-complicated when transactions are re-entering the mempool, especially if the parent of a CSV TX re-enters the mempool)
I don't think this is a much an issue with bcoin but it will be with Handshake, since this is the code all miners will be running, and there are more likely to be re-orgs in the early stages of the chain. The effect will be lots of transactions disappearing completely from mempools and blocks if a block is removed, the sender (or recipient) will have to re-broadcast. It is also very non-optimal for miners because they are throwing away fees.
Using the Bitcoin Core test as a guide, I'm going to try to implement deeper reorg-mempool behavior behavior in bcoin and after review and merge, port that back to hsd.
The text was updated successfully, but these errors were encountered:
This came to my attention when a user opened bcoin-org/bcoin#915, as an amazing coincidence I was also studying the Bitcoin Core BIP68 test which shed some important light on the subject.
The issue arises when a block is disconnected (either by a reorg, or locally with
rpc invalidateblock
) and there are two relevant places in the code.First: when a block is removed, if the mempool is empty, all the TXs in the block are discarded:
hsd/lib/mempool/mempool.js
Lines 333 to 339 in 27c99ad
Second, if a
'reorganize'
event is caught by mempool, the mempool is "sterilized" by_handleReorg()
but this function is a little brutal, it removes all CSV transactions and all coinbase-spends.The effect of these two snippets is to simplify mempool processing after a reorg (the BIP68 rules get stupid-complicated when transactions are re-entering the mempool, especially if the parent of a CSV TX re-enters the mempool)
I don't think this is a much an issue with bcoin but it will be with Handshake, since this is the code all miners will be running, and there are more likely to be re-orgs in the early stages of the chain. The effect will be lots of transactions disappearing completely from mempools and blocks if a block is removed, the sender (or recipient) will have to re-broadcast. It is also very non-optimal for miners because they are throwing away fees.
Using the Bitcoin Core test as a guide, I'm going to try to implement deeper reorg-mempool behavior behavior in bcoin and after review and merge, port that back to hsd.
The text was updated successfully, but these errors were encountered: