@aztec/pxe 0.0.1-commit.54489865 → 0.0.1-commit.592b9384
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/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 +3 -5
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +7 -7
- 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 +9 -9
- 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 +4 -4
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +15 -11
- 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 -19
- 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 +2 -1
- package/dest/entrypoints/client/lazy/utils.d.ts +1 -1
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +2 -1
- 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/logs/log_service.d.ts +4 -4
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +7 -10
- 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/pxe.d.ts +1 -1
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +1 -1
- 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 +169 -129
- 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 +126 -101
- 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/package.json +16 -16
- package/src/contract_function_simulator/contract_function_simulator.ts +0 -4
- package/src/contract_function_simulator/oracle/interfaces.ts +8 -8
- package/src/contract_function_simulator/oracle/oracle.ts +21 -11
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +1 -5
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +24 -20
- package/src/entrypoints/client/bundle/utils.ts +3 -1
- package/src/entrypoints/client/lazy/utils.ts +3 -1
- package/src/events/event_service.ts +4 -6
- package/src/logs/log_service.ts +6 -9
- package/src/notes/note_service.ts +5 -7
- package/src/oracle_version.ts +2 -2
- package/src/pxe.ts +0 -1
- 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 +185 -150
- package/src/storage/private_event_store/private_event_store.ts +151 -128
- 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
|
@@ -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.
|
|
@@ -66,55 +65,67 @@ import { StoredPrivateEvent } from './stored_private_event.js';
|
|
|
66
65
|
* scope: - The addresses that decrypted the logs.
|
|
67
66
|
* @returns - The event log contents, augmented with metadata about the transaction and block in which the event was
|
|
68
67
|
* included.
|
|
69
|
-
*/
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
this.logger.verbose(`EventId ${eventId} does not exist in main index but it is referenced from contract event selector index`);
|
|
79
|
-
continue;
|
|
80
|
-
}
|
|
81
|
-
const storedPrivateEvent = StoredPrivateEvent.fromBuffer(eventBuffer);
|
|
82
|
-
// Filter by block range
|
|
83
|
-
if (storedPrivateEvent.l2BlockNumber < filter.fromBlock || storedPrivateEvent.l2BlockNumber >= filter.toBlock) {
|
|
84
|
-
continue;
|
|
68
|
+
*/ getPrivateEvents(eventSelector, filter) {
|
|
69
|
+
return this.#store.transactionAsync(async ()=>{
|
|
70
|
+
const key = this.#keyFor(filter.contractAddress, eventSelector);
|
|
71
|
+
const targetScopes = new Set(filter.scopes.map((s)=>s.toString()));
|
|
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));
|
|
85
77
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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];
|
|
86
|
+
// Defensive, if it happens, there's a problem with how we're handling #eventsByContractAndEventSelector
|
|
87
|
+
if (!eventBuffer) {
|
|
88
|
+
this.logger.verbose(`EventId ${eventId} does not exist in main index but it is referenced from contract event selector index`);
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
const storedPrivateEvent = StoredPrivateEvent.fromBuffer(eventBuffer);
|
|
92
|
+
// Filter by block range
|
|
93
|
+
if (storedPrivateEvent.l2BlockNumber < filter.fromBlock || storedPrivateEvent.l2BlockNumber >= filter.toBlock) {
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
// Filter by scopes
|
|
97
|
+
if (storedPrivateEvent.scopes.intersection(targetScopes).size === 0) {
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
// Filter by txHash
|
|
101
|
+
if (filter.txHash && !storedPrivateEvent.txHash.equals(filter.txHash)) {
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
events.push({
|
|
105
|
+
l2BlockNumber: storedPrivateEvent.l2BlockNumber,
|
|
106
|
+
txIndexInBlock: storedPrivateEvent.txIndexInBlock,
|
|
107
|
+
eventIndexInTx: storedPrivateEvent.eventIndexInTx,
|
|
108
|
+
event: {
|
|
109
|
+
packedEvent: storedPrivateEvent.msgContent,
|
|
110
|
+
l2BlockNumber: BlockNumber(storedPrivateEvent.l2BlockNumber),
|
|
111
|
+
txHash: storedPrivateEvent.txHash,
|
|
112
|
+
l2BlockHash: storedPrivateEvent.l2BlockHash,
|
|
113
|
+
eventSelector
|
|
114
|
+
}
|
|
115
|
+
});
|
|
93
116
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
event: {
|
|
99
|
-
packedEvent: storedPrivateEvent.msgContent,
|
|
100
|
-
l2BlockNumber: BlockNumber(storedPrivateEvent.l2BlockNumber),
|
|
101
|
-
txHash: storedPrivateEvent.txHash,
|
|
102
|
-
l2BlockHash: storedPrivateEvent.l2BlockHash,
|
|
103
|
-
eventSelector
|
|
117
|
+
// Sort by block number, then by tx index within block, then by event index within tx
|
|
118
|
+
events.sort((a, b)=>{
|
|
119
|
+
if (a.l2BlockNumber !== b.l2BlockNumber) {
|
|
120
|
+
return a.l2BlockNumber - b.l2BlockNumber;
|
|
104
121
|
}
|
|
122
|
+
if (a.txIndexInBlock !== b.txIndexInBlock) {
|
|
123
|
+
return a.txIndexInBlock - b.txIndexInBlock;
|
|
124
|
+
}
|
|
125
|
+
return a.eventIndexInTx - b.eventIndexInTx;
|
|
105
126
|
});
|
|
106
|
-
|
|
107
|
-
// Sort by block number, then by tx index within block, then by event index within tx
|
|
108
|
-
events.sort((a, b)=>{
|
|
109
|
-
if (a.l2BlockNumber !== b.l2BlockNumber) {
|
|
110
|
-
return a.l2BlockNumber - b.l2BlockNumber;
|
|
111
|
-
}
|
|
112
|
-
if (a.txIndexInBlock !== b.txIndexInBlock) {
|
|
113
|
-
return a.txIndexInBlock - b.txIndexInBlock;
|
|
114
|
-
}
|
|
115
|
-
return a.eventIndexInTx - b.eventIndexInTx;
|
|
127
|
+
return events.map((ev)=>ev.event);
|
|
116
128
|
});
|
|
117
|
-
return events.map((ev)=>ev.event);
|
|
118
129
|
}
|
|
119
130
|
/**
|
|
120
131
|
* Rolls back private events that were stored after a given `blockNumber` and up to `synchedBlockNumber` (the block
|
|
@@ -133,21 +144,34 @@ import { StoredPrivateEvent } from './stored_private_event.js';
|
|
|
133
144
|
*
|
|
134
145
|
* IMPORTANT: This method must be called within a transaction to ensure atomicity.
|
|
135
146
|
*/ async rollback(blockNumber, synchedBlockNumber) {
|
|
136
|
-
|
|
147
|
+
// First pass: collect all event IDs for all blocks, starting reads during iteration to keep tx alive.
|
|
148
|
+
const eventsByBlock = new Map();
|
|
137
149
|
for(let block = blockNumber + 1; block <= synchedBlockNumber; block++){
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
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}`);
|
|
150
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++;
|
|
151
175
|
}
|
|
152
176
|
}
|
|
153
177
|
this.logger.verbose(`Rolled back ${removedCount} private events after block ${blockNumber}`);
|
|
@@ -161,39 +185,40 @@ import { StoredPrivateEvent } from './stored_private_event.js';
|
|
|
161
185
|
* (and using one would throw on IndexedDB as it does not support nested txs).
|
|
162
186
|
*
|
|
163
187
|
* @param jobId - The jobId identifying which staged data to commit
|
|
164
|
-
*/ commit(jobId) {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}
|
|
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);
|
|
180
205
|
}
|
|
181
206
|
/**
|
|
182
207
|
* Discards in memory job data without persisting it.
|
|
183
208
|
*/ discardStaged(jobId) {
|
|
184
|
-
|
|
209
|
+
this.#clearJobData(jobId);
|
|
210
|
+
return Promise.resolve();
|
|
185
211
|
}
|
|
186
212
|
/**
|
|
187
213
|
* Reads an event from in-memory job data first, falling back to persistent storage if not found.
|
|
188
214
|
*
|
|
189
215
|
* Returns undefined if the event does not exist in the store overall.
|
|
190
216
|
*/ async #readEvent(eventId, jobId) {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
return eventForJob;
|
|
194
|
-
}
|
|
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.
|
|
195
219
|
const buffer = await this.#events.getAsync(eventId);
|
|
196
|
-
|
|
220
|
+
const eventForJob = this.#getEventsForJob(jobId).get(eventId);
|
|
221
|
+
return eventForJob ?? (buffer ? StoredPrivateEvent.fromBuffer(buffer) : undefined);
|
|
197
222
|
}
|
|
198
223
|
/**
|
|
199
224
|
* Writes an event to in-memory job data.
|
|
@@ -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,eyJ2ZXJzaW9uIjozLCJm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LQUFLLEVBQUUsTUFBTSxHQUFHLE9BQU8sQ0FBQyxNQUFNLEdBQUcsU0FBUyxDQUFDLENBRXhHO0lBRUQsMkJBQTJCLENBQUMsTUFBTSxFQUFFLDJCQUEyQixFQUFFLEtBQUssRUFBRSxNQUFNLEVBQUUsS0FBSyxFQUFFLE1BQU0sR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLENBVTVHO0NBQ0YifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recipient_tagging_store.d.ts","sourceRoot":"","sources":["../../../src/storage/tagging_store/recipient_tagging_store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACxE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AAEtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAC;AAE5E;;;;;;;GAOG;AACH,qBAAa,qBAAsB,YAAW,WAAW;;IACvD,SAAS,EAAE,MAAM,CAAuB;IAaxC,YAAY,KAAK,EAAE,iBAAiB,EAQnC;
|
|
1
|
+
{"version":3,"file":"recipient_tagging_store.d.ts","sourceRoot":"","sources":["../../../src/storage/tagging_store/recipient_tagging_store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACxE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AAEtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAC;AAE5E;;;;;;;GAOG;AACH,qBAAa,qBAAsB,YAAW,WAAW;;IACvD,SAAS,EAAE,MAAM,CAAuB;IAaxC,YAAY,KAAK,EAAE,iBAAiB,EAQnC;IA4CD;;;;OAIG;IACG,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAgBzC;IAED,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAI1C;IAED,mBAAmB,CAAC,MAAM,EAAE,2BAA2B,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAEnG;IAED,sBAAsB,CAAC,MAAM,EAAE,2BAA2B,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CASvG;IAED,wBAAwB,CAAC,MAAM,EAAE,2BAA2B,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAExG;IAED,2BAA2B,CAAC,MAAM,EAAE,2BAA2B,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAU5G;CACF"}
|
|
@@ -30,7 +30,11 @@
|
|
|
30
30
|
return highestAgedIndexForJob;
|
|
31
31
|
}
|
|
32
32
|
async #readHighestAgedIndex(jobId, secret) {
|
|
33
|
-
|
|
33
|
+
// Always issue DB read to keep IndexedDB transaction alive (they auto-commit when a new micro-task starts and there
|
|
34
|
+
// are no pending read requests). The staged value still takes precedence if it exists.
|
|
35
|
+
const dbValue = await this.#highestAgedIndex.getAsync(secret);
|
|
36
|
+
const staged = this.#getHighestAgedIndexForJob(jobId).get(secret);
|
|
37
|
+
return staged ?? dbValue;
|
|
34
38
|
}
|
|
35
39
|
#writeHighestAgedIndex(jobId, secret, index) {
|
|
36
40
|
this.#getHighestAgedIndexForJob(jobId).set(secret, index);
|
|
@@ -44,7 +48,11 @@
|
|
|
44
48
|
return jobStagedHighestFinalizedIndex;
|
|
45
49
|
}
|
|
46
50
|
async #readHighestFinalizedIndex(jobId, secret) {
|
|
47
|
-
|
|
51
|
+
// Always issue DB read to keep IndexedDB transaction alive (they auto-commit when a new micro-task starts and there
|
|
52
|
+
// are no pending read requests). The staged value still takes precedence if it exists.
|
|
53
|
+
const dbValue = await this.#highestFinalizedIndex.getAsync(secret);
|
|
54
|
+
const staged = this.#getHighestFinalizedIndexForJob(jobId).get(secret);
|
|
55
|
+
return staged ?? dbValue;
|
|
48
56
|
}
|
|
49
57
|
#writeHighestFinalizedIndex(jobId, secret, index) {
|
|
50
58
|
this.#getHighestFinalizedIndexForJob(jobId).set(secret, index);
|
|
@@ -74,26 +82,30 @@
|
|
|
74
82
|
return Promise.resolve();
|
|
75
83
|
}
|
|
76
84
|
getHighestAgedIndex(secret, jobId) {
|
|
77
|
-
return this.#readHighestAgedIndex(jobId, secret.toString());
|
|
85
|
+
return this.#store.transactionAsync(()=>this.#readHighestAgedIndex(jobId, secret.toString()));
|
|
78
86
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
87
|
+
updateHighestAgedIndex(secret, index, jobId) {
|
|
88
|
+
return this.#store.transactionAsync(async ()=>{
|
|
89
|
+
const currentIndex = await this.#readHighestAgedIndex(jobId, secret.toString());
|
|
90
|
+
if (currentIndex !== undefined && index <= currentIndex) {
|
|
91
|
+
// Log sync should never set a lower highest aged index.
|
|
92
|
+
throw new Error(`New highest aged index (${index}) must be higher than the current one (${currentIndex})`);
|
|
93
|
+
}
|
|
94
|
+
this.#writeHighestAgedIndex(jobId, secret.toString(), index);
|
|
95
|
+
});
|
|
86
96
|
}
|
|
87
97
|
getHighestFinalizedIndex(secret, jobId) {
|
|
88
|
-
return this.#readHighestFinalizedIndex(jobId, secret.toString());
|
|
98
|
+
return this.#store.transactionAsync(()=>this.#readHighestFinalizedIndex(jobId, secret.toString()));
|
|
89
99
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
100
|
+
updateHighestFinalizedIndex(secret, index, jobId) {
|
|
101
|
+
return this.#store.transactionAsync(async ()=>{
|
|
102
|
+
const currentIndex = await this.#readHighestFinalizedIndex(jobId, secret.toString());
|
|
103
|
+
if (currentIndex !== undefined && index < currentIndex) {
|
|
104
|
+
// Log sync should never set a lower highest finalized index but it can happen that it would try to set the same
|
|
105
|
+
// one because we are loading logs from highest aged index + 1 and not from the highest finalized index.
|
|
106
|
+
throw new Error(`New highest finalized index (${index}) must be higher than the current one (${currentIndex})`);
|
|
107
|
+
}
|
|
108
|
+
this.#writeHighestFinalizedIndex(jobId, secret.toString(), index);
|
|
109
|
+
});
|
|
98
110
|
}
|
|
99
111
|
}
|
|
@@ -11,4 +11,4 @@ export declare class SenderAddressBookStore {
|
|
|
11
11
|
getSenders(): Promise<AztecAddress[]>;
|
|
12
12
|
removeSender(address: AztecAddress): Promise<boolean>;
|
|
13
13
|
}
|
|
14
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
14
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VuZGVyX2FkZHJlc3NfYm9va19zdG9yZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3N0b3JhZ2UvdGFnZ2luZ19zdG9yZS9zZW5kZXJfYWRkcmVzc19ib29rX3N0b3JlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sS0FBSyxFQUFFLGlCQUFpQixFQUFpQixNQUFNLGlCQUFpQixDQUFDO0FBQ3hFLE9BQU8sRUFBRSxZQUFZLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUUzRDs7O0dBR0c7QUFDSCxxQkFBYSxzQkFBc0I7O0lBSWpDLFlBQVksS0FBSyxFQUFFLGlCQUFpQixFQUluQztJQUVELFNBQVMsQ0FBQyxPQUFPLEVBQUUsWUFBWSxHQUFHLE9BQU8sQ0FBQyxPQUFPLENBQUMsQ0FVakQ7SUFFRCxVQUFVLElBQUksT0FBTyxDQUFDLFlBQVksRUFBRSxDQUFDLENBSXBDO0lBRUQsWUFBWSxDQUFDLE9BQU8sRUFBRSxZQUFZLEdBQUcsT0FBTyxDQUFDLE9BQU8sQ0FBQyxDQVVwRDtDQUNGIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sender_address_book_store.d.ts","sourceRoot":"","sources":["../../../src/storage/tagging_store/sender_address_book_store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D;;;GAGG;AACH,qBAAa,sBAAsB;;IAIjC,YAAY,KAAK,EAAE,iBAAiB,EAInC;
|
|
1
|
+
{"version":3,"file":"sender_address_book_store.d.ts","sourceRoot":"","sources":["../../../src/storage/tagging_store/sender_address_book_store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D;;;GAGG;AACH,qBAAa,sBAAsB;;IAIjC,YAAY,KAAK,EAAE,iBAAiB,EAInC;IAED,SAAS,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,CAUjD;IAED,UAAU,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC,CAIpC;IAED,YAAY,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,CAUpD;CACF"}
|
|
@@ -10,21 +10,27 @@ import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
|
10
10
|
this.#store = store;
|
|
11
11
|
this.#addressBook = this.#store.openMap('address_book');
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
addSender(address) {
|
|
14
|
+
return this.#store.transactionAsync(async ()=>{
|
|
15
|
+
if (await this.#addressBook.hasAsync(address.toString())) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
await this.#addressBook.set(address.toString(), true);
|
|
19
|
+
return true;
|
|
20
|
+
});
|
|
19
21
|
}
|
|
20
|
-
|
|
21
|
-
return
|
|
22
|
+
getSenders() {
|
|
23
|
+
return this.#store.transactionAsync(async ()=>{
|
|
24
|
+
return (await toArray(this.#addressBook.keysAsync())).map(AztecAddress.fromString);
|
|
25
|
+
});
|
|
22
26
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
removeSender(address) {
|
|
28
|
+
return this.#store.transactionAsync(async ()=>{
|
|
29
|
+
if (!await this.#addressBook.hasAsync(address.toString())) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
await this.#addressBook.delete(address.toString());
|
|
33
|
+
return true;
|
|
34
|
+
});
|
|
29
35
|
}
|
|
30
36
|
}
|
|
@@ -74,4 +74,4 @@ export declare class SenderTaggingStore implements StagedStore {
|
|
|
74
74
|
*/
|
|
75
75
|
finalizePendingIndexes(txHashes: TxHash[], jobId: string): Promise<void>;
|
|
76
76
|
}
|
|
77
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
77
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VuZGVyX3RhZ2dpbmdfc3RvcmUuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9zdG9yYWdlL3RhZ2dpbmdfc3RvcmUvc2VuZGVyX3RhZ2dpbmdfc3RvcmUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsaUJBQWlCLEVBQWlCLE1BQU0saUJBQWlCLENBQUM7QUFDeEUsT0FBTyxLQUFLLEVBQUUsMkJBQTJCLEVBQUUsTUFBTSxFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFDOUUsT0FBTyxFQUFFLE1BQU0sRUFBRSxNQUF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PQUFPLENBQUMsTUFBTSxHQUFHLFNBQVMsQ0FBQyxDQWtCaEc7SUFFRDs7T0FFRztJQUNILGtCQUFrQixDQUFDLFFBQVEsRUFBRSxNQUFNLEVBQUUsRUFBRSxLQUFLLEVBQUUsTUFBTSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0EyQ25FO0lBRUQ7OztPQUdHO0lBQ0gsc0JBQXNCLENBQUMsUUFBUSxFQUFFLE1BQU0sRUFBRSxFQUFFLEtBQUssRUFBRSxNQUFNLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxDQTJGdkU7Q0FDRiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sender_tagging_store.d.ts","sourceRoot":"","sources":["../../../src/storage/tagging_store/sender_tagging_store.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sender_tagging_store.d.ts","sourceRoot":"","sources":["../../../src/storage/tagging_store/sender_tagging_store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACxE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC9E,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAC;AAG5E;;;;GAIG;AACH,qBAAa,kBAAmB,YAAW,WAAW;;IACpD,QAAQ,CAAC,SAAS,oBAAoB;IA6BtC,YAAY,KAAK,EAAE,iBAAiB,EAQnC;IA4CD;;;;OAIG;IACG,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAoBzC;IAED,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAI1C;IAED;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,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