@aztec/pxe 0.0.1-commit.934299a21 → 0.0.1-commit.949a33fd8
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_stream_source.d.ts +10 -0
- package/dest/block_synchronizer/block_stream_source.d.ts.map +1 -0
- package/dest/block_synchronizer/block_stream_source.js +37 -0
- 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 +30 -10
- package/dest/config/index.d.ts +2 -2
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +8 -15
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +13 -5
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +39 -13
- 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/execution_tagging_index_cache.d.ts +7 -7
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_tagging_index_cache.js +19 -11
- 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 +4 -6
- 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 +8 -10
- 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 +2 -2
- 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 +2 -4
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +4 -7
- 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 +6 -11
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +63 -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 +47 -0
- package/dest/contract_function_simulator/oracle/oracle.d.ts +76 -44
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +288 -96
- package/dest/contract_function_simulator/oracle/private_execution.js +5 -3
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +32 -59
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +67 -86
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +100 -60
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +326 -111
- 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_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 +6 -5
- package/dest/contract_sync/contract_sync_service.d.ts.map +1 -1
- package/dest/contract_sync/contract_sync_service.js +62 -43
- 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 +26 -5
- 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 +7 -8
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +29 -39
- 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/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/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 +25 -10
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +91 -42
- package/dest/storage/anchor_block_store/anchor_block_store.js +1 -1
- 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 +36 -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/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/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/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/storage/tagging_store/recipient_tagging_store.d.ts +6 -6
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.d.ts +29 -28
- 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 +3 -3
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/index.js +1 -1
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +4 -5
- 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 +4 -18
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +6 -7
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -1
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +12 -11
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +4 -8
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +13 -7
- 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 +5 -7
- 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 +36 -24
- package/package.json +16 -16
- package/src/bin/check_oracle_version.ts +4 -4
- package/src/block_synchronizer/block_stream_source.ts +52 -0
- package/src/block_synchronizer/block_synchronizer.ts +33 -11
- package/src/config/index.ts +3 -9
- package/src/contract_function_simulator/contract_function_simulator.ts +52 -16
- package/src/contract_function_simulator/ephemeral_array_service.ts +110 -0
- package/src/contract_function_simulator/execution_tagging_index_cache.ts +19 -14
- package/src/contract_function_simulator/index.ts +1 -0
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +9 -9
- package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +1 -1
- package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +2 -5
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +4 -10
- package/src/contract_function_simulator/oracle/interfaces.ts +91 -53
- package/src/contract_function_simulator/oracle/legacy_oracle_mappings.ts +104 -0
- package/src/contract_function_simulator/oracle/oracle.ts +377 -139
- package/src/contract_function_simulator/oracle/private_execution.ts +4 -4
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +87 -109
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +530 -148
- 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_logging.ts +18 -5
- package/src/contract_sync/contract_sync_service.ts +99 -75
- 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 +30 -5
- package/src/events/private_event_filter_validator.ts +21 -1
- package/src/logs/log_service.ts +59 -75
- package/src/messages/message_context_service.ts +44 -0
- package/src/notes/note_service.ts +18 -8
- 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 +153 -53
- package/src/storage/anchor_block_store/anchor_block_store.ts +1 -1
- package/src/storage/capsule_store/capsule_service.ts +90 -0
- package/src/storage/capsule_store/capsule_store.ts +44 -26
- package/src/storage/capsule_store/index.ts +1 -0
- package/src/storage/contract_store/contract_store.ts +8 -6
- package/src/storage/metadata.ts +1 -1
- 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/storage/tagging_store/recipient_tagging_store.ts +9 -5
- package/src/storage/tagging_store/sender_tagging_store.ts +185 -138
- package/src/tagging/index.ts +2 -2
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +8 -21
- package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +10 -15
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +23 -10
- 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 +27 -26
- 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
package/src/pxe.ts
CHANGED
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
} from '@aztec/stdlib/abi';
|
|
19
19
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
20
20
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
21
|
+
import type { L2TipsProvider } from '@aztec/stdlib/block';
|
|
21
22
|
import {
|
|
22
23
|
CompleteAddress,
|
|
23
24
|
type ContractInstanceWithAddress,
|
|
@@ -52,7 +53,6 @@ import {
|
|
|
52
53
|
|
|
53
54
|
import { inspect } from 'util';
|
|
54
55
|
|
|
55
|
-
import type { AccessScopes } from './access_scopes.js';
|
|
56
56
|
import { BlockSynchronizer } from './block_synchronizer/index.js';
|
|
57
57
|
import type { PXEConfig } from './config/index.js';
|
|
58
58
|
import { BenchmarkedNodeFactory } from './contract_function_simulator/benchmarked_node.js';
|
|
@@ -68,6 +68,7 @@ import { PXEDebugUtils } from './debug/pxe_debug_utils.js';
|
|
|
68
68
|
import { enrichPublicSimulationError, enrichSimulationError } from './error_enriching.js';
|
|
69
69
|
import { PrivateEventFilterValidator } from './events/private_event_filter_validator.js';
|
|
70
70
|
import { JobCoordinator } from './job_coordinator/job_coordinator.js';
|
|
71
|
+
import { MessageContextService } from './messages/message_context_service.js';
|
|
71
72
|
import {
|
|
72
73
|
PrivateKernelExecutionProver,
|
|
73
74
|
type PrivateKernelExecutionProverConfig,
|
|
@@ -88,6 +89,14 @@ export type PackedPrivateEvent = InTx & {
|
|
|
88
89
|
eventSelector: EventSelector;
|
|
89
90
|
};
|
|
90
91
|
|
|
92
|
+
/** Options for PXE.proveTx. */
|
|
93
|
+
export type ProveTxOpts = {
|
|
94
|
+
/** Addresses whose private state and keys are accessible during private execution. */
|
|
95
|
+
scopes: AztecAddress[];
|
|
96
|
+
/** Sender address used to derive discovery tags for private messages (notes, events, logs) this tx emits. */
|
|
97
|
+
senderForTags?: AztecAddress;
|
|
98
|
+
};
|
|
99
|
+
|
|
91
100
|
/** Options for PXE.profileTx. */
|
|
92
101
|
export type ProfileTxOpts = {
|
|
93
102
|
/** The profiling mode to use. */
|
|
@@ -95,7 +104,9 @@ export type ProfileTxOpts = {
|
|
|
95
104
|
/** If true, proof generation is skipped during profiling. Defaults to true. */
|
|
96
105
|
skipProofGeneration?: boolean;
|
|
97
106
|
/** Addresses whose private state and keys are accessible during private execution. */
|
|
98
|
-
scopes:
|
|
107
|
+
scopes: AztecAddress[];
|
|
108
|
+
/** Sender address used to derive discovery tags for private messages (notes, events, logs) this tx emits. */
|
|
109
|
+
senderForTags?: AztecAddress;
|
|
99
110
|
};
|
|
100
111
|
|
|
101
112
|
/** Options for PXE.simulateTx. */
|
|
@@ -106,10 +117,14 @@ export type SimulateTxOpts = {
|
|
|
106
117
|
skipTxValidation?: boolean;
|
|
107
118
|
/** If false, fees are enforced. */
|
|
108
119
|
skipFeeEnforcement?: boolean;
|
|
109
|
-
/**
|
|
120
|
+
/** If true, kernel logic is emulated in TS for simulation */
|
|
121
|
+
skipKernels?: boolean;
|
|
122
|
+
/** State overrides for the simulation, such as contract instances and artifacts. Requires skipKernels: true */
|
|
110
123
|
overrides?: SimulationOverrides;
|
|
111
124
|
/** Addresses whose private state and keys are accessible during private execution */
|
|
112
|
-
scopes:
|
|
125
|
+
scopes: AztecAddress[];
|
|
126
|
+
/** Sender address used to derive discovery tags for private messages (notes, events, logs) this tx emits. */
|
|
127
|
+
senderForTags?: AztecAddress;
|
|
113
128
|
};
|
|
114
129
|
|
|
115
130
|
/** Options for PXE.executeUtility. */
|
|
@@ -117,7 +132,7 @@ export type ExecuteUtilityOpts = {
|
|
|
117
132
|
/** The authentication witnesses required for the function call. */
|
|
118
133
|
authwits?: AuthWitness[];
|
|
119
134
|
/** The accounts whose notes we can access in this call */
|
|
120
|
-
scopes:
|
|
135
|
+
scopes: AztecAddress[];
|
|
121
136
|
};
|
|
122
137
|
|
|
123
138
|
/** Args for PXE.create. */
|
|
@@ -145,6 +160,7 @@ export type PXECreateArgs = {
|
|
|
145
160
|
export class PXE {
|
|
146
161
|
private constructor(
|
|
147
162
|
private node: AztecNode,
|
|
163
|
+
private db: AztecAsyncKVStore,
|
|
148
164
|
private blockStateSynchronizer: BlockSynchronizer,
|
|
149
165
|
private keyStore: KeyStore,
|
|
150
166
|
private contractStore: ContractStore,
|
|
@@ -157,6 +173,8 @@ export class PXE {
|
|
|
157
173
|
private addressStore: AddressStore,
|
|
158
174
|
private privateEventStore: PrivateEventStore,
|
|
159
175
|
private contractSyncService: ContractSyncService,
|
|
176
|
+
private messageContextService: MessageContextService,
|
|
177
|
+
private l2TipsStore: L2TipsProvider,
|
|
160
178
|
private simulator: CircuitSimulator,
|
|
161
179
|
private proverEnabled: boolean,
|
|
162
180
|
private proofCreator: PrivateKernelProver,
|
|
@@ -212,6 +230,8 @@ export class PXE {
|
|
|
212
230
|
noteStore,
|
|
213
231
|
createLogger('pxe:contract_sync', bindings),
|
|
214
232
|
);
|
|
233
|
+
const messageContextService = new MessageContextService(node);
|
|
234
|
+
|
|
215
235
|
const synchronizer = new BlockSynchronizer(
|
|
216
236
|
node,
|
|
217
237
|
store,
|
|
@@ -240,6 +260,7 @@ export class PXE {
|
|
|
240
260
|
|
|
241
261
|
const pxe = new PXE(
|
|
242
262
|
node,
|
|
263
|
+
store,
|
|
243
264
|
synchronizer,
|
|
244
265
|
keyStore,
|
|
245
266
|
contractStore,
|
|
@@ -252,6 +273,8 @@ export class PXE {
|
|
|
252
273
|
addressStore,
|
|
253
274
|
privateEventStore,
|
|
254
275
|
contractSyncService,
|
|
276
|
+
messageContextService,
|
|
277
|
+
tipsStore,
|
|
255
278
|
simulator,
|
|
256
279
|
proverEnabled,
|
|
257
280
|
proofCreator,
|
|
@@ -286,6 +309,7 @@ export class PXE {
|
|
|
286
309
|
keyStore: this.keyStore,
|
|
287
310
|
addressStore: this.addressStore,
|
|
288
311
|
aztecNode: BenchmarkedNodeFactory.create(this.node),
|
|
312
|
+
l2TipsStore: this.l2TipsStore,
|
|
289
313
|
senderTaggingStore: this.senderTaggingStore,
|
|
290
314
|
recipientTaggingStore: this.recipientTaggingStore,
|
|
291
315
|
senderAddressBookStore: this.senderAddressBookStore,
|
|
@@ -293,6 +317,7 @@ export class PXE {
|
|
|
293
317
|
privateEventStore: this.privateEventStore,
|
|
294
318
|
simulator: this.simulator,
|
|
295
319
|
contractSyncService: this.contractSyncService,
|
|
320
|
+
messageContextService: this.messageContextService,
|
|
296
321
|
});
|
|
297
322
|
}
|
|
298
323
|
|
|
@@ -355,17 +380,24 @@ export class PXE {
|
|
|
355
380
|
|
|
356
381
|
// Executes the entrypoint private function, as well as all nested private
|
|
357
382
|
// functions that might arise.
|
|
358
|
-
async #executePrivate(
|
|
359
|
-
contractFunctionSimulator
|
|
360
|
-
txRequest
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
383
|
+
async #executePrivate({
|
|
384
|
+
contractFunctionSimulator,
|
|
385
|
+
txRequest,
|
|
386
|
+
anchorBlockHeader,
|
|
387
|
+
scopes,
|
|
388
|
+
jobId,
|
|
389
|
+
senderForTags,
|
|
390
|
+
}: {
|
|
391
|
+
contractFunctionSimulator: ContractFunctionSimulator;
|
|
392
|
+
txRequest: TxExecutionRequest;
|
|
393
|
+
anchorBlockHeader: BlockHeader;
|
|
394
|
+
scopes: AztecAddress[];
|
|
395
|
+
jobId: string;
|
|
396
|
+
senderForTags?: AztecAddress;
|
|
397
|
+
}): Promise<PrivateExecutionResult> {
|
|
364
398
|
const { origin: contractAddress, functionSelector } = txRequest;
|
|
365
399
|
|
|
366
400
|
try {
|
|
367
|
-
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
368
|
-
|
|
369
401
|
await this.contractSyncService.ensureContractSynced(
|
|
370
402
|
contractAddress,
|
|
371
403
|
functionSelector,
|
|
@@ -382,6 +414,7 @@ export class PXE {
|
|
|
382
414
|
anchorBlockHeader,
|
|
383
415
|
scopes,
|
|
384
416
|
jobId,
|
|
417
|
+
senderForTags,
|
|
385
418
|
});
|
|
386
419
|
this.log.debug(`Private simulation completed for ${contractAddress.toString()}:${functionSelector}`);
|
|
387
420
|
return result;
|
|
@@ -407,12 +440,19 @@ export class PXE {
|
|
|
407
440
|
contractFunctionSimulator: ContractFunctionSimulator,
|
|
408
441
|
call: FunctionCall,
|
|
409
442
|
authWitnesses: AuthWitness[] | undefined,
|
|
410
|
-
scopes:
|
|
443
|
+
scopes: AztecAddress[],
|
|
411
444
|
jobId: string,
|
|
412
445
|
) {
|
|
413
446
|
try {
|
|
414
447
|
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
415
|
-
|
|
448
|
+
const { result, offchainEffects } = await contractFunctionSimulator.runUtility(
|
|
449
|
+
call,
|
|
450
|
+
authWitnesses ?? [],
|
|
451
|
+
anchorBlockHeader,
|
|
452
|
+
scopes,
|
|
453
|
+
jobId,
|
|
454
|
+
);
|
|
455
|
+
return { result, offchainEffects };
|
|
416
456
|
} catch (err) {
|
|
417
457
|
if (err instanceof SimulationError) {
|
|
418
458
|
await enrichSimulationError(err, this.contractStore, this.log);
|
|
@@ -463,11 +503,10 @@ export class PXE {
|
|
|
463
503
|
txExecutionRequest: TxExecutionRequest,
|
|
464
504
|
proofCreator: PrivateKernelProver,
|
|
465
505
|
privateExecutionResult: PrivateExecutionResult,
|
|
506
|
+
anchorBlockHeader: BlockHeader,
|
|
466
507
|
config: PrivateKernelExecutionProverConfig,
|
|
467
508
|
): Promise<PrivateKernelExecutionProofOutput<PrivateKernelTailCircuitPublicInputs>> {
|
|
468
|
-
const
|
|
469
|
-
const anchorBlockHash = await anchorBlockHeader.hash();
|
|
470
|
-
const kernelOracle = new PrivateKernelOracle(this.contractStore, this.keyStore, this.node, anchorBlockHash);
|
|
509
|
+
const kernelOracle = new PrivateKernelOracle(this.contractStore, this.keyStore, this.node, anchorBlockHeader);
|
|
471
510
|
const kernelTraceProver = new PrivateKernelExecutionProver(
|
|
472
511
|
kernelOracle,
|
|
473
512
|
proofCreator,
|
|
@@ -485,7 +524,9 @@ export class PXE {
|
|
|
485
524
|
* @returns The synced block header
|
|
486
525
|
*/
|
|
487
526
|
public getSyncedBlockHeader(): Promise<BlockHeader> {
|
|
488
|
-
return this
|
|
527
|
+
return this.#putInJobQueue(() => {
|
|
528
|
+
return this.anchorBlockStore.getBlockHeader();
|
|
529
|
+
});
|
|
489
530
|
}
|
|
490
531
|
|
|
491
532
|
/**
|
|
@@ -542,6 +583,12 @@ export class PXE {
|
|
|
542
583
|
* TODO: It's strange that we return the address here and I (benesjan) think we should drop the return value.
|
|
543
584
|
*/
|
|
544
585
|
public async registerSender(sender: AztecAddress): Promise<AztecAddress> {
|
|
586
|
+
if (!(await sender.isValid())) {
|
|
587
|
+
throw new Error(
|
|
588
|
+
`Address ${sender} is not valid: it does not correspond to a point on the Grumpkin curve. Cannot register it as a sender.`,
|
|
589
|
+
);
|
|
590
|
+
}
|
|
591
|
+
|
|
545
592
|
const accounts = await this.keyStore.getAccounts();
|
|
546
593
|
if (accounts.includes(sender)) {
|
|
547
594
|
this.log.info(`Sender:\n "${sender.toString()}"\n already registered.`);
|
|
@@ -552,6 +599,9 @@ export class PXE {
|
|
|
552
599
|
|
|
553
600
|
if (wasAdded) {
|
|
554
601
|
this.log.info(`Added sender:\n ${sender.toString()}`);
|
|
602
|
+
// Wipe the entire sync cache: the new sender's tagged logs could contain notes/events for any contract, so
|
|
603
|
+
// all contracts must re-sync to discover them. Queued to avoid wiping while a job is in flight.
|
|
604
|
+
await this.#putInJobQueue(() => Promise.resolve(this.contractSyncService.wipe()));
|
|
555
605
|
} else {
|
|
556
606
|
this.log.info(`Sender:\n "${sender.toString()}"\n already registered.`);
|
|
557
607
|
}
|
|
@@ -711,7 +761,7 @@ export class PXE {
|
|
|
711
761
|
* @throws If contract code not found, or public simulation reverts.
|
|
712
762
|
* Also throws if simulatePublic is true and public simulation reverts.
|
|
713
763
|
*/
|
|
714
|
-
public proveTx(txRequest: TxExecutionRequest, scopes:
|
|
764
|
+
public proveTx(txRequest: TxExecutionRequest, { scopes, senderForTags }: ProveTxOpts): Promise<TxProvingResult> {
|
|
715
765
|
let privateExecutionResult: PrivateExecutionResult;
|
|
716
766
|
// We disable proving concurrently mostly out of caution, since it accesses some of our stores. Proving is so
|
|
717
767
|
// computationally demanding that it'd be rare for someone to try to do it concurrently regardless.
|
|
@@ -720,16 +770,24 @@ export class PXE {
|
|
|
720
770
|
try {
|
|
721
771
|
const syncTimer = new Timer();
|
|
722
772
|
await this.blockStateSynchronizer.sync();
|
|
773
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
723
774
|
const syncTime = syncTimer.ms();
|
|
724
775
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
725
|
-
privateExecutionResult = await this.#executePrivate(
|
|
776
|
+
privateExecutionResult = await this.#executePrivate({
|
|
777
|
+
contractFunctionSimulator,
|
|
778
|
+
txRequest,
|
|
779
|
+
anchorBlockHeader,
|
|
780
|
+
scopes,
|
|
781
|
+
jobId,
|
|
782
|
+
senderForTags,
|
|
783
|
+
});
|
|
726
784
|
|
|
727
785
|
const {
|
|
728
786
|
publicInputs,
|
|
729
787
|
chonkProof,
|
|
730
788
|
executionSteps,
|
|
731
789
|
timings: { proving } = {},
|
|
732
|
-
} = await this.#prove(txRequest, this.proofCreator, privateExecutionResult, {
|
|
790
|
+
} = await this.#prove(txRequest, this.proofCreator, privateExecutionResult, anchorBlockHeader, {
|
|
733
791
|
simulate: false,
|
|
734
792
|
skipFeeEnforcement: false,
|
|
735
793
|
profileMode: 'none',
|
|
@@ -764,17 +822,17 @@ export class PXE {
|
|
|
764
822
|
// transaction before this one is included in a block from this PXE, and that transaction contains a log with
|
|
765
823
|
// a tag derived from the same secret, we would reuse the tag and the transactions would be linked. Hence
|
|
766
824
|
// storing the tags here prevents linkage of txs sent from the same PXE.
|
|
767
|
-
const
|
|
768
|
-
if (
|
|
825
|
+
const taggingIndexRangesUsedInTheTx = privateExecutionResult.entrypoint.taggingIndexRanges;
|
|
826
|
+
if (taggingIndexRangesUsedInTheTx.length > 0) {
|
|
769
827
|
// TODO(benesjan): The following is an expensive operation. Figure out a way to avoid it.
|
|
770
828
|
const txHash = (await txProvingResult.toTx()).txHash;
|
|
771
829
|
|
|
772
|
-
await this.senderTaggingStore.storePendingIndexes(
|
|
773
|
-
this.log.debug(`Stored used
|
|
774
|
-
|
|
830
|
+
await this.senderTaggingStore.storePendingIndexes(taggingIndexRangesUsedInTheTx, txHash, jobId);
|
|
831
|
+
this.log.debug(`Stored used tagging index ranges as sender for the tx`, {
|
|
832
|
+
taggingIndexRangesUsedInTheTx,
|
|
775
833
|
});
|
|
776
834
|
} else {
|
|
777
|
-
this.log.debug(`No
|
|
835
|
+
this.log.debug(`No tagging index ranges used in the tx`);
|
|
778
836
|
}
|
|
779
837
|
|
|
780
838
|
return txProvingResult;
|
|
@@ -792,7 +850,7 @@ export class PXE {
|
|
|
792
850
|
*/
|
|
793
851
|
public profileTx(
|
|
794
852
|
txRequest: TxExecutionRequest,
|
|
795
|
-
{ profileMode, skipProofGeneration = true, scopes }: ProfileTxOpts,
|
|
853
|
+
{ profileMode, skipProofGeneration = true, scopes, senderForTags }: ProfileTxOpts,
|
|
796
854
|
): Promise<TxProfileResult> {
|
|
797
855
|
// We disable concurrent profiles for consistency with simulateTx.
|
|
798
856
|
return this.#putInJobQueue(async jobId => {
|
|
@@ -812,15 +870,24 @@ export class PXE {
|
|
|
812
870
|
);
|
|
813
871
|
const syncTimer = new Timer();
|
|
814
872
|
await this.blockStateSynchronizer.sync();
|
|
873
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
815
874
|
const syncTime = syncTimer.ms();
|
|
816
875
|
|
|
817
876
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
818
|
-
const privateExecutionResult = await this.#executePrivate(
|
|
877
|
+
const privateExecutionResult = await this.#executePrivate({
|
|
878
|
+
contractFunctionSimulator,
|
|
879
|
+
txRequest,
|
|
880
|
+
anchorBlockHeader,
|
|
881
|
+
scopes,
|
|
882
|
+
jobId,
|
|
883
|
+
senderForTags,
|
|
884
|
+
});
|
|
819
885
|
|
|
820
886
|
const { executionSteps, timings: { proving } = {} } = await this.#prove(
|
|
821
887
|
txRequest,
|
|
822
888
|
this.proofCreator,
|
|
823
889
|
privateExecutionResult,
|
|
890
|
+
anchorBlockHeader,
|
|
824
891
|
{
|
|
825
892
|
simulate: skipProofGeneration,
|
|
826
893
|
skipFeeEnforcement: false,
|
|
@@ -881,7 +948,15 @@ export class PXE {
|
|
|
881
948
|
*/
|
|
882
949
|
public simulateTx(
|
|
883
950
|
txRequest: TxExecutionRequest,
|
|
884
|
-
{
|
|
951
|
+
{
|
|
952
|
+
simulatePublic,
|
|
953
|
+
skipTxValidation = false,
|
|
954
|
+
skipFeeEnforcement = false,
|
|
955
|
+
skipKernels = true,
|
|
956
|
+
overrides,
|
|
957
|
+
scopes,
|
|
958
|
+
senderForTags,
|
|
959
|
+
}: SimulateTxOpts,
|
|
885
960
|
): Promise<TxSimulationResult> {
|
|
886
961
|
// We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
|
|
887
962
|
// to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
|
|
@@ -903,23 +978,34 @@ export class PXE {
|
|
|
903
978
|
);
|
|
904
979
|
const syncTimer = new Timer();
|
|
905
980
|
await this.blockStateSynchronizer.sync();
|
|
981
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
906
982
|
const syncTime = syncTimer.ms();
|
|
907
983
|
|
|
908
|
-
const contractFunctionSimulator = this.#getSimulatorForTx(overrides);
|
|
909
|
-
// Temporary: in case there are overrides, we have to skip the kernels or validations
|
|
910
|
-
// will fail. Consider handing control to the user/wallet on whether they want to run them
|
|
911
|
-
// or not.
|
|
912
984
|
const overriddenContracts = overrides?.contracts ? new Set(Object.keys(overrides.contracts)) : undefined;
|
|
913
985
|
const hasOverriddenContracts = overriddenContracts !== undefined && overriddenContracts.size > 0;
|
|
914
|
-
const skipKernels = hasOverriddenContracts;
|
|
915
986
|
|
|
916
|
-
|
|
987
|
+
if (hasOverriddenContracts && !skipKernels) {
|
|
988
|
+
throw new Error(
|
|
989
|
+
'Simulating with overridden contracts is not compatible with kernel execution. Please set skipKernels to true when simulating with overridden contracts.',
|
|
990
|
+
);
|
|
991
|
+
}
|
|
992
|
+
const contractFunctionSimulator = this.#getSimulatorForTx(overrides);
|
|
993
|
+
|
|
917
994
|
if (hasOverriddenContracts) {
|
|
918
|
-
|
|
995
|
+
// Overridden contracts don't have a sync function, so calling sync on them would fail.
|
|
996
|
+
// We exclude them so the sync service skips them entirely.
|
|
997
|
+
this.contractSyncService.setExcludedFromSync(jobId, overriddenContracts);
|
|
919
998
|
}
|
|
920
999
|
|
|
921
1000
|
// Execution of private functions only; no proving, and no kernel logic.
|
|
922
|
-
const privateExecutionResult = await this.#executePrivate(
|
|
1001
|
+
const privateExecutionResult = await this.#executePrivate({
|
|
1002
|
+
contractFunctionSimulator,
|
|
1003
|
+
txRequest,
|
|
1004
|
+
anchorBlockHeader,
|
|
1005
|
+
scopes,
|
|
1006
|
+
jobId,
|
|
1007
|
+
senderForTags,
|
|
1008
|
+
});
|
|
923
1009
|
|
|
924
1010
|
let publicInputs: PrivateKernelTailCircuitPublicInputs | undefined;
|
|
925
1011
|
let executionSteps: PrivateExecutionStep[] = [];
|
|
@@ -932,11 +1018,17 @@ export class PXE {
|
|
|
932
1018
|
));
|
|
933
1019
|
} else {
|
|
934
1020
|
// Kernel logic, plus proving of all private functions and kernels.
|
|
935
|
-
({ publicInputs, executionSteps } = await this.#prove(
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
1021
|
+
({ publicInputs, executionSteps } = await this.#prove(
|
|
1022
|
+
txRequest,
|
|
1023
|
+
this.proofCreator,
|
|
1024
|
+
privateExecutionResult,
|
|
1025
|
+
anchorBlockHeader,
|
|
1026
|
+
{
|
|
1027
|
+
simulate: true,
|
|
1028
|
+
skipFeeEnforcement,
|
|
1029
|
+
profileMode: 'none',
|
|
1030
|
+
},
|
|
1031
|
+
));
|
|
940
1032
|
}
|
|
941
1033
|
|
|
942
1034
|
const privateSimulationResult = new PrivateSimulationResult(privateExecutionResult, publicInputs);
|
|
@@ -958,7 +1050,8 @@ export class PXE {
|
|
|
958
1050
|
const validationResult = await this.node.isValidTx(simulatedTx, { isSimulation: true, skipFeeEnforcement });
|
|
959
1051
|
validationTime = validationTimer.ms();
|
|
960
1052
|
if (validationResult.result === 'invalid') {
|
|
961
|
-
|
|
1053
|
+
const reason = validationResult.reason.length > 0 ? ` Reason: ${validationResult.reason.join(', ')}` : '';
|
|
1054
|
+
throw new Error(`The simulated transaction is unable to be added to state and is invalid.${reason}`);
|
|
962
1055
|
}
|
|
963
1056
|
}
|
|
964
1057
|
|
|
@@ -1009,7 +1102,7 @@ export class PXE {
|
|
|
1009
1102
|
inspect(txRequest),
|
|
1010
1103
|
`simulatePublic=${simulatePublic}`,
|
|
1011
1104
|
`skipTxValidation=${skipTxValidation}`,
|
|
1012
|
-
`scopes=${scopes
|
|
1105
|
+
`scopes=${scopes.map(s => s.toString()).join(', ')}`,
|
|
1013
1106
|
);
|
|
1014
1107
|
}
|
|
1015
1108
|
});
|
|
@@ -1021,7 +1114,7 @@ export class PXE {
|
|
|
1021
1114
|
*/
|
|
1022
1115
|
public executeUtility(
|
|
1023
1116
|
call: FunctionCall,
|
|
1024
|
-
{ authwits, scopes }: ExecuteUtilityOpts = { scopes:
|
|
1117
|
+
{ authwits, scopes }: ExecuteUtilityOpts = { scopes: [] },
|
|
1025
1118
|
): Promise<UtilityExecutionResult> {
|
|
1026
1119
|
// We disable concurrent executions since those might execute oracles which read and write to the PXE stores (e.g.
|
|
1027
1120
|
// to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
|
|
@@ -1046,7 +1139,7 @@ export class PXE {
|
|
|
1046
1139
|
scopes,
|
|
1047
1140
|
);
|
|
1048
1141
|
|
|
1049
|
-
const executionResult = await this.#executeUtility(
|
|
1142
|
+
const { result: executionResult, offchainEffects } = await this.#executeUtility(
|
|
1050
1143
|
contractFunctionSimulator,
|
|
1051
1144
|
call,
|
|
1052
1145
|
authwits ?? [],
|
|
@@ -1067,14 +1160,19 @@ export class PXE {
|
|
|
1067
1160
|
};
|
|
1068
1161
|
|
|
1069
1162
|
const simulationStats = contractFunctionSimulator.getStats();
|
|
1070
|
-
return {
|
|
1163
|
+
return {
|
|
1164
|
+
result: executionResult,
|
|
1165
|
+
offchainEffects,
|
|
1166
|
+
anchorBlockTimestamp: anchorBlockHeader.globalVariables.timestamp,
|
|
1167
|
+
stats: { timings, nodeRPCCalls: simulationStats.nodeRPCCalls },
|
|
1168
|
+
};
|
|
1071
1169
|
} catch (err: any) {
|
|
1072
1170
|
const { to, name, args } = call;
|
|
1073
1171
|
const stringifiedArgs = args.map(arg => arg.toString()).join(', ');
|
|
1074
1172
|
throw this.#contextualizeError(
|
|
1075
1173
|
err,
|
|
1076
1174
|
`executeUtility ${to}:${name}(${stringifiedArgs})`,
|
|
1077
|
-
`scopes=${scopes
|
|
1175
|
+
`scopes=${scopes.map(s => s.toString()).join(', ')}`,
|
|
1078
1176
|
);
|
|
1079
1177
|
}
|
|
1080
1178
|
});
|
|
@@ -1129,9 +1227,11 @@ export class PXE {
|
|
|
1129
1227
|
}
|
|
1130
1228
|
|
|
1131
1229
|
/**
|
|
1132
|
-
* Stops the PXE's job queue.
|
|
1230
|
+
* Stops the PXE's job queue and closes the backing store.
|
|
1133
1231
|
*/
|
|
1134
|
-
public stop(): Promise<void> {
|
|
1135
|
-
|
|
1232
|
+
public async stop(): Promise<void> {
|
|
1233
|
+
await this.jobQueue.end();
|
|
1234
|
+
await this.blockStateSynchronizer.stop();
|
|
1235
|
+
await this.db.close();
|
|
1136
1236
|
}
|
|
1137
1237
|
}
|
|
@@ -23,7 +23,7 @@ export class AnchorBlockStore {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
async getBlockHeader(): Promise<BlockHeader> {
|
|
26
|
-
const headerBuffer = await this.#synchronizedHeader.getAsync();
|
|
26
|
+
const headerBuffer = await this.#store.transactionAsync(() => this.#synchronizedHeader.getAsync());
|
|
27
27
|
if (!headerBuffer) {
|
|
28
28
|
throw new Error(`Trying to get block header with a not-yet-synchronized PXE - this should never happen`);
|
|
29
29
|
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
|
+
import type { Capsule } from '@aztec/stdlib/tx';
|
|
4
|
+
|
|
5
|
+
import type { CapsuleStore } from './capsule_store.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Wraps a CapsuleStore with scope-based access control. Each operation asserts that the requested scope is in the
|
|
9
|
+
* allowed scopes list before delegating to the underlying store.
|
|
10
|
+
*/
|
|
11
|
+
export class CapsuleService {
|
|
12
|
+
constructor(
|
|
13
|
+
private readonly capsuleStore: CapsuleStore,
|
|
14
|
+
private readonly allowedScopes: AztecAddress[],
|
|
15
|
+
) {}
|
|
16
|
+
|
|
17
|
+
setCapsule(contractAddress: AztecAddress, slot: Fr, capsule: Fr[], jobId: string, scope: AztecAddress) {
|
|
18
|
+
assertAllowedScope(scope, this.allowedScopes);
|
|
19
|
+
this.capsuleStore.setCapsule(contractAddress, slot, capsule, jobId, scope);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async getCapsule(
|
|
23
|
+
contractAddress: AztecAddress,
|
|
24
|
+
slot: Fr,
|
|
25
|
+
jobId: string,
|
|
26
|
+
scope: AztecAddress,
|
|
27
|
+
transientCapsules?: Capsule[],
|
|
28
|
+
): Promise<Fr[] | null> {
|
|
29
|
+
assertAllowedScope(scope, this.allowedScopes);
|
|
30
|
+
|
|
31
|
+
// TODO(#12425): On the following line, the pertinent capsule gets overshadowed by the transient one. Tackle this.
|
|
32
|
+
const maybeTransientCapsule = transientCapsules?.find(
|
|
33
|
+
c =>
|
|
34
|
+
c.contractAddress.equals(contractAddress) &&
|
|
35
|
+
c.storageSlot.equals(slot) &&
|
|
36
|
+
(c.scope ?? AztecAddress.ZERO).equals(scope),
|
|
37
|
+
)?.data;
|
|
38
|
+
|
|
39
|
+
return maybeTransientCapsule ?? (await this.capsuleStore.getCapsule(contractAddress, slot, jobId, scope));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
deleteCapsule(contractAddress: AztecAddress, slot: Fr, jobId: string, scope: AztecAddress) {
|
|
43
|
+
assertAllowedScope(scope, this.allowedScopes);
|
|
44
|
+
this.capsuleStore.deleteCapsule(contractAddress, slot, jobId, scope);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
copyCapsule(
|
|
48
|
+
contractAddress: AztecAddress,
|
|
49
|
+
srcSlot: Fr,
|
|
50
|
+
dstSlot: Fr,
|
|
51
|
+
numEntries: number,
|
|
52
|
+
jobId: string,
|
|
53
|
+
scope: AztecAddress,
|
|
54
|
+
): Promise<void> {
|
|
55
|
+
assertAllowedScope(scope, this.allowedScopes);
|
|
56
|
+
return this.capsuleStore.copyCapsule(contractAddress, srcSlot, dstSlot, numEntries, jobId, scope);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
appendToCapsuleArray(
|
|
60
|
+
contractAddress: AztecAddress,
|
|
61
|
+
baseSlot: Fr,
|
|
62
|
+
content: Fr[][],
|
|
63
|
+
jobId: string,
|
|
64
|
+
scope: AztecAddress,
|
|
65
|
+
): Promise<void> {
|
|
66
|
+
assertAllowedScope(scope, this.allowedScopes);
|
|
67
|
+
return this.capsuleStore.appendToCapsuleArray(contractAddress, baseSlot, content, jobId, scope);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
readCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr, jobId: string, scope: AztecAddress): Promise<Fr[][]> {
|
|
71
|
+
assertAllowedScope(scope, this.allowedScopes);
|
|
72
|
+
return this.capsuleStore.readCapsuleArray(contractAddress, baseSlot, jobId, scope);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
setCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr, content: Fr[][], jobId: string, scope: AztecAddress) {
|
|
76
|
+
assertAllowedScope(scope, this.allowedScopes);
|
|
77
|
+
return this.capsuleStore.setCapsuleArray(contractAddress, baseSlot, content, jobId, scope);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function assertAllowedScope(scope: AztecAddress, allowedScopes: AztecAddress[]) {
|
|
82
|
+
if (scope.equals(AztecAddress.ZERO)) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (!allowedScopes.some((allowed: AztecAddress) => allowed.equals(scope))) {
|
|
86
|
+
throw new Error(
|
|
87
|
+
`Scope ${scope.toString()} is not in the allowed scopes list: [${allowedScopes.map((s: AztecAddress) => s.toString()).join(', ')}]. See https://docs.aztec.network/errors/10`,
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
}
|