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(state): Limit the retrieval of note commitment subtrees #7734

Merged
merged 10 commits into from
Oct 12, 2023

Conversation

upbqdn
Copy link
Member

@upbqdn upbqdn commented Oct 12, 2023

Motivation

Close #7708.

The issue in #7708 was that when retrieving the subtrees from the finalized and non-finalized state, we always added all subtrees from the non-finalized state to the response without paying attention to the requested limit.

Solution

  • Apply the given limit when retrieving subtrees.
  • In non-release builds, make sure the limit applies.
  • Add tests that test if we combine the subtrees from finalized and non-finalized states correctly. In order to implement the tests:
    • Derive Default for Chain.
    • Derive Default for Sapling & Orchard note commitment tree Node.
    • Allow direct insertions of subtrees into Chain for tests.
    • Set the visibility of DiskWriteBatch to pub(super).

Unrelated Clean-ups

  • Use default() for subtree roots in other tests.
  • Clarify some docs.

Reviewer Checklist

  • Will the PR name make sense to users?
    • Does it need extra CHANGELOG info? (new features, breaking changes, large changes)
  • Are the PR labels correct?
  • Does the code do what the ticket and PR says?
    • Does it change concurrent code, unsafe code, or consensus rules?
  • How do you know it works? Does it have tests?

This commit fixes a bug due to which the function `sapling_subtrees`
used to always include all subtrees from the non-finalized state without
respecting the given limit.
This commit fixes a bug due to which the function `orchard_subtrees`
used to always include all subtrees from the non-finalized state without
respecting the given limit.
Set the visibility of `DiskWriteBatch` to `pub(super)`.
This change is unrelated to the PR.
This change is unrelated to the PR.
@upbqdn upbqdn added C-bug Category: This is a bug A-consensus Area: Consensus rule updates P-Medium ⚡ I-integration-fail Continuous integration fails, including build and test failures I-invalid-data Zebra relies on invalid or untrusted data, or sends invalid data A-state Area: State / database changes labels Oct 12, 2023
@upbqdn upbqdn requested a review from teor2345 October 12, 2023 13:08
@upbqdn upbqdn self-assigned this Oct 12, 2023
@upbqdn upbqdn requested review from a team as code owners October 12, 2023 13:08
Copy link
Contributor

@arya2 arya2 left a comment

Choose a reason for hiding this comment

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

This looks great, thank you!

@mergify mergify bot merged commit 1dfebd7 into main Oct 12, 2023
125 checks passed
@mergify mergify bot deleted the fix-subtree-combining branch October 12, 2023 20:00
@upbqdn upbqdn mentioned this pull request Oct 13, 2023
38 tasks
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-consensus Area: Consensus rule updates A-state Area: State / database changes C-bug Category: This is a bug I-integration-fail Continuous integration fails, including build and test failures I-invalid-data Zebra relies on invalid or untrusted data, or sends invalid data
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: z_getsubtreesbyindex can return 2 subtrees when 1 was requested
3 participants