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): Avoid possibly returning data from different blocks in z_get_treestate RPC method #8460

Merged
merged 1 commit into from
Apr 24, 2024

Conversation

arya2
Copy link
Contributor

@arya2 arya2 commented Apr 24, 2024

Motivation

This avoids a concurrency bug where the z_get_treestate RPC method could return the note commitment trees for a different block than the one used to return the block hash and time.

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

  • Use the block hash to read Sapling/Orchard trees in z_get_treestate RPC method.

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

  • BlockQuery state request?

@arya2 arya2 added A-rpc Area: Remote Procedure Call interfaces A-concurrency Area: Async code, needs extra work to make it work properly. P-Low ❄️ labels Apr 24, 2024
@arya2 arya2 self-assigned this Apr 24, 2024
@arya2 arya2 requested a review from a team as a code owner April 24, 2024 17:54
@arya2 arya2 requested review from oxarbitrage and removed request for a team April 24, 2024 17:54
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.

thanks!

mergify bot added a commit that referenced this pull request Apr 24, 2024
@mergify mergify bot merged commit ee9ab31 into main Apr 24, 2024
137 checks passed
@mergify mergify bot deleted the use-hash-z-treestate branch April 24, 2024 20:27
Copy link
Member

@upbqdn upbqdn left a comment

Choose a reason for hiding this comment

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

I can't see how the original code could return the wrong data. @arya2 or @oxarbitrage, could you provide more context?

@arya2
Copy link
Contributor Author

arya2 commented May 13, 2024

I can't see how the original code could return the wrong data.

If the best chain changes between calls for the block data and its Sapling/Orchard trees when queried by height, it could've returned the trees for the new best chain at that height while returning the block data from the old best chain at that height.

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 P-Low ❄️
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants