Skip to content
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

Send crawled transaction IDs to downloader #2801

Merged

Conversation

jvff
Copy link
Contributor

@jvff jvff commented Sep 24, 2021

Motivation

The mempool crawler currently only logs crawled transaction IDs, but doesn't forward them so that the transactions can be downloaded and stored in the mempool.

This closes #2650.

Solution

The mempool::Crawler was updated to receive a handle to the mempool service, and after it receives crawled transactions it just forwards them to be queued in the mempool's transaction downloader.

Review

Anyone working on the mempool can review this PR.

Reviewer Checklist

  • Code implements Specs and Designs
  • Tests for Expected Behaviour
  • Tests for Errors

Follow Up Work

@jvff jvff requested a review from a team September 24, 2021 16:27
@jvff jvff self-assigned this Sep 24, 2021
@jvff jvff changed the title Send crawled transaction ids to downloader Send crawled transaction IDs to downloader Sep 27, 2021
Copy link
Contributor

@teor2345 teor2345 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, I just have a question about error handling.

zebrad/src/components/mempool/crawler.rs Outdated Show resolved Hide resolved
@jvff jvff force-pushed the send-crawled-transaction-ids-to-downloader branch from 9ad2e55 to 9cb7499 Compare September 30, 2021 12:09
@jvff
Copy link
Contributor Author

jvff commented Sep 30, 2021

I updated the PR to include a test to ensure the crawler survives forwarding errors. This was a bit harder than I expected, and I ended up refactoring the tests a bit to try to make it readable. Hopefully it's not too complicated 😅

You can see only the changes here.

@jvff jvff requested a review from teor2345 September 30, 2021 12:15
Copy link
Contributor

@teor2345 teor2345 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to shut down the task if the mempool shuts down or has a fatal error.

But I don't think any of the other errors are particularly serious.

zebrad/src/components/mempool/crawler.rs Outdated Show resolved Hide resolved
zebrad/src/components/mempool/crawler.rs Outdated Show resolved Hide resolved
@teor2345
Copy link
Contributor

teor2345 commented Oct 1, 2021

Thanks again for the comprehensive tests here, I think they'll really help us get the error handling right.

jvff added 18 commits October 1, 2021 20:30
Replace the single letter with a proper name.
The type names will conflict with the ones for the mempool service.
Add a field to the `Crawler` type to store a way to access the `Mempool`
service.
The crawled transactions are now sent to the transaction downloader and
verifier, to be included in the mempool.
Make it simpler to use the `MockService::expect_request` method.
Create some dummy crawled transactions, and let the crawler discover
them. Then check if they are forwarded to the mempool to be downloaded
and verified.
Ignore response from peers that don't provide any crawled transactions.
Calling the Mempool service should not fail, so if an error happens it
should be visible. However, errors when downloading individual
transactions can happen from time to time, so there's no need for them
to be very visible.
Provide some depth as to what the test expect from the crawler's
behavior.
Make it easier to reuse the common test setup code.
Now that `zebra_network::Request` implement `Eq`, the call can be
simplified into `expect_request`.
A helper function that checks for a network crawl request and responds
with the given list of crawled transaction IDs.
A function to intercept and respond to the fanned-out requests sent
during a single crawl iteration.
Reduce the repeated code necessary to intercept and reply to a request
for queuing transactions to be downloaded.
Intercepts a mempool request to queue transactions to be downloaded, and
responds with an error, simulating an internal problem in the mempool
service implementation.
This is required for deriving `Arbitrary` for some error types.
Allow random transaction errors to be generated for property tests.
Allow random Mempool errors to be generated for property tests.
jvff and others added 3 commits October 1, 2021 20:31
The crawler should be robust enough to continue operating even if the
mempool service fails to download transactions or even fails to handle
requests to enqueue transactions.
They should happen regularly, so there's no need to have them with a
high visibility level.

Co-authored-by: teor <[email protected]>
If `Mempool::poll_ready` returns an error, it's because the mempool
service has stopped and can't handle any requests, so the crawler should
stop as well.
@jvff jvff force-pushed the send-crawled-transaction-ids-to-downloader branch from f668cde to ddad6d1 Compare October 1, 2021 20:31
@jvff jvff requested review from conradoplg and teor2345 October 1, 2021 20:40
Copy link
Collaborator

@conradoplg conradoplg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

Copy link
Contributor

@teor2345 teor2345 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for these changes, let's merge!

@teor2345 teor2345 merged commit 5d9893c into ZcashFoundation:main Oct 5, 2021
@jvff jvff deleted the send-crawled-transaction-ids-to-downloader branch November 23, 2021 22:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Send mempool crawler peer TransactionIds responses to the download and verify stream
3 participants