@aztec/pxe 0.0.1-commit.dbf9cec → 0.0.1-commit.e0f15ab9b
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/config/index.d.ts +2 -2
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +9 -3
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +28 -6
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +5 -5
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_tagging_index_cache.js +17 -9
- package/dest/contract_function_simulator/index.d.ts +2 -1
- package/dest/contract_function_simulator/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.js +1 -0
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +2 -3
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/event_validation_request.js +5 -4
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +1 -3
- package/dest/contract_function_simulator/noir-structs/message_tx_context.d.ts +16 -0
- package/dest/contract_function_simulator/noir-structs/message_tx_context.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/message_tx_context.js +57 -0
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +2 -4
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/note_validation_request.js +3 -5
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +50 -45
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts +9 -0
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.js +42 -0
- package/dest/contract_function_simulator/oracle/oracle.d.ts +45 -44
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +163 -94
- package/dest/contract_function_simulator/oracle/private_execution.js +5 -3
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +22 -47
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +30 -62
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +53 -35
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +101 -43
- package/dest/contract_sync/contract_sync_service.d.ts +5 -3
- package/dest/contract_sync/contract_sync_service.d.ts.map +1 -1
- package/dest/contract_sync/contract_sync_service.js +47 -30
- package/dest/messages/message_context_service.d.ts +17 -0
- package/dest/messages/message_context_service.d.ts.map +1 -0
- package/dest/messages/message_context_service.js +36 -0
- package/dest/oracle_version.d.ts +2 -2
- package/dest/oracle_version.js +3 -3
- package/dest/pxe.d.ts +8 -4
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +39 -22
- package/dest/storage/metadata.d.ts +1 -1
- package/dest/storage/metadata.js +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.d.ts +26 -25
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.js +141 -115
- package/dest/tagging/index.d.ts +2 -2
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +1 -1
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +10 -1
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +4 -3
- 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 +20 -10
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +2 -1
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +24 -11
- package/package.json +16 -16
- package/src/config/index.ts +1 -1
- package/src/contract_function_simulator/contract_function_simulator.ts +39 -7
- package/src/contract_function_simulator/execution_tagging_index_cache.ts +16 -11
- package/src/contract_function_simulator/index.ts +1 -0
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +8 -5
- package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +1 -4
- package/src/contract_function_simulator/noir-structs/message_tx_context.ts +55 -0
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +3 -6
- package/src/contract_function_simulator/oracle/interfaces.ts +54 -54
- package/src/contract_function_simulator/oracle/legacy_oracle_mappings.ts +135 -0
- package/src/contract_function_simulator/oracle/oracle.ts +176 -138
- package/src/contract_function_simulator/oracle/private_execution.ts +4 -4
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +32 -80
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +136 -53
- package/src/contract_sync/contract_sync_service.ts +67 -38
- package/src/messages/message_context_service.ts +45 -0
- package/src/oracle_version.ts +3 -3
- package/src/pxe.ts +57 -21
- package/src/storage/metadata.ts +1 -1
- package/src/storage/tagging_store/sender_tagging_store.ts +182 -135
- package/src/tagging/index.ts +1 -1
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +19 -1
- package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +26 -11
- package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +19 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/pxe",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.e0f15ab9b",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"typedocOptions": {
|
|
6
6
|
"entryPoints": [
|
|
@@ -70,19 +70,19 @@
|
|
|
70
70
|
]
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
|
-
"@aztec/bb-prover": "0.0.1-commit.
|
|
74
|
-
"@aztec/bb.js": "0.0.1-commit.
|
|
75
|
-
"@aztec/builder": "0.0.1-commit.
|
|
76
|
-
"@aztec/constants": "0.0.1-commit.
|
|
77
|
-
"@aztec/ethereum": "0.0.1-commit.
|
|
78
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
79
|
-
"@aztec/key-store": "0.0.1-commit.
|
|
80
|
-
"@aztec/kv-store": "0.0.1-commit.
|
|
81
|
-
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.
|
|
82
|
-
"@aztec/noir-types": "0.0.1-commit.
|
|
83
|
-
"@aztec/protocol-contracts": "0.0.1-commit.
|
|
84
|
-
"@aztec/simulator": "0.0.1-commit.
|
|
85
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
73
|
+
"@aztec/bb-prover": "0.0.1-commit.e0f15ab9b",
|
|
74
|
+
"@aztec/bb.js": "0.0.1-commit.e0f15ab9b",
|
|
75
|
+
"@aztec/builder": "0.0.1-commit.e0f15ab9b",
|
|
76
|
+
"@aztec/constants": "0.0.1-commit.e0f15ab9b",
|
|
77
|
+
"@aztec/ethereum": "0.0.1-commit.e0f15ab9b",
|
|
78
|
+
"@aztec/foundation": "0.0.1-commit.e0f15ab9b",
|
|
79
|
+
"@aztec/key-store": "0.0.1-commit.e0f15ab9b",
|
|
80
|
+
"@aztec/kv-store": "0.0.1-commit.e0f15ab9b",
|
|
81
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.e0f15ab9b",
|
|
82
|
+
"@aztec/noir-types": "0.0.1-commit.e0f15ab9b",
|
|
83
|
+
"@aztec/protocol-contracts": "0.0.1-commit.e0f15ab9b",
|
|
84
|
+
"@aztec/simulator": "0.0.1-commit.e0f15ab9b",
|
|
85
|
+
"@aztec/stdlib": "0.0.1-commit.e0f15ab9b",
|
|
86
86
|
"koa": "^2.16.1",
|
|
87
87
|
"koa-router": "^13.1.1",
|
|
88
88
|
"lodash.omit": "^4.5.0",
|
|
@@ -91,8 +91,8 @@
|
|
|
91
91
|
"viem": "npm:@aztec/viem@2.38.2"
|
|
92
92
|
},
|
|
93
93
|
"devDependencies": {
|
|
94
|
-
"@aztec/
|
|
95
|
-
"@aztec/
|
|
94
|
+
"@aztec/noir-test-contracts.js": "0.0.1-commit.e0f15ab9b",
|
|
95
|
+
"@aztec/world-state": "0.0.1-commit.e0f15ab9b",
|
|
96
96
|
"@jest/globals": "^30.0.0",
|
|
97
97
|
"@types/jest": "^30.0.0",
|
|
98
98
|
"@types/lodash.omit": "^4.5.7",
|
package/src/config/index.ts
CHANGED
|
@@ -5,8 +5,8 @@ import {
|
|
|
5
5
|
numberConfigHelper,
|
|
6
6
|
parseBooleanEnv,
|
|
7
7
|
} from '@aztec/foundation/config';
|
|
8
|
-
import { type DataStoreConfig, dataConfigMappings } from '@aztec/kv-store/config';
|
|
9
8
|
import { type ChainConfig, chainConfigMappings } from '@aztec/stdlib/config';
|
|
9
|
+
import { type DataStoreConfig, dataConfigMappings } from '@aztec/stdlib/kv-store';
|
|
10
10
|
|
|
11
11
|
export { getPackageInfo } from './package_info.js';
|
|
12
12
|
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
MAX_NULLIFIERS_PER_TX,
|
|
18
18
|
MAX_NULLIFIER_READ_REQUESTS_PER_TX,
|
|
19
19
|
MAX_PRIVATE_LOGS_PER_TX,
|
|
20
|
+
MAX_TX_LIFETIME,
|
|
20
21
|
PRIVATE_TX_L2_GAS_OVERHEAD,
|
|
21
22
|
PUBLIC_TX_L2_GAS_OVERHEAD,
|
|
22
23
|
TX_DA_GAS_OVERHEAD,
|
|
@@ -79,6 +80,7 @@ import {
|
|
|
79
80
|
BlockHeader,
|
|
80
81
|
CallContext,
|
|
81
82
|
HashedValues,
|
|
83
|
+
type OffchainEffect,
|
|
82
84
|
PrivateExecutionResult,
|
|
83
85
|
TxConstantData,
|
|
84
86
|
TxExecutionRequest,
|
|
@@ -89,6 +91,7 @@ import {
|
|
|
89
91
|
|
|
90
92
|
import type { AccessScopes } from '../access_scopes.js';
|
|
91
93
|
import type { ContractSyncService } from '../contract_sync/contract_sync_service.js';
|
|
94
|
+
import type { MessageContextService } from '../messages/message_context_service.js';
|
|
92
95
|
import type { AddressStore } from '../storage/address_store/address_store.js';
|
|
93
96
|
import type { CapsuleStore } from '../storage/capsule_store/capsule_store.js';
|
|
94
97
|
import type { ContractStore } from '../storage/contract_store/contract_store.js';
|
|
@@ -138,6 +141,7 @@ export type ContractFunctionSimulatorArgs = {
|
|
|
138
141
|
privateEventStore: PrivateEventStore;
|
|
139
142
|
simulator: CircuitSimulator;
|
|
140
143
|
contractSyncService: ContractSyncService;
|
|
144
|
+
messageContextService: MessageContextService;
|
|
141
145
|
};
|
|
142
146
|
|
|
143
147
|
/**
|
|
@@ -157,6 +161,7 @@ export class ContractFunctionSimulator {
|
|
|
157
161
|
private readonly privateEventStore: PrivateEventStore;
|
|
158
162
|
private readonly simulator: CircuitSimulator;
|
|
159
163
|
private readonly contractSyncService: ContractSyncService;
|
|
164
|
+
private readonly messageContextService: MessageContextService;
|
|
160
165
|
|
|
161
166
|
constructor(args: ContractFunctionSimulatorArgs) {
|
|
162
167
|
this.contractStore = args.contractStore;
|
|
@@ -171,6 +176,7 @@ export class ContractFunctionSimulator {
|
|
|
171
176
|
this.privateEventStore = args.privateEventStore;
|
|
172
177
|
this.simulator = args.simulator;
|
|
173
178
|
this.contractSyncService = args.contractSyncService;
|
|
179
|
+
this.messageContextService = args.messageContextService;
|
|
174
180
|
this.log = createLogger('simulator');
|
|
175
181
|
}
|
|
176
182
|
|
|
@@ -241,6 +247,7 @@ export class ContractFunctionSimulator {
|
|
|
241
247
|
senderAddressBookStore: this.senderAddressBookStore,
|
|
242
248
|
capsuleStore: this.capsuleStore,
|
|
243
249
|
privateEventStore: this.privateEventStore,
|
|
250
|
+
messageContextService: this.messageContextService,
|
|
244
251
|
contractSyncService: this.contractSyncService,
|
|
245
252
|
jobId,
|
|
246
253
|
totalPublicCalldataCount: 0,
|
|
@@ -277,7 +284,7 @@ export class ContractFunctionSimulator {
|
|
|
277
284
|
);
|
|
278
285
|
const publicFunctionsCalldata = await Promise.all(
|
|
279
286
|
publicCallRequests.map(async r => {
|
|
280
|
-
const calldata = await privateExecutionOracle.
|
|
287
|
+
const calldata = await privateExecutionOracle.loadFromExecutionCache(r.calldataHash);
|
|
281
288
|
return new HashedValues(calldata, r.calldataHash);
|
|
282
289
|
}),
|
|
283
290
|
);
|
|
@@ -314,7 +321,7 @@ export class ContractFunctionSimulator {
|
|
|
314
321
|
anchorBlockHeader: BlockHeader,
|
|
315
322
|
scopes: AccessScopes,
|
|
316
323
|
jobId: string,
|
|
317
|
-
): Promise<Fr[]> {
|
|
324
|
+
): Promise<{ result: Fr[]; offchainEffects: OffchainEffect[] }> {
|
|
318
325
|
const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
|
|
319
326
|
|
|
320
327
|
if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
|
|
@@ -335,6 +342,8 @@ export class ContractFunctionSimulator {
|
|
|
335
342
|
senderAddressBookStore: this.senderAddressBookStore,
|
|
336
343
|
capsuleStore: this.capsuleStore,
|
|
337
344
|
privateEventStore: this.privateEventStore,
|
|
345
|
+
messageContextService: this.messageContextService,
|
|
346
|
+
contractSyncService: this.contractSyncService,
|
|
338
347
|
jobId,
|
|
339
348
|
scopes,
|
|
340
349
|
});
|
|
@@ -362,7 +371,10 @@ export class ContractFunctionSimulator {
|
|
|
362
371
|
});
|
|
363
372
|
|
|
364
373
|
this.log.verbose(`Utility execution for ${call.to}.${call.selector} completed`);
|
|
365
|
-
return
|
|
374
|
+
return {
|
|
375
|
+
result: witnessMapToFields(acirExecutionResult.returnWitness),
|
|
376
|
+
offchainEffects: oracle.getOffchainEffects(),
|
|
377
|
+
};
|
|
366
378
|
} catch (err) {
|
|
367
379
|
throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during private execution'));
|
|
368
380
|
}
|
|
@@ -432,14 +444,34 @@ export async function generateSimulatedProvingResult(
|
|
|
432
444
|
|
|
433
445
|
let publicTeardownCallRequest;
|
|
434
446
|
|
|
447
|
+
// We set expiration timestamp to anchor_block_timestamp + MAX_TX_LIFETIME (24h) just like kernels do
|
|
448
|
+
let expirationTimestamp =
|
|
449
|
+
privateExecutionResult.entrypoint.publicInputs.anchorBlockHeader.globalVariables.timestamp +
|
|
450
|
+
BigInt(MAX_TX_LIFETIME);
|
|
451
|
+
|
|
452
|
+
let feePayer = AztecAddress.zero();
|
|
453
|
+
|
|
435
454
|
const executions = [privateExecutionResult.entrypoint];
|
|
436
455
|
|
|
437
456
|
while (executions.length !== 0) {
|
|
438
457
|
const execution = executions.shift()!;
|
|
439
458
|
executions.unshift(...execution!.nestedExecutionResults);
|
|
440
459
|
|
|
460
|
+
// Just like kernels we overwrite the default value if the call sets it.
|
|
461
|
+
const callExpirationTimestamp = execution.publicInputs.expirationTimestamp;
|
|
462
|
+
if (callExpirationTimestamp !== 0n && callExpirationTimestamp < expirationTimestamp) {
|
|
463
|
+
expirationTimestamp = callExpirationTimestamp;
|
|
464
|
+
}
|
|
465
|
+
|
|
441
466
|
const { contractAddress } = execution.publicInputs.callContext;
|
|
442
467
|
|
|
468
|
+
if (execution.publicInputs.isFeePayer) {
|
|
469
|
+
if (!feePayer.isZero()) {
|
|
470
|
+
throw new Error('Multiple fee payers found in private execution result');
|
|
471
|
+
}
|
|
472
|
+
feePayer = contractAddress;
|
|
473
|
+
}
|
|
474
|
+
|
|
443
475
|
scopedNoteHashes.push(
|
|
444
476
|
...execution.publicInputs.noteHashes
|
|
445
477
|
.getActiveItems()
|
|
@@ -660,8 +692,8 @@ export async function generateSimulatedProvingResult(
|
|
|
660
692
|
daGas: TX_DA_GAS_OVERHEAD,
|
|
661
693
|
}),
|
|
662
694
|
),
|
|
663
|
-
/*feePayer=*/
|
|
664
|
-
/*expirationTimestamp=*/
|
|
695
|
+
/*feePayer=*/ feePayer,
|
|
696
|
+
/*expirationTimestamp=*/ expirationTimestamp,
|
|
665
697
|
hasPublicCalls ? inputsForPublic : undefined,
|
|
666
698
|
!hasPublicCalls ? inputsForRollup : undefined,
|
|
667
699
|
);
|
|
@@ -809,9 +841,9 @@ function meterGasUsed(data: PrivateToRollupAccumulatedData | PrivateToPublicAccu
|
|
|
809
841
|
meteredL2Gas += numPrivatelogs * L2_GAS_PER_PRIVATE_LOG;
|
|
810
842
|
|
|
811
843
|
const numContractClassLogs = arrayNonEmptyLength(data.contractClassLogsHashes, log => log.isEmpty());
|
|
812
|
-
// Every contract class log emits its
|
|
844
|
+
// Every contract class log emits its contract address as an additional field
|
|
813
845
|
meteredDAFields += data.contractClassLogsHashes.reduce(
|
|
814
|
-
(acc, log) => (!log.isEmpty() ? acc + log.logHash.length +
|
|
846
|
+
(acc, log) => (!log.isEmpty() ? acc + log.logHash.length + 1 : acc),
|
|
815
847
|
0,
|
|
816
848
|
);
|
|
817
849
|
meteredL2Gas += numContractClassLogs * L2_GAS_PER_CONTRACT_CLASS_LOG;
|
|
@@ -1,32 +1,37 @@
|
|
|
1
|
-
import { ExtendedDirectionalAppTaggingSecret, type
|
|
1
|
+
import { ExtendedDirectionalAppTaggingSecret, type TaggingIndexRange } from '@aztec/stdlib/logs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* A map that stores the tagging index for a given extended directional app tagging secret.
|
|
4
|
+
* A map that stores the tagging index range for a given extended directional app tagging secret.
|
|
5
5
|
* Note: The directional app tagging secret is unique for a (sender, recipient, contract) tuple while the direction
|
|
6
6
|
* of sender -> recipient matters.
|
|
7
7
|
*/
|
|
8
8
|
export class ExecutionTaggingIndexCache {
|
|
9
|
-
private taggingIndexMap: Map<string, number> = new Map();
|
|
9
|
+
private taggingIndexMap: Map<string, { lowestIndex: number; highestIndex: number }> = new Map();
|
|
10
10
|
|
|
11
11
|
public getLastUsedIndex(secret: ExtendedDirectionalAppTaggingSecret): number | undefined {
|
|
12
|
-
return this.taggingIndexMap.get(secret.toString());
|
|
12
|
+
return this.taggingIndexMap.get(secret.toString())?.highestIndex;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
public setLastUsedIndex(secret: ExtendedDirectionalAppTaggingSecret, index: number) {
|
|
16
16
|
const currentValue = this.taggingIndexMap.get(secret.toString());
|
|
17
|
-
if (currentValue !== undefined && currentValue !== index - 1) {
|
|
18
|
-
throw new Error(`Invalid tagging index update. Current value: ${currentValue}, new value: ${index}`);
|
|
17
|
+
if (currentValue !== undefined && currentValue.highestIndex !== index - 1) {
|
|
18
|
+
throw new Error(`Invalid tagging index update. Current value: ${currentValue.highestIndex}, new value: ${index}`);
|
|
19
|
+
}
|
|
20
|
+
if (currentValue !== undefined) {
|
|
21
|
+
currentValue.highestIndex = index;
|
|
22
|
+
} else {
|
|
23
|
+
this.taggingIndexMap.set(secret.toString(), { lowestIndex: index, highestIndex: index });
|
|
19
24
|
}
|
|
20
|
-
this.taggingIndexMap.set(secret.toString(), index);
|
|
21
25
|
}
|
|
22
26
|
|
|
23
27
|
/**
|
|
24
|
-
* Returns the
|
|
28
|
+
* Returns the tagging index ranges that were used in this execution (and that need to be stored in the db).
|
|
25
29
|
*/
|
|
26
|
-
public
|
|
27
|
-
return Array.from(this.taggingIndexMap.entries()).map(([secret,
|
|
30
|
+
public getUsedTaggingIndexRanges(): TaggingIndexRange[] {
|
|
31
|
+
return Array.from(this.taggingIndexMap.entries()).map(([secret, { lowestIndex, highestIndex }]) => ({
|
|
28
32
|
extendedSecret: ExtendedDirectionalAppTaggingSecret.fromString(secret),
|
|
29
|
-
|
|
33
|
+
lowestIndex,
|
|
34
|
+
highestIndex,
|
|
30
35
|
}));
|
|
31
36
|
}
|
|
32
37
|
}
|
|
@@ -4,6 +4,7 @@ export { HashedValuesCache } from './hashed_values_cache.js';
|
|
|
4
4
|
export { pickNotes } from './pick_notes.js';
|
|
5
5
|
export type { NoteData, IMiscOracle, IUtilityExecutionOracle, IPrivateExecutionOracle } from './oracle/interfaces.js';
|
|
6
6
|
export { MessageLoadOracleInputs } from './oracle/message_load_oracle_inputs.js';
|
|
7
|
+
export { MessageContextService } from '../messages/message_context_service.js';
|
|
7
8
|
export { UtilityExecutionOracle } from './oracle/utility_execution_oracle.js';
|
|
8
9
|
export { PrivateExecutionOracle } from './oracle/private_execution_oracle.js';
|
|
9
10
|
export { Oracle } from './oracle/oracle.js';
|
|
@@ -4,9 +4,6 @@ import { EventSelector } from '@aztec/stdlib/abi';
|
|
|
4
4
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
5
|
import { TxHash } from '@aztec/stdlib/tx';
|
|
6
6
|
|
|
7
|
-
// TODO(#14617): should we compute this from constants? This value is aztec-nr specific.
|
|
8
|
-
const MAX_EVENT_SERIALIZED_LEN = 11;
|
|
9
|
-
|
|
10
7
|
/**
|
|
11
8
|
* Intermediate struct used to perform batch event validation by PXE. The `utilityValidateAndStoreEnqueuedNotesAndEvents` oracle
|
|
12
9
|
* expects for values of this type to be stored in a `CapsuleArray`.
|
|
@@ -22,7 +19,7 @@ export class EventValidationRequest {
|
|
|
22
19
|
public recipient: AztecAddress,
|
|
23
20
|
) {}
|
|
24
21
|
|
|
25
|
-
static fromFields(fields: Fr[]
|
|
22
|
+
static fromFields(fields: Fr[], maxEventSerializedLen: number): EventValidationRequest {
|
|
26
23
|
const reader = FieldReader.asReader(fields);
|
|
27
24
|
|
|
28
25
|
const contractAddress = AztecAddress.fromField(reader.readField());
|
|
@@ -30,7 +27,7 @@ export class EventValidationRequest {
|
|
|
30
27
|
|
|
31
28
|
const randomness = reader.readField();
|
|
32
29
|
|
|
33
|
-
const eventStorage = reader.readFieldArray(
|
|
30
|
+
const eventStorage = reader.readFieldArray(maxEventSerializedLen);
|
|
34
31
|
const eventLen = reader.readField().toNumber();
|
|
35
32
|
const serializedEvent = eventStorage.slice(0, eventLen);
|
|
36
33
|
|
|
@@ -38,6 +35,12 @@ export class EventValidationRequest {
|
|
|
38
35
|
const txHash = TxHash.fromField(reader.readField());
|
|
39
36
|
const recipient = AztecAddress.fromField(reader.readField());
|
|
40
37
|
|
|
38
|
+
if (reader.remainingFields() !== 0) {
|
|
39
|
+
throw new Error(
|
|
40
|
+
`Error converting array of fields to EventValidationRequest: expected ${reader.cursor} fields but received ${fields.length} (maxEventSerializedLen=${maxEventSerializedLen}).`,
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
41
44
|
return new EventValidationRequest(
|
|
42
45
|
contractAddress,
|
|
43
46
|
eventTypeId,
|
|
@@ -3,10 +3,7 @@ import { range } from '@aztec/foundation/array';
|
|
|
3
3
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
4
|
import type { TxHash } from '@aztec/stdlib/tx';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const MAX_PUBLIC_LOG_LEN_FOR_NOTE_COMPLETION = MAX_NOTE_PACKED_LEN;
|
|
9
|
-
const MAX_LOG_CONTENT_LEN = Math.max(MAX_PUBLIC_LOG_LEN_FOR_NOTE_COMPLETION, PRIVATE_LOG_CIPHERTEXT_LEN);
|
|
6
|
+
const MAX_LOG_CONTENT_LEN = PRIVATE_LOG_CIPHERTEXT_LEN;
|
|
10
7
|
|
|
11
8
|
/**
|
|
12
9
|
* Intermediate struct used to perform batch log retrieval by PXE. The `utilityBulkRetrieveLogs` oracle stores values of this
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { MAX_NOTE_HASHES_PER_TX } from '@aztec/constants';
|
|
2
|
+
import { range } from '@aztec/foundation/array';
|
|
3
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
|
+
import type { TxHash } from '@aztec/stdlib/tx';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Intermediate struct used to return resolved message contexts from PXE. The
|
|
8
|
+
* `utilityResolveMessageContexts` oracle stores values of this type in a CapsuleArray.
|
|
9
|
+
*/
|
|
10
|
+
export class MessageTxContext {
|
|
11
|
+
constructor(
|
|
12
|
+
public txHash: TxHash,
|
|
13
|
+
public uniqueNoteHashesInTx: Fr[],
|
|
14
|
+
public firstNullifierInTx: Fr,
|
|
15
|
+
) {}
|
|
16
|
+
|
|
17
|
+
toFields(): Fr[] {
|
|
18
|
+
return [
|
|
19
|
+
this.txHash.hash,
|
|
20
|
+
...serializeBoundedVec(this.uniqueNoteHashesInTx, MAX_NOTE_HASHES_PER_TX),
|
|
21
|
+
this.firstNullifierInTx,
|
|
22
|
+
];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
static toEmptyFields(): Fr[] {
|
|
26
|
+
const serializationLen =
|
|
27
|
+
1 /* txHash */ + MAX_NOTE_HASHES_PER_TX + 1 /* uniqueNoteHashesInTx BVec */ + 1; /* firstNullifierInTx */
|
|
28
|
+
return range(serializationLen).map(_ => Fr.zero());
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
static toSerializedOption(response: MessageTxContext | null): Fr[] {
|
|
32
|
+
if (response) {
|
|
33
|
+
return [new Fr(1), ...response.toFields()];
|
|
34
|
+
} else {
|
|
35
|
+
return [new Fr(0), ...MessageTxContext.toEmptyFields()];
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Helper function to serialize a bounded vector according to Noir's BoundedVec format
|
|
42
|
+
* @param values - The values to serialize
|
|
43
|
+
* @param maxLength - The maximum length of the bounded vector
|
|
44
|
+
* @returns The serialized bounded vector as Fr[]
|
|
45
|
+
*/
|
|
46
|
+
function serializeBoundedVec(values: Fr[], maxLength: number): Fr[] {
|
|
47
|
+
if (values.length > maxLength) {
|
|
48
|
+
throw new Error(`Attempted to serialize ${values} values into a BoundedVec with max length ${maxLength}`);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const lengthDiff = maxLength - values.length;
|
|
52
|
+
const zeroPaddingArray = Array(lengthDiff).fill(Fr.ZERO);
|
|
53
|
+
const storage = values.concat(zeroPaddingArray);
|
|
54
|
+
return [...storage, new Fr(values.length)];
|
|
55
|
+
}
|
|
@@ -3,9 +3,6 @@ import { FieldReader } from '@aztec/foundation/serialize';
|
|
|
3
3
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
4
|
import { TxHash } from '@aztec/stdlib/tx';
|
|
5
5
|
|
|
6
|
-
// TODO(#14617): should we compute this from constants? This value is aztec-nr specific.
|
|
7
|
-
export const MAX_NOTE_PACKED_LEN = 9;
|
|
8
|
-
|
|
9
6
|
/**
|
|
10
7
|
* Intermediate struct used to perform batch note validation by PXE. The `utilityValidateAndStoreEnqueuedNotesAndEvents` oracle
|
|
11
8
|
* expects for values of this type to be stored in a `CapsuleArray`.
|
|
@@ -24,7 +21,7 @@ export class NoteValidationRequest {
|
|
|
24
21
|
public recipient: AztecAddress,
|
|
25
22
|
) {}
|
|
26
23
|
|
|
27
|
-
static fromFields(fields: Fr[]
|
|
24
|
+
static fromFields(fields: Fr[], maxNotePackedLen: number): NoteValidationRequest {
|
|
28
25
|
const reader = FieldReader.asReader(fields);
|
|
29
26
|
|
|
30
27
|
const contractAddress = AztecAddress.fromField(reader.readField());
|
|
@@ -33,7 +30,7 @@ export class NoteValidationRequest {
|
|
|
33
30
|
const randomness = reader.readField();
|
|
34
31
|
const noteNonce = reader.readField();
|
|
35
32
|
|
|
36
|
-
const contentStorage = reader.readFieldArray(
|
|
33
|
+
const contentStorage = reader.readFieldArray(maxNotePackedLen);
|
|
37
34
|
const contentLen = reader.readField().toNumber();
|
|
38
35
|
const content = contentStorage.slice(0, contentLen);
|
|
39
36
|
|
|
@@ -44,7 +41,7 @@ export class NoteValidationRequest {
|
|
|
44
41
|
|
|
45
42
|
if (reader.remainingFields() !== 0) {
|
|
46
43
|
throw new Error(
|
|
47
|
-
`Error converting array of fields to NoteValidationRequest
|
|
44
|
+
`Error converting array of fields to NoteValidationRequest: expected ${reader.cursor} fields but received ${fields.length} (maxNotePackedLen=${maxNotePackedLen}).`,
|
|
48
45
|
);
|
|
49
46
|
}
|
|
50
47
|
|
|
@@ -6,8 +6,9 @@ import { MembershipWitness } from '@aztec/foundation/trees';
|
|
|
6
6
|
import type { FunctionSelector, NoteSelector } from '@aztec/stdlib/abi';
|
|
7
7
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
8
8
|
import { BlockHash } from '@aztec/stdlib/block';
|
|
9
|
-
import type {
|
|
9
|
+
import type { ContractInstance, PartialAddress } from '@aztec/stdlib/contract';
|
|
10
10
|
import type { KeyValidationRequest } from '@aztec/stdlib/kernel';
|
|
11
|
+
import type { PublicKeys } from '@aztec/stdlib/keys';
|
|
11
12
|
import type { ContractClassLog, Tag } from '@aztec/stdlib/logs';
|
|
12
13
|
import type { Note, NoteStatus } from '@aztec/stdlib/note';
|
|
13
14
|
import { type NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
|
|
@@ -52,9 +53,9 @@ export interface NoteData {
|
|
|
52
53
|
export interface IMiscOracle {
|
|
53
54
|
isMisc: true;
|
|
54
55
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
getRandomField(): Fr;
|
|
57
|
+
assertCompatibleOracleVersion(version: number): void;
|
|
58
|
+
log(level: number, message: string, fields: Fr[]): Promise<void>;
|
|
58
59
|
}
|
|
59
60
|
|
|
60
61
|
/**
|
|
@@ -64,30 +65,32 @@ export interface IMiscOracle {
|
|
|
64
65
|
export interface IUtilityExecutionOracle {
|
|
65
66
|
isUtility: true;
|
|
66
67
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
getUtilityContext(): UtilityContext;
|
|
69
|
+
getKeyValidationRequest(pkMHash: Fr): Promise<KeyValidationRequest>;
|
|
70
|
+
getContractInstance(address: AztecAddress): Promise<ContractInstance>;
|
|
71
|
+
getNoteHashMembershipWitness(
|
|
71
72
|
anchorBlockHash: BlockHash,
|
|
72
73
|
noteHash: Fr,
|
|
73
74
|
): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT> | undefined>;
|
|
74
|
-
|
|
75
|
+
getBlockHashMembershipWitness(
|
|
75
76
|
anchorBlockHash: BlockHash,
|
|
76
77
|
blockHash: BlockHash,
|
|
77
78
|
): Promise<MembershipWitness<typeof ARCHIVE_HEIGHT> | undefined>;
|
|
78
|
-
|
|
79
|
+
getNullifierMembershipWitness(
|
|
79
80
|
anchorBlockHash: BlockHash,
|
|
80
81
|
nullifier: Fr,
|
|
81
82
|
): Promise<NullifierMembershipWitness | undefined>;
|
|
82
|
-
|
|
83
|
-
|
|
83
|
+
getPublicDataWitness(anchorBlockHash: BlockHash, leafSlot: Fr): Promise<PublicDataWitness | undefined>;
|
|
84
|
+
getLowNullifierMembershipWitness(
|
|
84
85
|
anchorBlockHash: BlockHash,
|
|
85
86
|
nullifier: Fr,
|
|
86
87
|
): Promise<NullifierMembershipWitness | undefined>;
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
getBlockHeader(blockNumber: BlockNumber): Promise<BlockHeader | undefined>;
|
|
89
|
+
tryGetPublicKeysAndPartialAddress(
|
|
90
|
+
account: AztecAddress,
|
|
91
|
+
): Promise<{ publicKeys: PublicKeys; partialAddress: PartialAddress } | undefined>;
|
|
92
|
+
getAuthWitness(messageHash: Fr): Promise<Fr[] | undefined>;
|
|
93
|
+
getNotes(
|
|
91
94
|
owner: AztecAddress | undefined,
|
|
92
95
|
storageSlot: Fr,
|
|
93
96
|
numSelects: number,
|
|
@@ -104,35 +107,44 @@ export interface IUtilityExecutionOracle {
|
|
|
104
107
|
offset: number,
|
|
105
108
|
status: NoteStatus,
|
|
106
109
|
): Promise<NoteData[]>;
|
|
107
|
-
|
|
108
|
-
|
|
110
|
+
checkNullifierExists(innerNullifier: Fr): Promise<boolean>;
|
|
111
|
+
getL1ToL2MembershipWitness(
|
|
109
112
|
contractAddress: AztecAddress,
|
|
110
113
|
messageHash: Fr,
|
|
111
114
|
secret: Fr,
|
|
112
115
|
): Promise<MessageLoadOracleInputs<typeof L1_TO_L2_MSG_TREE_HEIGHT>>;
|
|
113
|
-
|
|
116
|
+
storageRead(
|
|
114
117
|
anchorBlockHash: BlockHash,
|
|
115
118
|
contractAddress: AztecAddress,
|
|
116
119
|
startStorageSlot: Fr,
|
|
117
120
|
numberOfElements: number,
|
|
118
121
|
): Promise<Fr[]>;
|
|
119
|
-
|
|
120
|
-
|
|
122
|
+
fetchTaggedLogs(pendingTaggedLogArrayBaseSlot: Fr): Promise<void>;
|
|
123
|
+
validateAndStoreEnqueuedNotesAndEvents(
|
|
121
124
|
contractAddress: AztecAddress,
|
|
122
125
|
noteValidationRequestsArrayBaseSlot: Fr,
|
|
123
126
|
eventValidationRequestsArrayBaseSlot: Fr,
|
|
127
|
+
maxNotePackedLen: number,
|
|
128
|
+
maxEventSerializedLen: number,
|
|
124
129
|
): Promise<void>;
|
|
125
|
-
|
|
130
|
+
bulkRetrieveLogs(
|
|
126
131
|
contractAddress: AztecAddress,
|
|
127
132
|
logRetrievalRequestsArrayBaseSlot: Fr,
|
|
128
133
|
logRetrievalResponsesArrayBaseSlot: Fr,
|
|
129
134
|
): Promise<void>;
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
135
|
+
utilityResolveMessageContexts(
|
|
136
|
+
contractAddress: AztecAddress,
|
|
137
|
+
messageContextRequestsArrayBaseSlot: Fr,
|
|
138
|
+
messageContextResponsesArrayBaseSlot: Fr,
|
|
139
|
+
): Promise<void>;
|
|
140
|
+
storeCapsule(contractAddress: AztecAddress, key: Fr, capsule: Fr[]): Promise<void>;
|
|
141
|
+
loadCapsule(contractAddress: AztecAddress, key: Fr): Promise<Fr[] | null>;
|
|
142
|
+
deleteCapsule(contractAddress: AztecAddress, key: Fr): Promise<void>;
|
|
143
|
+
copyCapsule(contractAddress: AztecAddress, srcKey: Fr, dstKey: Fr, numEntries: number): Promise<void>;
|
|
144
|
+
aes128Decrypt(ciphertext: Buffer, iv: Buffer, symKey: Buffer): Promise<Buffer>;
|
|
145
|
+
getSharedSecret(address: AztecAddress, ephPk: Point): Promise<Point>;
|
|
146
|
+
invalidateContractSyncCache(contractAddress: AztecAddress, scopes: AztecAddress[]): void;
|
|
147
|
+
emitOffchainEffect(data: Fr[]): Promise<void>;
|
|
136
148
|
}
|
|
137
149
|
|
|
138
150
|
/**
|
|
@@ -142,9 +154,9 @@ export interface IUtilityExecutionOracle {
|
|
|
142
154
|
export interface IPrivateExecutionOracle {
|
|
143
155
|
isPrivate: true;
|
|
144
156
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
157
|
+
storeInExecutionCache(values: Fr[], hash: Fr): void;
|
|
158
|
+
loadFromExecutionCache(hash: Fr): Promise<Fr[]>;
|
|
159
|
+
notifyCreatedNote(
|
|
148
160
|
owner: AztecAddress,
|
|
149
161
|
storageSlot: Fr,
|
|
150
162
|
randomness: Fr,
|
|
@@ -153,33 +165,21 @@ export interface IPrivateExecutionOracle {
|
|
|
153
165
|
noteHash: Fr,
|
|
154
166
|
counter: number,
|
|
155
167
|
): void;
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
168
|
+
notifyNullifiedNote(innerNullifier: Fr, noteHash: Fr, counter: number): Promise<void>;
|
|
169
|
+
notifyCreatedNullifier(innerNullifier: Fr): Promise<void>;
|
|
170
|
+
isNullifierPending(innerNullifier: Fr, contractAddress: AztecAddress): Promise<boolean>;
|
|
171
|
+
notifyCreatedContractClassLog(log: ContractClassLog, counter: number): void;
|
|
172
|
+
callPrivateFunction(
|
|
161
173
|
targetContractAddress: AztecAddress,
|
|
162
174
|
functionSelector: FunctionSelector,
|
|
163
175
|
argsHash: Fr,
|
|
164
176
|
sideEffectCounter: number,
|
|
165
177
|
isStaticCall: boolean,
|
|
166
178
|
): Promise<{ endSideEffectCounter: Fr; returnsHash: Fr }>;
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
): Promise<
|
|
173
|
-
privateNotifySetPublicTeardownFunctionCall(
|
|
174
|
-
targetContractAddress: AztecAddress,
|
|
175
|
-
calldataHash: Fr,
|
|
176
|
-
sideEffectCounter: number,
|
|
177
|
-
isStaticCall: boolean,
|
|
178
|
-
): Promise<void>;
|
|
179
|
-
privateNotifySetMinRevertibleSideEffectCounter(minRevertibleSideEffectCounter: number): Promise<void>;
|
|
180
|
-
privateIsSideEffectCounterRevertible(sideEffectCounter: number): Promise<boolean>;
|
|
181
|
-
privateGetSenderForTags(): Promise<AztecAddress | undefined>;
|
|
182
|
-
privateSetSenderForTags(senderForTags: AztecAddress): Promise<void>;
|
|
183
|
-
privateGetNextAppTagAsSender(sender: AztecAddress, recipient: AztecAddress): Promise<Tag>;
|
|
184
|
-
utilityEmitOffchainEffect(data: Fr[]): Promise<void>;
|
|
179
|
+
validatePublicCalldata(calldataHash: Fr): Promise<void>;
|
|
180
|
+
notifyRevertiblePhaseStart(minRevertibleSideEffectCounter: number): Promise<void>;
|
|
181
|
+
inRevertiblePhase(sideEffectCounter: number): Promise<boolean>;
|
|
182
|
+
getSenderForTags(): Promise<AztecAddress | undefined>;
|
|
183
|
+
setSenderForTags(senderForTags: AztecAddress): Promise<void>;
|
|
184
|
+
getNextAppTagAsSender(sender: AztecAddress, recipient: AztecAddress): Promise<Tag>;
|
|
185
185
|
}
|