-
Notifications
You must be signed in to change notification settings - Fork 267
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Secondary mechanism to trigger watches for transactions from past blocks #3002
Conversation
When a new block is found, we want to check its confirmed transactions to potentially trigger watches. This is especially important when a channel is spent and we haven't seen the spending transaction in our mempool before receiving it in a block. This is already supposed to be handled through the ZMQ `rawtx` topic, where bitcoind should send us every transaction it receives (either in the mempool or in a block). But when using remote `bitcoind` instances, ZMQ seems to sometimes be unreliable and silently drop some events. That's why we add another mechanism for extra safety, where whenever a new block is found, we fetch the last `N` blocks and re-process their transactions. We keep a cache of the processed blocks to ensure that we don't needlessly re-process them multiple times.
d7d00fb
to
d32a21a
Compare
Did you notice that all ZMQ messages contain a Also, I wonder if the cause of unreliability could be that we are using the same ZMQ adress for both transactions and blocks. Could we run into high watermarks due to a burst of transactions (maybe unrelayed txs directly found in a new block), and drop blocks? Finally, the implementation looks fine to me, but I wonder if we should instead rely on |
Yes, but what would you do when you detect that you missed events? There is no mechanism to ask for a retransmission of a past event.
According to
We've already disabled the high watermark (see The main case where this issue can happen is when we get disconnected or if
I think this would be much more complex to implement correctly than the simple behavior of this PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough! Just a nit
When a new block is found, we want to check its confirmed transactions to potentially trigger watches. This is especially important when a channel is spent and we haven't seen the spending transaction in our mempool before receiving it in a block.
This is already handled through the ZMQ
rawtx
topic, where bitcoind sends us every transaction it receives (either in the mempool or in a block). But when using remotebitcoind
instances, ZMQ seems to sometimes be unreliable and silently drop some events (mostly when the connection is unstable with thebitcoind
instance). That's why we add another mechanism for extra safety, where whenever a new block is found, we fetch the lastN
blocks and re-process their transactions. We keep a cache of the processed blocks to ensure that we don't needlessly re-process them multiple times.