-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Add zmq notifications for evicted transactions, tests #19462
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Concept ACK. Definitely useful since there's no easy way to currently track replacement for systems listening to bitcoind. |
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
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.
Concept ACK.
678d449
to
b9f4e8d
Compare
Pushed some fixes, and documentation. |
Single run failure unrelated:
restarted |
Concept ACK |
At the moment, the way that I synchronise with mempool contents is to poll One consideration is that it's not currently possible to perfectly synchronise the poll of Since this implementation adds another new zmq notifier, it might be worthwhile to take this opportunity to design the notifier such that it can be used exclusively to maintain mempool synchronisation, then you would only need to query Could I suggest adding a new notifier called
Since this new notifier has all the relevant events for mempool synchonisation strongly sequenced by a single notifier sequence number, you could then (when zmq is compiled in) add an additional field in the return value for |
Couldn't this just be a new message for the existing endpoints? |
@luke-jr I thought I'd break someone's integration perhaps if I did so since there's no "options" or anything in current messages, just txids AFAICT. (maybe I'm wrong!) |
b9f4e8d
to
432a333
Compare
pushed fixups |
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.
Concept ACK
@@ -177,6 +179,25 @@ void CZMQNotificationInterface::TransactionAddedToMempool(const CTransactionRef& | |||
} | |||
} | |||
|
|||
void CZMQNotificationInterface::TransactionRemovedFromMempool(const CTransactionRef& ptx, MemPoolRemovalReason reason) |
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.
Also a some code duplication here with the two functions above.
@@ -178,6 +180,16 @@ bool CZMQPublishHashTransactionNotifier::NotifyTransaction(const CTransaction &t | |||
return SendMessage(MSG_HASHTX, data, 32); | |||
} | |||
|
|||
bool CZMQPublishHashTransactionEvictionNotifier::NotifyTransactionEviction(const CTransaction &transaction, MemPoolRemovalReason reason) |
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.
Code between this function and NotifyTransaction
is almost identical, could be de-dublicated, maybe also together with NotifyBlock
but it's not blocking IMO
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.
Deduplicated the txn publishing portion, left block stuff alone for now.
ee86391
to
0686a96
Compare
0686a96
to
78a9583
Compare
Oddly enough I'm going to concept NACK my own PR. After spending some time trying to write a "mempool tracker" via ZMQ with mempool sequence numbers, this plus legacy zmq notifications are insufficient.
In my estimation, these transaction feeds can be subsumed by a single feed that is
|
…empool tracking 759d94e Update zmq notification documentation and sample consumer (Gregory Sanders) 68c3c7e Add functional tests for zmq sequence topic and mempool sequence logic (Gregory Sanders) e76fc2b Add 'sequence' zmq publisher to track all block (dis)connects, mempool deltas (Gregory Sanders) 1b615e6 zmq test: Actually make reorg occur (Gregory Sanders) Pull request description: This PR creates a new ZMQ notifier that gives a "total hash history" of block (dis)connection, mempool addition/substraction, all in one pipeline. It also exposes a "mempool sequence number" to both this notifier and `getrawmempool` results, which allows the consumer to use the results together without confusion about ordering of results and without excessive `getrawmempool` polling. See the functional test `interfaces_zmq.py::test_mempool_sync` which shows the proposed user flow for the client-side tracking of mempool contents and confirmations. Inspired by #19462 (comment) Alternative to #19462 due to noted deficiencies in current zmq notification streams. Also fixes a legacy zmq test that didn't actually trigger a reorg because of identical blocks being generated on each side of the split(oops) ACKs for top commit: laanwj: Code review ACK 759d94e Tree-SHA512: 9daf0d7d996190f3a68ff40340a687519323d7a6c51dcb26be457fbc013217ea7b62fbd0700b74b654433d2e370704feb61e5584399290692464fcfcb72ce3b7
…-side mempool tracking 759d94e Update zmq notification documentation and sample consumer (Gregory Sanders) 68c3c7e Add functional tests for zmq sequence topic and mempool sequence logic (Gregory Sanders) e76fc2b Add 'sequence' zmq publisher to track all block (dis)connects, mempool deltas (Gregory Sanders) 1b615e6 zmq test: Actually make reorg occur (Gregory Sanders) Pull request description: This PR creates a new ZMQ notifier that gives a "total hash history" of block (dis)connection, mempool addition/substraction, all in one pipeline. It also exposes a "mempool sequence number" to both this notifier and `getrawmempool` results, which allows the consumer to use the results together without confusion about ordering of results and without excessive `getrawmempool` polling. See the functional test `interfaces_zmq.py::test_mempool_sync` which shows the proposed user flow for the client-side tracking of mempool contents and confirmations. Inspired by bitcoin#19462 (comment) Alternative to bitcoin#19462 due to noted deficiencies in current zmq notification streams. Also fixes a legacy zmq test that didn't actually trigger a reorg because of identical blocks being generated on each side of the split(oops) ACKs for top commit: laanwj: Code review ACK 759d94e Tree-SHA512: 9daf0d7d996190f3a68ff40340a687519323d7a6c51dcb26be457fbc013217ea7b62fbd0700b74b654433d2e370704feb61e5584399290692464fcfcb72ce3b7
Currently the only zmq notifications that exist for transactions are for:
For mempool-tracking purposes, it's useful to know when transactions are being dropped from the local mempool without relying on a tight polling loop. This notification publishes anytime a transaction is removed from the mempool, aside from the case where it is confirmed in the new incoming block(already published in 2 above).
Based on #19507
Additional test cases that could be added: