@aztec/pxe 0.0.1-commit.e61ad554 → 0.0.1-commit.ee80a48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/block_synchronizer/block_synchronizer.d.ts +3 -3
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +5 -5
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +2 -4
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +7 -9
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +8 -8
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.d.ts +3 -3
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +15 -15
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +2 -3
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +5 -5
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +20 -16
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +23 -27
- package/dest/contract_sync/index.d.ts +4 -3
- package/dest/contract_sync/index.d.ts.map +1 -1
- package/dest/contract_sync/index.js +11 -4
- package/dest/debug/pxe_debug_utils.d.ts +16 -6
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
- package/dest/debug/pxe_debug_utils.js +17 -8
- package/dest/entrypoints/client/bundle/utils.d.ts +1 -1
- package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/utils.js +12 -6
- package/dest/entrypoints/client/lazy/utils.d.ts +2 -2
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +13 -7
- package/dest/entrypoints/pxe_creation_options.d.ts +3 -2
- package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.d.ts +1 -1
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +19 -8
- package/dest/events/event_service.d.ts +4 -5
- package/dest/events/event_service.d.ts.map +1 -1
- package/dest/events/event_service.js +5 -6
- package/dest/job_coordinator/job_coordinator.d.ts +3 -2
- package/dest/job_coordinator/job_coordinator.d.ts.map +1 -1
- package/dest/job_coordinator/job_coordinator.js +3 -2
- package/dest/logs/log_service.d.ts +6 -5
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +10 -15
- package/dest/notes/note_service.d.ts +4 -5
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +6 -7
- package/dest/oracle_version.d.ts +3 -3
- package/dest/oracle_version.d.ts.map +1 -1
- package/dest/oracle_version.js +2 -2
- package/dest/private_kernel/private_kernel_execution_prover.d.ts +3 -2
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.js +2 -2
- package/dest/private_kernel/private_kernel_oracle.d.ts +3 -3
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/pxe.d.ts +1 -1
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +11 -9
- package/dest/storage/address_store/address_store.d.ts +1 -1
- package/dest/storage/address_store/address_store.d.ts.map +1 -1
- package/dest/storage/address_store/address_store.js +12 -11
- package/dest/storage/anchor_block_store/anchor_block_store.d.ts +9 -1
- package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -1
- package/dest/storage/anchor_block_store/anchor_block_store.js +8 -1
- package/dest/storage/capsule_store/capsule_store.js +6 -8
- package/dest/storage/contract_store/contract_store.d.ts +1 -1
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
- package/dest/storage/contract_store/contract_store.js +22 -13
- package/dest/storage/metadata.d.ts +1 -1
- package/dest/storage/metadata.js +1 -1
- package/dest/storage/note_store/note_store.d.ts +11 -1
- package/dest/storage/note_store/note_store.d.ts.map +1 -1
- package/dest/storage/note_store/note_store.js +143 -105
- package/dest/storage/private_event_store/private_event_store.d.ts +1 -1
- package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
- package/dest/storage/private_event_store/private_event_store.js +84 -61
- package/dest/storage/private_event_store/stored_private_event.d.ts +4 -4
- package/dest/storage/private_event_store/stored_private_event.d.ts.map +1 -1
- package/dest/storage/private_event_store/stored_private_event.js +2 -2
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts +1 -1
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/recipient_tagging_store.js +31 -19
- package/dest/storage/tagging_store/sender_address_book_store.d.ts +1 -1
- package/dest/storage/tagging_store/sender_address_book_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_address_book_store.js +20 -14
- package/dest/storage/tagging_store/sender_tagging_store.d.ts +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.js +183 -113
- package/dest/tagging/get_all_logs_by_tags.d.ts +4 -4
- package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -1
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +3 -3
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -1
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +3 -3
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -1
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +3 -3
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +3 -3
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
- package/package.json +16 -16
- package/src/block_synchronizer/block_synchronizer.ts +17 -19
- package/src/contract_function_simulator/contract_function_simulator.ts +6 -6
- package/src/contract_function_simulator/oracle/interfaces.ts +10 -10
- package/src/contract_function_simulator/oracle/oracle.ts +27 -17
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +3 -5
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +32 -35
- package/src/contract_sync/index.ts +23 -2
- package/src/debug/pxe_debug_utils.ts +23 -9
- package/src/entrypoints/client/bundle/utils.ts +7 -14
- package/src/entrypoints/client/lazy/utils.ts +8 -14
- package/src/entrypoints/pxe_creation_options.ts +2 -1
- package/src/entrypoints/server/utils.ts +15 -19
- package/src/events/event_service.ts +4 -6
- package/src/job_coordinator/job_coordinator.ts +4 -3
- package/src/logs/log_service.ts +14 -14
- package/src/notes/note_service.ts +5 -7
- package/src/oracle_version.ts +2 -2
- package/src/private_kernel/private_kernel_execution_prover.ts +6 -3
- package/src/private_kernel/private_kernel_oracle.ts +2 -2
- package/src/pxe.ts +21 -7
- package/src/storage/address_store/address_store.ts +15 -15
- package/src/storage/anchor_block_store/anchor_block_store.ts +8 -0
- package/src/storage/capsule_store/capsule_store.ts +8 -8
- package/src/storage/contract_store/contract_store.ts +22 -11
- package/src/storage/metadata.ts +1 -1
- package/src/storage/note_store/note_store.ts +159 -129
- package/src/storage/private_event_store/private_event_store.ts +102 -81
- package/src/storage/private_event_store/stored_private_event.ts +3 -3
- package/src/storage/tagging_store/recipient_tagging_store.ts +31 -21
- package/src/storage/tagging_store/sender_address_book_store.ts +20 -14
- package/src/storage/tagging_store/sender_tagging_store.ts +210 -126
- package/src/tagging/get_all_logs_by_tags.ts +3 -3
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +2 -2
- package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +2 -2
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +2 -2
- package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +3 -3
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { toArray } from '@aztec/foundation/iterable';
|
|
2
1
|
import { Semaphore } from '@aztec/foundation/queue';
|
|
3
2
|
import { NoteStatus } from '@aztec/stdlib/note';
|
|
4
3
|
import { StoredNote } from './stored_note.js';
|
|
@@ -49,26 +48,18 @@ import { StoredNote } from './stored_note.js';
|
|
|
49
48
|
* @param scope - The scope (user/account) under which to store the notes
|
|
50
49
|
* @param jobId - The job context for staged writes
|
|
51
50
|
*/ addNotes(notes, scope, jobId) {
|
|
52
|
-
return this.#withJobLock(jobId, ()=>Promise.all(notes.map((
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
noteForJob.addScope(scope.toString());
|
|
58
|
-
this.#writeNote(noteForJob, jobId);
|
|
51
|
+
return this.#withJobLock(jobId, ()=>this.#store.transactionAsync(()=>Promise.all(notes.map(async (note)=>{
|
|
52
|
+
const noteForJob = await this.#readNote(note.siloedNullifier.toString(), jobId) ?? new StoredNote(note, new Set());
|
|
53
|
+
noteForJob.addScope(scope.toString());
|
|
54
|
+
this.#writeNote(noteForJob, jobId);
|
|
55
|
+
}))));
|
|
59
56
|
}
|
|
60
57
|
async #readNote(nullifier, jobId) {
|
|
61
|
-
//
|
|
62
|
-
|
|
63
|
-
if (noteForJob) {
|
|
64
|
-
return noteForJob;
|
|
65
|
-
}
|
|
66
|
-
// Then check persistent storage
|
|
58
|
+
// Always issue DB read to keep IndexedDB transaction alive (they auto-commit when a new micro-task starts and there
|
|
59
|
+
// are no pending read requests). The staged value still takes precedence if it exists.
|
|
67
60
|
const noteBuffer = await this.#notes.getAsync(nullifier);
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
return undefined;
|
|
61
|
+
const noteForJob = this.#getNotesForJob(jobId).get(nullifier);
|
|
62
|
+
return noteForJob ?? (noteBuffer ? StoredNote.fromBuffer(noteBuffer) : undefined);
|
|
72
63
|
}
|
|
73
64
|
#writeNote(note, jobId) {
|
|
74
65
|
this.#getNotesForJob(jobId).set(note.noteDao.siloedNullifier.toString(), note);
|
|
@@ -84,48 +75,84 @@ import { StoredNote } from './stored_note.js';
|
|
|
84
75
|
* @returns Filtered and deduplicated notes (a note might be present in multiple scopes - we ensure it is only
|
|
85
76
|
* returned once if this is the case)
|
|
86
77
|
* @throws If filtering by an empty scopes array. Scopes have to be set to undefined or to a non-empty array.
|
|
87
|
-
*/
|
|
78
|
+
*/ getNotes(filter, jobId) {
|
|
88
79
|
if (filter.scopes !== undefined && filter.scopes.length === 0) {
|
|
89
|
-
|
|
80
|
+
return Promise.reject(new Error('Trying to get notes with an empty scopes array'));
|
|
90
81
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
//
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
//
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
82
|
+
return this.#store.transactionAsync(async ()=>{
|
|
83
|
+
const targetStatus = filter.status ?? NoteStatus.ACTIVE;
|
|
84
|
+
// The code below might read a bit unnatural, the reason is that we need to be careful in how we use `await` inside
|
|
85
|
+
// `transactionAsync`, otherwise browsers might choose to auto-commit the IndexedDB transaction forcing us to
|
|
86
|
+
// explicitly handle that condition. The rule we need to honor is: do not await unless you generate a database
|
|
87
|
+
// read or write or you're done using the DB for the remainder of the transaction. The following sequence is
|
|
88
|
+
// unsafe in IndexedDB:
|
|
89
|
+
//
|
|
90
|
+
// 1. start transactionAsync()
|
|
91
|
+
// 2. await readDb() <-- OK, transaction alive because we issued DB ops
|
|
92
|
+
// 3. run a bunch of computations (no await involved) <-- OK, tx alive because we are in the same microtask
|
|
93
|
+
// 4. await doSthNotInDb() <-- no DB ops issued in this task, browser's free to decide to commit the tx
|
|
94
|
+
// 5. await readDb() <-- BOOM, TransactionInactiveError
|
|
95
|
+
//
|
|
96
|
+
// Note that the real issue is in step number 5: we try to continue using a transaction that the browser might
|
|
97
|
+
// have already committed.
|
|
98
|
+
//
|
|
99
|
+
// We need to read candidate notes which are either indexed by contract address in the DB (in
|
|
100
|
+
// #nullifiersByContractAddress), or lie in memory for the not yet committed `jobId`.
|
|
101
|
+
// So we collect promises based on both sources without awaiting for them.
|
|
102
|
+
const noteReadPromises = new Map();
|
|
103
|
+
// Awaiting the getValuesAsync iterator is fine because it's reading from the DB
|
|
104
|
+
for await (const nullifier of this.#nullifiersByContractAddress.getValuesAsync(filter.contractAddress.toString())){
|
|
105
|
+
// Each #readNote will perform a DB read
|
|
106
|
+
noteReadPromises.set(nullifier, this.#readNote(nullifier, jobId));
|
|
115
107
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
108
|
+
// Add staged nullifiers from job, no awaits involved, so we are fine
|
|
109
|
+
for (const storedNote of this.#getNotesForJob(jobId).values()){
|
|
110
|
+
if (storedNote.noteDao.contractAddress.equals(filter.contractAddress)) {
|
|
111
|
+
const nullifier = storedNote.noteDao.siloedNullifier.toString();
|
|
112
|
+
if (!noteReadPromises.has(nullifier)) {
|
|
113
|
+
noteReadPromises.set(nullifier, Promise.resolve(storedNote));
|
|
114
|
+
}
|
|
115
|
+
}
|
|
124
116
|
}
|
|
125
|
-
|
|
126
|
-
|
|
117
|
+
// By now we have pending DB requests from all the #readNote calls. Await them all together.
|
|
118
|
+
const notes = await Promise.all(noteReadPromises.values());
|
|
119
|
+
// The rest of the function is await-free, and just deals with filtering and sorting our findings.
|
|
120
|
+
const foundNotes = new Map();
|
|
121
|
+
for (const note of notes){
|
|
122
|
+
// Defensive: hitting this case means we're mishandling contract indices or in-memory job data
|
|
123
|
+
if (!note) {
|
|
124
|
+
throw new Error('PXE note database is corrupted.');
|
|
125
|
+
}
|
|
126
|
+
// Apply filters
|
|
127
|
+
if (targetStatus === NoteStatus.ACTIVE && note.isNullified()) {
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
if (filter.owner && !note.noteDao.owner.equals(filter.owner)) {
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
if (filter.storageSlot && !note.noteDao.storageSlot.equals(filter.storageSlot)) {
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
if (filter.siloedNullifier && !note.noteDao.siloedNullifier.equals(filter.siloedNullifier)) {
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
if (filter.scopes && note.scopes.intersection(new Set(filter.scopes.map((s)=>s.toString()))).size === 0) {
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
foundNotes.set(note.noteDao.siloedNullifier.toString(), note.noteDao);
|
|
127
143
|
}
|
|
128
|
-
|
|
144
|
+
// Sort by block number, then by tx index within block, then by note index within tx
|
|
145
|
+
return [
|
|
146
|
+
...foundNotes.values()
|
|
147
|
+
].sort((a, b)=>{
|
|
148
|
+
if (a.l2BlockNumber !== b.l2BlockNumber) {
|
|
149
|
+
return a.l2BlockNumber - b.l2BlockNumber;
|
|
150
|
+
}
|
|
151
|
+
if (a.txIndexInBlock !== b.txIndexInBlock) {
|
|
152
|
+
return a.txIndexInBlock - b.txIndexInBlock;
|
|
153
|
+
}
|
|
154
|
+
return a.noteIndexInTx - b.noteIndexInTx;
|
|
155
|
+
});
|
|
129
156
|
});
|
|
130
157
|
}
|
|
131
158
|
/**
|
|
@@ -143,10 +170,10 @@ import { StoredNote } from './stored_note.js';
|
|
|
143
170
|
* @returns Array of NoteDao objects that were nullified
|
|
144
171
|
* @throws Error if any nullifier is not found in this notes store
|
|
145
172
|
*/ applyNullifiers(nullifiers, jobId) {
|
|
173
|
+
if (nullifiers.length === 0) {
|
|
174
|
+
return Promise.resolve([]);
|
|
175
|
+
}
|
|
146
176
|
return this.#withJobLock(jobId, ()=>this.#store.transactionAsync(async ()=>{
|
|
147
|
-
if (nullifiers.length === 0) {
|
|
148
|
-
return [];
|
|
149
|
-
}
|
|
150
177
|
const notesToNullify = await Promise.all(nullifiers.map(async (nullifierInBlock)=>{
|
|
151
178
|
const nullifier = nullifierInBlock.data.toString();
|
|
152
179
|
const storedNote = await this.#readNote(nullifier, jobId);
|
|
@@ -154,13 +181,12 @@ import { StoredNote } from './stored_note.js';
|
|
|
154
181
|
throw new Error(`Attempted to mark a note as nullified which does not exist in PXE DB`);
|
|
155
182
|
}
|
|
156
183
|
return {
|
|
157
|
-
storedNote
|
|
184
|
+
storedNote,
|
|
158
185
|
blockNumber: nullifierInBlock.l2BlockNumber
|
|
159
186
|
};
|
|
160
187
|
}));
|
|
161
188
|
const notesNullifiedInThisCall = new Map();
|
|
162
189
|
for (const noteToNullify of notesToNullify){
|
|
163
|
-
// Safe to coerce (!) because we throw if we find any undefined above
|
|
164
190
|
const note = noteToNullify.storedNote;
|
|
165
191
|
// Skip already nullified notes
|
|
166
192
|
if (note.isNullified()) {
|
|
@@ -200,15 +226,22 @@ import { StoredNote } from './stored_note.js';
|
|
|
200
226
|
*
|
|
201
227
|
* @param blockNumber - Notes created after this block number will be deleted
|
|
202
228
|
*/ async #deleteActiveNotesAfterBlock(blockNumber) {
|
|
203
|
-
|
|
204
|
-
|
|
229
|
+
// Collect notes to delete during iteration to keep IndexedDB transaction alive.
|
|
230
|
+
const notesToDelete = [];
|
|
231
|
+
for await (const noteBuffer of this.#notes.valuesAsync()){
|
|
205
232
|
const storedNote = StoredNote.fromBuffer(noteBuffer);
|
|
206
233
|
if (storedNote.noteDao.l2BlockNumber > blockNumber) {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
234
|
+
notesToDelete.push({
|
|
235
|
+
nullifier: storedNote.noteDao.siloedNullifier.toString(),
|
|
236
|
+
contractAddress: storedNote.noteDao.contractAddress.toString()
|
|
237
|
+
});
|
|
210
238
|
}
|
|
211
239
|
}
|
|
240
|
+
// Delete all collected notes. Each delete is a DB operation that keeps the transaction alive.
|
|
241
|
+
for (const { nullifier, contractAddress } of notesToDelete){
|
|
242
|
+
await this.#notes.delete(nullifier);
|
|
243
|
+
await this.#nullifiersByContractAddress.deleteValue(contractAddress, nullifier);
|
|
244
|
+
}
|
|
212
245
|
}
|
|
213
246
|
/**
|
|
214
247
|
* Rewinds nullifications after a given block number.
|
|
@@ -219,47 +252,62 @@ import { StoredNote } from './stored_note.js';
|
|
|
219
252
|
* @param blockNumber - Revert nullifications that occurred after this block
|
|
220
253
|
* @param anchorBlockNumber - Upper bound for the block range to process
|
|
221
254
|
*/ async #rewindNullifiedNotesAfterBlock(blockNumber, anchorBlockNumber) {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
const
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
255
|
+
// First pass: collect all nullifiers for all blocks, starting reads during iteration to keep tx alive.
|
|
256
|
+
const nullifiersByBlock = new Map();
|
|
257
|
+
for(let i = blockNumber + 1; i <= anchorBlockNumber; i++){
|
|
258
|
+
const blockNullifiers = [];
|
|
259
|
+
for await (const nullifier of this.#nullifiersByNullificationBlockNumber.getValuesAsync(i)){
|
|
260
|
+
// Start read immediately during iteration to keep IndexedDB transaction alive
|
|
261
|
+
blockNullifiers.push({
|
|
262
|
+
nullifier,
|
|
263
|
+
noteReadPromise: this.#notes.getAsync(nullifier)
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
if (blockNullifiers.length > 0) {
|
|
267
|
+
nullifiersByBlock.set(i, blockNullifiers);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
// Second pass: await reads and perform writes
|
|
271
|
+
for (const [block, nullifiers] of nullifiersByBlock){
|
|
272
|
+
for (const { nullifier, noteReadPromise } of nullifiers){
|
|
273
|
+
const noteBuffer = await noteReadPromise;
|
|
274
|
+
if (!noteBuffer) {
|
|
275
|
+
throw new Error(`PXE DB integrity error: no note found with nullifier ${nullifier}`);
|
|
229
276
|
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
for (const storedNote of storedNotes){
|
|
234
|
-
const noteNullifier = storedNote.noteDao.siloedNullifier.toString();
|
|
235
|
-
const scopes = storedNote.scopes;
|
|
236
|
-
if (scopes.size === 0) {
|
|
237
|
-
// We should never run into this error because notes always have a scope assigned to them - either on initial
|
|
238
|
-
// insertion via `addNotes` or when removing their nullifiers.
|
|
239
|
-
throw new Error(`No scopes found for nullified note with nullifier ${noteNullifier}`);
|
|
277
|
+
const storedNote = StoredNote.fromBuffer(noteBuffer);
|
|
278
|
+
if (storedNote.scopes.size === 0) {
|
|
279
|
+
throw new Error(`No scopes found for nullified note with nullifier ${nullifier}`);
|
|
240
280
|
}
|
|
241
281
|
storedNote.markAsActive();
|
|
242
282
|
await Promise.all([
|
|
243
|
-
this.#notes.set(
|
|
244
|
-
this.#nullifiersByNullificationBlockNumber.deleteValue(
|
|
283
|
+
this.#notes.set(nullifier, storedNote.toBuffer()),
|
|
284
|
+
this.#nullifiersByNullificationBlockNumber.deleteValue(block, nullifier)
|
|
245
285
|
]);
|
|
246
286
|
}
|
|
247
287
|
}
|
|
248
288
|
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
289
|
+
/**
|
|
290
|
+
* Commits in memory job data to persistent storage.
|
|
291
|
+
*
|
|
292
|
+
* Called by JobCoordinator when a job completes successfully.
|
|
293
|
+
*
|
|
294
|
+
* Note: JobCoordinator wraps all commits in a single transaction, so we don't need our own transactionAsync here
|
|
295
|
+
* (and using one would throw on IndexedDB as it does not support nested txs).
|
|
296
|
+
*
|
|
297
|
+
* @param jobId - The jobId identifying which staged data to commit
|
|
298
|
+
*/ async commit(jobId) {
|
|
299
|
+
for (const [nullifier, storedNote] of this.#getNotesForJob(jobId)){
|
|
300
|
+
await this.#notes.set(nullifier, storedNote.toBuffer());
|
|
301
|
+
await this.#nullifiersByContractAddress.set(storedNote.noteDao.contractAddress.toString(), nullifier);
|
|
302
|
+
if (storedNote.nullifiedAt !== undefined) {
|
|
303
|
+
await this.#nullifiersByNullificationBlockNumber.set(storedNote.nullifiedAt, nullifier);
|
|
257
304
|
}
|
|
258
|
-
|
|
259
|
-
|
|
305
|
+
}
|
|
306
|
+
this.#clearJobData(jobId);
|
|
260
307
|
}
|
|
261
308
|
discardStaged(jobId) {
|
|
262
|
-
|
|
309
|
+
this.#clearJobData(jobId);
|
|
310
|
+
return Promise.resolve();
|
|
263
311
|
}
|
|
264
312
|
#clearJobData(jobId) {
|
|
265
313
|
this.#notesForJob.delete(jobId);
|
|
@@ -290,14 +338,4 @@ import { StoredNote } from './stored_note.js';
|
|
|
290
338
|
}
|
|
291
339
|
return notesForJob;
|
|
292
340
|
}
|
|
293
|
-
async #nullifiersOfContract(contractAddress, jobId) {
|
|
294
|
-
// Collect persisted nullifiers for this contract
|
|
295
|
-
const persistedNullifiers = await toArray(this.#nullifiersByContractAddress.getValuesAsync(contractAddress.toString()));
|
|
296
|
-
// Collect staged nullifiers from the job where the note's contract matches
|
|
297
|
-
const stagedNullifiers = this.#getNotesForJob(jobId).values().filter((storedNote)=>storedNote.noteDao.contractAddress.equals(contractAddress)).map((storedNote)=>storedNote.noteDao.siloedNullifier.toString());
|
|
298
|
-
return new Set([
|
|
299
|
-
...persistedNullifiers,
|
|
300
|
-
...stagedNullifiers
|
|
301
|
-
]);
|
|
302
|
-
}
|
|
303
341
|
}
|
|
@@ -88,4 +88,4 @@ export declare class PrivateEventStore implements StagedStore {
|
|
|
88
88
|
discardStaged(jobId: string): Promise<void>;
|
|
89
89
|
}
|
|
90
90
|
export {};
|
|
91
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
91
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJ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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"private_event_store.d.ts","sourceRoot":"","sources":["../../../src/storage/private_event_store/private_event_store.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"private_event_store.d.ts","sourceRoot":"","sources":["../../../src/storage/private_event_store/private_event_store.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAGpD,OAAO,KAAK,EAAE,iBAAiB,EAAqC,MAAM,iBAAiB,CAAC;AAC5F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAC;AAC5E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAGvD,MAAM,MAAM,uBAAuB,GAAG;IACpC,eAAe,EAAE,YAAY,CAAC;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,KAAK,oBAAoB,GAAG,IAAI,GAAG;IACjC,eAAe,EAAE,YAAY,CAAC;IAC9B,KAAK,EAAE,YAAY,CAAC;IACpB,2CAA2C;IAC3C,cAAc,EAAE,MAAM,CAAC;IACvB,yEAAyE;IACzE,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF;;GAEG;AACH,qBAAa,iBAAkB,YAAW,WAAW;;IACnD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAmB;IAgB7C,MAAM,yCAAuC;IAE7C,YAAY,KAAK,EAAE,iBAAiB,EAQnC;IAED;;;;;;;;;;;OAWG;IACH,oBAAoB,CAClB,aAAa,EAAE,aAAa,EAC5B,UAAU,EAAE,EAAE,EACd,UAAU,EAAE,EAAE,EAAE,EAChB,qBAAqB,EAAE,EAAE,EACzB,QAAQ,EAAE,oBAAoB,EAC9B,KAAK,EAAE,MAAM,iBAyCd;IAED;;;;;;;;;;OAUG;IACI,gBAAgB,CACrB,aAAa,EAAE,aAAa,EAC5B,MAAM,EAAE,uBAAuB,GAC9B,OAAO,CAAC,kBAAkB,EAAE,CAAC,CA+E/B;IAED;;;;;;;;;;;;;;;;OAgBG;IACU,QAAQ,CAAC,WAAW,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAsCpF;IAED;;;;;;;;;OASG;IACG,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAgBzC;IAED;;OAEG;IACH,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAG1C;CA0EF"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
-
import { toArray } from '@aztec/foundation/iterable';
|
|
3
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
3
|
import { Semaphore } from '@aztec/foundation/queue';
|
|
5
4
|
import { StoredPrivateEvent } from './stored_private_event.js';
|
|
@@ -34,27 +33,27 @@ import { StoredPrivateEvent } from './stored_private_event.js';
|
|
|
34
33
|
* txHash - The transaction hash of the event log.
|
|
35
34
|
* blockNumber - The block number in which the event was emitted.
|
|
36
35
|
*/ storePrivateEventLog(eventSelector, randomness, msgContent, siloedEventCommitment, metadata, jobId) {
|
|
37
|
-
return this.#withJobLock(jobId, async ()=>{
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
36
|
+
return this.#withJobLock(jobId, ()=>this.#store.transactionAsync(async ()=>{
|
|
37
|
+
const { contractAddress, scope, txHash, l2BlockNumber, l2BlockHash, txIndexInBlock, eventIndexInTx } = metadata;
|
|
38
|
+
const eventId = siloedEventCommitment.toString();
|
|
39
|
+
this.logger.verbose('storing private event log (job stage)', {
|
|
40
|
+
eventId,
|
|
41
|
+
contractAddress,
|
|
42
|
+
scope,
|
|
43
|
+
msgContent,
|
|
44
|
+
l2BlockNumber
|
|
45
|
+
});
|
|
46
|
+
const existing = await this.#readEvent(eventId, jobId);
|
|
47
|
+
if (existing) {
|
|
48
|
+
// If we already stored this event, we still want to make sure to track it for the given scope
|
|
49
|
+
existing.addScope(scope.toString());
|
|
50
|
+
this.#writeEvent(eventId, existing, jobId);
|
|
51
|
+
} else {
|
|
52
|
+
this.#writeEvent(eventId, new StoredPrivateEvent(randomness, msgContent, l2BlockNumber, l2BlockHash, txHash, txIndexInBlock, eventIndexInTx, contractAddress, eventSelector, new Set([
|
|
53
|
+
scope.toString()
|
|
54
|
+
])), jobId);
|
|
55
|
+
}
|
|
56
|
+
}));
|
|
58
57
|
}
|
|
59
58
|
/**
|
|
60
59
|
* Returns the private events given search parameters.
|
|
@@ -68,12 +67,22 @@ import { StoredPrivateEvent } from './stored_private_event.js';
|
|
|
68
67
|
* included.
|
|
69
68
|
*/ getPrivateEvents(eventSelector, filter) {
|
|
70
69
|
return this.#store.transactionAsync(async ()=>{
|
|
71
|
-
const events = [];
|
|
72
70
|
const key = this.#keyFor(filter.contractAddress, eventSelector);
|
|
73
71
|
const targetScopes = new Set(filter.scopes.map((s)=>s.toString()));
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
72
|
+
// Map from eventId to the promise that reads the event buffer.
|
|
73
|
+
// We start reads during iteration to keep DB requests pending and avoid IndexedDB auto-commit.
|
|
74
|
+
const eventReadPromises = new Map();
|
|
75
|
+
for await (const eventId of this.#eventsByContractAndEventSelector.getValuesAsync(key)){
|
|
76
|
+
eventReadPromises.set(eventId, this.#events.getAsync(eventId));
|
|
77
|
+
}
|
|
78
|
+
const eventIds = [
|
|
79
|
+
...eventReadPromises.keys()
|
|
80
|
+
];
|
|
81
|
+
const eventBuffers = await Promise.all(eventReadPromises.values());
|
|
82
|
+
const events = [];
|
|
83
|
+
for(let i = 0; i < eventIds.length; i++){
|
|
84
|
+
const eventId = eventIds[i];
|
|
85
|
+
const eventBuffer = eventBuffers[i];
|
|
77
86
|
// Defensive, if it happens, there's a problem with how we're handling #eventsByContractAndEventSelector
|
|
78
87
|
if (!eventBuffer) {
|
|
79
88
|
this.logger.verbose(`EventId ${eventId} does not exist in main index but it is referenced from contract event selector index`);
|
|
@@ -135,21 +144,34 @@ import { StoredPrivateEvent } from './stored_private_event.js';
|
|
|
135
144
|
*
|
|
136
145
|
* IMPORTANT: This method must be called within a transaction to ensure atomicity.
|
|
137
146
|
*/ async rollback(blockNumber, synchedBlockNumber) {
|
|
138
|
-
|
|
147
|
+
// First pass: collect all event IDs for all blocks, starting reads during iteration to keep tx alive.
|
|
148
|
+
const eventsByBlock = new Map();
|
|
139
149
|
for(let block = blockNumber + 1; block <= synchedBlockNumber; block++){
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
150
|
+
const blockEvents = [];
|
|
151
|
+
for await (const eventId of this.#eventsByBlockNumber.getValuesAsync(block)){
|
|
152
|
+
// Start read immediately during iteration to keep IndexedDB transaction alive
|
|
153
|
+
blockEvents.push({
|
|
154
|
+
eventId,
|
|
155
|
+
eventReadPromise: this.#events.getAsync(eventId)
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
if (blockEvents.length > 0) {
|
|
159
|
+
eventsByBlock.set(block, blockEvents);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
// Second pass: await reads and perform deletes
|
|
163
|
+
let removedCount = 0;
|
|
164
|
+
for (const [block, events] of eventsByBlock){
|
|
165
|
+
await this.#eventsByBlockNumber.delete(block);
|
|
166
|
+
for (const { eventId, eventReadPromise } of events){
|
|
167
|
+
const buffer = await eventReadPromise;
|
|
168
|
+
if (!buffer) {
|
|
169
|
+
throw new Error(`Event not found for eventId ${eventId}`);
|
|
152
170
|
}
|
|
171
|
+
const entry = StoredPrivateEvent.fromBuffer(buffer);
|
|
172
|
+
await this.#events.delete(eventId);
|
|
173
|
+
await this.#eventsByContractAndEventSelector.deleteValue(this.#keyFor(entry.contractAddress, entry.eventSelector), eventId);
|
|
174
|
+
removedCount++;
|
|
153
175
|
}
|
|
154
176
|
}
|
|
155
177
|
this.logger.verbose(`Rolled back ${removedCount} private events after block ${blockNumber}`);
|
|
@@ -163,39 +185,40 @@ import { StoredPrivateEvent } from './stored_private_event.js';
|
|
|
163
185
|
* (and using one would throw on IndexedDB as it does not support nested txs).
|
|
164
186
|
*
|
|
165
187
|
* @param jobId - The jobId identifying which staged data to commit
|
|
166
|
-
*/ commit(jobId) {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
}
|
|
188
|
+
*/ async commit(jobId) {
|
|
189
|
+
// Note: Don't use #withJobLock here - commit runs within JobCoordinator's transactionAsync,
|
|
190
|
+
// and awaiting the lock would create a microtask boundary with no pending DB request,
|
|
191
|
+
// causing IndexedDB to auto-commit the transaction.
|
|
192
|
+
for (const [eventId, entry] of this.#getEventsForJob(jobId).entries()){
|
|
193
|
+
const lookupKey = this.#keyFor(entry.contractAddress, entry.eventSelector);
|
|
194
|
+
this.logger.verbose('storing private event log', {
|
|
195
|
+
eventId,
|
|
196
|
+
lookupKey
|
|
197
|
+
});
|
|
198
|
+
await Promise.all([
|
|
199
|
+
this.#events.set(eventId, entry.toBuffer()),
|
|
200
|
+
this.#eventsByContractAndEventSelector.set(lookupKey, eventId),
|
|
201
|
+
this.#eventsByBlockNumber.set(entry.l2BlockNumber, eventId)
|
|
202
|
+
]);
|
|
203
|
+
}
|
|
204
|
+
this.#clearJobData(jobId);
|
|
182
205
|
}
|
|
183
206
|
/**
|
|
184
207
|
* Discards in memory job data without persisting it.
|
|
185
208
|
*/ discardStaged(jobId) {
|
|
186
|
-
|
|
209
|
+
this.#clearJobData(jobId);
|
|
210
|
+
return Promise.resolve();
|
|
187
211
|
}
|
|
188
212
|
/**
|
|
189
213
|
* Reads an event from in-memory job data first, falling back to persistent storage if not found.
|
|
190
214
|
*
|
|
191
215
|
* Returns undefined if the event does not exist in the store overall.
|
|
192
216
|
*/ async #readEvent(eventId, jobId) {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
return eventForJob;
|
|
196
|
-
}
|
|
217
|
+
// Always issue DB read to keep IndexedDB transaction alive (they auto-commit when a new micro-task starts and there
|
|
218
|
+
// are no pending read requests). The staged value still takes precedence if it exists.
|
|
197
219
|
const buffer = await this.#events.getAsync(eventId);
|
|
198
|
-
|
|
220
|
+
const eventForJob = this.#getEventsForJob(jobId).get(eventId);
|
|
221
|
+
return eventForJob ?? (buffer ? StoredPrivateEvent.fromBuffer(buffer) : undefined);
|
|
199
222
|
}
|
|
200
223
|
/**
|
|
201
224
|
* Writes an event to in-memory job data.
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
2
|
import { EventSelector } from '@aztec/stdlib/abi';
|
|
3
3
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
-
import {
|
|
4
|
+
import { BlockHash } from '@aztec/stdlib/block';
|
|
5
5
|
import { TxHash } from '@aztec/stdlib/tx';
|
|
6
6
|
/** Serializable private event entry with scope tracking. */
|
|
7
7
|
export declare class StoredPrivateEvent {
|
|
8
8
|
readonly randomness: Fr;
|
|
9
9
|
readonly msgContent: Fr[];
|
|
10
10
|
readonly l2BlockNumber: number;
|
|
11
|
-
readonly l2BlockHash:
|
|
11
|
+
readonly l2BlockHash: BlockHash;
|
|
12
12
|
readonly txHash: TxHash;
|
|
13
13
|
readonly txIndexInBlock: number;
|
|
14
14
|
readonly eventIndexInTx: number;
|
|
15
15
|
readonly contractAddress: AztecAddress;
|
|
16
16
|
readonly eventSelector: EventSelector;
|
|
17
17
|
readonly scopes: Set<string>;
|
|
18
|
-
constructor(randomness: Fr, msgContent: Fr[], l2BlockNumber: number, l2BlockHash:
|
|
18
|
+
constructor(randomness: Fr, msgContent: Fr[], l2BlockNumber: number, l2BlockHash: BlockHash, txHash: TxHash, txIndexInBlock: number, eventIndexInTx: number, contractAddress: AztecAddress, eventSelector: EventSelector, scopes: Set<string>);
|
|
19
19
|
addScope(scope: string): void;
|
|
20
20
|
toBuffer(): Buffer;
|
|
21
21
|
static fromBuffer(buffer: Buffer): StoredPrivateEvent;
|
|
22
22
|
}
|
|
23
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
23
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RvcmVkX3ByaXZhdGVfZXZlbnQuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9zdG9yYWdlL3ByaXZhdGVfZXZlbnRfc3RvcmUvc3RvcmVkX3ByaXZhdGVfZXZlbnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBRXBELE9BQU8sRUFBRSxhQUFhLEVBQUUsTUFBTSxtQkFBbUIsQ0FB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LElBQUksTUFBTSxDQWdCakI7SUFFRCxNQUFNLENBQUMsVUFBVSxDQUFDLE1BQU0sRUFBRSxNQUFNLEdBQUcsa0JBQWtCLENBMkJwRDtDQUNGIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stored_private_event.d.ts","sourceRoot":"","sources":["../../../src/storage/private_event_store/stored_private_event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAEpD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"stored_private_event.d.ts","sourceRoot":"","sources":["../../../src/storage/private_event_store/stored_private_event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAEpD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,4DAA4D;AAC5D,qBAAa,kBAAkB;IAE3B,QAAQ,CAAC,UAAU,EAAE,EAAE;IACvB,QAAQ,CAAC,UAAU,EAAE,EAAE,EAAE;IACzB,QAAQ,CAAC,aAAa,EAAE,MAAM;IAC9B,QAAQ,CAAC,WAAW,EAAE,SAAS;IAC/B,QAAQ,CAAC,MAAM,EAAE,MAAM;IACvB,QAAQ,CAAC,cAAc,EAAE,MAAM;IAC/B,QAAQ,CAAC,cAAc,EAAE,MAAM;IAC/B,QAAQ,CAAC,eAAe,EAAE,YAAY;IACtC,QAAQ,CAAC,aAAa,EAAE,aAAa;IACrC,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC;IAV9B,YACW,UAAU,EAAE,EAAE,EACd,UAAU,EAAE,EAAE,EAAE,EAChB,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,SAAS,EACtB,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,MAAM,EACtB,cAAc,EAAE,MAAM,EACtB,eAAe,EAAE,YAAY,EAC7B,aAAa,EAAE,aAAa,EAC5B,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,EAC1B;IAEJ,QAAQ,CAAC,KAAK,EAAE,MAAM,QAErB;IAED,QAAQ,IAAI,MAAM,CAgBjB;IAED,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,kBAAkB,CA2BpD;CACF"}
|
|
@@ -2,7 +2,7 @@ import { Fr } from '@aztec/foundation/curves/bn254';
|
|
|
2
2
|
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
3
3
|
import { EventSelector } from '@aztec/stdlib/abi';
|
|
4
4
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
-
import {
|
|
5
|
+
import { BlockHash } from '@aztec/stdlib/block';
|
|
6
6
|
import { TxHash } from '@aztec/stdlib/tx';
|
|
7
7
|
/** Serializable private event entry with scope tracking. */ export class StoredPrivateEvent {
|
|
8
8
|
randomness;
|
|
@@ -42,7 +42,7 @@ import { TxHash } from '@aztec/stdlib/tx';
|
|
|
42
42
|
const msgContentLength = reader.readNumber();
|
|
43
43
|
const msgContent = reader.readArray(msgContentLength, Fr);
|
|
44
44
|
const l2BlockNumber = reader.readNumber();
|
|
45
|
-
const l2BlockHash =
|
|
45
|
+
const l2BlockHash = new BlockHash(Fr.fromBuffer(reader));
|
|
46
46
|
const txHash = TxHash.fromBuffer(reader);
|
|
47
47
|
const txIndexInBlock = reader.readNumber();
|
|
48
48
|
const eventIndexInTx = reader.readNumber();
|
|
@@ -25,4 +25,4 @@ export declare class RecipientTaggingStore implements StagedStore {
|
|
|
25
25
|
getHighestFinalizedIndex(secret: DirectionalAppTaggingSecret, jobId: string): Promise<number | undefined>;
|
|
26
26
|
updateHighestFinalizedIndex(secret: DirectionalAppTaggingSecret, index: number, jobId: string): Promise<void>;
|
|
27
27
|
}
|
|
28
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
28
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVjaXBpZW50X3RhZ2dpbmdfc3RvcmUuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9zdG9yYWdlL3RhZ2dpbmdfc3RvcmUvcmVjaXBpZW50X3RhZ2dpbmdfc3RvcmUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsaUJBQWlCLEVBQWlCLE1BQU0saUJBQWlCLENBQUM7QUFDeEUsT0FBTyxLQUFLLEVBQUUsMkJBQTJCLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUV0RSxPQUFPLEtBQUssRUFBRSxXQUFXLEVBQUUsTUFBTSwwQ0FBMEMsQ0FBQztBQUU1RTs7Ozs7OztHQU9HO0FBQ0gscUJBQWEscUJBQXNCLFlBQVcsV0FBVzs7SUFDdkQsU0FBUyxFQUFFLE1BQU0sQ0FBdUI7SUFheEMsWUFBWSxLQUFLLEVBQUUsaUJBQWlCLEVBUW5DO0lBNENEOzs7O09BSUc7SUFDRyxNQUFNLENBQUMsS0FBSyxFQUFFLE1BQU0sR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLENBZ0J6QztJQUVELGFBQWEsQ0FBQyxLQUFLLEVBQUUsTUFBTSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FJMUM7SUFFRCxtQkFBbUIsQ0FBQyxNQUFNLEVBQUUsMkJBQTJCLEVBQUUsS0FBSyxFQUFFLE1BQU0sR0FBRyxPQUFPLENBQUMsTUFBTSxHQUFHLFNBQVMsQ0FBQyxDQUVuRztJQUVELHNCQUFzQixDQUFDL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