@aztec/pxe 0.0.1-commit.3f296a7d2 → 0.0.1-commit.3f5453c7b
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/bin/check_oracle_version.js +4 -4
- package/dest/block_synchronizer/block_synchronizer.d.ts +1 -1
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +6 -0
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +3 -4
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +4 -3
- package/dest/contract_function_simulator/ephemeral_array_service.d.ts +28 -0
- package/dest/contract_function_simulator/ephemeral_array_service.d.ts.map +1 -0
- package/dest/contract_function_simulator/ephemeral_array_service.js +78 -0
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +3 -4
- 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 +3 -6
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +1 -1
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +3 -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 -6
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +31 -20
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts +1 -1
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.js +28 -23
- package/dest/contract_function_simulator/oracle/oracle.d.ts +50 -20
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +157 -41
- package/dest/contract_function_simulator/oracle/private_execution.js +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +7 -8
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +16 -7
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +53 -38
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +200 -93
- package/dest/contract_function_simulator/pick_notes.d.ts +1 -1
- package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -1
- package/dest/contract_function_simulator/pick_notes.js +9 -2
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +1 -1
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -1
- package/dest/contract_function_simulator/proxied_contract_data_source.js +3 -0
- package/dest/contract_logging.d.ts +9 -4
- package/dest/contract_logging.d.ts.map +1 -1
- package/dest/contract_logging.js +21 -6
- package/dest/contract_sync/contract_sync_service.d.ts +3 -4
- package/dest/contract_sync/contract_sync_service.d.ts.map +1 -1
- package/dest/contract_sync/contract_sync_service.js +12 -22
- package/dest/contract_sync/helpers.d.ts +2 -3
- package/dest/contract_sync/helpers.d.ts.map +1 -1
- package/dest/contract_sync/helpers.js +7 -2
- package/dest/debug/pxe_debug_utils.d.ts +3 -3
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.d.ts +1 -2
- package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.js +0 -1
- package/dest/entrypoints/client/bundle/utils.d.ts +2 -2
- package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/utils.js +2 -2
- package/dest/entrypoints/client/lazy/index.d.ts +1 -2
- package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/index.js +0 -1
- package/dest/entrypoints/client/lazy/utils.d.ts +2 -2
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +2 -2
- package/dest/entrypoints/pxe_creation_options.d.ts +3 -1
- package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
- package/dest/entrypoints/pxe_creation_options.js +3 -1
- package/dest/entrypoints/server/index.d.ts +2 -3
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +1 -2
- package/dest/entrypoints/server/utils.d.ts +2 -2
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +2 -2
- package/dest/events/event_service.d.ts +3 -2
- package/dest/events/event_service.d.ts.map +1 -1
- package/dest/events/event_service.js +16 -4
- package/dest/logs/log_service.d.ts +5 -8
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +24 -37
- package/dest/messages/message_context_service.d.ts +3 -3
- package/dest/messages/message_context_service.d.ts.map +1 -1
- package/dest/messages/message_context_service.js +3 -3
- 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 +14 -5
- package/dest/notes_filter.d.ts +2 -3
- package/dest/notes_filter.d.ts.map +1 -1
- package/dest/oracle_version.d.ts +4 -3
- package/dest/oracle_version.d.ts.map +1 -1
- package/dest/oracle_version.js +20 -10
- package/dest/pxe.d.ts +4 -5
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +6 -4
- package/dest/storage/capsule_store/capsule_service.d.ts +21 -0
- package/dest/storage/capsule_store/capsule_service.d.ts.map +1 -0
- package/dest/storage/capsule_store/capsule_service.js +50 -0
- package/dest/storage/capsule_store/capsule_store.d.ts +9 -9
- package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -1
- package/dest/storage/capsule_store/capsule_store.js +33 -28
- package/dest/storage/capsule_store/index.d.ts +2 -1
- package/dest/storage/capsule_store/index.d.ts.map +1 -1
- package/dest/storage/capsule_store/index.js +1 -0
- package/dest/storage/metadata.d.ts +1 -1
- package/dest/storage/metadata.js +1 -1
- package/dest/storage/note_store/note_store.d.ts +1 -1
- package/dest/storage/note_store/note_store.d.ts.map +1 -1
- package/dest/storage/note_store/note_store.js +2 -2
- package/package.json +16 -16
- package/src/bin/check_oracle_version.ts +4 -4
- package/src/block_synchronizer/block_synchronizer.ts +6 -0
- package/src/contract_function_simulator/contract_function_simulator.ts +6 -6
- package/src/contract_function_simulator/ephemeral_array_service.ts +110 -0
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +1 -4
- package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +1 -1
- package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +1 -1
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +1 -4
- package/src/contract_function_simulator/oracle/interfaces.ts +46 -18
- package/src/contract_function_simulator/oracle/legacy_oracle_mappings.ts +20 -51
- package/src/contract_function_simulator/oracle/oracle.ts +222 -36
- package/src/contract_function_simulator/oracle/private_execution.ts +1 -1
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +19 -10
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +337 -119
- package/src/contract_function_simulator/pick_notes.ts +9 -2
- package/src/contract_function_simulator/proxied_contract_data_source.ts +8 -1
- package/src/contract_logging.ts +18 -5
- package/src/contract_sync/contract_sync_service.ts +32 -43
- package/src/contract_sync/helpers.ts +4 -4
- package/src/debug/pxe_debug_utils.ts +3 -3
- package/src/entrypoints/client/bundle/index.ts +0 -1
- package/src/entrypoints/client/bundle/utils.ts +2 -3
- package/src/entrypoints/client/lazy/index.ts +0 -1
- package/src/entrypoints/client/lazy/utils.ts +2 -3
- package/src/entrypoints/pxe_creation_options.ts +7 -0
- package/src/entrypoints/server/index.ts +1 -2
- package/src/entrypoints/server/utils.ts +2 -3
- package/src/events/event_service.ts +17 -4
- package/src/logs/log_service.ts +52 -78
- package/src/messages/message_context_service.ts +3 -4
- package/src/notes/note_service.ts +18 -8
- package/src/notes_filter.ts +1 -3
- package/src/oracle_version.ts +20 -10
- package/src/pxe.ts +11 -10
- package/src/storage/capsule_store/capsule_service.ts +90 -0
- package/src/storage/capsule_store/capsule_store.ts +34 -26
- package/src/storage/capsule_store/index.ts +1 -0
- package/src/storage/metadata.ts +1 -1
- package/src/storage/note_store/note_store.ts +2 -5
- package/dest/access_scopes.d.ts +0 -9
- package/dest/access_scopes.d.ts.map +0 -1
- package/dest/access_scopes.js +0 -6
- package/dest/contract_function_simulator/noir-structs/message_tx_context.d.ts +0 -16
- package/dest/contract_function_simulator/noir-structs/message_tx_context.d.ts.map +0 -1
- package/dest/contract_function_simulator/noir-structs/message_tx_context.js +0 -57
- package/src/access_scopes.ts +0 -9
- package/src/contract_function_simulator/noir-structs/message_tx_context.ts +0 -55
|
@@ -15,6 +15,7 @@ import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
|
15
15
|
import { BlockHash } from '@aztec/stdlib/block';
|
|
16
16
|
import { ContractClassLog, ContractClassLogFields } from '@aztec/stdlib/logs';
|
|
17
17
|
|
|
18
|
+
import { ORACLE_VERSION_MAJOR, ORACLE_VERSION_MINOR } from '../../oracle_version.js';
|
|
18
19
|
import type { IMiscOracle, IPrivateExecutionOracle, IUtilityExecutionOracle } from './interfaces.js';
|
|
19
20
|
import { buildLegacyOracleCallbacks } from './legacy_oracle_mappings.js';
|
|
20
21
|
import { packAsHintedNote } from './note_packing_utils.js';
|
|
@@ -27,6 +28,25 @@ export class UnavailableOracleError extends Error {
|
|
|
27
28
|
|
|
28
29
|
/**
|
|
29
30
|
* A data source that has all the apis required by Aztec.nr.
|
|
31
|
+
*
|
|
32
|
+
* ## Oracle naming conventions
|
|
33
|
+
*
|
|
34
|
+
* We try to keep oracle naming consistent, please see below the conventions we adhere to.
|
|
35
|
+
*
|
|
36
|
+
* Each oracle method name has the form `aztec_{scope}_{verb}{Object}`, where:
|
|
37
|
+
*
|
|
38
|
+
* - **Scope prefix** indicates the execution context required:
|
|
39
|
+
* - `aztec_prv_` — available only during private function execution.
|
|
40
|
+
* - `aztec_utl_` — available during both utility and private execution.
|
|
41
|
+
*
|
|
42
|
+
* - **Verb** signals the operation's semantics (verb-first, then object):
|
|
43
|
+
* - `get` — read / lookup / get data from oracle into contract.
|
|
44
|
+
* - `does`/`is`/`has` — predicate (returns boolean).
|
|
45
|
+
* - `emit`/`notify` — propagate data from contract to oracle.
|
|
46
|
+
* - `set` — contract driven oracle state mutation (capsules, execution cache, tagging, etc).
|
|
47
|
+
* - `call` — trigger nested execution (control flow).
|
|
48
|
+
* - `assert` — validate a condition, throw on failure.
|
|
49
|
+
* - Standalone verbs (`delete`, `copy`, `decrypt`, `log`, etc) are used when no generic verb fits.
|
|
30
50
|
*/
|
|
31
51
|
export class Oracle {
|
|
32
52
|
constructor(private handler: IMiscOracle | IUtilityExecutionOracle | IPrivateExecutionOracle) {}
|
|
@@ -92,12 +112,67 @@ export class Oracle {
|
|
|
92
112
|
return acc;
|
|
93
113
|
}, {} as ACIRCallback);
|
|
94
114
|
|
|
95
|
-
|
|
115
|
+
const allCallbacks = { ...callback, ...buildLegacyOracleCallbacks(this) };
|
|
116
|
+
|
|
117
|
+
// Wrap in a Proxy to intercept access to missing oracle names and provide enhanced error messages when the
|
|
118
|
+
// contract's minor version is higher than the PXE's (i.e. the contract expects oracles that were added in a newer
|
|
119
|
+
// minor version).
|
|
120
|
+
const handler = this.handler;
|
|
121
|
+
return new Proxy(allCallbacks, {
|
|
122
|
+
get(target, prop: string) {
|
|
123
|
+
if (prop in target) {
|
|
124
|
+
return target[prop];
|
|
125
|
+
}
|
|
126
|
+
// Return a function that throws with an enhanced error message if applicable
|
|
127
|
+
return () => {
|
|
128
|
+
type NonOracleFunctionGetContractOracleVersion = {
|
|
129
|
+
nonOracleFunctionGetContractOracleVersion(): { major: number; minor: number } | undefined;
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
let contractVersion = undefined;
|
|
133
|
+
if ('nonOracleFunctionGetContractOracleVersion' in handler) {
|
|
134
|
+
contractVersion = (
|
|
135
|
+
handler as unknown as NonOracleFunctionGetContractOracleVersion
|
|
136
|
+
).nonOracleFunctionGetContractOracleVersion();
|
|
137
|
+
}
|
|
138
|
+
if (!contractVersion) {
|
|
139
|
+
throw new Error(
|
|
140
|
+
`Oracle '${prop}' not found and the contract's oracle version is unknown (the version check oracle ` +
|
|
141
|
+
`was not called before '${prop}'). This usually means the contract was not compiled with the ` +
|
|
142
|
+
`#[aztec] macro, which injects the version check as the first oracle call in every private/utility ` +
|
|
143
|
+
`external function. If you're using a custom entry point, ensure assert_compatible_oracle_version() ` +
|
|
144
|
+
`is called before any other oracle calls. See https://docs.aztec.network/errors/8`,
|
|
145
|
+
);
|
|
146
|
+
} else if (contractVersion.minor > ORACLE_VERSION_MINOR) {
|
|
147
|
+
throw new Error(
|
|
148
|
+
`Oracle '${prop}' not found.` +
|
|
149
|
+
` This usually means the contract requires a newer private execution environment than you have.` +
|
|
150
|
+
` Upgrade your private execution environment to a compatible version. The contract was compiled with` +
|
|
151
|
+
` Aztec.nr oracle version ${contractVersion.major}.${contractVersion.minor}, but this private` +
|
|
152
|
+
` execution environment only supports up to ${ORACLE_VERSION_MAJOR}.${ORACLE_VERSION_MINOR}.` +
|
|
153
|
+
` See https://docs.aztec.network/errors/8`,
|
|
154
|
+
);
|
|
155
|
+
} else {
|
|
156
|
+
throw new Error(
|
|
157
|
+
`Oracle '${prop}' not found.` +
|
|
158
|
+
` The contract's oracle version (${contractVersion.major}.${contractVersion.minor}) is compatible` +
|
|
159
|
+
` with this private execution environment (${ORACLE_VERSION_MAJOR}.${ORACLE_VERSION_MINOR}), so all` +
|
|
160
|
+
` standard oracles should be available. This could mean the contract was compiled against a modified` +
|
|
161
|
+
` version of Aztec.nr, or that it references an oracle that does not exist.` +
|
|
162
|
+
` See https://docs.aztec.network/errors/8`,
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
},
|
|
167
|
+
});
|
|
96
168
|
}
|
|
97
169
|
|
|
98
170
|
// eslint-disable-next-line camelcase
|
|
99
|
-
|
|
100
|
-
this.handlerAsMisc().assertCompatibleOracleVersion(
|
|
171
|
+
aztec_utl_assertCompatibleOracleVersionV2([major]: ACVMField[], [minor]: ACVMField[]) {
|
|
172
|
+
this.handlerAsMisc().assertCompatibleOracleVersion(
|
|
173
|
+
Fr.fromString(major).toNumber(),
|
|
174
|
+
Fr.fromString(minor).toNumber(),
|
|
175
|
+
);
|
|
101
176
|
return Promise.resolve([]);
|
|
102
177
|
}
|
|
103
178
|
|
|
@@ -108,14 +183,14 @@ export class Oracle {
|
|
|
108
183
|
}
|
|
109
184
|
|
|
110
185
|
// eslint-disable-next-line camelcase
|
|
111
|
-
|
|
112
|
-
this.handlerAsPrivate().
|
|
186
|
+
aztec_prv_setHashPreimage(values: ACVMField[], [hash]: ACVMField[]): Promise<ACVMField[]> {
|
|
187
|
+
this.handlerAsPrivate().setHashPreimage(values.map(Fr.fromString), Fr.fromString(hash));
|
|
113
188
|
return Promise.resolve([]);
|
|
114
189
|
}
|
|
115
190
|
|
|
116
191
|
// eslint-disable-next-line camelcase
|
|
117
|
-
async
|
|
118
|
-
const values = await this.handlerAsPrivate().
|
|
192
|
+
async aztec_prv_getHashPreimage([returnsHash]: ACVMField[]): Promise<ACVMField[][]> {
|
|
193
|
+
const values = await this.handlerAsPrivate().getHashPreimage(Fr.fromString(returnsHash));
|
|
119
194
|
return [values.map(toACVMField)];
|
|
120
195
|
}
|
|
121
196
|
|
|
@@ -252,9 +327,9 @@ export class Oracle {
|
|
|
252
327
|
}
|
|
253
328
|
|
|
254
329
|
// eslint-disable-next-line camelcase
|
|
255
|
-
async
|
|
330
|
+
async aztec_utl_getPublicKeysAndPartialAddress([address]: ACVMField[]): Promise<(ACVMField | ACVMField[])[]> {
|
|
256
331
|
const parsedAddress = AztecAddress.fromField(Fr.fromString(address));
|
|
257
|
-
const result = await this.handlerAsUtility().
|
|
332
|
+
const result = await this.handlerAsUtility().getPublicKeysAndPartialAddress(parsedAddress);
|
|
258
333
|
|
|
259
334
|
// We are going to return a Noir Option struct to represent the possibility of null values. Options are a struct
|
|
260
335
|
// with two fields: `some` (a boolean) and `value` (a field array in this case).
|
|
@@ -380,8 +455,8 @@ export class Oracle {
|
|
|
380
455
|
}
|
|
381
456
|
|
|
382
457
|
// eslint-disable-next-line camelcase
|
|
383
|
-
async
|
|
384
|
-
const exists = await this.handlerAsUtility().
|
|
458
|
+
async aztec_utl_doesNullifierExist([innerNullifier]: ACVMField[]): Promise<ACVMField[]> {
|
|
459
|
+
const exists = await this.handlerAsUtility().doesNullifierExist(Fr.fromString(innerNullifier));
|
|
385
460
|
return [toACVMField(exists)];
|
|
386
461
|
}
|
|
387
462
|
|
|
@@ -400,13 +475,13 @@ export class Oracle {
|
|
|
400
475
|
}
|
|
401
476
|
|
|
402
477
|
// eslint-disable-next-line camelcase
|
|
403
|
-
async
|
|
478
|
+
async aztec_utl_getFromPublicStorage(
|
|
404
479
|
[blockHash]: ACVMField[],
|
|
405
480
|
[contractAddress]: ACVMField[],
|
|
406
481
|
[startStorageSlot]: ACVMField[],
|
|
407
482
|
[numberOfElements]: ACVMField[],
|
|
408
483
|
): Promise<ACVMField[][]> {
|
|
409
|
-
const values = await this.handlerAsUtility().
|
|
484
|
+
const values = await this.handlerAsUtility().getFromPublicStorage(
|
|
410
485
|
BlockHash.fromString(blockHash),
|
|
411
486
|
new AztecAddress(Fr.fromString(contractAddress)),
|
|
412
487
|
Fr.fromString(startStorageSlot),
|
|
@@ -464,8 +539,8 @@ export class Oracle {
|
|
|
464
539
|
}
|
|
465
540
|
|
|
466
541
|
// eslint-disable-next-line camelcase
|
|
467
|
-
async
|
|
468
|
-
await this.handlerAsPrivate().
|
|
542
|
+
async aztec_prv_assertValidPublicCalldata([calldataHash]: ACVMField[]): Promise<ACVMField[]> {
|
|
543
|
+
await this.handlerAsPrivate().assertValidPublicCalldata(Fr.fromString(calldataHash));
|
|
469
544
|
return [];
|
|
470
545
|
}
|
|
471
546
|
|
|
@@ -476,8 +551,10 @@ export class Oracle {
|
|
|
476
551
|
}
|
|
477
552
|
|
|
478
553
|
// eslint-disable-next-line camelcase
|
|
479
|
-
async
|
|
480
|
-
const isRevertible = await this.handlerAsPrivate().
|
|
554
|
+
async aztec_prv_isExecutionInRevertiblePhase([sideEffectCounter]: ACVMField[]): Promise<ACVMField[]> {
|
|
555
|
+
const isRevertible = await this.handlerAsPrivate().isExecutionInRevertiblePhase(
|
|
556
|
+
Fr.fromString(sideEffectCounter).toNumber(),
|
|
557
|
+
);
|
|
481
558
|
return Promise.resolve([toACVMField(isRevertible)]);
|
|
482
559
|
}
|
|
483
560
|
|
|
@@ -491,11 +568,23 @@ export class Oracle {
|
|
|
491
568
|
}
|
|
492
569
|
|
|
493
570
|
// eslint-disable-next-line camelcase
|
|
494
|
-
async
|
|
495
|
-
|
|
571
|
+
async aztec_utl_getPendingTaggedLogs(
|
|
572
|
+
[pendingTaggedLogArrayBaseSlot]: ACVMField[],
|
|
573
|
+
[scope]: ACVMField[],
|
|
574
|
+
): Promise<ACVMField[]> {
|
|
575
|
+
await this.handlerAsUtility().getPendingTaggedLogs(
|
|
576
|
+
Fr.fromString(pendingTaggedLogArrayBaseSlot),
|
|
577
|
+
AztecAddress.fromString(scope),
|
|
578
|
+
);
|
|
496
579
|
return [];
|
|
497
580
|
}
|
|
498
581
|
|
|
582
|
+
// eslint-disable-next-line camelcase
|
|
583
|
+
async aztec_utl_getPendingTaggedLogs_v2([scope]: ACVMField[]): Promise<ACVMField[]> {
|
|
584
|
+
const slot = await this.handlerAsUtility().getPendingTaggedLogsV2(AztecAddress.fromString(scope));
|
|
585
|
+
return [toACVMField(slot)];
|
|
586
|
+
}
|
|
587
|
+
|
|
499
588
|
// eslint-disable-next-line camelcase
|
|
500
589
|
async aztec_utl_validateAndStoreEnqueuedNotesAndEvents(
|
|
501
590
|
[contractAddress]: ACVMField[],
|
|
@@ -503,6 +592,7 @@ export class Oracle {
|
|
|
503
592
|
[eventValidationRequestsArrayBaseSlot]: ACVMField[],
|
|
504
593
|
[maxNotePackedLen]: ACVMField[],
|
|
505
594
|
[maxEventSerializedLen]: ACVMField[],
|
|
595
|
+
[scope]: ACVMField[],
|
|
506
596
|
): Promise<ACVMField[]> {
|
|
507
597
|
await this.handlerAsUtility().validateAndStoreEnqueuedNotesAndEvents(
|
|
508
598
|
AztecAddress.fromString(contractAddress),
|
|
@@ -510,62 +600,103 @@ export class Oracle {
|
|
|
510
600
|
Fr.fromString(eventValidationRequestsArrayBaseSlot),
|
|
511
601
|
Fr.fromString(maxNotePackedLen).toNumber(),
|
|
512
602
|
Fr.fromString(maxEventSerializedLen).toNumber(),
|
|
603
|
+
AztecAddress.fromString(scope),
|
|
513
604
|
);
|
|
514
605
|
|
|
515
606
|
return [];
|
|
516
607
|
}
|
|
517
608
|
|
|
518
609
|
// eslint-disable-next-line camelcase
|
|
519
|
-
async
|
|
610
|
+
async aztec_utl_validateAndStoreEnqueuedNotesAndEvents_v2(
|
|
611
|
+
[noteValidationRequestsArrayBaseSlot]: ACVMField[],
|
|
612
|
+
[eventValidationRequestsArrayBaseSlot]: ACVMField[],
|
|
613
|
+
[maxNotePackedLen]: ACVMField[],
|
|
614
|
+
[maxEventSerializedLen]: ACVMField[],
|
|
615
|
+
[scope]: ACVMField[],
|
|
616
|
+
): Promise<ACVMField[]> {
|
|
617
|
+
await this.handlerAsUtility().validateAndStoreEnqueuedNotesAndEventsV2(
|
|
618
|
+
Fr.fromString(noteValidationRequestsArrayBaseSlot),
|
|
619
|
+
Fr.fromString(eventValidationRequestsArrayBaseSlot),
|
|
620
|
+
Fr.fromString(maxNotePackedLen).toNumber(),
|
|
621
|
+
Fr.fromString(maxEventSerializedLen).toNumber(),
|
|
622
|
+
AztecAddress.fromString(scope),
|
|
623
|
+
);
|
|
624
|
+
return [];
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
// eslint-disable-next-line camelcase
|
|
628
|
+
async aztec_utl_getLogsByTag(
|
|
520
629
|
[contractAddress]: ACVMField[],
|
|
521
630
|
[logRetrievalRequestsArrayBaseSlot]: ACVMField[],
|
|
522
631
|
[logRetrievalResponsesArrayBaseSlot]: ACVMField[],
|
|
632
|
+
[scope]: ACVMField[],
|
|
523
633
|
): Promise<ACVMField[]> {
|
|
524
|
-
await this.handlerAsUtility().
|
|
634
|
+
await this.handlerAsUtility().getLogsByTag(
|
|
525
635
|
AztecAddress.fromString(contractAddress),
|
|
526
636
|
Fr.fromString(logRetrievalRequestsArrayBaseSlot),
|
|
527
637
|
Fr.fromString(logRetrievalResponsesArrayBaseSlot),
|
|
638
|
+
AztecAddress.fromString(scope),
|
|
528
639
|
);
|
|
529
640
|
return [];
|
|
530
641
|
}
|
|
531
642
|
|
|
532
643
|
// eslint-disable-next-line camelcase
|
|
533
|
-
async
|
|
644
|
+
async aztec_utl_getMessageContextsByTxHash(
|
|
534
645
|
[contractAddress]: ACVMField[],
|
|
535
646
|
[messageContextRequestsArrayBaseSlot]: ACVMField[],
|
|
536
647
|
[messageContextResponsesArrayBaseSlot]: ACVMField[],
|
|
648
|
+
[scope]: ACVMField[],
|
|
537
649
|
): Promise<ACVMField[]> {
|
|
538
|
-
await this.handlerAsUtility().
|
|
650
|
+
await this.handlerAsUtility().getMessageContextsByTxHash(
|
|
539
651
|
AztecAddress.fromString(contractAddress),
|
|
540
652
|
Fr.fromString(messageContextRequestsArrayBaseSlot),
|
|
541
653
|
Fr.fromString(messageContextResponsesArrayBaseSlot),
|
|
654
|
+
AztecAddress.fromString(scope),
|
|
542
655
|
);
|
|
543
656
|
return [];
|
|
544
657
|
}
|
|
545
658
|
|
|
546
659
|
// eslint-disable-next-line camelcase
|
|
547
|
-
async
|
|
660
|
+
async aztec_utl_getLogsByTag_v2([requestArrayBaseSlot]: ACVMField[]): Promise<ACVMField[]> {
|
|
661
|
+
const responseSlot = await this.handlerAsUtility().getLogsByTagV2(Fr.fromString(requestArrayBaseSlot));
|
|
662
|
+
return [toACVMField(responseSlot)];
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
// eslint-disable-next-line camelcase
|
|
666
|
+
async aztec_utl_getMessageContextsByTxHash_v2([requestArrayBaseSlot]: ACVMField[]): Promise<ACVMField[]> {
|
|
667
|
+
const responseSlot = await this.handlerAsUtility().getMessageContextsByTxHashV2(
|
|
668
|
+
Fr.fromString(requestArrayBaseSlot),
|
|
669
|
+
);
|
|
670
|
+
return [toACVMField(responseSlot)];
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
// eslint-disable-next-line camelcase
|
|
674
|
+
aztec_utl_setCapsule(
|
|
548
675
|
[contractAddress]: ACVMField[],
|
|
549
676
|
[slot]: ACVMField[],
|
|
550
677
|
capsule: ACVMField[],
|
|
678
|
+
[scope]: ACVMField[],
|
|
551
679
|
): Promise<ACVMField[]> {
|
|
552
|
-
|
|
680
|
+
this.handlerAsUtility().setCapsule(
|
|
553
681
|
AztecAddress.fromField(Fr.fromString(contractAddress)),
|
|
554
682
|
Fr.fromString(slot),
|
|
555
683
|
capsule.map(Fr.fromString),
|
|
684
|
+
AztecAddress.fromField(Fr.fromString(scope)),
|
|
556
685
|
);
|
|
557
|
-
return [];
|
|
686
|
+
return Promise.resolve([]);
|
|
558
687
|
}
|
|
559
688
|
|
|
560
689
|
// eslint-disable-next-line camelcase
|
|
561
|
-
async
|
|
690
|
+
async aztec_utl_getCapsule(
|
|
562
691
|
[contractAddress]: ACVMField[],
|
|
563
692
|
[slot]: ACVMField[],
|
|
564
693
|
[tSize]: ACVMField[],
|
|
694
|
+
[scope]: ACVMField[],
|
|
565
695
|
): Promise<(ACVMField | ACVMField[])[]> {
|
|
566
|
-
const values = await this.handlerAsUtility().
|
|
696
|
+
const values = await this.handlerAsUtility().getCapsule(
|
|
567
697
|
AztecAddress.fromField(Fr.fromString(contractAddress)),
|
|
568
698
|
Fr.fromString(slot),
|
|
699
|
+
AztecAddress.fromField(Fr.fromString(scope)),
|
|
569
700
|
);
|
|
570
701
|
|
|
571
702
|
// We are going to return a Noir Option struct to represent the possibility of null values. Options are a struct
|
|
@@ -580,12 +711,17 @@ export class Oracle {
|
|
|
580
711
|
}
|
|
581
712
|
|
|
582
713
|
// eslint-disable-next-line camelcase
|
|
583
|
-
|
|
584
|
-
|
|
714
|
+
aztec_utl_deleteCapsule(
|
|
715
|
+
[contractAddress]: ACVMField[],
|
|
716
|
+
[slot]: ACVMField[],
|
|
717
|
+
[scope]: ACVMField[],
|
|
718
|
+
): Promise<ACVMField[]> {
|
|
719
|
+
this.handlerAsUtility().deleteCapsule(
|
|
585
720
|
AztecAddress.fromField(Fr.fromString(contractAddress)),
|
|
586
721
|
Fr.fromString(slot),
|
|
722
|
+
AztecAddress.fromField(Fr.fromString(scope)),
|
|
587
723
|
);
|
|
588
|
-
return [];
|
|
724
|
+
return Promise.resolve([]);
|
|
589
725
|
}
|
|
590
726
|
|
|
591
727
|
// eslint-disable-next-line camelcase
|
|
@@ -594,18 +730,66 @@ export class Oracle {
|
|
|
594
730
|
[srcSlot]: ACVMField[],
|
|
595
731
|
[dstSlot]: ACVMField[],
|
|
596
732
|
[numEntries]: ACVMField[],
|
|
733
|
+
[scope]: ACVMField[],
|
|
597
734
|
): Promise<ACVMField[]> {
|
|
598
735
|
await this.handlerAsUtility().copyCapsule(
|
|
599
736
|
AztecAddress.fromField(Fr.fromString(contractAddress)),
|
|
600
737
|
Fr.fromString(srcSlot),
|
|
601
738
|
Fr.fromString(dstSlot),
|
|
602
739
|
Fr.fromString(numEntries).toNumber(),
|
|
740
|
+
AztecAddress.fromField(Fr.fromString(scope)),
|
|
603
741
|
);
|
|
604
742
|
return [];
|
|
605
743
|
}
|
|
606
744
|
|
|
607
745
|
// eslint-disable-next-line camelcase
|
|
608
|
-
|
|
746
|
+
aztec_utl_pushEphemeral([slot]: ACVMField[], elements: ACVMField[]): Promise<ACVMField[]> {
|
|
747
|
+
const newLen = this.handlerAsUtility().pushEphemeral(Fr.fromString(slot), elements.map(Fr.fromString));
|
|
748
|
+
return Promise.resolve([toACVMField(newLen)]);
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
// eslint-disable-next-line camelcase
|
|
752
|
+
aztec_utl_popEphemeral([slot]: ACVMField[]): Promise<ACVMField[][]> {
|
|
753
|
+
const element = this.handlerAsUtility().popEphemeral(Fr.fromString(slot));
|
|
754
|
+
return Promise.resolve([element.map(toACVMField)]);
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
// eslint-disable-next-line camelcase
|
|
758
|
+
aztec_utl_getEphemeral([slot]: ACVMField[], [index]: ACVMField[]): Promise<ACVMField[][]> {
|
|
759
|
+
const element = this.handlerAsUtility().getEphemeral(Fr.fromString(slot), Fr.fromString(index).toNumber());
|
|
760
|
+
return Promise.resolve([element.map(toACVMField)]);
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
// eslint-disable-next-line camelcase
|
|
764
|
+
aztec_utl_setEphemeral([slot]: ACVMField[], [index]: ACVMField[], elements: ACVMField[]): Promise<ACVMField[]> {
|
|
765
|
+
this.handlerAsUtility().setEphemeral(
|
|
766
|
+
Fr.fromString(slot),
|
|
767
|
+
Fr.fromString(index).toNumber(),
|
|
768
|
+
elements.map(Fr.fromString),
|
|
769
|
+
);
|
|
770
|
+
return Promise.resolve([]);
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
// eslint-disable-next-line camelcase
|
|
774
|
+
aztec_utl_getEphemeralLen([slot]: ACVMField[]): Promise<ACVMField[]> {
|
|
775
|
+
const len = this.handlerAsUtility().getEphemeralLen(Fr.fromString(slot));
|
|
776
|
+
return Promise.resolve([toACVMField(len)]);
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
// eslint-disable-next-line camelcase
|
|
780
|
+
aztec_utl_removeEphemeral([slot]: ACVMField[], [index]: ACVMField[]): Promise<ACVMField[]> {
|
|
781
|
+
this.handlerAsUtility().removeEphemeral(Fr.fromString(slot), Fr.fromString(index).toNumber());
|
|
782
|
+
return Promise.resolve([]);
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
// eslint-disable-next-line camelcase
|
|
786
|
+
aztec_utl_clearEphemeral([slot]: ACVMField[]): Promise<ACVMField[]> {
|
|
787
|
+
this.handlerAsUtility().clearEphemeral(Fr.fromString(slot));
|
|
788
|
+
return Promise.resolve([]);
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
// eslint-disable-next-line camelcase
|
|
792
|
+
async aztec_utl_decryptAes128(
|
|
609
793
|
ciphertextBVecStorage: ACVMField[],
|
|
610
794
|
[ciphertextLength]: ACVMField[],
|
|
611
795
|
iv: ACVMField[],
|
|
@@ -617,7 +801,7 @@ export class Oracle {
|
|
|
617
801
|
|
|
618
802
|
// Noir Option<BoundedVec> is encoded as [is_some: Field, storage: Field[], length: Field].
|
|
619
803
|
try {
|
|
620
|
-
const plaintext = await this.handlerAsUtility().
|
|
804
|
+
const plaintext = await this.handlerAsUtility().decryptAes128(ciphertext, ivBuffer, symKeyBuffer);
|
|
621
805
|
const [storage, length] = bufferToBoundedVec(plaintext, ciphertextBVecStorage.length);
|
|
622
806
|
return [toACVMField(1), storage, length];
|
|
623
807
|
} catch {
|
|
@@ -632,22 +816,24 @@ export class Oracle {
|
|
|
632
816
|
[ephPKField0]: ACVMField[],
|
|
633
817
|
[ephPKField1]: ACVMField[],
|
|
634
818
|
[ephPKField2]: ACVMField[],
|
|
819
|
+
[contractAddress]: ACVMField[],
|
|
635
820
|
): Promise<ACVMField[]> {
|
|
636
821
|
const secret = await this.handlerAsUtility().getSharedSecret(
|
|
637
822
|
AztecAddress.fromField(Fr.fromString(address)),
|
|
638
823
|
Point.fromFields([ephPKField0, ephPKField1, ephPKField2].map(Fr.fromString)),
|
|
824
|
+
AztecAddress.fromField(Fr.fromString(contractAddress)),
|
|
639
825
|
);
|
|
640
|
-
return secret
|
|
826
|
+
return [toACVMField(secret)];
|
|
641
827
|
}
|
|
642
828
|
|
|
643
829
|
// eslint-disable-next-line camelcase
|
|
644
|
-
|
|
830
|
+
aztec_utl_setContractSyncCacheInvalid(
|
|
645
831
|
[contractAddress]: ACVMField[],
|
|
646
832
|
scopes: ACVMField[],
|
|
647
833
|
[scopeCount]: ACVMField[],
|
|
648
834
|
): Promise<ACVMField[]> {
|
|
649
835
|
const scopeAddresses = scopes.slice(0, +scopeCount).map(s => AztecAddress.fromField(Fr.fromString(s)));
|
|
650
|
-
this.handlerAsUtility().
|
|
836
|
+
this.handlerAsUtility().setContractSyncCacheInvalid(
|
|
651
837
|
AztecAddress.fromField(Fr.fromString(contractAddress)),
|
|
652
838
|
scopeAddresses,
|
|
653
839
|
);
|
|
@@ -76,7 +76,7 @@ export async function executePrivateFunction(
|
|
|
76
76
|
|
|
77
77
|
const contractClassLogs = privateExecutionOracle.getContractClassLogs();
|
|
78
78
|
|
|
79
|
-
const rawReturnValues = await privateExecutionOracle.
|
|
79
|
+
const rawReturnValues = await privateExecutionOracle.getHashPreimage(publicInputs.returnsHash);
|
|
80
80
|
|
|
81
81
|
const newNotes = privateExecutionOracle.getNewNotes();
|
|
82
82
|
const noteHashNullifierCounterMap = privateExecutionOracle.getNoteHashNullifierCounterMap();
|
|
@@ -25,7 +25,6 @@ import {
|
|
|
25
25
|
type TxContext,
|
|
26
26
|
} from '@aztec/stdlib/tx';
|
|
27
27
|
|
|
28
|
-
import type { AccessScopes } from '../../access_scopes.js';
|
|
29
28
|
import { NoteService } from '../../notes/note_service.js';
|
|
30
29
|
import type { SenderTaggingStore } from '../../storage/tagging_store/sender_tagging_store.js';
|
|
31
30
|
import { syncSenderTaggingIndexes } from '../../tagging/index.js';
|
|
@@ -43,7 +42,7 @@ export type PrivateExecutionOracleArgs = Omit<UtilityExecutionOracleArgs, 'contr
|
|
|
43
42
|
txContext: TxContext;
|
|
44
43
|
callContext: CallContext;
|
|
45
44
|
/** Needed to trigger contract synchronization before nested calls */
|
|
46
|
-
utilityExecutor: (call: FunctionCall, scopes:
|
|
45
|
+
utilityExecutor: (call: FunctionCall, scopes: AztecAddress[]) => Promise<void>;
|
|
47
46
|
executionCache: HashedValuesCache;
|
|
48
47
|
noteCache: ExecutionNoteCache;
|
|
49
48
|
taggingIndexCache: ExecutionTaggingIndexCache;
|
|
@@ -76,7 +75,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
|
|
|
76
75
|
private readonly argsHash: Fr;
|
|
77
76
|
private readonly txContext: TxContext;
|
|
78
77
|
private readonly callContext: CallContext;
|
|
79
|
-
private readonly utilityExecutor: (call: FunctionCall, scopes:
|
|
78
|
+
private readonly utilityExecutor: (call: FunctionCall, scopes: AztecAddress[]) => Promise<void>;
|
|
80
79
|
private readonly executionCache: HashedValuesCache;
|
|
81
80
|
private readonly noteCache: ExecutionNoteCache;
|
|
82
81
|
private readonly taggingIndexCache: ExecutionTaggingIndexCache;
|
|
@@ -210,6 +209,16 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
|
|
|
210
209
|
recipient,
|
|
211
210
|
);
|
|
212
211
|
|
|
212
|
+
if (!extendedSecret) {
|
|
213
|
+
// We'd only fail to compute an extended secret if the recipient is an invalid address. To prevent
|
|
214
|
+
// king-of-the-hill attacks, instead of failing we use a random tag. By including a correct-looking tag in the
|
|
215
|
+
// log, the transaction shape is preserved and no privacy is leaked, even if the tag is bogus.
|
|
216
|
+
this.logger.warn(`Computing a tag for invalid recipient ${recipient} - returning a random tag instead`, {
|
|
217
|
+
contractAddress: this.contractAddress,
|
|
218
|
+
});
|
|
219
|
+
return new Tag(Fr.random());
|
|
220
|
+
}
|
|
221
|
+
|
|
213
222
|
const index = await this.#getIndexToUseForSecret(extendedSecret);
|
|
214
223
|
this.logger.debug(
|
|
215
224
|
`Incrementing tagging index for sender: ${sender}, recipient: ${recipient}, contract: ${this.contractAddress} to ${index}`,
|
|
@@ -265,7 +274,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
|
|
|
265
274
|
* @param values - Values to store.
|
|
266
275
|
* @returns The hash of the values.
|
|
267
276
|
*/
|
|
268
|
-
public
|
|
277
|
+
public setHashPreimage(values: Fr[], hash: Fr) {
|
|
269
278
|
return this.executionCache.store(values, hash);
|
|
270
279
|
}
|
|
271
280
|
|
|
@@ -274,7 +283,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
|
|
|
274
283
|
* @param hash - Hash of the values.
|
|
275
284
|
* @returns The values.
|
|
276
285
|
*/
|
|
277
|
-
public
|
|
286
|
+
public getHashPreimage(hash: Fr): Promise<Fr[]> {
|
|
278
287
|
const preimage = this.executionCache.getPreimage(hash);
|
|
279
288
|
if (!preimage) {
|
|
280
289
|
throw new Error(`Preimage for hash ${hash.toString()} not found in cache`);
|
|
@@ -282,7 +291,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
|
|
|
282
291
|
return Promise.resolve(preimage);
|
|
283
292
|
}
|
|
284
293
|
|
|
285
|
-
override async
|
|
294
|
+
override async doesNullifierExist(innerNullifier: Fr): Promise<boolean> {
|
|
286
295
|
// This oracle must be overridden because while utility execution can only meaningfully check if a nullifier exists
|
|
287
296
|
// in the synched block, during private execution there's also the possibility of it being pending, i.e. created
|
|
288
297
|
// in the current transaction.
|
|
@@ -295,7 +304,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
|
|
|
295
304
|
|
|
296
305
|
return (
|
|
297
306
|
this.noteCache.getNullifiers(this.contractAddress).has(nullifier) ||
|
|
298
|
-
(await super.
|
|
307
|
+
(await super.doesNullifierExist(innerNullifier))
|
|
299
308
|
);
|
|
300
309
|
}
|
|
301
310
|
|
|
@@ -555,7 +564,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
|
|
|
555
564
|
senderTaggingStore: this.senderTaggingStore,
|
|
556
565
|
recipientTaggingStore: this.recipientTaggingStore,
|
|
557
566
|
senderAddressBookStore: this.senderAddressBookStore,
|
|
558
|
-
|
|
567
|
+
capsuleService: this.capsuleService,
|
|
559
568
|
privateEventStore: this.privateEventStore,
|
|
560
569
|
messageContextService: this.messageContextService,
|
|
561
570
|
contractSyncService: this.contractSyncService,
|
|
@@ -598,7 +607,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
|
|
|
598
607
|
}
|
|
599
608
|
|
|
600
609
|
/** Validates the calldata preimage exists in the cache and checks cumulative calldata size is within limits. */
|
|
601
|
-
public
|
|
610
|
+
public assertValidPublicCalldata(calldataHash: Fr) {
|
|
602
611
|
const calldata = this.executionCache.getPreimage(calldataHash);
|
|
603
612
|
if (!calldata) {
|
|
604
613
|
throw new Error('Calldata for public call not found in cache');
|
|
@@ -615,7 +624,7 @@ export class PrivateExecutionOracle extends UtilityExecutionOracle implements IP
|
|
|
615
624
|
return this.noteCache.setMinRevertibleSideEffectCounter(minRevertibleSideEffectCounter);
|
|
616
625
|
}
|
|
617
626
|
|
|
618
|
-
public
|
|
627
|
+
public isExecutionInRevertiblePhase(sideEffectCounter: number): Promise<boolean> {
|
|
619
628
|
return Promise.resolve(this.noteCache.isSideEffectCounterRevertible(sideEffectCounter));
|
|
620
629
|
}
|
|
621
630
|
|