-
Notifications
You must be signed in to change notification settings - Fork 581
refactor: dropping unnecessary indexes from db #19451
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
refactor: dropping unnecessary indexes from db #19451
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
f4ea108 to
e7a50d3
Compare
eba9c04 to
e5f9c22
Compare
yarn-project/pxe/src/storage/private_event_store/private_event_store.test.ts
Show resolved
Hide resolved
yarn-project/pxe/src/contract_function_simulator/oracle/note_packing_utils.ts
Show resolved
Hide resolved
e5f9c22 to
44d8dd8
Compare
2ed482d to
b1e4cc8
Compare
As Martin mentioned [here](#19327 (comment)) makes sense to have the reorg handling be atomic. In this PR I tackle that. Note that this PR doesn't need to be in stack with #19443 but #19451 depends on both so putting this one into stack was the only way to unblock myself working on #19451.
As Martin mentioned [here](#19327 (comment)) makes sense to have the reorg handling be atomic. In this PR I tackle that. Note that this PR doesn't need to be in stack with #19443 but #19451 depends on both so putting this one into stack was the only way to unblock myself working on #19451.
As Martin mentioned [here](#19327 (comment)) makes sense to have the reorg handling be atomic. In this PR I tackle that. Note that this PR doesn't need to be in stack with #19443 but #19451 depends on both so putting this one into stack was the only way to unblock myself working on #19451.
b1e4cc8 to
8aca6d0
Compare
44d8dd8 to
b7c8acf
Compare
acedb00 to
2b4115d
Compare
Flakey Tests🤖 says: This CI run detected 3 tests that failed, but were tolerated due to a .test_patterns.yml entry. |
mverzilli
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
| await this.#notes.set(noteIndex, dao.toBuffer()); | ||
| await this.#notesToScope.set(noteIndex, scope.toString()); | ||
| await this.#nullifierToNoteId.set(dao.siloedNullifier.toString(), noteIndex); | ||
| const noteId = dao.siloedNullifier.toString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes so much more sense this way. I would suggest renaming noteId to noteNullifier or even just nullifier: I'm currently editing this same file and I keep coming back to "what was noteId again?" So it seems there's no reason to have that "naming indirection"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In #rewindNullifiersAfterBlock we have noteIdsToReinsert variable which would not work well with the noteNullifier naming so I think it's better to keep it as is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then I think a little comment above the corresponding async maps clarifying semantics would be helpful so people don't need to read the whole file to know "I see, noteId is just the nullifier"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added it in b169e49
Anyway if you would feel like changing that later on feel free to do so. If you come up with some reasonable name for noteIdsToReinsert then I think it's a good change.
aee5dd0 to
6f4fe87
Compare
| await this.#notes.set(noteIndex, dao.toBuffer()); | ||
| await this.#notesToScope.set(noteIndex, scope.toString()); | ||
| await this.#nullifierToNoteId.set(dao.siloedNullifier.toString(), noteIndex); | ||
| const noteId = dao.siloedNullifier.toString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then I think a little comment above the corresponding async maps clarifying semantics would be helpful so people don't need to read the whole file to know "I see, noteId is just the nullifier"
b169e49 to
9859d00
Compare
We were fetching note hash index and event commitment index to verify that a given note or event exists. This was redundant because we were already fetching tx effect and verifying the corresponding commitment is present in the effect. For this reason in this PR I drop the indexes. (Note that for notes we still need to fetch nullifier index to verify whether the note has already been nullified or not) This change forces me to rework how events get ordered (we want them to be returned in the order in which they were emitted). Before the events were ordered by this global event commitment index. With this PR they get ordered by `block_number-tx_index_in_block-commitment_index_in_tx`. We can do this cheaply because we already had all this info returned from node from the `getTxEffect` endpoint. Fixes https://linear.app/aztec-labs/issue/F-218/remove-note-and-nullif-indexes-from-note-and-event-storage Co-authored-by: Jan Beneš <janbenes1234@gmail.com>
9859d00 to
5269c9f
Compare

We were fetching note hash index and event commitment index to verify that a given note or event exists. This was redundant because we were already fetching tx effect and verifying the corresponding commitment is present in the effect.
For this reason in this PR I drop the indexes. (Note that for notes we still need to fetch nullifier index to verify whether the note has already been nullified or not)
This change forces me to rework how events get ordered (we want them to be returned in the order in which they were emitted). Before the events were ordered by this global event commitment index. With this PR they get ordered by
block_number-tx_index_in_block-commitment_index_in_tx. We can do this cheaply because we already had all this info returned from node from thegetTxEffectendpoint.Fixes https://linear.app/aztec-labs/issue/F-218/remove-note-and-nullif-indexes-from-note-and-event-storage