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

Convert public data tree to an indexed merkle tree #501

Closed
iAmMichaelConnor opened this issue May 8, 2023 · 0 comments · Fixed by #3566
Closed

Convert public data tree to an indexed merkle tree #501

iAmMichaelConnor opened this issue May 8, 2023 · 0 comments · Fixed by #3566
Labels
T-optimisation Type: Optimisation. Making something faster / cheaper / smaller

Comments

@iAmMichaelConnor
Copy link
Contributor

iAmMichaelConnor commented May 8, 2023

Zac made a good point. We can copy the optimisation we made to the nullifier tree (converting it from a sparse tree to an indexed tree) with the public data tree.

Note a difference:

The nullifier tree has leaves of the form:

value,
next_index, // points to the index of the leaf which contains the next-highest value
next_value, // the value of the leaf at leaf_index = next_index

The public data tree's leaf will also need to contain a 'key' field. In its sparse version, the key is the leaf_index, but when we migrate to an indexed tree, the leaf_index loses such a meaning, so the key needs to become part of the leaf's preimage. Note, we don't include a key in a nullifier tree leaf's preimage, because in the sparse version of the nullifier tree, the key and the value were always equal!

key,
value,
next_index,
next_value,

Note: this will be fiddly to do, and since it's only an optimisation (which only really 'bites' when we're generating actual proofs), I'd be in favour of deferring this task until after we've built out other features for the local developer testnet.

@iAmMichaelConnor iAmMichaelConnor added the T-optimisation Type: Optimisation. Making something faster / cheaper / smaller label May 8, 2023
@github-project-automation github-project-automation bot moved this to Todo in A3 May 8, 2023
ludamad pushed a commit that referenced this issue Jul 14, 2023
Gets rid of the composers class that wrapped a circuit constructor and a composer helper. This entailed various improvements such as a refactor of the stdlib verifier tests. Cleanup such a renaming of classes and moving of files will come in another PR. Corresponding PR in the core circuits library is #895.
sirasistant added a commit that referenced this issue Dec 14, 2023
Resolves #501 

This PR changes the Public Data tree to an indexed tree of height 40.
This optimizes insertions at the base rollup, reducing hashing and
allowing batch insertion. In order to do this:
 - Now blocks use a snapshot for the public data tree, not just a root
- Now indexed leaves have an updateTo method that allows updates.
Nullifiers disallow updates.
- The standard indexed tree realizes when a low leaf is an exact match
and updates the low leaf instead.
- The base rollup does indexed tree insertions for the public data tree,
applying the update logic.
- When fetching a slot from the public data tree, we get the low leaf
for the given slot. If the low leaf is not an exact match, the value
hasn't been inserted and the stored value is zero. If it's an exact
match, the latest value is contained in the leaf.
@github-project-automation github-project-automation bot moved this from Todo to Done in A3 Dec 14, 2023
michaelelliot pushed a commit to Swoir/noir_rs that referenced this issue Feb 28, 2024
Resolves AztecProtocol#501 

This PR changes the Public Data tree to an indexed tree of height 40.
This optimizes insertions at the base rollup, reducing hashing and
allowing batch insertion. In order to do this:
 - Now blocks use a snapshot for the public data tree, not just a root
- Now indexed leaves have an updateTo method that allows updates.
Nullifiers disallow updates.
- The standard indexed tree realizes when a low leaf is an exact match
and updates the low leaf instead.
- The base rollup does indexed tree insertions for the public data tree,
applying the update logic.
- When fetching a slot from the public data tree, we get the low leaf
for the given slot. If the low leaf is not an exact match, the value
hasn't been inserted and the stored value is zero. If it's an exact
match, the latest value is contained in the leaf.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-optimisation Type: Optimisation. Making something faster / cheaper / smaller
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant