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

fix(scan): Fix minor concurrency bug in the scan gRPC method #8303

Merged
merged 5 commits into from
Feb 21, 2024

Conversation

arya2
Copy link
Contributor

@arya2 arya2 commented Feb 21, 2024

Motivation

This PR is a follow up to #8268 and fixes an issue around missing results from a block in the scan gRPC method response.

PR Author Checklist

Check before marking the PR as ready for review:

  • Will the PR name make sense to users?
  • Does the PR have a priority label?
  • Have you added or updated tests?
  • Is the documentation up to date?
For significant changes:
  • Is there a summary in the CHANGELOG?
  • Can these changes be split into multiple PRs?

If a checkbox isn't relevant to the PR, mark it as done.

Solution

  • Updates scan task to:
    • Notify caller after updating the subscribed_keys collection and sending it to the watch channel (and sending it the result receiver)
    • Check for result senders in latest version of subscribed_keys in watch channel before writing results to storage
  • Updates scan() gRPC method to:
    • Call ScanService with a SubscribeResults request and to wait for the response before calling the scan service with a Results request
    • Empty out the result_receiver channel to filter out any duplicates from the Results response

Related cleanups:

  • Removes outdated TODOs
  • Joins RegisterKeys and SubscribeResults service call futures

Review

Anyone can review.

Reviewer Checklist

Check before approving the PR:

  • Does the PR scope match the ticket?
  • Are there enough tests to make sure it works? Do the tests cover the PR motivation?
  • Are all the PR blockers dealt with?
    PR blockers can be dealt with in new tickets or PRs.

And check the PR Author checklist is complete.

Follow Up Work

  • Test that every expected result from the scan() method is present and unique

Joins register/subscribe scan service calls, sends SubscribeResults request first, and filters out duplicate results from channel
@arya2 arya2 added A-rpc Area: Remote Procedure Call interfaces A-concurrency Area: Async code, needs extra work to make it work properly. A-blockchain-scanner Area: Blockchain scanner of shielded transactions P-Medium ⚡ labels Feb 21, 2024
@arya2 arya2 self-assigned this Feb 21, 2024
@arya2 arya2 requested a review from a team as a code owner February 21, 2024 03:43
@arya2 arya2 requested review from upbqdn and removed request for a team February 21, 2024 03:43
@github-actions github-actions bot added the C-bug Category: This is a bug label Feb 21, 2024
@arya2 arya2 requested a review from oxarbitrage February 21, 2024 03:43
@arya2 arya2 changed the title fix(scan): Fixes a concurrency bug in the scan gRPC method fix(scan): Fix minor concurrency bug in the scan gRPC method Feb 21, 2024
Copy link
Contributor

@oxarbitrage oxarbitrage 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.

mergify bot added a commit that referenced this pull request Feb 21, 2024
@mergify mergify bot merged commit 5a9281a into main Feb 21, 2024
132 checks passed
@mergify mergify bot deleted the fix-scan-rpc-bug branch February 21, 2024 23:29
@mpguerra mpguerra linked an issue Feb 22, 2024 that may be closed by this pull request
idky137 pushed a commit to idky137/zebra that referenced this pull request Feb 28, 2024
…Foundation#8303)

* update scan task to notify subscribe caller once the new subscribed_keys are sent on the watch channel

* Fixes timing bug in scan gRPC method:

Joins register/subscribe scan service calls, sends SubscribeResults request first, and filters out duplicate results from channel

* Removes outdated TODO

* wraps subscribed_keys in an Arc before sending to watch channel, fixes typo

* Remove result senders for keys that have been removed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-blockchain-scanner Area: Blockchain scanner of shielded transactions A-concurrency Area: Async code, needs extra work to make it work properly. A-rpc Area: Remote Procedure Call interfaces C-bug Category: This is a bug P-Medium ⚡
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement scan grpc method
2 participants