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(rpc): Await state service requests in getblock method in parallel #8376

Merged
merged 2 commits into from Mar 26, 2024

Conversation

arya2
Copy link
Contributor

@arya2 arya2 commented Mar 23, 2024

Motivation

This is cleanup in the getblock method ahead of adding any additional service calls, adding other fields to the getblock response that are provided in zcashd would likely require another state service call to request the block header, and we may also want to look up the height if the method was called with a block hash.

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.

Complex Code or Requirements

This could change the order in which the state service receives and responds to these requests, which should be okay.

Solution

  • Calls state.oneshot() instead of .ready().and_then(svc.call()) for getting the transactions ids, sapling/orchard trees, and block depth
  • Awaits the futures in a FuturesOrdered

Testing

Existing tests should cover this change.

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

  • Look up block heights and headers in the state service
  • Add fields in zcashd to GetBlock::Object verbose response of the getblock method
  • We may also want to:
    • Use a join!() instead of a FuturesOrdered (not done here due to rustfmt issues)
    • Move the error conversion to a trait method + From impl to avoid duplicate code

@arya2 arya2 added C-cleanup Category: This is a cleanup A-rpc Area: Remote Procedure Call interfaces A-concurrency Area: Async code, needs extra work to make it work properly. P-Low ❄️ labels Mar 23, 2024
@arya2 arya2 self-assigned this Mar 23, 2024
@arya2 arya2 requested a review from a team as a code owner March 23, 2024 01:37
@arya2 arya2 requested review from upbqdn and removed request for a team March 23, 2024 01:37
@arya2 arya2 added the C-trivial Category: A trivial change that is not worth mentioning in the CHANGELOG label Mar 23, 2024
@arya2 arya2 requested review from oxarbitrage and removed request for upbqdn March 23, 2024 01:37
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 a lot better. Thank you.

@mergify mergify bot merged commit c54fb84 into main Mar 26, 2024
135 checks passed
@mergify mergify bot deleted the parallel-svc-calls branch March 26, 2024 11:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-concurrency Area: Async code, needs extra work to make it work properly. A-rpc Area: Remote Procedure Call interfaces C-cleanup Category: This is a cleanup C-trivial Category: A trivial change that is not worth mentioning in the CHANGELOG P-Low ❄️
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants