refactor(pxe): migrate PrivateEventStore to BaseStagingStore - #110
Conversation
14ce305 to
3e2d9de
Compare
3e2d9de to
21d7d81
Compare
21d7d81 to
b851976
Compare
|
|
||
| // anchorBlockNumber is set during the operation and fixed to whatever it is after a block sync | ||
| const sanitizedFilter = new PrivateEventFilterValidator(anchorBlockNumber!).validate(filter); | ||
| const sanitizedFilter = new PrivateEventFilterValidator(anchorBlockHeader.getBlockNumber()).validate(filter); |
There was a problem hiding this comment.
There's a small behavioral change in that if this validation fails then we discard the sync result, even though everything that happens from this point on is read-only. We could technically commit the changeset after the contract sync runs, but we still need to read from the db (and hence keep the PXE lock). Probably not worth doing anything about now, but it's an interesting pattern.
| [...changeSet.entries()] | ||
| .filter( | ||
| ([eventId, stagedEvent]) => | ||
| !eventReadPromises.has(eventId) && | ||
| this.#keyFor(stagedEvent.contractAddress, stagedEvent.eventSelector) === key, | ||
| ) | ||
| .forEach(([eventId, stagedEvent]) => eventReadPromises.set(eventId, Promise.resolve(stagedEvent))); |
There was a problem hiding this comment.
This reads a bit strange. We have the same code in note store in a plain for loop and I find that more readable. Your call
There was a problem hiding this comment.
I actually asked Claude to do it this way, I didn't like the loop + the conditional inside. Feels more "functional" this way
1e92e5b to
aeaac77
Compare
Summary
PrivateEventStoreontoBaseStagingStore(fix(pxe): per-change-set staging store that rejects dead change sets #47): the per-change-set maps, locks,commitChangeSet/discardChangeSetand the rollback guard now come from the base class, leavingflushChangeSetandapplyRollback.getPrivateEventstakes achangeSetIdand layers staged events over the committed index, andPXE.getPrivateEventsreads inside itsrunSyncedblock rather than after the commit. Same events either way: the sync that produces them stages them under that change set.eventIdsAtBlock, which had no production callers, as fix(pxe): per-change-set staging store that rejects dead change sets #47 did forNoteStore.nullifiersOfNotesAtBlock.StagedWriteCoordinator's registry, soStagedStore.beginChangeSetis now required, resolving its TODO.Stacked on #108.