chore: Faster getLeafOrLowLeafInfo in AVM ephemeral trees #10943
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The implementation of
_getLeafOrLowLeafInfo
would search for the low leaf info in both the ephemeral indexed updates and on the actual db. If it didn't get an exact hit for the leaf, it would start from the hit on the indexed updates, and then linearly walk through the underlying nullifier tree until it got to the low leaf.This PR changes it so queries low leaf from both indexed and external, and picks the closest one.
I tested this using the
builds blocks with multiple public fns after multiple nullifier insertions
e2e (flagged as skipped) which first inserts 128 nullifiers and then runs 128 public functions that write to storage. The number of total calls toGET_LEAF_PREIMAGE
in world-state went from 20403 to 915.