@aztec/pxe 0.0.1-commit.f5d02921e → 0.0.1-commit.f7ea82942
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 +6 -2
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +13 -1
- package/dest/config/index.d.ts +1 -1
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +7 -14
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +6 -4
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +6 -4
- 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 +1 -1
- package/dest/contract_function_simulator/noir-structs/event_validation_request.js +1 -1
- 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 +1 -1
- package/dest/contract_function_simulator/noir-structs/note_validation_request.js +1 -1
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +13 -2
- 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 +10 -1
- package/dest/contract_function_simulator/oracle/oracle.d.ts +13 -2
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +98 -3
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +4 -4
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +19 -4
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +30 -16
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +106 -37
- 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 +20 -3
- 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_sync/contract_sync_service.d.ts +4 -6
- package/dest/contract_sync/contract_sync_service.d.ts.map +1 -1
- package/dest/contract_sync/contract_sync_service.js +38 -46
- package/dest/contract_sync/helpers.d.ts +2 -3
- package/dest/contract_sync/helpers.d.ts.map +1 -1
- 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 +1 -1
- package/dest/events/event_service.d.ts.map +1 -1
- package/dest/events/event_service.js +10 -1
- package/dest/events/private_event_filter_validator.d.ts +3 -2
- package/dest/events/private_event_filter_validator.d.ts.map +1 -1
- package/dest/events/private_event_filter_validator.js +15 -0
- package/dest/logs/log_service.d.ts +6 -6
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +15 -21
- package/dest/notes/note_service.d.ts +3 -4
- package/dest/notes/note_service.d.ts.map +1 -1
- 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/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 +4 -7
- package/dest/private_kernel/private_kernel_oracle.d.ts +5 -5
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle.js +12 -15
- package/dest/pxe.d.ts +5 -5
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +27 -20
- package/dest/storage/anchor_block_store/anchor_block_store.js +1 -1
- package/dest/storage/capsule_store/capsule_service.d.ts +2 -3
- package/dest/storage/capsule_store/capsule_service.d.ts.map +1 -1
- package/dest/storage/capsule_store/capsule_service.js +1 -1
- package/dest/storage/capsule_store/capsule_store.d.ts +1 -1
- package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -1
- package/dest/storage/capsule_store/capsule_store.js +8 -5
- package/dest/storage/contract_store/contract_store.d.ts +1 -1
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
- package/dest/storage/contract_store/contract_store.js +4 -2
- 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/dest/storage/private_event_store/private_event_store.d.ts +1 -1
- package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
- package/dest/storage/private_event_store/private_event_store.js +3 -0
- package/dest/storage/private_event_store/stored_private_event.js +1 -1
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +2 -2
- 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 +2 -16
- package/package.json +16 -16
- package/src/bin/check_oracle_version.ts +4 -4
- package/src/block_synchronizer/block_synchronizer.ts +16 -2
- package/src/config/index.ts +2 -8
- package/src/contract_function_simulator/contract_function_simulator.ts +9 -7
- package/src/contract_function_simulator/ephemeral_array_service.ts +110 -0
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +1 -1
- 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 -1
- package/src/contract_function_simulator/oracle/interfaces.ts +20 -1
- package/src/contract_function_simulator/oracle/legacy_oracle_mappings.ts +7 -1
- package/src/contract_function_simulator/oracle/oracle.ts +143 -3
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +28 -6
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +171 -67
- package/src/contract_function_simulator/pick_notes.ts +22 -3
- package/src/contract_function_simulator/proxied_contract_data_source.ts +8 -1
- package/src/contract_sync/contract_sync_service.ts +64 -80
- package/src/contract_sync/helpers.ts +2 -3
- 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 +13 -1
- package/src/events/private_event_filter_validator.ts +21 -1
- package/src/logs/log_service.ts +24 -50
- package/src/notes/note_service.ts +2 -3
- package/src/notes_filter.ts +1 -3
- package/src/oracle_version.ts +20 -10
- package/src/private_kernel/private_kernel_execution_prover.ts +4 -9
- package/src/private_kernel/private_kernel_oracle.ts +14 -14
- package/src/pxe.ts +61 -26
- package/src/storage/anchor_block_store/anchor_block_store.ts +1 -1
- package/src/storage/capsule_store/capsule_service.ts +5 -6
- package/src/storage/capsule_store/capsule_store.ts +15 -5
- package/src/storage/contract_store/contract_store.ts +8 -6
- package/src/storage/note_store/note_store.ts +2 -5
- package/src/storage/private_event_store/private_event_store.ts +4 -0
- package/src/storage/private_event_store/stored_private_event.ts +1 -1
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +5 -15
- 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/src/access_scopes.ts +0 -9
|
@@ -13,8 +13,9 @@ import { ORACLE_INTERFACE_HASH } from '../oracle_version.js';
|
|
|
13
13
|
*
|
|
14
14
|
* The Oracle interface needs to be versioned to ensure compatibility between Aztec.nr and PXE. This function computes
|
|
15
15
|
* a hash of the Oracle interface and compares it against a known hash. If they don't match, it means the interface has
|
|
16
|
-
* changed and the
|
|
17
|
-
*
|
|
16
|
+
* changed and the oracle version needs to be bumped:
|
|
17
|
+
* - If the change is backward-breaking (e.g. removing/renaming an oracle), bump ORACLE_VERSION_MAJOR.
|
|
18
|
+
* - If the change is an oracle addition (non-breaking), bump ORACLE_VERSION_MINOR.
|
|
18
19
|
*
|
|
19
20
|
* TODO(#16581): The following only takes into consideration changes to the oracles defined in Oracle.ts and omits TXE
|
|
20
21
|
* oracles. Ensure this checks TXE oracles as well. This hasn't been implemented yet since we don't have a clean TXE
|
|
@@ -26,9 +27,8 @@ function assertOracleInterfaceMatches(): void {
|
|
|
26
27
|
// We use keccak256 here just because we already have it in the dependencies.
|
|
27
28
|
const oracleInterfaceHash = keccak256String(oracleInterfaceSignature);
|
|
28
29
|
if (oracleInterfaceHash !== ORACLE_INTERFACE_HASH) {
|
|
29
|
-
// This check exists only to notify you when you need to update the ORACLE_VERSION constant.
|
|
30
30
|
throw new Error(
|
|
31
|
-
`The Oracle interface has changed
|
|
31
|
+
`The Oracle interface has changed. Update ORACLE_INTERFACE_HASH to ${oracleInterfaceHash} in pxe/src/oracle_version.ts and bump the oracle version (ORACLE_VERSION_MAJOR for breaking changes, ORACLE_VERSION_MINOR for oracle additions).`,
|
|
32
32
|
);
|
|
33
33
|
}
|
|
34
34
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
3
|
+
import { SerialQueue } from '@aztec/foundation/queue';
|
|
3
4
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
4
5
|
import type { L2TipsKVStore } from '@aztec/kv-store/stores';
|
|
5
6
|
import { BlockHash, L2BlockStream, type L2BlockStreamEvent, type L2BlockStreamEventHandler } from '@aztec/stdlib/block';
|
|
@@ -20,6 +21,7 @@ import type { PrivateEventStore } from '../storage/private_event_store/private_e
|
|
|
20
21
|
export class BlockSynchronizer implements L2BlockStreamEventHandler {
|
|
21
22
|
private log: Logger;
|
|
22
23
|
private isSyncing: Promise<void> | undefined;
|
|
24
|
+
private readonly eventQueue = new SerialQueue();
|
|
23
25
|
protected readonly blockStream: L2BlockStream;
|
|
24
26
|
|
|
25
27
|
constructor(
|
|
@@ -35,6 +37,7 @@ export class BlockSynchronizer implements L2BlockStreamEventHandler {
|
|
|
35
37
|
) {
|
|
36
38
|
this.log = createLogger('pxe:block_synchronizer', bindings);
|
|
37
39
|
this.blockStream = this.createBlockStream(config);
|
|
40
|
+
this.eventQueue.start();
|
|
38
41
|
}
|
|
39
42
|
|
|
40
43
|
protected createBlockStream(config: Partial<BlockSynchronizerConfig>): L2BlockStream {
|
|
@@ -52,8 +55,12 @@ export class BlockSynchronizer implements L2BlockStreamEventHandler {
|
|
|
52
55
|
);
|
|
53
56
|
}
|
|
54
57
|
|
|
55
|
-
/** Handle events emitted by the block stream. */
|
|
56
|
-
public
|
|
58
|
+
/** Handle events emitted by the block stream. Serialized to prevent concurrent mutations to anchor state. */
|
|
59
|
+
public handleBlockStreamEvent(event: L2BlockStreamEvent): Promise<void> {
|
|
60
|
+
return this.eventQueue.put(() => this.doHandleBlockStreamEvent(event));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
private async doHandleBlockStreamEvent(event: L2BlockStreamEvent): Promise<void> {
|
|
57
64
|
await this.l2TipsStore.handleBlockStreamEvent(event);
|
|
58
65
|
|
|
59
66
|
switch (event.type) {
|
|
@@ -167,6 +174,13 @@ export class BlockSynchronizer implements L2BlockStreamEventHandler {
|
|
|
167
174
|
}
|
|
168
175
|
}
|
|
169
176
|
|
|
177
|
+
/** Stops the block synchronizer, waiting for any in-progress sync and queued events to complete. */
|
|
178
|
+
public async stop() {
|
|
179
|
+
await this.isSyncing;
|
|
180
|
+
await this.blockStream.stop();
|
|
181
|
+
await this.eventQueue.end();
|
|
182
|
+
}
|
|
183
|
+
|
|
170
184
|
private async doSync() {
|
|
171
185
|
let currentHeader;
|
|
172
186
|
|
package/src/config/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
type ConfigMappingsType,
|
|
3
3
|
booleanConfigHelper,
|
|
4
|
+
enumConfigHelper,
|
|
4
5
|
getConfigFromMappings,
|
|
5
6
|
numberConfigHelper,
|
|
6
7
|
parseBooleanEnv,
|
|
@@ -58,14 +59,7 @@ export const pxeConfigMappings: ConfigMappingsType<PXEConfig> = {
|
|
|
58
59
|
syncChainTip: {
|
|
59
60
|
env: 'PXE_SYNC_CHAIN_TIP',
|
|
60
61
|
description: 'Which chain tip to sync to (proposed, checkpointed, proven, finalized)',
|
|
61
|
-
|
|
62
|
-
parseEnv: (val: string) => {
|
|
63
|
-
const allowedValues = ['proposed', 'checkpointed', 'proven', 'finalized'];
|
|
64
|
-
if (allowedValues.includes(val)) {
|
|
65
|
-
return val;
|
|
66
|
-
}
|
|
67
|
-
throw new Error(`Invalid value for PXE_SYNC_CHAIN_TIP: ${val}. Allowed values are: ${allowedValues.join(', ')}`);
|
|
68
|
-
},
|
|
62
|
+
...enumConfigHelper(['proposed', 'checkpointed', 'proven', 'finalized'], 'proposed'),
|
|
69
63
|
},
|
|
70
64
|
};
|
|
71
65
|
|
|
@@ -42,7 +42,7 @@ import type { FunctionCall } from '@aztec/stdlib/abi';
|
|
|
42
42
|
import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
43
43
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
44
44
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
45
|
-
import type { BlockParameter } from '@aztec/stdlib/block';
|
|
45
|
+
import type { BlockParameter, L2TipsProvider } from '@aztec/stdlib/block';
|
|
46
46
|
import { Gas } from '@aztec/stdlib/gas';
|
|
47
47
|
import {
|
|
48
48
|
computeNoteHashNonce,
|
|
@@ -89,7 +89,6 @@ import {
|
|
|
89
89
|
getFinalMinRevertibleSideEffectCounter,
|
|
90
90
|
} from '@aztec/stdlib/tx';
|
|
91
91
|
|
|
92
|
-
import type { AccessScopes } from '../access_scopes.js';
|
|
93
92
|
import type { ContractSyncService } from '../contract_sync/contract_sync_service.js';
|
|
94
93
|
import type { MessageContextService } from '../messages/message_context_service.js';
|
|
95
94
|
import type { AddressStore } from '../storage/address_store/address_store.js';
|
|
@@ -123,7 +122,7 @@ export type ContractSimulatorRunOpts = {
|
|
|
123
122
|
/** The address used as a tagging sender when emitting private logs. */
|
|
124
123
|
senderForTags?: AztecAddress;
|
|
125
124
|
/** The accounts whose notes we can access in this call. */
|
|
126
|
-
scopes:
|
|
125
|
+
scopes: AztecAddress[];
|
|
127
126
|
/** The job ID for staged writes. */
|
|
128
127
|
jobId: string;
|
|
129
128
|
};
|
|
@@ -135,6 +134,7 @@ export type ContractFunctionSimulatorArgs = {
|
|
|
135
134
|
keyStore: KeyStore;
|
|
136
135
|
addressStore: AddressStore;
|
|
137
136
|
aztecNode: AztecNode;
|
|
137
|
+
l2TipsStore: L2TipsProvider;
|
|
138
138
|
senderTaggingStore: SenderTaggingStore;
|
|
139
139
|
recipientTaggingStore: RecipientTaggingStore;
|
|
140
140
|
senderAddressBookStore: SenderAddressBookStore;
|
|
@@ -155,6 +155,7 @@ export class ContractFunctionSimulator {
|
|
|
155
155
|
private readonly keyStore: KeyStore;
|
|
156
156
|
private readonly addressStore: AddressStore;
|
|
157
157
|
private readonly aztecNode: AztecNode;
|
|
158
|
+
private readonly l2TipsStore: L2TipsProvider;
|
|
158
159
|
private readonly senderTaggingStore: SenderTaggingStore;
|
|
159
160
|
private readonly recipientTaggingStore: RecipientTaggingStore;
|
|
160
161
|
private readonly senderAddressBookStore: SenderAddressBookStore;
|
|
@@ -170,6 +171,7 @@ export class ContractFunctionSimulator {
|
|
|
170
171
|
this.keyStore = args.keyStore;
|
|
171
172
|
this.addressStore = args.addressStore;
|
|
172
173
|
this.aztecNode = args.aztecNode;
|
|
174
|
+
this.l2TipsStore = args.l2TipsStore;
|
|
173
175
|
this.senderTaggingStore = args.senderTaggingStore;
|
|
174
176
|
this.recipientTaggingStore = args.recipientTaggingStore;
|
|
175
177
|
this.senderAddressBookStore = args.senderAddressBookStore;
|
|
@@ -206,7 +208,7 @@ export class ContractFunctionSimulator {
|
|
|
206
208
|
}
|
|
207
209
|
|
|
208
210
|
if (request.origin !== contractAddress) {
|
|
209
|
-
|
|
211
|
+
throw new Error(
|
|
210
212
|
`Request origin does not match contract address in simulation. Request origin: ${request.origin}, contract address: ${contractAddress}`,
|
|
211
213
|
);
|
|
212
214
|
}
|
|
@@ -256,6 +258,7 @@ export class ContractFunctionSimulator {
|
|
|
256
258
|
scopes,
|
|
257
259
|
senderForTags,
|
|
258
260
|
simulator: this.simulator,
|
|
261
|
+
l2TipsStore: this.l2TipsStore,
|
|
259
262
|
});
|
|
260
263
|
|
|
261
264
|
const setupTime = simulatorSetupTimer.ms();
|
|
@@ -306,7 +309,6 @@ export class ContractFunctionSimulator {
|
|
|
306
309
|
}
|
|
307
310
|
}
|
|
308
311
|
|
|
309
|
-
// docs:start:execute_utility_function
|
|
310
312
|
/**
|
|
311
313
|
* Runs a utility function.
|
|
312
314
|
* @param call - The function call to execute.
|
|
@@ -320,7 +322,7 @@ export class ContractFunctionSimulator {
|
|
|
320
322
|
call: FunctionCall,
|
|
321
323
|
authwits: AuthWitness[],
|
|
322
324
|
anchorBlockHeader: BlockHeader,
|
|
323
|
-
scopes:
|
|
325
|
+
scopes: AztecAddress[],
|
|
324
326
|
jobId: string,
|
|
325
327
|
): Promise<{ result: Fr[]; offchainEffects: OffchainEffect[] }> {
|
|
326
328
|
const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
|
|
@@ -345,6 +347,7 @@ export class ContractFunctionSimulator {
|
|
|
345
347
|
privateEventStore: this.privateEventStore,
|
|
346
348
|
messageContextService: this.messageContextService,
|
|
347
349
|
contractSyncService: this.contractSyncService,
|
|
350
|
+
l2TipsStore: this.l2TipsStore,
|
|
348
351
|
jobId,
|
|
349
352
|
scopes,
|
|
350
353
|
});
|
|
@@ -380,7 +383,6 @@ export class ContractFunctionSimulator {
|
|
|
380
383
|
throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during private execution'));
|
|
381
384
|
}
|
|
382
385
|
}
|
|
383
|
-
// docs:end:execute_utility_function
|
|
384
386
|
|
|
385
387
|
/**
|
|
386
388
|
* Returns the execution statistics collected during the simulator run.
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
|
|
3
|
+
/** In-memory store for ephemeral arrays scoped to a single contract call frame. */
|
|
4
|
+
export class EphemeralArrayService {
|
|
5
|
+
/**
|
|
6
|
+
* Maps a slot to the elements of the array stored at that slot. Each element is a serialized representation of
|
|
7
|
+
* the original type.
|
|
8
|
+
*/
|
|
9
|
+
#arrays: Map<string, Fr[][]> = new Map();
|
|
10
|
+
|
|
11
|
+
/** Returns all elements in the array, or an empty array if uninitialized. */
|
|
12
|
+
readArrayAt(slot: Fr): Fr[][] {
|
|
13
|
+
return this.#arrays.get(slot.toString()) ?? [];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
#setArray(slot: Fr, array: Fr[][]): void {
|
|
17
|
+
this.#arrays.set(slot.toString(), array);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Returns the number of elements in the array at the given slot. */
|
|
21
|
+
len(slot: Fr): number {
|
|
22
|
+
return this.readArrayAt(slot).length;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Appends an element to the array and returns the new length. */
|
|
26
|
+
push(slot: Fr, elements: Fr[]): number {
|
|
27
|
+
const array = this.readArrayAt(slot);
|
|
28
|
+
array.push(elements);
|
|
29
|
+
this.#setArray(slot, array);
|
|
30
|
+
return array.length;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Removes and returns the last element. Throws if empty. */
|
|
34
|
+
pop(slot: Fr): Fr[] {
|
|
35
|
+
const array = this.readArrayAt(slot);
|
|
36
|
+
if (array.length === 0) {
|
|
37
|
+
throw new Error(`Ephemeral array at slot ${slot} is empty`);
|
|
38
|
+
}
|
|
39
|
+
const element = array.pop()!;
|
|
40
|
+
this.#setArray(slot, array);
|
|
41
|
+
return element;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Returns the element at the given index. Throws if out of bounds. */
|
|
45
|
+
get(slot: Fr, index: number): Fr[] {
|
|
46
|
+
const array = this.readArrayAt(slot);
|
|
47
|
+
if (index < 0 || index >= array.length) {
|
|
48
|
+
throw new Error(
|
|
49
|
+
`Ephemeral array index ${index} out of bounds for array of length ${array.length} at slot ${slot}`,
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
return array[index];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Overwrites the element at the given index. Throws if out of bounds. */
|
|
56
|
+
set(slot: Fr, index: number, value: Fr[]): void {
|
|
57
|
+
const array = this.readArrayAt(slot);
|
|
58
|
+
if (index < 0 || index >= array.length) {
|
|
59
|
+
throw new Error(
|
|
60
|
+
`Ephemeral array index ${index} out of bounds for array of length ${array.length} at slot ${slot}`,
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
array[index] = value;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Removes the element at the given index, shifting subsequent elements backward. Throws if out of bounds. */
|
|
67
|
+
remove(slot: Fr, index: number): void {
|
|
68
|
+
const array = this.readArrayAt(slot);
|
|
69
|
+
if (index < 0 || index >= array.length) {
|
|
70
|
+
throw new Error(
|
|
71
|
+
`Ephemeral array index ${index} out of bounds for array of length ${array.length} at slot ${slot}`,
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
array.splice(index, 1);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Removes all elements from the array. */
|
|
78
|
+
clear(slot: Fr): void {
|
|
79
|
+
this.#arrays.delete(slot.toString());
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** Allocates a fresh, unused slot for a new ephemeral array. */
|
|
83
|
+
allocateSlot(): Fr {
|
|
84
|
+
let slot: Fr;
|
|
85
|
+
do {
|
|
86
|
+
slot = Fr.random();
|
|
87
|
+
} while (this.#arrays.has(slot.toString()));
|
|
88
|
+
return slot;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** Creates a new ephemeral array pre-populated with the given elements and returns its slot. */
|
|
92
|
+
newArray(elements: Fr[][]): Fr {
|
|
93
|
+
const slot = this.allocateSlot();
|
|
94
|
+
this.#setArray(slot, elements);
|
|
95
|
+
return slot;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** Copies `count` elements from the source array to the destination array (overwrites destination). */
|
|
99
|
+
copy(srcSlot: Fr, dstSlot: Fr, count: number): void {
|
|
100
|
+
const srcArray = this.readArrayAt(srcSlot);
|
|
101
|
+
if (count > srcArray.length) {
|
|
102
|
+
throw new Error(
|
|
103
|
+
`Cannot copy ${count} elements from ephemeral array of length ${srcArray.length} at slot ${srcSlot}`,
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
// Deep copy the elements to avoid aliasing
|
|
107
|
+
const copied = srcArray.slice(0, count).map(el => [...el]);
|
|
108
|
+
this.#setArray(dstSlot, copied);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
@@ -6,7 +6,7 @@ import { TxHash } from '@aztec/stdlib/tx';
|
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Intermediate struct used to perform batch event validation by PXE. The `utilityValidateAndStoreEnqueuedNotesAndEvents` oracle
|
|
9
|
-
* expects for values of this type to be stored in a `
|
|
9
|
+
* expects for values of this type to be stored in a `EphemeralArray`.
|
|
10
10
|
*/
|
|
11
11
|
export class EventValidationRequest {
|
|
12
12
|
constructor(
|
|
@@ -5,7 +5,7 @@ import { Tag } from '@aztec/stdlib/logs';
|
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Intermediate struct used to perform batch log retrieval by PXE. The `utilityBulkRetrieveLogs` oracle expects values of this
|
|
8
|
-
* type to be stored in a `
|
|
8
|
+
* type to be stored in a `EphemeralArray`.
|
|
9
9
|
*/
|
|
10
10
|
export class LogRetrievalRequest {
|
|
11
11
|
constructor(
|
|
@@ -7,7 +7,7 @@ const MAX_LOG_CONTENT_LEN = PRIVATE_LOG_CIPHERTEXT_LEN;
|
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Intermediate struct used to perform batch log retrieval by PXE. The `utilityBulkRetrieveLogs` oracle stores values of this
|
|
10
|
-
* type in a `
|
|
10
|
+
* type in a `EphemeralArray`.
|
|
11
11
|
*/
|
|
12
12
|
export class LogRetrievalResponse {
|
|
13
13
|
constructor(
|
|
@@ -5,7 +5,7 @@ import { TxHash } from '@aztec/stdlib/tx';
|
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Intermediate struct used to perform batch note validation by PXE. The `utilityValidateAndStoreEnqueuedNotesAndEvents` oracle
|
|
8
|
-
* expects for values of this type to be stored in a `
|
|
8
|
+
* expects for values of this type to be stored in a `EphemeralArray`.
|
|
9
9
|
*/
|
|
10
10
|
export class NoteValidationRequest {
|
|
11
11
|
constructor(
|
|
@@ -54,7 +54,7 @@ export interface IMiscOracle {
|
|
|
54
54
|
isMisc: true;
|
|
55
55
|
|
|
56
56
|
getRandomField(): Fr;
|
|
57
|
-
assertCompatibleOracleVersion(
|
|
57
|
+
assertCompatibleOracleVersion(major: number, minor: number): void;
|
|
58
58
|
log(level: number, message: string, fields: Fr[]): Promise<void>;
|
|
59
59
|
}
|
|
60
60
|
|
|
@@ -120,6 +120,7 @@ export interface IUtilityExecutionOracle {
|
|
|
120
120
|
numberOfElements: number,
|
|
121
121
|
): Promise<Fr[]>;
|
|
122
122
|
getPendingTaggedLogs(pendingTaggedLogArrayBaseSlot: Fr, scope: AztecAddress): Promise<void>;
|
|
123
|
+
getPendingTaggedLogsV2(scope: AztecAddress): Promise<Fr>;
|
|
123
124
|
validateAndStoreEnqueuedNotesAndEvents(
|
|
124
125
|
contractAddress: AztecAddress,
|
|
125
126
|
noteValidationRequestsArrayBaseSlot: Fr,
|
|
@@ -134,6 +135,15 @@ export interface IUtilityExecutionOracle {
|
|
|
134
135
|
logRetrievalResponsesArrayBaseSlot: Fr,
|
|
135
136
|
scope: AztecAddress,
|
|
136
137
|
): Promise<void>;
|
|
138
|
+
validateAndStoreEnqueuedNotesAndEventsV2(
|
|
139
|
+
noteValidationRequestsArrayBaseSlot: Fr,
|
|
140
|
+
eventValidationRequestsArrayBaseSlot: Fr,
|
|
141
|
+
maxNotePackedLen: number,
|
|
142
|
+
maxEventSerializedLen: number,
|
|
143
|
+
scope: AztecAddress,
|
|
144
|
+
): Promise<void>;
|
|
145
|
+
getLogsByTagV2(requestArrayBaseSlot: Fr): Promise<Fr>;
|
|
146
|
+
getMessageContextsByTxHashV2(requestArrayBaseSlot: Fr): Promise<Fr>;
|
|
137
147
|
getMessageContextsByTxHash(
|
|
138
148
|
contractAddress: AztecAddress,
|
|
139
149
|
messageContextRequestsArrayBaseSlot: Fr,
|
|
@@ -154,6 +164,15 @@ export interface IUtilityExecutionOracle {
|
|
|
154
164
|
getSharedSecret(address: AztecAddress, ephPk: Point, contractAddress: AztecAddress): Promise<Fr>;
|
|
155
165
|
setContractSyncCacheInvalid(contractAddress: AztecAddress, scopes: AztecAddress[]): void;
|
|
156
166
|
emitOffchainEffect(data: Fr[]): Promise<void>;
|
|
167
|
+
|
|
168
|
+
// Ephemeral array methods
|
|
169
|
+
pushEphemeral(slot: Fr, elements: Fr[]): number;
|
|
170
|
+
popEphemeral(slot: Fr): Fr[];
|
|
171
|
+
getEphemeral(slot: Fr, index: number): Fr[];
|
|
172
|
+
setEphemeral(slot: Fr, index: number, elements: Fr[]): void;
|
|
173
|
+
getEphemeralLen(slot: Fr): number;
|
|
174
|
+
removeEphemeral(slot: Fr, index: number): void;
|
|
175
|
+
clearEphemeral(slot: Fr): void;
|
|
157
176
|
}
|
|
158
177
|
|
|
159
178
|
/**
|
|
@@ -10,6 +10,8 @@ import type { Oracle } from './oracle.js';
|
|
|
10
10
|
* TODO(F-416): Remove these aliases on v5 when protocol contracts are redeployed.
|
|
11
11
|
*/
|
|
12
12
|
export function buildLegacyOracleCallbacks(oracle: Oracle): ACIRCallback {
|
|
13
|
+
// If you are about to add a new mapping ensure that the old oracle name is different from the new one - this can
|
|
14
|
+
// commonly occur when only the args are getting modified.
|
|
13
15
|
return {
|
|
14
16
|
// Simple prefix renames (privateXxx/utilityXxx → aztec_prv_/aztec_utl_)
|
|
15
17
|
utilityLog: (
|
|
@@ -19,7 +21,11 @@ export function buildLegacyOracleCallbacks(oracle: Oracle): ACIRCallback {
|
|
|
19
21
|
fields: ACVMField[],
|
|
20
22
|
): Promise<ACVMField[]> => oracle.aztec_utl_log(level, message, _ignoredFieldsSize, fields),
|
|
21
23
|
utilityAssertCompatibleOracleVersion: (version: ACVMField[]): Promise<ACVMField[]> =>
|
|
22
|
-
oracle.
|
|
24
|
+
oracle.aztec_utl_assertCompatibleOracleVersionV2(version, [toACVMField(0)]),
|
|
25
|
+
// Old 1-arg oracle before minor/major split. Maps to V2 with minor=0.
|
|
26
|
+
// eslint-disable-next-line camelcase
|
|
27
|
+
aztec_utl_assertCompatibleOracleVersion: (version: ACVMField[]): Promise<ACVMField[]> =>
|
|
28
|
+
oracle.aztec_utl_assertCompatibleOracleVersionV2(version, [toACVMField(0)]),
|
|
23
29
|
utilityLoadCapsule: (
|
|
24
30
|
contractAddress: ACVMField[],
|
|
25
31
|
slot: ACVMField[],
|
|
@@ -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';
|
|
@@ -111,12 +112,67 @@ export class Oracle {
|
|
|
111
112
|
return acc;
|
|
112
113
|
}, {} as ACIRCallback);
|
|
113
114
|
|
|
114
|
-
|
|
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
|
+
});
|
|
115
168
|
}
|
|
116
169
|
|
|
117
170
|
// eslint-disable-next-line camelcase
|
|
118
|
-
|
|
119
|
-
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
|
+
);
|
|
120
176
|
return Promise.resolve([]);
|
|
121
177
|
}
|
|
122
178
|
|
|
@@ -523,6 +579,12 @@ export class Oracle {
|
|
|
523
579
|
return [];
|
|
524
580
|
}
|
|
525
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
|
+
|
|
526
588
|
// eslint-disable-next-line camelcase
|
|
527
589
|
async aztec_utl_validateAndStoreEnqueuedNotesAndEvents(
|
|
528
590
|
[contractAddress]: ACVMField[],
|
|
@@ -544,6 +606,24 @@ export class Oracle {
|
|
|
544
606
|
return [];
|
|
545
607
|
}
|
|
546
608
|
|
|
609
|
+
// eslint-disable-next-line camelcase
|
|
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
|
+
|
|
547
627
|
// eslint-disable-next-line camelcase
|
|
548
628
|
async aztec_utl_getLogsByTag(
|
|
549
629
|
[contractAddress]: ACVMField[],
|
|
@@ -576,6 +656,20 @@ export class Oracle {
|
|
|
576
656
|
return [];
|
|
577
657
|
}
|
|
578
658
|
|
|
659
|
+
// eslint-disable-next-line camelcase
|
|
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
|
+
|
|
579
673
|
// eslint-disable-next-line camelcase
|
|
580
674
|
aztec_utl_setCapsule(
|
|
581
675
|
[contractAddress]: ACVMField[],
|
|
@@ -648,6 +742,52 @@ export class Oracle {
|
|
|
648
742
|
return [];
|
|
649
743
|
}
|
|
650
744
|
|
|
745
|
+
// eslint-disable-next-line camelcase
|
|
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
|
+
|
|
651
791
|
// eslint-disable-next-line camelcase
|
|
652
792
|
async aztec_utl_decryptAes128(
|
|
653
793
|
ciphertextBVecStorage: ACVMField[],
|