-
Notifications
You must be signed in to change notification settings - Fork 117
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
Create initial transaction crawler for the mempool #2646
Conversation
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.
This all looks amazing!
I have a few suggestions about timeouts and error handling.
I've updated the code. I don't know if this is useful, but here's a link to what has changed: https://github.com/jvff/zebra/compare/mempool-crawler-r1..mempool-crawler-r1-fixes. |
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.
I've suggested some more changes, but happy with whatever you want here.
The mempool crawler is responsible for periodically asking peers for transactions to insert into the local mempool. This initial implementation will periodically ask for transactions, but won't do anything with them yet. Also, the crawler is currently configured to be always enabled, but this should be fixed to avoid crawling while Zebra is still syncing the chain.
Prevent the crawler from getting stuck if there's communication with a peer that takes too long to respond.
Spawn a task for the crawler when Zebra starts.
Create a mock for the `PeerSet` service to intercept requests and verify that the transaction requests are sent periodically.
Make it simpler to select the features for test builds. Co-authored-by: teor <[email protected]>
Make it easy to navigate from the `TODO` comment to the current project planning. Co-authored-by: teor <[email protected]>
Make it easy to navigate from the `TODO` comment to the current project planning. Co-authored-by: teor <[email protected]>
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.
I'm fine with whatever workaround you want to use until tokio
is updated.
Feel free to merge with the Mutex
workaround, or to use the &mut self
workaround in PR #2657.
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.
👍
Motivation
As part of the work to implement a mempool for Zebra, there's a need to crawl peers for transactions to populate the mempool. The mempool crawler is a background task that periodically asks a few peers for transactions.
Specifications
The Bitcoin documentation contains a small description about the mempool related network messages.
Designs
Solution
A
Crawler
type is created inside themempool
component. CallingCrawler::spawn
will construct the type and spawn a task to run it on the background. The crawler periodically requests a few peers (configured by a fan-out constant) for transaction IDs.There's a single test to make sure that the requests are sent in a timely manner to the
PeerSet
service.Review
@teor2345 has been following the design of this, but anyone else can chime in as well.
Reviewer Checklist
Follow Up Work
TransactionIds
responses to the download and verify stream #2650