@aztec/pxe 4.0.0-nightly.20260112 → 4.0.0-nightly.20260114
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 +4 -2
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +19 -13
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +3 -3
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +4 -4
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/note_packing_utils.js +5 -5
- package/dest/contract_function_simulator/oracle/oracle.js +1 -1
- package/dest/contract_function_simulator/oracle/private_execution.d.ts +1 -1
- package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution.js +1 -2
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +1 -16
- 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 -31
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +15 -13
- package/dest/events/event_service.d.ts +1 -1
- package/dest/events/event_service.d.ts.map +1 -1
- package/dest/events/event_service.js +8 -12
- package/dest/logs/log_service.d.ts +3 -2
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +4 -2
- package/dest/notes/note_service.d.ts +2 -2
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +14 -22
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts +2 -2
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts.map +1 -1
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.js +2 -2
- package/dest/private_kernel/private_kernel_execution_prover.d.ts +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.js +3 -4
- package/dest/private_kernel/private_kernel_oracle.d.ts +24 -28
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle.js +92 -2
- package/dest/pxe.d.ts +7 -36
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +12 -59
- package/dest/storage/capsule_store/capsule_store.d.ts +24 -9
- package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -1
- package/dest/storage/capsule_store/capsule_store.js +132 -23
- package/dest/storage/note_store/note_store.d.ts +6 -5
- package/dest/storage/note_store/note_store.d.ts.map +1 -1
- package/dest/storage/note_store/note_store.js +89 -94
- package/dest/storage/private_event_store/private_event_store.d.ts +13 -6
- package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
- package/dest/storage/private_event_store/private_event_store.js +70 -56
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +1 -1
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -1
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +1 -1
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +1 -1
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -1
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +2 -2
- package/package.json +16 -16
- package/src/block_synchronizer/block_synchronizer.ts +23 -12
- package/src/contract_function_simulator/oracle/interfaces.ts +2 -2
- package/src/contract_function_simulator/oracle/note_packing_utils.ts +6 -6
- package/src/contract_function_simulator/oracle/oracle.ts +1 -1
- package/src/contract_function_simulator/oracle/private_execution.ts +0 -2
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +2 -36
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +15 -10
- package/src/events/event_service.ts +12 -26
- package/src/logs/log_service.ts +2 -1
- package/src/notes/note_service.ts +14 -23
- package/src/private_kernel/hints/build_private_kernel_reset_private_inputs.ts +1 -2
- package/src/private_kernel/private_kernel_execution_prover.ts +2 -4
- package/src/private_kernel/private_kernel_oracle.ts +119 -36
- package/src/pxe.ts +10 -81
- package/src/storage/capsule_store/capsule_store.ts +159 -23
- package/src/storage/note_store/note_store.ts +98 -95
- package/src/storage/private_event_store/private_event_store.ts +92 -65
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +4 -1
- package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +6 -2
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts +0 -46
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +0 -1
- package/dest/private_kernel/private_kernel_oracle_impl.js +0 -86
- package/src/private_kernel/private_kernel_oracle_impl.ts +0 -133
|
@@ -21,10 +21,13 @@ export type PrivateEventStoreFilter = {
|
|
|
21
21
|
type PrivateEventEntry = {
|
|
22
22
|
randomness: Fr; // Note that this value is currently not being returned on queries and is therefore temporarily unused
|
|
23
23
|
msgContent: Buffer;
|
|
24
|
-
eventCommitmentIndex: number;
|
|
25
24
|
l2BlockNumber: number;
|
|
26
25
|
l2BlockHash: Buffer;
|
|
27
26
|
txHash: Buffer;
|
|
27
|
+
/** The index of the tx within the block, used for ordering events */
|
|
28
|
+
txIndexInBlock: number;
|
|
29
|
+
/** The index of the event within the tx (based on nullifier position), used for ordering events */
|
|
30
|
+
eventIndexInTx: number;
|
|
28
31
|
/** The lookup key for #eventsByContractScopeSelector, used for cleanup during rollback */
|
|
29
32
|
lookupKey: string;
|
|
30
33
|
};
|
|
@@ -32,6 +35,10 @@ type PrivateEventEntry = {
|
|
|
32
35
|
type PrivateEventMetadata = InTx & {
|
|
33
36
|
contractAddress: AztecAddress;
|
|
34
37
|
scope: AztecAddress;
|
|
38
|
+
/** The index of the tx within the block */
|
|
39
|
+
txIndexInBlock: number;
|
|
40
|
+
/** The index of the event within the tx (based on nullifier position) */
|
|
41
|
+
eventIndexInTx: number;
|
|
35
42
|
};
|
|
36
43
|
|
|
37
44
|
/**
|
|
@@ -39,14 +46,14 @@ type PrivateEventMetadata = InTx & {
|
|
|
39
46
|
*/
|
|
40
47
|
export class PrivateEventStore {
|
|
41
48
|
#store: AztecAsyncKVStore;
|
|
42
|
-
/** Map storing the actual private event log entries, keyed by
|
|
43
|
-
#eventLogs: AztecAsyncMap<
|
|
44
|
-
/** Map from contractAddress_scope_eventSelector to
|
|
45
|
-
#eventsByContractScopeSelector: AztecAsyncMap<string,
|
|
46
|
-
/** Map from block number to
|
|
47
|
-
#eventsByBlockNumber: AztecAsyncMap<number,
|
|
48
|
-
/** Map from
|
|
49
|
-
#seenLogs: AztecAsyncMap<
|
|
49
|
+
/** Map storing the actual private event log entries, keyed by siloedEventCommitment */
|
|
50
|
+
#eventLogs: AztecAsyncMap<string, PrivateEventEntry>;
|
|
51
|
+
/** Map from contractAddress_scope_eventSelector to siloedEventCommitment[] for efficient lookup */
|
|
52
|
+
#eventsByContractScopeSelector: AztecAsyncMap<string, string[]>;
|
|
53
|
+
/** Map from block number to siloedEventCommitment[] for rollback support */
|
|
54
|
+
#eventsByBlockNumber: AztecAsyncMap<number, string[]>;
|
|
55
|
+
/** Map from siloedEventCommitment to boolean indicating if log has been seen. */
|
|
56
|
+
#seenLogs: AztecAsyncMap<string, boolean>;
|
|
50
57
|
|
|
51
58
|
logger = createLogger('private_event_store');
|
|
52
59
|
|
|
@@ -65,8 +72,9 @@ export class PrivateEventStore {
|
|
|
65
72
|
/**
|
|
66
73
|
* Store a private event log.
|
|
67
74
|
* @param eventSelector - The event selector of the event.
|
|
75
|
+
* @param randomness - The randomness used for the event commitment.
|
|
68
76
|
* @param msgContent - The content of the event.
|
|
69
|
-
* @param
|
|
77
|
+
* @param siloedEventCommitment - The siloed event commitment (used as unique identifier).
|
|
70
78
|
* @param metadata
|
|
71
79
|
* contractAddress - The address of the contract that emitted the event.
|
|
72
80
|
* scope - The address to which the event is scoped.
|
|
@@ -77,41 +85,45 @@ export class PrivateEventStore {
|
|
|
77
85
|
eventSelector: EventSelector,
|
|
78
86
|
randomness: Fr,
|
|
79
87
|
msgContent: Fr[],
|
|
80
|
-
|
|
88
|
+
siloedEventCommitment: Fr,
|
|
81
89
|
metadata: PrivateEventMetadata,
|
|
82
90
|
): Promise<void> {
|
|
83
|
-
const { contractAddress, scope, txHash, l2BlockNumber, l2BlockHash } = metadata;
|
|
91
|
+
const { contractAddress, scope, txHash, l2BlockNumber, l2BlockHash, txIndexInBlock, eventIndexInTx } = metadata;
|
|
84
92
|
|
|
85
93
|
return this.#store.transactionAsync(async () => {
|
|
86
94
|
const key = this.#keyFor(contractAddress, scope, eventSelector);
|
|
87
95
|
|
|
88
|
-
//
|
|
89
|
-
|
|
96
|
+
// The siloed event commitment is guaranteed to be unique as it's inserted into the nullifier tree. For this
|
|
97
|
+
// reason we use it as id.
|
|
98
|
+
const eventId = siloedEventCommitment.toString();
|
|
99
|
+
|
|
100
|
+
const hasBeenSeen = await this.#seenLogs.getAsync(eventId);
|
|
90
101
|
if (hasBeenSeen) {
|
|
91
|
-
this.logger.verbose('Ignoring duplicate event log', { txHash: txHash.toString(),
|
|
102
|
+
this.logger.verbose('Ignoring duplicate event log', { txHash: txHash.toString(), siloedEventCommitment });
|
|
92
103
|
return;
|
|
93
104
|
}
|
|
94
105
|
|
|
95
106
|
this.logger.verbose('storing private event log', { contractAddress, scope, msgContent, l2BlockNumber });
|
|
96
107
|
|
|
97
|
-
await this.#eventLogs.set(
|
|
108
|
+
await this.#eventLogs.set(eventId, {
|
|
98
109
|
randomness,
|
|
99
110
|
msgContent: serializeToBuffer(msgContent),
|
|
100
111
|
l2BlockNumber,
|
|
101
112
|
l2BlockHash: l2BlockHash.toBuffer(),
|
|
102
|
-
eventCommitmentIndex,
|
|
103
113
|
txHash: txHash.toBuffer(),
|
|
114
|
+
txIndexInBlock,
|
|
115
|
+
eventIndexInTx,
|
|
104
116
|
lookupKey: key,
|
|
105
117
|
});
|
|
106
118
|
|
|
107
|
-
const
|
|
108
|
-
await this.#eventsByContractScopeSelector.set(key, [...
|
|
119
|
+
const existingIds = (await this.#eventsByContractScopeSelector.getAsync(key)) || [];
|
|
120
|
+
await this.#eventsByContractScopeSelector.set(key, [...existingIds, eventId]);
|
|
109
121
|
|
|
110
|
-
const
|
|
111
|
-
await this.#eventsByBlockNumber.set(l2BlockNumber, [...
|
|
122
|
+
const existingBlockIds = (await this.#eventsByBlockNumber.getAsync(l2BlockNumber)) || [];
|
|
123
|
+
await this.#eventsByBlockNumber.set(l2BlockNumber, [...existingBlockIds, eventId]);
|
|
112
124
|
|
|
113
|
-
// Mark this log as seen
|
|
114
|
-
await this.#seenLogs.set(
|
|
125
|
+
// Mark this log as seen
|
|
126
|
+
await this.#seenLogs.set(eventId, true);
|
|
115
127
|
});
|
|
116
128
|
}
|
|
117
129
|
|
|
@@ -123,21 +135,26 @@ export class PrivateEventStore {
|
|
|
123
135
|
* fromBlock: The block number to search from (inclusive).
|
|
124
136
|
* toBlock: The block number to search upto (exclusive).
|
|
125
137
|
* scope: - The addresses that decrypted the logs.
|
|
126
|
-
* @returns - The event log contents, augmented with metadata about
|
|
127
|
-
*
|
|
138
|
+
* @returns - The event log contents, augmented with metadata about the transaction and block in which the event was
|
|
139
|
+
* included.
|
|
128
140
|
*/
|
|
129
141
|
public async getPrivateEvents(
|
|
130
142
|
eventSelector: EventSelector,
|
|
131
143
|
filter: PrivateEventStoreFilter,
|
|
132
144
|
): Promise<PackedPrivateEvent[]> {
|
|
133
|
-
const events: Array<{
|
|
145
|
+
const events: Array<{
|
|
146
|
+
l2BlockNumber: number;
|
|
147
|
+
txIndexInBlock: number;
|
|
148
|
+
eventIndexInTx: number;
|
|
149
|
+
event: PackedPrivateEvent;
|
|
150
|
+
}> = [];
|
|
134
151
|
|
|
135
152
|
for (const scope of filter.scopes) {
|
|
136
153
|
const key = this.#keyFor(filter.contractAddress, scope, eventSelector);
|
|
137
|
-
const
|
|
154
|
+
const eventIds = (await this.#eventsByContractScopeSelector.getAsync(key)) || [];
|
|
138
155
|
|
|
139
|
-
for (const
|
|
140
|
-
const entry = await this.#eventLogs.getAsync(
|
|
156
|
+
for (const eventId of eventIds) {
|
|
157
|
+
const entry = await this.#eventLogs.getAsync(eventId);
|
|
141
158
|
if (!entry || entry.l2BlockNumber < filter.fromBlock || entry.l2BlockNumber >= filter.toBlock) {
|
|
142
159
|
continue;
|
|
143
160
|
}
|
|
@@ -154,7 +171,9 @@ export class PrivateEventStore {
|
|
|
154
171
|
}
|
|
155
172
|
|
|
156
173
|
events.push({
|
|
157
|
-
|
|
174
|
+
l2BlockNumber: entry.l2BlockNumber,
|
|
175
|
+
txIndexInBlock: entry.txIndexInBlock,
|
|
176
|
+
eventIndexInTx: entry.eventIndexInTx,
|
|
158
177
|
event: {
|
|
159
178
|
packedEvent: msgContent,
|
|
160
179
|
l2BlockNumber: BlockNumber(entry.l2BlockNumber),
|
|
@@ -166,51 +185,59 @@ export class PrivateEventStore {
|
|
|
166
185
|
}
|
|
167
186
|
}
|
|
168
187
|
|
|
169
|
-
// Sort by
|
|
170
|
-
events.sort((a, b) =>
|
|
188
|
+
// Sort by block number, then by tx index within block, then by event index within tx
|
|
189
|
+
events.sort((a, b) => {
|
|
190
|
+
if (a.l2BlockNumber !== b.l2BlockNumber) {
|
|
191
|
+
return a.l2BlockNumber - b.l2BlockNumber;
|
|
192
|
+
}
|
|
193
|
+
if (a.txIndexInBlock !== b.txIndexInBlock) {
|
|
194
|
+
return a.txIndexInBlock - b.txIndexInBlock;
|
|
195
|
+
}
|
|
196
|
+
return a.eventIndexInTx - b.eventIndexInTx;
|
|
197
|
+
});
|
|
171
198
|
return events.map(ev => ev.event);
|
|
172
199
|
}
|
|
173
200
|
|
|
174
201
|
/**
|
|
175
202
|
* Rolls back private events that were stored after a given `blockNumber` and up to `synchedBlockNumber` (the block
|
|
176
203
|
* number up to which PXE managed to sync before the reorg happened).
|
|
204
|
+
*
|
|
205
|
+
* IMPORTANT: This method must be called within a transaction to ensure atomicity.
|
|
177
206
|
*/
|
|
178
|
-
public async
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
throw new Error(`Event log not found for eventCommitmentIndex ${eventCommitmentIndex}`);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
await this.#eventLogs.delete(eventCommitmentIndex);
|
|
194
|
-
await this.#seenLogs.delete(eventCommitmentIndex);
|
|
195
|
-
|
|
196
|
-
// Update #eventsByContractScopeSelector using the stored lookupKey
|
|
197
|
-
const existingIndices = await this.#eventsByContractScopeSelector.getAsync(entry.lookupKey);
|
|
198
|
-
if (!existingIndices || existingIndices.length === 0) {
|
|
199
|
-
throw new Error(`No indices found in #eventsByContractScopeSelector for key ${entry.lookupKey}`);
|
|
200
|
-
}
|
|
201
|
-
const filteredIndices = existingIndices.filter(idx => idx !== eventCommitmentIndex);
|
|
202
|
-
if (filteredIndices.length === 0) {
|
|
203
|
-
await this.#eventsByContractScopeSelector.delete(entry.lookupKey);
|
|
204
|
-
} else {
|
|
205
|
-
await this.#eventsByContractScopeSelector.set(entry.lookupKey, filteredIndices);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
removedCount++;
|
|
207
|
+
public async rollback(blockNumber: number, synchedBlockNumber: number): Promise<void> {
|
|
208
|
+
let removedCount = 0;
|
|
209
|
+
|
|
210
|
+
for (let block = blockNumber + 1; block <= synchedBlockNumber; block++) {
|
|
211
|
+
const eventIds = await this.#eventsByBlockNumber.getAsync(block);
|
|
212
|
+
if (eventIds) {
|
|
213
|
+
await this.#eventsByBlockNumber.delete(block);
|
|
214
|
+
|
|
215
|
+
for (const eventId of eventIds) {
|
|
216
|
+
const entry = await this.#eventLogs.getAsync(eventId);
|
|
217
|
+
if (!entry) {
|
|
218
|
+
throw new Error(`Event log not found for eventId ${eventId}`);
|
|
209
219
|
}
|
|
220
|
+
|
|
221
|
+
await this.#eventLogs.delete(eventId);
|
|
222
|
+
await this.#seenLogs.delete(eventId);
|
|
223
|
+
|
|
224
|
+
// Update #eventsByContractScopeSelector using the stored lookupKey
|
|
225
|
+
const existingIds = await this.#eventsByContractScopeSelector.getAsync(entry.lookupKey);
|
|
226
|
+
if (!existingIds || existingIds.length === 0) {
|
|
227
|
+
throw new Error(`No ids found in #eventsByContractScopeSelector for key ${entry.lookupKey}`);
|
|
228
|
+
}
|
|
229
|
+
const filteredIds = existingIds.filter(id => id !== eventId);
|
|
230
|
+
if (filteredIds.length === 0) {
|
|
231
|
+
await this.#eventsByContractScopeSelector.delete(entry.lookupKey);
|
|
232
|
+
} else {
|
|
233
|
+
await this.#eventsByContractScopeSelector.set(entry.lookupKey, filteredIds);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
removedCount++;
|
|
210
237
|
}
|
|
211
238
|
}
|
|
239
|
+
}
|
|
212
240
|
|
|
213
|
-
|
|
214
|
-
});
|
|
241
|
+
this.logger.verbose(`Rolled back ${removedCount} private events after block ${blockNumber}`);
|
|
215
242
|
}
|
|
216
243
|
}
|
|
@@ -68,7 +68,10 @@ export async function loadPrivateLogsForSenderRecipientPair(
|
|
|
68
68
|
throw new Error('Node failed to return latest block header when syncing logs');
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
[finalizedBlockNumber, currentTimestamp] = [
|
|
71
|
+
[finalizedBlockNumber, currentTimestamp] = [
|
|
72
|
+
l2Tips.finalized.block.number,
|
|
73
|
+
latestBlockHeader.globalVariables.timestamp,
|
|
74
|
+
];
|
|
72
75
|
}
|
|
73
76
|
|
|
74
77
|
let start: number, end: number;
|
|
@@ -10,7 +10,7 @@ export async function getStatusChangeOfPending(
|
|
|
10
10
|
aztecNode: AztecNode,
|
|
11
11
|
): Promise<{ txHashesToFinalize: TxHash[]; txHashesToDrop: TxHash[] }> {
|
|
12
12
|
// Get receipts for all pending tx hashes and the finalized block number.
|
|
13
|
-
const [receipts,
|
|
13
|
+
const [receipts, tips] = await Promise.all([
|
|
14
14
|
Promise.all(pending.map(pendingTxHash => aztecNode.getTxReceipt(pendingTxHash))),
|
|
15
15
|
aztecNode.getL2Tips(),
|
|
16
16
|
]);
|
|
@@ -22,7 +22,11 @@ export async function getStatusChangeOfPending(
|
|
|
22
22
|
const receipt = receipts[i];
|
|
23
23
|
const txHash = pending[i];
|
|
24
24
|
|
|
25
|
-
if (
|
|
25
|
+
if (
|
|
26
|
+
receipt.status === TxStatus.SUCCESS &&
|
|
27
|
+
receipt.blockNumber &&
|
|
28
|
+
receipt.blockNumber <= tips.finalized.block.number
|
|
29
|
+
) {
|
|
26
30
|
// Tx has been included in a block and the corresponding block is finalized --> we mark the indexes as
|
|
27
31
|
// finalized.
|
|
28
32
|
txHashesToFinalize.push(txHash);
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { NOTE_HASH_TREE_HEIGHT } from '@aztec/constants';
|
|
2
|
-
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
-
import type { GrumpkinScalar, Point } from '@aztec/foundation/curves/grumpkin';
|
|
4
|
-
import { MembershipWitness } from '@aztec/foundation/trees';
|
|
5
|
-
import type { KeyStore } from '@aztec/key-store';
|
|
6
|
-
import type { FunctionSelector } from '@aztec/stdlib/abi';
|
|
7
|
-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
8
|
-
import type { BlockParameter } from '@aztec/stdlib/block';
|
|
9
|
-
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
10
|
-
import { UpdatedClassIdHints } from '@aztec/stdlib/kernel';
|
|
11
|
-
import type { NullifierMembershipWitness } from '@aztec/stdlib/trees';
|
|
12
|
-
import type { VerificationKeyAsFields } from '@aztec/stdlib/vks';
|
|
13
|
-
import type { ContractStore } from '../storage/contract_store/contract_store.js';
|
|
14
|
-
import type { PrivateKernelOracle } from './private_kernel_oracle.js';
|
|
15
|
-
/**
|
|
16
|
-
* A data oracle that provides information needed for simulating a transaction.
|
|
17
|
-
*/
|
|
18
|
-
export declare class PrivateKernelOracleImpl implements PrivateKernelOracle {
|
|
19
|
-
private contractStore;
|
|
20
|
-
private keyStore;
|
|
21
|
-
private node;
|
|
22
|
-
private blockNumber;
|
|
23
|
-
private log;
|
|
24
|
-
constructor(contractStore: ContractStore, keyStore: KeyStore, node: AztecNode, blockNumber?: BlockParameter, log?: import("@aztec/foundation/log").Logger);
|
|
25
|
-
getContractAddressPreimage(address: AztecAddress): Promise<{
|
|
26
|
-
version: 1;
|
|
27
|
-
salt: Fr;
|
|
28
|
-
deployer: AztecAddress;
|
|
29
|
-
currentContractClassId: Fr;
|
|
30
|
-
originalContractClassId: Fr;
|
|
31
|
-
initializationHash: Fr;
|
|
32
|
-
publicKeys: import("../../../stdlib/dest/keys/public_keys.js").PublicKeys;
|
|
33
|
-
address: AztecAddress;
|
|
34
|
-
saltedInitializationHash: Fr;
|
|
35
|
-
}>;
|
|
36
|
-
getContractClassIdPreimage(contractClassId: Fr): Promise<import("@aztec/stdlib/contract").ContractClassIdPreimage>;
|
|
37
|
-
getFunctionMembershipWitness(contractClassId: Fr, selector: FunctionSelector): Promise<MembershipWitness<7>>;
|
|
38
|
-
getVkMembershipWitness(vk: VerificationKeyAsFields): Promise<MembershipWitness<7>>;
|
|
39
|
-
getNoteHashMembershipWitness(leafIndex: bigint): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT>>;
|
|
40
|
-
getNullifierMembershipWitness(nullifier: Fr): Promise<NullifierMembershipWitness | undefined>;
|
|
41
|
-
getNoteHashTreeRoot(): Promise<Fr>;
|
|
42
|
-
getMasterSecretKey(masterPublicKey: Point): Promise<GrumpkinScalar>;
|
|
43
|
-
getDebugFunctionName(contractAddress: AztecAddress, selector: FunctionSelector): Promise<string>;
|
|
44
|
-
getUpdatedClassIdHints(contractAddress: AztecAddress): Promise<UpdatedClassIdHints>;
|
|
45
|
-
}
|
|
46
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJpdmF0ZV9rZXJuZWxfb3JhY2xlX2ltcGwuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9wcml2YXRlX2tlcm5lbC9wcml2YXRlX2tlcm5lbF9vcmFjbGVfaW1wbC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUscUJBQXFCLEVBQTJDLE1BQU0sa0JBQWtCLENBQUM7QUFDbEcsT0FBTyxLQUFLLEVBQUUsRUFBRSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDekQsT0FBTyxLQUFLLEVBQUUsY0FBYyxFQUFFLEtBQUssRUFBRSxNQUFNLG1DQUFtQyxDQUFDO0FBRy9FLE9BQU8sRUFBRSxpQkFBaUIsRUFBRSxNQUFNLHlCQUF5QixDQUFDO0FBQzVELE9BQU8sS0FBSyxFQUFFLFFBQVEsRUFBRSxNQUFNLGtCQUFrQixDQUFDO0FBR2pELE9BQU8sS0FBSyxFQUFFLGdCQUFnQixFQUFFLE1BQU0sbUJBQW1CLENBQUM7QUFDMUQsT0FBTyxLQUFLLEVBQUUsWUFBWSxFQUFFLE1BQU0sNkJBQTZCLENBQUM7QUFDaEUsT0FBTyxLQUFLLEVBQUUsY0FBYyxFQUFFLE1BQU0scUJBQXFCLENBQUM7QUFJMUQsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFDakUsT0FBTyxFQUFFLG1CQUFtQixFQUFFLE1BQU0sc0JBQXNCLENBQUM7QUFDM0QsT0FBTyxLQUFLLEVBQUUsMEJBQTBCLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUN0RSxPQUFPLEtBQ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from '@aztec/foundation/log';
|
|
3
|
-
import { MembershipWitness } from '@aztec/foundation/trees';
|
|
4
|
-
import { getVKIndex, getVKSiblingPath } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
5
|
-
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
6
|
-
import { computeContractClassIdPreimage, computeSaltedInitializationHash } from '@aztec/stdlib/contract';
|
|
7
|
-
import { DelayedPublicMutableValues, DelayedPublicMutableValuesWithHash } from '@aztec/stdlib/delayed-public-mutable';
|
|
8
|
-
import { computePublicDataTreeLeafSlot } from '@aztec/stdlib/hash';
|
|
9
|
-
import { UpdatedClassIdHints } from '@aztec/stdlib/kernel';
|
|
10
|
-
// TODO: Block number should not be "latest".
|
|
11
|
-
// It should be fixed at the time the proof is being simulated. I.e., it should be the same as the value defined in the constant data.
|
|
12
|
-
/**
|
|
13
|
-
* A data oracle that provides information needed for simulating a transaction.
|
|
14
|
-
*/ export class PrivateKernelOracleImpl {
|
|
15
|
-
contractStore;
|
|
16
|
-
keyStore;
|
|
17
|
-
node;
|
|
18
|
-
blockNumber;
|
|
19
|
-
log;
|
|
20
|
-
constructor(contractStore, keyStore, node, blockNumber = 'latest', log = createLogger('pxe:kernel_oracle')){
|
|
21
|
-
this.contractStore = contractStore;
|
|
22
|
-
this.keyStore = keyStore;
|
|
23
|
-
this.node = node;
|
|
24
|
-
this.blockNumber = blockNumber;
|
|
25
|
-
this.log = log;
|
|
26
|
-
}
|
|
27
|
-
async getContractAddressPreimage(address) {
|
|
28
|
-
const instance = await this.contractStore.getContractInstance(address);
|
|
29
|
-
if (!instance) {
|
|
30
|
-
throw new Error(`Contract instance not found when getting address preimage. Contract address: ${address}.`);
|
|
31
|
-
}
|
|
32
|
-
return {
|
|
33
|
-
saltedInitializationHash: await computeSaltedInitializationHash(instance),
|
|
34
|
-
...instance
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
async getContractClassIdPreimage(contractClassId) {
|
|
38
|
-
const contractClass = await this.contractStore.getContractClass(contractClassId);
|
|
39
|
-
if (!contractClass) {
|
|
40
|
-
throw new Error(`Contract class not found when getting class id preimage. Class id: ${contractClassId}.`);
|
|
41
|
-
}
|
|
42
|
-
return computeContractClassIdPreimage(contractClass);
|
|
43
|
-
}
|
|
44
|
-
async getFunctionMembershipWitness(contractClassId, selector) {
|
|
45
|
-
const membershipWitness = await this.contractStore.getFunctionMembershipWitness(contractClassId, selector);
|
|
46
|
-
if (!membershipWitness) {
|
|
47
|
-
throw new Error(`Membership witness not found for contract class id ${contractClassId} and selector ${selector}.`);
|
|
48
|
-
}
|
|
49
|
-
return membershipWitness;
|
|
50
|
-
}
|
|
51
|
-
getVkMembershipWitness(vk) {
|
|
52
|
-
const leafIndex = getVKIndex(vk);
|
|
53
|
-
return Promise.resolve(new MembershipWitness(VK_TREE_HEIGHT, BigInt(leafIndex), getVKSiblingPath(leafIndex)));
|
|
54
|
-
}
|
|
55
|
-
async getNoteHashMembershipWitness(leafIndex) {
|
|
56
|
-
const path = await this.node.getNoteHashSiblingPath(this.blockNumber, leafIndex);
|
|
57
|
-
return new MembershipWitness(path.pathSize, leafIndex, path.toFields());
|
|
58
|
-
}
|
|
59
|
-
getNullifierMembershipWitness(nullifier) {
|
|
60
|
-
return this.node.getNullifierMembershipWitness(this.blockNumber, nullifier);
|
|
61
|
-
}
|
|
62
|
-
async getNoteHashTreeRoot() {
|
|
63
|
-
const header = await this.node.getBlockHeader(this.blockNumber);
|
|
64
|
-
if (!header) {
|
|
65
|
-
throw new Error(`No block header found for block number ${this.blockNumber}`);
|
|
66
|
-
}
|
|
67
|
-
return header.state.partial.noteHashTree.root;
|
|
68
|
-
}
|
|
69
|
-
getMasterSecretKey(masterPublicKey) {
|
|
70
|
-
return this.keyStore.getMasterSecretKey(masterPublicKey);
|
|
71
|
-
}
|
|
72
|
-
getDebugFunctionName(contractAddress, selector) {
|
|
73
|
-
return this.contractStore.getDebugFunctionName(contractAddress, selector);
|
|
74
|
-
}
|
|
75
|
-
async getUpdatedClassIdHints(contractAddress) {
|
|
76
|
-
const { delayedPublicMutableSlot, delayedPublicMutableHashSlot } = await DelayedPublicMutableValuesWithHash.getContractUpdateSlots(contractAddress);
|
|
77
|
-
const hashLeafSlot = await computePublicDataTreeLeafSlot(ProtocolContractAddress.ContractInstanceRegistry, delayedPublicMutableHashSlot);
|
|
78
|
-
const updatedClassIdWitness = await this.node.getPublicDataWitness(this.blockNumber, hashLeafSlot);
|
|
79
|
-
if (!updatedClassIdWitness) {
|
|
80
|
-
throw new Error(`No public data tree witness found for ${hashLeafSlot}`);
|
|
81
|
-
}
|
|
82
|
-
const readStorage = (storageSlot)=>this.node.getPublicStorageAt(this.blockNumber, ProtocolContractAddress.ContractInstanceRegistry, storageSlot);
|
|
83
|
-
const delayedPublicMutableValues = await DelayedPublicMutableValues.readFromTree(delayedPublicMutableSlot, readStorage);
|
|
84
|
-
return new UpdatedClassIdHints(new MembershipWitness(PUBLIC_DATA_TREE_HEIGHT, updatedClassIdWitness.index, updatedClassIdWitness.siblingPath.toTuple()), updatedClassIdWitness.leafPreimage, delayedPublicMutableValues);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import { NOTE_HASH_TREE_HEIGHT, PUBLIC_DATA_TREE_HEIGHT, VK_TREE_HEIGHT } from '@aztec/constants';
|
|
2
|
-
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
-
import type { GrumpkinScalar, Point } from '@aztec/foundation/curves/grumpkin';
|
|
4
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
5
|
-
import type { Tuple } from '@aztec/foundation/serialize';
|
|
6
|
-
import { MembershipWitness } from '@aztec/foundation/trees';
|
|
7
|
-
import type { KeyStore } from '@aztec/key-store';
|
|
8
|
-
import { getVKIndex, getVKSiblingPath } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
9
|
-
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
10
|
-
import type { FunctionSelector } from '@aztec/stdlib/abi';
|
|
11
|
-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
12
|
-
import type { BlockParameter } from '@aztec/stdlib/block';
|
|
13
|
-
import { computeContractClassIdPreimage, computeSaltedInitializationHash } from '@aztec/stdlib/contract';
|
|
14
|
-
import { DelayedPublicMutableValues, DelayedPublicMutableValuesWithHash } from '@aztec/stdlib/delayed-public-mutable';
|
|
15
|
-
import { computePublicDataTreeLeafSlot } from '@aztec/stdlib/hash';
|
|
16
|
-
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
17
|
-
import { UpdatedClassIdHints } from '@aztec/stdlib/kernel';
|
|
18
|
-
import type { NullifierMembershipWitness } from '@aztec/stdlib/trees';
|
|
19
|
-
import type { VerificationKeyAsFields } from '@aztec/stdlib/vks';
|
|
20
|
-
|
|
21
|
-
import type { ContractStore } from '../storage/contract_store/contract_store.js';
|
|
22
|
-
import type { PrivateKernelOracle } from './private_kernel_oracle.js';
|
|
23
|
-
|
|
24
|
-
// TODO: Block number should not be "latest".
|
|
25
|
-
// It should be fixed at the time the proof is being simulated. I.e., it should be the same as the value defined in the constant data.
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* A data oracle that provides information needed for simulating a transaction.
|
|
29
|
-
*/
|
|
30
|
-
export class PrivateKernelOracleImpl implements PrivateKernelOracle {
|
|
31
|
-
constructor(
|
|
32
|
-
private contractStore: ContractStore,
|
|
33
|
-
private keyStore: KeyStore,
|
|
34
|
-
private node: AztecNode,
|
|
35
|
-
private blockNumber: BlockParameter = 'latest',
|
|
36
|
-
private log = createLogger('pxe:kernel_oracle'),
|
|
37
|
-
) {}
|
|
38
|
-
|
|
39
|
-
public async getContractAddressPreimage(address: AztecAddress) {
|
|
40
|
-
const instance = await this.contractStore.getContractInstance(address);
|
|
41
|
-
if (!instance) {
|
|
42
|
-
throw new Error(`Contract instance not found when getting address preimage. Contract address: ${address}.`);
|
|
43
|
-
}
|
|
44
|
-
return {
|
|
45
|
-
saltedInitializationHash: await computeSaltedInitializationHash(instance),
|
|
46
|
-
...instance,
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
public async getContractClassIdPreimage(contractClassId: Fr) {
|
|
51
|
-
const contractClass = await this.contractStore.getContractClass(contractClassId);
|
|
52
|
-
if (!contractClass) {
|
|
53
|
-
throw new Error(`Contract class not found when getting class id preimage. Class id: ${contractClassId}.`);
|
|
54
|
-
}
|
|
55
|
-
return computeContractClassIdPreimage(contractClass);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
public async getFunctionMembershipWitness(contractClassId: Fr, selector: FunctionSelector) {
|
|
59
|
-
const membershipWitness = await this.contractStore.getFunctionMembershipWitness(contractClassId, selector);
|
|
60
|
-
if (!membershipWitness) {
|
|
61
|
-
throw new Error(
|
|
62
|
-
`Membership witness not found for contract class id ${contractClassId} and selector ${selector}.`,
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
return membershipWitness;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
public getVkMembershipWitness(vk: VerificationKeyAsFields) {
|
|
69
|
-
const leafIndex = getVKIndex(vk);
|
|
70
|
-
return Promise.resolve(new MembershipWitness(VK_TREE_HEIGHT, BigInt(leafIndex), getVKSiblingPath(leafIndex)));
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
async getNoteHashMembershipWitness(leafIndex: bigint): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT>> {
|
|
74
|
-
const path = await this.node.getNoteHashSiblingPath(this.blockNumber, leafIndex);
|
|
75
|
-
return new MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT>(
|
|
76
|
-
path.pathSize,
|
|
77
|
-
leafIndex,
|
|
78
|
-
path.toFields() as Tuple<Fr, typeof NOTE_HASH_TREE_HEIGHT>,
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
getNullifierMembershipWitness(nullifier: Fr): Promise<NullifierMembershipWitness | undefined> {
|
|
83
|
-
return this.node.getNullifierMembershipWitness(this.blockNumber, nullifier);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
async getNoteHashTreeRoot(): Promise<Fr> {
|
|
87
|
-
const header = await this.node.getBlockHeader(this.blockNumber);
|
|
88
|
-
if (!header) {
|
|
89
|
-
throw new Error(`No block header found for block number ${this.blockNumber}`);
|
|
90
|
-
}
|
|
91
|
-
return header.state.partial.noteHashTree.root;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
public getMasterSecretKey(masterPublicKey: Point): Promise<GrumpkinScalar> {
|
|
95
|
-
return this.keyStore.getMasterSecretKey(masterPublicKey);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
public getDebugFunctionName(contractAddress: AztecAddress, selector: FunctionSelector): Promise<string> {
|
|
99
|
-
return this.contractStore.getDebugFunctionName(contractAddress, selector);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
public async getUpdatedClassIdHints(contractAddress: AztecAddress): Promise<UpdatedClassIdHints> {
|
|
103
|
-
const { delayedPublicMutableSlot, delayedPublicMutableHashSlot } =
|
|
104
|
-
await DelayedPublicMutableValuesWithHash.getContractUpdateSlots(contractAddress);
|
|
105
|
-
|
|
106
|
-
const hashLeafSlot = await computePublicDataTreeLeafSlot(
|
|
107
|
-
ProtocolContractAddress.ContractInstanceRegistry,
|
|
108
|
-
delayedPublicMutableHashSlot,
|
|
109
|
-
);
|
|
110
|
-
const updatedClassIdWitness = await this.node.getPublicDataWitness(this.blockNumber, hashLeafSlot);
|
|
111
|
-
|
|
112
|
-
if (!updatedClassIdWitness) {
|
|
113
|
-
throw new Error(`No public data tree witness found for ${hashLeafSlot}`);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
const readStorage = (storageSlot: Fr) =>
|
|
117
|
-
this.node.getPublicStorageAt(this.blockNumber, ProtocolContractAddress.ContractInstanceRegistry, storageSlot);
|
|
118
|
-
const delayedPublicMutableValues = await DelayedPublicMutableValues.readFromTree(
|
|
119
|
-
delayedPublicMutableSlot,
|
|
120
|
-
readStorage,
|
|
121
|
-
);
|
|
122
|
-
|
|
123
|
-
return new UpdatedClassIdHints(
|
|
124
|
-
new MembershipWitness(
|
|
125
|
-
PUBLIC_DATA_TREE_HEIGHT,
|
|
126
|
-
updatedClassIdWitness.index,
|
|
127
|
-
updatedClassIdWitness.siblingPath.toTuple(),
|
|
128
|
-
),
|
|
129
|
-
updatedClassIdWitness.leafPreimage,
|
|
130
|
-
delayedPublicMutableValues,
|
|
131
|
-
);
|
|
132
|
-
}
|
|
133
|
-
}
|