Skip to content

Conversation

@benesjan
Copy link
Contributor

@benesjan benesjan commented Jan 9, 2026

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

Copy link
Contributor Author

benesjan commented Jan 9, 2026

@benesjan benesjan force-pushed the 01-09-refactor_dropping_unnecessary_indexes_from_db branch from f4ea108 to e7a50d3 Compare January 9, 2026 03:27
@benesjan benesjan force-pushed the 01-06-refactor_atomic_reorg_handling branch from eba9c04 to e5f9c22 Compare January 9, 2026 03:27
@benesjan benesjan added the ci-no-fail-fast Sets NO_FAIL_FAST in the CI so the run is not aborted on the first failure label Jan 9, 2026
@benesjan benesjan marked this pull request as ready for review January 9, 2026 05:19
@benesjan benesjan marked this pull request as draft January 9, 2026 05:50
@benesjan benesjan force-pushed the 01-06-refactor_atomic_reorg_handling branch from e5f9c22 to 44d8dd8 Compare January 12, 2026 15:22
@benesjan benesjan force-pushed the 01-09-refactor_dropping_unnecessary_indexes_from_db branch from 2ed482d to b1e4cc8 Compare January 12, 2026 15:22
@benesjan benesjan changed the base branch from 01-06-refactor_atomic_reorg_handling to graphite-base/19451 January 12, 2026 15:40
AztecBot pushed a commit that referenced this pull request Jan 12, 2026
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.
AztecBot pushed a commit that referenced this pull request Jan 12, 2026
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.
github-merge-queue bot pushed a commit that referenced this pull request Jan 12, 2026
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.
@benesjan benesjan force-pushed the 01-09-refactor_dropping_unnecessary_indexes_from_db branch from b1e4cc8 to 8aca6d0 Compare January 12, 2026 20:53
@benesjan benesjan force-pushed the graphite-base/19451 branch from 44d8dd8 to b7c8acf Compare January 12, 2026 20:53
@benesjan benesjan changed the base branch from graphite-base/19451 to next January 12, 2026 20:53
@benesjan benesjan force-pushed the 01-09-refactor_dropping_unnecessary_indexes_from_db branch from acedb00 to 2b4115d Compare January 12, 2026 21:29
@benesjan benesjan marked this pull request as ready for review January 12, 2026 21:57
@AztecBot
Copy link
Collaborator

AztecBot commented Jan 12, 2026

Flakey Tests

🤖 says: This CI run detected 3 tests that failed, but were tolerated due to a .test_patterns.yml entry.

\033FLAKED\033 (8;;http://ci.aztec-labs.com/11226004f376fe16�11226004f376fe168;;�):  yarn-project/end-to-end/scripts/run_test.sh simple src/e2e_p2p/multiple_validators_sentinel.parallel.test.ts "collects attestations for validators in proposer node when block is not published" (115s) (code: 1) group:e2e-p2p-epoch-flakes (\033Jan Beneš\033: refactor: dropping unnecessary indexes from db (#19451))
\033FLAKED\033 (8;;http://ci.aztec-labs.com/675aba67f5f557a2�675aba67f5f557a28;;�): yarn-project/end-to-end/scripts/run_test.sh web3signer src/composed/web3signer/e2e_multi_validator_node_key_store.test.ts (39s) (code: 1) (\033Jan Beneš\033: refactor: dropping unnecessary indexes from db (#19451))
\033FLAKED\033 (8;;http://ci.aztec-labs.com/d46cd2faf32d5fea�d46cd2faf32d5fea8;;�):  yarn-project/end-to-end/scripts/run_test.sh simple src/e2e_p2p/gossip_network.test.ts (428s) (code: 1) group:e2e-p2p-epoch-flakes (\033Jan Beneš\033: refactor: dropping unnecessary indexes from db (#19451))

@benesjan benesjan requested a review from mverzilli January 12, 2026 22:56
Copy link
Contributor

@mverzilli mverzilli left a 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();
Copy link
Contributor

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"

Copy link
Contributor Author

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.

Copy link
Contributor

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"

Copy link
Contributor Author

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.

@benesjan benesjan marked this pull request as draft January 13, 2026 14:41
@benesjan benesjan force-pushed the 01-09-refactor_dropping_unnecessary_indexes_from_db branch 3 times, most recently from aee5dd0 to 6f4fe87 Compare January 13, 2026 15:41
@benesjan benesjan marked this pull request as ready for review January 13, 2026 15:41
@benesjan benesjan enabled auto-merge January 13, 2026 15:52
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();
Copy link
Contributor

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"

@benesjan benesjan disabled auto-merge January 13, 2026 15:57
@benesjan benesjan force-pushed the 01-09-refactor_dropping_unnecessary_indexes_from_db branch from b169e49 to 9859d00 Compare January 13, 2026 17:44
@benesjan benesjan enabled auto-merge January 13, 2026 17:55
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>
@AztecBot AztecBot force-pushed the 01-09-refactor_dropping_unnecessary_indexes_from_db branch from 9859d00 to 5269c9f Compare January 13, 2026 18:06
@benesjan benesjan added this pull request to the merge queue Jan 13, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 13, 2026
@benesjan benesjan added this pull request to the merge queue Jan 13, 2026
Merged via the queue into next with commit 1dd7a90 Jan 13, 2026
19 checks passed
@benesjan benesjan deleted the 01-09-refactor_dropping_unnecessary_indexes_from_db branch January 13, 2026 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-no-fail-fast Sets NO_FAIL_FAST in the CI so the run is not aborted on the first failure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants