@aztec/pxe 0.0.1-commit.9372f48 → 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 +9 -3
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +37 -11
- 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/config/package_info.js +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +63 -29
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +207 -75
- 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 +307 -103
- package/dest/contract_function_simulator/oracle/private_execution.js +5 -3
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +58 -84
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +122 -96
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +126 -66
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +366 -134
- 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 +27 -0
- package/dest/contract_logging.d.ts.map +1 -0
- package/dest/contract_logging.js +38 -0
- package/dest/contract_sync/contract_sync_service.d.ts +44 -0
- package/dest/contract_sync/contract_sync_service.d.ts.map +1 -0
- package/dest/contract_sync/contract_sync_service.js +116 -0
- package/dest/contract_sync/helpers.d.ts +28 -0
- package/dest/contract_sync/helpers.d.ts.map +1 -0
- package/dest/contract_sync/{index.js → helpers.js} +19 -13
- package/dest/debug/pxe_debug_utils.d.ts +14 -10
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
- package/dest/debug/pxe_debug_utils.js +16 -15
- package/dest/entrypoints/client/bundle/index.d.ts +3 -1
- package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.js +2 -0
- 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 +11 -3
- package/dest/entrypoints/client/lazy/index.d.ts +3 -1
- package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/index.js +2 -0
- 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 +11 -3
- 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 +4 -3
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +3 -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 +11 -3
- 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 -7
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +34 -51
- 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 -4
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +17 -7
- package/dest/notes_filter.d.ts +24 -0
- package/dest/notes_filter.d.ts.map +1 -0
- package/dest/notes_filter.js +4 -0
- 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/hints/compute_tx_expiration_timestamp.d.ts +4 -0
- package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts.map +1 -0
- package/dest/private_kernel/hints/{compute_tx_include_by_timestamp.js → compute_tx_expiration_timestamp.js} +12 -12
- package/dest/private_kernel/hints/index.d.ts +1 -1
- package/dest/private_kernel/hints/index.js +1 -1
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +4 -3
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -1
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.js +129 -68
- package/dest/private_kernel/hints/test_utils.d.ts +122 -0
- package/dest/private_kernel/hints/test_utils.d.ts.map +1 -0
- package/dest/private_kernel/hints/test_utils.js +203 -0
- 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 +18 -13
- package/dest/private_kernel/private_kernel_oracle.d.ts +10 -6
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle.js +19 -18
- package/dest/pxe.d.ts +85 -24
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +165 -84
- 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 +42 -15
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
- package/dest/storage/contract_store/contract_store.js +148 -70
- package/dest/storage/metadata.d.ts +1 -1
- package/dest/storage/metadata.js +1 -1
- package/dest/storage/note_store/note_store.d.ts +3 -3
- package/dest/storage/note_store/note_store.d.ts.map +1 -1
- package/dest/storage/note_store/note_store.js +6 -4
- 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/get_all_logs_by_tags.d.ts +1 -1
- package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -1
- package/dest/tagging/get_all_logs_by_tags.js +17 -3
- 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 +8 -22
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +2 -2
- 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 +25 -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 +39 -11
- package/src/config/index.ts +3 -9
- package/src/config/package_info.ts +1 -1
- package/src/contract_function_simulator/contract_function_simulator.ts +367 -136
- 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 +387 -142
- package/src/contract_function_simulator/oracle/private_execution.ts +4 -4
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +154 -185
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +610 -165
- 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 +52 -0
- package/src/contract_sync/contract_sync_service.ts +176 -0
- package/src/contract_sync/{index.ts → helpers.ts} +22 -22
- package/src/debug/pxe_debug_utils.ts +48 -18
- package/src/entrypoints/client/bundle/index.ts +2 -0
- package/src/entrypoints/client/bundle/utils.ts +11 -4
- package/src/entrypoints/client/lazy/index.ts +2 -0
- package/src/entrypoints/client/lazy/utils.ts +11 -4
- package/src/entrypoints/pxe_creation_options.ts +7 -0
- package/src/entrypoints/server/index.ts +3 -2
- package/src/entrypoints/server/utils.ts +9 -10
- package/src/events/event_service.ts +30 -5
- package/src/events/private_event_filter_validator.ts +21 -1
- package/src/logs/log_service.ts +64 -92
- package/src/messages/message_context_service.ts +44 -0
- package/src/notes/note_service.ts +19 -8
- package/src/notes_filter.ts +24 -0
- package/src/oracle_version.ts +20 -10
- package/src/private_kernel/hints/{compute_tx_include_by_timestamp.ts → compute_tx_expiration_timestamp.ts} +13 -13
- package/src/private_kernel/hints/index.ts +1 -1
- package/src/private_kernel/hints/private_kernel_reset_private_inputs_builder.ts +164 -117
- package/src/private_kernel/hints/test_utils.ts +325 -0
- package/src/private_kernel/private_kernel_execution_prover.ts +18 -16
- package/src/private_kernel/private_kernel_oracle.ts +21 -21
- package/src/pxe.ts +305 -138
- 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 +181 -80
- package/src/storage/metadata.ts +1 -1
- package/src/storage/note_store/note_store.ts +9 -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/get_all_logs_by_tags.ts +28 -4
- package/src/tagging/index.ts +2 -2
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +12 -25
- package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +2 -2
- 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/contract_sync/index.d.ts +0 -23
- package/dest/contract_sync/index.d.ts.map +0 -1
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +0 -4
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts.map +0 -1
package/dest/pxe.js
CHANGED
|
@@ -13,11 +13,14 @@ import { BlockSynchronizer } from './block_synchronizer/index.js';
|
|
|
13
13
|
import { BenchmarkedNodeFactory } from './contract_function_simulator/benchmarked_node.js';
|
|
14
14
|
import { ContractFunctionSimulator, generateSimulatedProvingResult } from './contract_function_simulator/contract_function_simulator.js';
|
|
15
15
|
import { ProxiedContractStoreFactory } from './contract_function_simulator/proxied_contract_data_source.js';
|
|
16
|
-
import {
|
|
16
|
+
import { displayDebugLogs } from './contract_logging.js';
|
|
17
|
+
import { ContractSyncService } from './contract_sync/contract_sync_service.js';
|
|
18
|
+
import { readCurrentClassId } from './contract_sync/helpers.js';
|
|
17
19
|
import { PXEDebugUtils } from './debug/pxe_debug_utils.js';
|
|
18
20
|
import { enrichPublicSimulationError, enrichSimulationError } from './error_enriching.js';
|
|
19
21
|
import { PrivateEventFilterValidator } from './events/private_event_filter_validator.js';
|
|
20
22
|
import { JobCoordinator } from './job_coordinator/job_coordinator.js';
|
|
23
|
+
import { MessageContextService } from './messages/message_context_service.js';
|
|
21
24
|
import { PrivateKernelExecutionProver } from './private_kernel/private_kernel_execution_prover.js';
|
|
22
25
|
import { PrivateKernelOracle } from './private_kernel/private_kernel_oracle.js';
|
|
23
26
|
import { AddressStore } from './storage/address_store/address_store.js';
|
|
@@ -34,6 +37,7 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
34
37
|
* manage private state of users.
|
|
35
38
|
*/ export class PXE {
|
|
36
39
|
node;
|
|
40
|
+
db;
|
|
37
41
|
blockStateSynchronizer;
|
|
38
42
|
keyStore;
|
|
39
43
|
contractStore;
|
|
@@ -45,6 +49,9 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
45
49
|
recipientTaggingStore;
|
|
46
50
|
addressStore;
|
|
47
51
|
privateEventStore;
|
|
52
|
+
contractSyncService;
|
|
53
|
+
messageContextService;
|
|
54
|
+
l2TipsStore;
|
|
48
55
|
simulator;
|
|
49
56
|
proverEnabled;
|
|
50
57
|
proofCreator;
|
|
@@ -53,8 +60,9 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
53
60
|
jobQueue;
|
|
54
61
|
jobCoordinator;
|
|
55
62
|
debug;
|
|
56
|
-
constructor(node, blockStateSynchronizer, keyStore, contractStore, noteStore, capsuleStore, anchorBlockStore, senderTaggingStore, senderAddressBookStore, recipientTaggingStore, addressStore, privateEventStore, simulator, proverEnabled, proofCreator, protocolContractsProvider, log, jobQueue, jobCoordinator, debug){
|
|
63
|
+
constructor(node, db, blockStateSynchronizer, keyStore, contractStore, noteStore, capsuleStore, anchorBlockStore, senderTaggingStore, senderAddressBookStore, recipientTaggingStore, addressStore, privateEventStore, contractSyncService, messageContextService, l2TipsStore, simulator, proverEnabled, proofCreator, protocolContractsProvider, log, jobQueue, jobCoordinator, debug){
|
|
57
64
|
this.node = node;
|
|
65
|
+
this.db = db;
|
|
58
66
|
this.blockStateSynchronizer = blockStateSynchronizer;
|
|
59
67
|
this.keyStore = keyStore;
|
|
60
68
|
this.contractStore = contractStore;
|
|
@@ -66,6 +74,9 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
66
74
|
this.recipientTaggingStore = recipientTaggingStore;
|
|
67
75
|
this.addressStore = addressStore;
|
|
68
76
|
this.privateEventStore = privateEventStore;
|
|
77
|
+
this.contractSyncService = contractSyncService;
|
|
78
|
+
this.messageContextService = messageContextService;
|
|
79
|
+
this.l2TipsStore = l2TipsStore;
|
|
69
80
|
this.simulator = simulator;
|
|
70
81
|
this.proverEnabled = proverEnabled;
|
|
71
82
|
this.proofCreator = proofCreator;
|
|
@@ -81,11 +92,12 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
81
92
|
* can be contacted.
|
|
82
93
|
*
|
|
83
94
|
* @returns A promise that resolves PXE is ready to be used.
|
|
84
|
-
*/ static async create(node, store, proofCreator, simulator, protocolContractsProvider, config, loggerOrSuffix) {
|
|
95
|
+
*/ static async create({ node, store, proofCreator, simulator, protocolContractsProvider, config, loggerOrSuffix }) {
|
|
85
96
|
// Extract bindings from the logger, or use empty bindings if a string suffix is provided.
|
|
86
97
|
const bindings = loggerOrSuffix && typeof loggerOrSuffix !== 'string' ? loggerOrSuffix.getBindings() : undefined;
|
|
87
98
|
const log = !loggerOrSuffix || typeof loggerOrSuffix === 'string' ? createLogger(loggerOrSuffix ? `pxe:service:${loggerOrSuffix}` : `pxe:service`) : loggerOrSuffix;
|
|
88
|
-
const
|
|
99
|
+
const info = await node.getNodeInfo();
|
|
100
|
+
const proverEnabled = config.proverEnabled !== undefined ? config.proverEnabled : info.realProofs;
|
|
89
101
|
const addressStore = new AddressStore(store);
|
|
90
102
|
const privateEventStore = new PrivateEventStore(store);
|
|
91
103
|
const contractStore = new ContractStore(store);
|
|
@@ -97,29 +109,46 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
97
109
|
const capsuleStore = new CapsuleStore(store);
|
|
98
110
|
const keyStore = new KeyStore(store);
|
|
99
111
|
const tipsStore = new L2TipsKVStore(store, 'pxe');
|
|
100
|
-
const
|
|
112
|
+
const contractSyncService = new ContractSyncService(node, contractStore, noteStore, createLogger('pxe:contract_sync', bindings));
|
|
113
|
+
const messageContextService = new MessageContextService(node);
|
|
114
|
+
const synchronizer = new BlockSynchronizer(node, store, anchorBlockStore, noteStore, privateEventStore, tipsStore, contractSyncService, config, bindings);
|
|
101
115
|
const jobCoordinator = new JobCoordinator(store, bindings);
|
|
102
116
|
jobCoordinator.registerStores([
|
|
103
117
|
capsuleStore,
|
|
104
118
|
senderTaggingStore,
|
|
105
119
|
recipientTaggingStore,
|
|
106
120
|
privateEventStore,
|
|
107
|
-
noteStore
|
|
121
|
+
noteStore,
|
|
122
|
+
contractSyncService
|
|
108
123
|
]);
|
|
109
|
-
const debugUtils = new PXEDebugUtils(
|
|
124
|
+
const debugUtils = new PXEDebugUtils(contractSyncService, noteStore, synchronizer, anchorBlockStore);
|
|
110
125
|
const jobQueue = new SerialQueue();
|
|
111
|
-
const pxe = new PXE(node, synchronizer, keyStore, contractStore, noteStore, capsuleStore, anchorBlockStore, senderTaggingStore, senderAddressBookStore, recipientTaggingStore, addressStore, privateEventStore, simulator, proverEnabled, proofCreator, protocolContractsProvider, log, jobQueue, jobCoordinator, debugUtils);
|
|
112
|
-
debugUtils.
|
|
126
|
+
const pxe = new PXE(node, store, synchronizer, keyStore, contractStore, noteStore, capsuleStore, anchorBlockStore, senderTaggingStore, senderAddressBookStore, recipientTaggingStore, addressStore, privateEventStore, contractSyncService, messageContextService, tipsStore, simulator, proverEnabled, proofCreator, protocolContractsProvider, log, jobQueue, jobCoordinator, debugUtils);
|
|
127
|
+
debugUtils.setPXEHelpers(pxe.#putInJobQueue.bind(pxe), pxe.#getSimulatorForTx.bind(pxe), pxe.#executeUtility.bind(pxe));
|
|
113
128
|
pxe.jobQueue.start();
|
|
114
129
|
await pxe.#registerProtocolContracts();
|
|
115
|
-
const info = await node.getNodeInfo();
|
|
116
130
|
log.info(`Started PXE connected to chain ${info.l1ChainId} version ${info.rollupVersion}`);
|
|
117
131
|
return pxe;
|
|
118
132
|
}
|
|
119
133
|
// Internal methods
|
|
120
134
|
#getSimulatorForTx(overrides) {
|
|
121
135
|
const proxyContractStore = ProxiedContractStoreFactory.create(this.contractStore, overrides?.contracts);
|
|
122
|
-
return new ContractFunctionSimulator(
|
|
136
|
+
return new ContractFunctionSimulator({
|
|
137
|
+
contractStore: proxyContractStore,
|
|
138
|
+
noteStore: this.noteStore,
|
|
139
|
+
keyStore: this.keyStore,
|
|
140
|
+
addressStore: this.addressStore,
|
|
141
|
+
aztecNode: BenchmarkedNodeFactory.create(this.node),
|
|
142
|
+
l2TipsStore: this.l2TipsStore,
|
|
143
|
+
senderTaggingStore: this.senderTaggingStore,
|
|
144
|
+
recipientTaggingStore: this.recipientTaggingStore,
|
|
145
|
+
senderAddressBookStore: this.senderAddressBookStore,
|
|
146
|
+
capsuleStore: this.capsuleStore,
|
|
147
|
+
privateEventStore: this.privateEventStore,
|
|
148
|
+
simulator: this.simulator,
|
|
149
|
+
contractSyncService: this.contractSyncService,
|
|
150
|
+
messageContextService: this.messageContextService
|
|
151
|
+
});
|
|
123
152
|
}
|
|
124
153
|
#contextualizeError(err, ...context) {
|
|
125
154
|
let contextStr = '';
|
|
@@ -162,8 +191,8 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
162
191
|
async #registerProtocolContracts() {
|
|
163
192
|
const registered = {};
|
|
164
193
|
for (const name of protocolContractNames){
|
|
165
|
-
const { address,
|
|
166
|
-
await this.contractStore.addContractArtifact(
|
|
194
|
+
const { address, instance, artifact } = await this.protocolContractsProvider.getProtocolContractArtifact(name);
|
|
195
|
+
await this.contractStore.addContractArtifact(artifact);
|
|
167
196
|
await this.contractStore.addContractInstance(instance);
|
|
168
197
|
registered[name] = address.toString();
|
|
169
198
|
}
|
|
@@ -171,14 +200,18 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
171
200
|
}
|
|
172
201
|
// Executes the entrypoint private function, as well as all nested private
|
|
173
202
|
// functions that might arise.
|
|
174
|
-
async #executePrivate(contractFunctionSimulator, txRequest, scopes, jobId) {
|
|
203
|
+
async #executePrivate({ contractFunctionSimulator, txRequest, anchorBlockHeader, scopes, jobId, senderForTags }) {
|
|
175
204
|
const { origin: contractAddress, functionSelector } = txRequest;
|
|
176
205
|
try {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
206
|
+
await this.contractSyncService.ensureContractSynced(contractAddress, functionSelector, (privateSyncCall, execScopes)=>this.#executeUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId), anchorBlockHeader, jobId, scopes);
|
|
207
|
+
const result = await contractFunctionSimulator.run(txRequest, {
|
|
208
|
+
contractAddress,
|
|
209
|
+
selector: functionSelector,
|
|
210
|
+
anchorBlockHeader,
|
|
211
|
+
scopes,
|
|
212
|
+
jobId,
|
|
213
|
+
senderForTags
|
|
214
|
+
});
|
|
182
215
|
this.log.debug(`Private simulation completed for ${contractAddress.toString()}:${functionSelector}`);
|
|
183
216
|
return result;
|
|
184
217
|
} catch (err) {
|
|
@@ -189,18 +222,22 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
189
222
|
}
|
|
190
223
|
}
|
|
191
224
|
/**
|
|
192
|
-
*
|
|
225
|
+
* Execute a utility function call on the given contract.
|
|
193
226
|
* @param contractFunctionSimulator - The simulator to use for the function call.
|
|
194
227
|
* @param call - The function call to execute.
|
|
195
228
|
* @param authWitnesses - Authentication witnesses required for the function call.
|
|
196
229
|
* @param scopes - Optional array of account addresses whose notes can be accessed in this call. Defaults to all
|
|
197
230
|
* accounts if not specified.
|
|
198
231
|
* @param jobId - The job ID for staged writes.
|
|
199
|
-
* @returns The
|
|
200
|
-
*/ async #
|
|
232
|
+
* @returns The execution result containing the outputs of the utility function.
|
|
233
|
+
*/ async #executeUtility(contractFunctionSimulator, call, authWitnesses, scopes, jobId) {
|
|
201
234
|
try {
|
|
202
235
|
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
203
|
-
|
|
236
|
+
const { result, offchainEffects } = await contractFunctionSimulator.runUtility(call, authWitnesses ?? [], anchorBlockHeader, scopes, jobId);
|
|
237
|
+
return {
|
|
238
|
+
result,
|
|
239
|
+
offchainEffects
|
|
240
|
+
};
|
|
204
241
|
} catch (err) {
|
|
205
242
|
if (err instanceof SimulationError) {
|
|
206
243
|
await enrichSimulationError(err, this.contractStore, this.log);
|
|
@@ -243,16 +280,26 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
243
280
|
* @param privateExecutionResult - The result of the private execution
|
|
244
281
|
* @param config - The configuration for the kernel execution prover.
|
|
245
282
|
* @returns An object that contains the output of the kernel execution, including the ChonkProof if proving is enabled.
|
|
246
|
-
*/ async #prove(txExecutionRequest, proofCreator, privateExecutionResult, config) {
|
|
247
|
-
const
|
|
248
|
-
const anchorBlockHash = await anchorBlockHeader.hash();
|
|
249
|
-
const kernelOracle = new PrivateKernelOracle(this.contractStore, this.keyStore, this.node, anchorBlockHash);
|
|
283
|
+
*/ async #prove(txExecutionRequest, proofCreator, privateExecutionResult, anchorBlockHeader, config) {
|
|
284
|
+
const kernelOracle = new PrivateKernelOracle(this.contractStore, this.keyStore, this.node, anchorBlockHeader);
|
|
250
285
|
const kernelTraceProver = new PrivateKernelExecutionProver(kernelOracle, proofCreator, !this.proverEnabled, this.log.getBindings());
|
|
251
286
|
this.log.debug(`Executing kernel trace prover (${JSON.stringify(config)})...`);
|
|
252
287
|
return await kernelTraceProver.proveWithKernels(txExecutionRequest.toTxRequest(), privateExecutionResult, config);
|
|
253
288
|
}
|
|
254
289
|
// Public API
|
|
255
|
-
|
|
290
|
+
/**
|
|
291
|
+
* Returns the block header up to which the PXE has synced.
|
|
292
|
+
* @returns The synced block header
|
|
293
|
+
*/ getSyncedBlockHeader() {
|
|
294
|
+
return this.#putInJobQueue(()=>{
|
|
295
|
+
return this.anchorBlockStore.getBlockHeader();
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Returns the contract instance for a given address, if it's registered in the PXE.
|
|
300
|
+
* @param address - The contract address.
|
|
301
|
+
* @returns The contract instance if found, undefined otherwise.
|
|
302
|
+
*/ getContractInstance(address) {
|
|
256
303
|
return this.contractStore.getContractInstance(address);
|
|
257
304
|
}
|
|
258
305
|
/**
|
|
@@ -294,6 +341,9 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
294
341
|
* @returns The address of the sender.
|
|
295
342
|
* TODO: It's strange that we return the address here and I (benesjan) think we should drop the return value.
|
|
296
343
|
*/ async registerSender(sender) {
|
|
344
|
+
if (!await sender.isValid()) {
|
|
345
|
+
throw new Error(`Address ${sender} is not valid: it does not correspond to a point on the Grumpkin curve. Cannot register it as a sender.`);
|
|
346
|
+
}
|
|
297
347
|
const accounts = await this.keyStore.getAccounts();
|
|
298
348
|
if (accounts.includes(sender)) {
|
|
299
349
|
this.log.info(`Sender:\n "${sender.toString()}"\n already registered.`);
|
|
@@ -302,6 +352,9 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
302
352
|
const wasAdded = await this.senderAddressBookStore.addSender(sender);
|
|
303
353
|
if (wasAdded) {
|
|
304
354
|
this.log.info(`Added sender:\n ${sender.toString()}`);
|
|
355
|
+
// Wipe the entire sync cache: the new sender's tagged logs could contain notes/events for any contract, so
|
|
356
|
+
// all contracts must re-sync to discover them. Queued to avoid wiping while a job is in flight.
|
|
357
|
+
await this.#putInJobQueue(()=>Promise.resolve(this.contractSyncService.wipe()));
|
|
305
358
|
} else {
|
|
306
359
|
this.log.info(`Sender:\n "${sender.toString()}"\n already registered.`);
|
|
307
360
|
}
|
|
@@ -339,8 +392,7 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
339
392
|
*
|
|
340
393
|
* @param artifact - The build artifact for the contract class.
|
|
341
394
|
*/ async registerContractClass(artifact) {
|
|
342
|
-
const
|
|
343
|
-
await this.contractStore.addContractArtifact(contractClassId, artifact);
|
|
395
|
+
const contractClassId = await this.contractStore.addContractArtifact(artifact);
|
|
344
396
|
this.log.info(`Added contract class ${artifact.name} with id ${contractClassId}`);
|
|
345
397
|
}
|
|
346
398
|
/**
|
|
@@ -356,15 +408,14 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
356
408
|
if (artifact) {
|
|
357
409
|
// If the user provides an artifact, validate it against the expected class id and register it
|
|
358
410
|
const contractClass = await getContractClassFromArtifact(artifact);
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
throw new Error(`Artifact does not match expected class id (computed ${contractClassId} but instance refers to ${instance.currentContractClassId})`);
|
|
411
|
+
if (!contractClass.id.equals(instance.currentContractClassId)) {
|
|
412
|
+
throw new Error(`Artifact does not match expected class id (computed ${contractClass.id} but instance refers to ${instance.currentContractClassId})`);
|
|
362
413
|
}
|
|
363
414
|
const computedAddress = await computeContractAddressFromInstance(instance);
|
|
364
415
|
if (!computedAddress.equals(instance.address)) {
|
|
365
416
|
throw new Error('Added a contract in which the address does not match the contract instance.');
|
|
366
417
|
}
|
|
367
|
-
await this.contractStore.addContractArtifact(
|
|
418
|
+
await this.contractStore.addContractArtifact(artifact, contractClass);
|
|
368
419
|
const publicFunctionSignatures = artifact.functions.filter((fn)=>fn.functionType === FunctionType.PUBLIC).map((fn)=>decodeFunctionSignature(fn.name, fn.parameters));
|
|
369
420
|
await this.node.registerContractFunctionSignatures(publicFunctionSignatures);
|
|
370
421
|
} else {
|
|
@@ -400,11 +451,13 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
400
451
|
if (!contractClass.id.equals(currentClassId)) {
|
|
401
452
|
throw new Error('Could not update contract to a class different from the current one.');
|
|
402
453
|
}
|
|
403
|
-
await this.contractStore.addContractArtifact(contractClass.id, artifact);
|
|
404
454
|
const publicFunctionSignatures = artifact.functions.filter((fn)=>fn.functionType === FunctionType.PUBLIC).map((fn)=>decodeFunctionSignature(fn.name, fn.parameters));
|
|
405
455
|
await this.node.registerContractFunctionSignatures(publicFunctionSignatures);
|
|
406
456
|
currentInstance.currentContractClassId = contractClass.id;
|
|
407
|
-
await
|
|
457
|
+
await Promise.all([
|
|
458
|
+
this.contractStore.addContractArtifact(artifact, contractClass),
|
|
459
|
+
this.contractStore.addContractInstance(currentInstance)
|
|
460
|
+
]);
|
|
408
461
|
this.log.info(`Updated contract ${artifact.name} at ${contractAddress.toString()} to class ${contractClass.id}`);
|
|
409
462
|
});
|
|
410
463
|
}
|
|
@@ -419,10 +472,11 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
419
472
|
* (where validators prove the public portion).
|
|
420
473
|
*
|
|
421
474
|
* @param txRequest - An authenticated tx request ready for proving
|
|
475
|
+
* @param scopes - Addresses whose private state and keys are accessible during private execution.
|
|
422
476
|
* @returns A result containing the proof and public inputs of the tail circuit.
|
|
423
477
|
* @throws If contract code not found, or public simulation reverts.
|
|
424
478
|
* Also throws if simulatePublic is true and public simulation reverts.
|
|
425
|
-
*/ proveTx(txRequest) {
|
|
479
|
+
*/ proveTx(txRequest, { scopes, senderForTags }) {
|
|
426
480
|
let privateExecutionResult;
|
|
427
481
|
// We disable proving concurrently mostly out of caution, since it accesses some of our stores. Proving is so
|
|
428
482
|
// computationally demanding that it'd be rare for someone to try to do it concurrently regardless.
|
|
@@ -431,10 +485,18 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
431
485
|
try {
|
|
432
486
|
const syncTimer = new Timer();
|
|
433
487
|
await this.blockStateSynchronizer.sync();
|
|
488
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
434
489
|
const syncTime = syncTimer.ms();
|
|
435
490
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
436
|
-
privateExecutionResult = await this.#executePrivate(
|
|
437
|
-
|
|
491
|
+
privateExecutionResult = await this.#executePrivate({
|
|
492
|
+
contractFunctionSimulator,
|
|
493
|
+
txRequest,
|
|
494
|
+
anchorBlockHeader,
|
|
495
|
+
scopes,
|
|
496
|
+
jobId,
|
|
497
|
+
senderForTags
|
|
498
|
+
});
|
|
499
|
+
const { publicInputs, chonkProof, executionSteps, timings: { proving } = {} } = await this.#prove(txRequest, this.proofCreator, privateExecutionResult, anchorBlockHeader, {
|
|
438
500
|
simulate: false,
|
|
439
501
|
skipFeeEnforcement: false,
|
|
440
502
|
profileMode: 'none'
|
|
@@ -464,16 +526,16 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
464
526
|
// transaction before this one is included in a block from this PXE, and that transaction contains a log with
|
|
465
527
|
// a tag derived from the same secret, we would reuse the tag and the transactions would be linked. Hence
|
|
466
528
|
// storing the tags here prevents linkage of txs sent from the same PXE.
|
|
467
|
-
const
|
|
468
|
-
if (
|
|
529
|
+
const taggingIndexRangesUsedInTheTx = privateExecutionResult.entrypoint.taggingIndexRanges;
|
|
530
|
+
if (taggingIndexRangesUsedInTheTx.length > 0) {
|
|
469
531
|
// TODO(benesjan): The following is an expensive operation. Figure out a way to avoid it.
|
|
470
532
|
const txHash = (await txProvingResult.toTx()).txHash;
|
|
471
|
-
await this.senderTaggingStore.storePendingIndexes(
|
|
472
|
-
this.log.debug(`Stored used
|
|
473
|
-
|
|
533
|
+
await this.senderTaggingStore.storePendingIndexes(taggingIndexRangesUsedInTheTx, txHash, jobId);
|
|
534
|
+
this.log.debug(`Stored used tagging index ranges as sender for the tx`, {
|
|
535
|
+
taggingIndexRangesUsedInTheTx
|
|
474
536
|
});
|
|
475
537
|
} else {
|
|
476
|
-
this.log.debug(`No
|
|
538
|
+
this.log.debug(`No tagging index ranges used in the tx`);
|
|
477
539
|
}
|
|
478
540
|
return txProvingResult;
|
|
479
541
|
} catch (err) {
|
|
@@ -483,13 +545,10 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
483
545
|
}
|
|
484
546
|
/**
|
|
485
547
|
* Profiles a transaction, reporting gate counts (unless disabled) and returns an execution trace.
|
|
486
|
-
*
|
|
487
|
-
* @param txRequest - An authenticated tx request ready for simulation
|
|
488
|
-
* @param msgSender - (Optional) The message sender to use for the simulation.
|
|
489
|
-
* @param skipTxValidation - (Optional) If false, this function throws if the transaction is unable to be included in a block at the current state.
|
|
548
|
+
* @param txRequest - An authenticated tx request ready for simulation.
|
|
490
549
|
* @returns A trace of the program execution with gate counts.
|
|
491
550
|
* @throws If the code for the functions executed in this transaction have not been made available via `addContracts`.
|
|
492
|
-
*/ profileTx(txRequest, profileMode, skipProofGeneration = true) {
|
|
551
|
+
*/ profileTx(txRequest, { profileMode, skipProofGeneration = true, scopes, senderForTags }) {
|
|
493
552
|
// We disable concurrent profiles for consistency with simulateTx.
|
|
494
553
|
return this.#putInJobQueue(async (jobId)=>{
|
|
495
554
|
const totalTimer = new Timer();
|
|
@@ -505,10 +564,18 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
505
564
|
this.log.info(`Profiling transaction execution request to ${txRequest.functionSelector} at ${txRequest.origin}`, txInfo);
|
|
506
565
|
const syncTimer = new Timer();
|
|
507
566
|
await this.blockStateSynchronizer.sync();
|
|
567
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
508
568
|
const syncTime = syncTimer.ms();
|
|
509
569
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
510
|
-
const privateExecutionResult = await this.#executePrivate(
|
|
511
|
-
|
|
570
|
+
const privateExecutionResult = await this.#executePrivate({
|
|
571
|
+
contractFunctionSimulator,
|
|
572
|
+
txRequest,
|
|
573
|
+
anchorBlockHeader,
|
|
574
|
+
scopes,
|
|
575
|
+
jobId,
|
|
576
|
+
senderForTags
|
|
577
|
+
});
|
|
578
|
+
const { executionSteps, timings: { proving } = {} } = await this.#prove(txRequest, this.proofCreator, privateExecutionResult, anchorBlockHeader, {
|
|
512
579
|
simulate: skipProofGeneration,
|
|
513
580
|
skipFeeEnforcement: false,
|
|
514
581
|
profileMode
|
|
@@ -552,18 +619,13 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
552
619
|
* In that case, the transaction returned is only potentially ready to be sent to the network for execution.
|
|
553
620
|
*
|
|
554
621
|
*
|
|
555
|
-
* @param txRequest - An authenticated tx request ready for simulation
|
|
556
|
-
* @param simulatePublic - Whether to simulate the public part of the transaction.
|
|
557
|
-
* @param skipTxValidation - (Optional) If false, this function throws if the transaction is unable to be included in a block at the current state.
|
|
558
|
-
* @param skipFeeEnforcement - (Optional) If false, fees are enforced.
|
|
559
|
-
* @param overrides - (Optional) State overrides for the simulation, such as msgSender, contract instances and artifacts.
|
|
560
|
-
* @param scopes - (Optional) The accounts whose notes we can access in this call. Currently optional and will default to all.
|
|
622
|
+
* @param txRequest - An authenticated tx request ready for simulation.
|
|
561
623
|
* @returns A simulated transaction result object that includes public and private return values.
|
|
562
624
|
* @throws If the code for the functions executed in this transaction have not been made available via `addContracts`.
|
|
563
625
|
* Also throws if simulatePublic is true and public simulation reverts.
|
|
564
626
|
*
|
|
565
627
|
* TODO(#7456) Prevent msgSender being defined here for the first call
|
|
566
|
-
*/ simulateTx(txRequest, simulatePublic, skipTxValidation = false, skipFeeEnforcement = false, overrides, scopes) {
|
|
628
|
+
*/ simulateTx(txRequest, { simulatePublic, skipTxValidation = false, skipFeeEnforcement = false, skipKernels = true, overrides, scopes, senderForTags }) {
|
|
567
629
|
// We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
|
|
568
630
|
// to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
|
|
569
631
|
// delete the same read value, or reading values that another simulation is currently modifying).
|
|
@@ -581,21 +643,35 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
581
643
|
this.log.info(`Simulating transaction execution request to ${txRequest.functionSelector} at ${txRequest.origin}`, txInfo);
|
|
582
644
|
const syncTimer = new Timer();
|
|
583
645
|
await this.blockStateSynchronizer.sync();
|
|
646
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
584
647
|
const syncTime = syncTimer.ms();
|
|
648
|
+
const overriddenContracts = overrides?.contracts ? new Set(Object.keys(overrides.contracts)) : undefined;
|
|
649
|
+
const hasOverriddenContracts = overriddenContracts !== undefined && overriddenContracts.size > 0;
|
|
650
|
+
if (hasOverriddenContracts && !skipKernels) {
|
|
651
|
+
throw new Error('Simulating with overridden contracts is not compatible with kernel execution. Please set skipKernels to true when simulating with overridden contracts.');
|
|
652
|
+
}
|
|
585
653
|
const contractFunctionSimulator = this.#getSimulatorForTx(overrides);
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
654
|
+
if (hasOverriddenContracts) {
|
|
655
|
+
// Overridden contracts don't have a sync function, so calling sync on them would fail.
|
|
656
|
+
// We exclude them so the sync service skips them entirely.
|
|
657
|
+
this.contractSyncService.setExcludedFromSync(jobId, overriddenContracts);
|
|
658
|
+
}
|
|
590
659
|
// Execution of private functions only; no proving, and no kernel logic.
|
|
591
|
-
const privateExecutionResult = await this.#executePrivate(
|
|
660
|
+
const privateExecutionResult = await this.#executePrivate({
|
|
661
|
+
contractFunctionSimulator,
|
|
662
|
+
txRequest,
|
|
663
|
+
anchorBlockHeader,
|
|
664
|
+
scopes,
|
|
665
|
+
jobId,
|
|
666
|
+
senderForTags
|
|
667
|
+
});
|
|
592
668
|
let publicInputs;
|
|
593
669
|
let executionSteps = [];
|
|
594
670
|
if (skipKernels) {
|
|
595
|
-
({ publicInputs, executionSteps } = await generateSimulatedProvingResult(privateExecutionResult, this.contractStore));
|
|
671
|
+
({ publicInputs, executionSteps } = await generateSimulatedProvingResult(privateExecutionResult, (addr, sel)=>this.contractStore.getDebugFunctionName(addr, sel), this.node));
|
|
596
672
|
} else {
|
|
597
673
|
// Kernel logic, plus proving of all private functions and kernels.
|
|
598
|
-
({ publicInputs, executionSteps } = await this.#prove(txRequest, this.proofCreator, privateExecutionResult, {
|
|
674
|
+
({ publicInputs, executionSteps } = await this.#prove(txRequest, this.proofCreator, privateExecutionResult, anchorBlockHeader, {
|
|
599
675
|
simulate: true,
|
|
600
676
|
skipFeeEnforcement,
|
|
601
677
|
profileMode: 'none'
|
|
@@ -609,6 +685,9 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
609
685
|
const publicSimulationTimer = new Timer();
|
|
610
686
|
publicOutput = await this.#simulatePublicCalls(simulatedTx, skipFeeEnforcement);
|
|
611
687
|
publicSimulationTime = publicSimulationTimer.ms();
|
|
688
|
+
if (publicOutput?.debugLogs?.length) {
|
|
689
|
+
await displayDebugLogs(publicOutput.debugLogs, (addr)=>this.contractStore.getDebugContractName(addr));
|
|
690
|
+
}
|
|
612
691
|
}
|
|
613
692
|
let validationTime;
|
|
614
693
|
if (!skipTxValidation) {
|
|
@@ -619,7 +698,8 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
619
698
|
});
|
|
620
699
|
validationTime = validationTimer.ms();
|
|
621
700
|
if (validationResult.result === 'invalid') {
|
|
622
|
-
|
|
701
|
+
const reason = validationResult.reason.length > 0 ? ` Reason: ${validationResult.reason.join(', ')}` : '';
|
|
702
|
+
throw new Error(`The simulated transaction is unable to be added to state and is invalid.${reason}`);
|
|
623
703
|
}
|
|
624
704
|
}
|
|
625
705
|
const txHash = simulatedTx.getTxHash();
|
|
@@ -652,22 +732,19 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
652
732
|
nodeRPCCalls: simulatorStats.nodeRPCCalls
|
|
653
733
|
});
|
|
654
734
|
} catch (err) {
|
|
655
|
-
throw this.#contextualizeError(err, inspect(txRequest), `simulatePublic=${simulatePublic}`, `skipTxValidation=${skipTxValidation}`, `scopes=${scopes
|
|
735
|
+
throw this.#contextualizeError(err, inspect(txRequest), `simulatePublic=${simulatePublic}`, `skipTxValidation=${skipTxValidation}`, `scopes=${scopes.map((s)=>s.toString()).join(', ')}`);
|
|
656
736
|
}
|
|
657
737
|
});
|
|
658
738
|
}
|
|
659
739
|
/**
|
|
660
|
-
*
|
|
661
|
-
*
|
|
740
|
+
* Executes a contract utility function.
|
|
662
741
|
* @param call - The function call containing the function details, arguments, and target contract address.
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
*/ simulateUtility(call, authwits, scopes) {
|
|
668
|
-
// We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
|
|
742
|
+
*/ executeUtility(call, { authwits, scopes } = {
|
|
743
|
+
scopes: []
|
|
744
|
+
}) {
|
|
745
|
+
// We disable concurrent executions since those might execute oracles which read and write to the PXE stores (e.g.
|
|
669
746
|
// to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
|
|
670
|
-
// delete the same read value, or reading values that another
|
|
747
|
+
// delete the same read value, or reading values that another execution is currently modifying).
|
|
671
748
|
return this.#putInJobQueue(async (jobId)=>{
|
|
672
749
|
try {
|
|
673
750
|
const totalTimer = new Timer();
|
|
@@ -677,8 +754,8 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
677
754
|
const functionTimer = new Timer();
|
|
678
755
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
679
756
|
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
680
|
-
await ensureContractSynced(call.to, call.selector, (privateSyncCall)=>this.#
|
|
681
|
-
const executionResult = await this.#
|
|
757
|
+
await this.contractSyncService.ensureContractSynced(call.to, call.selector, (privateSyncCall, execScopes)=>this.#executeUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId), anchorBlockHeader, jobId, scopes);
|
|
758
|
+
const { result: executionResult, offchainEffects } = await this.#executeUtility(contractFunctionSimulator, call, authwits ?? [], scopes, jobId);
|
|
682
759
|
const functionTime = functionTimer.ms();
|
|
683
760
|
const totalTime = totalTimer.ms();
|
|
684
761
|
const perFunction = [
|
|
@@ -696,6 +773,8 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
696
773
|
const simulationStats = contractFunctionSimulator.getStats();
|
|
697
774
|
return {
|
|
698
775
|
result: executionResult,
|
|
776
|
+
offchainEffects,
|
|
777
|
+
anchorBlockTimestamp: anchorBlockHeader.globalVariables.timestamp,
|
|
699
778
|
stats: {
|
|
700
779
|
timings,
|
|
701
780
|
nodeRPCCalls: simulationStats.nodeRPCCalls
|
|
@@ -704,7 +783,7 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
704
783
|
} catch (err) {
|
|
705
784
|
const { to, name, args } = call;
|
|
706
785
|
const stringifiedArgs = args.map((arg)=>arg.toString()).join(', ');
|
|
707
|
-
throw this.#contextualizeError(err, `
|
|
786
|
+
throw this.#contextualizeError(err, `executeUtility ${to}:${name}(${stringifiedArgs})`, `scopes=${scopes.map((s)=>s.toString()).join(', ')}`);
|
|
708
787
|
}
|
|
709
788
|
});
|
|
710
789
|
}
|
|
@@ -727,7 +806,7 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
727
806
|
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
728
807
|
anchorBlockNumber = anchorBlockHeader.getBlockNumber();
|
|
729
808
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
730
|
-
await ensureContractSynced(filter.contractAddress, null, async (privateSyncCall)=>await this.#
|
|
809
|
+
await this.contractSyncService.ensureContractSynced(filter.contractAddress, null, async (privateSyncCall, execScopes)=>await this.#executeUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId), anchorBlockHeader, jobId, filter.scopes);
|
|
731
810
|
});
|
|
732
811
|
// anchorBlockNumber is set during the job and fixed to whatever it is after a block sync
|
|
733
812
|
const sanitizedFilter = new PrivateEventFilterValidator(anchorBlockNumber).validate(filter);
|
|
@@ -735,8 +814,10 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
735
814
|
return this.privateEventStore.getPrivateEvents(eventSelector, sanitizedFilter);
|
|
736
815
|
}
|
|
737
816
|
/**
|
|
738
|
-
* Stops the PXE's job queue.
|
|
739
|
-
*/ stop() {
|
|
740
|
-
|
|
817
|
+
* Stops the PXE's job queue and closes the backing store.
|
|
818
|
+
*/ async stop() {
|
|
819
|
+
await this.jobQueue.end();
|
|
820
|
+
await this.blockStateSynchronizer.stop();
|
|
821
|
+
await this.db.close();
|
|
741
822
|
}
|
|
742
823
|
}
|
|
@@ -17,7 +17,7 @@ export class AnchorBlockStore {
|
|
|
17
17
|
await this.#synchronizedHeader.set(header.toBuffer());
|
|
18
18
|
}
|
|
19
19
|
async getBlockHeader() {
|
|
20
|
-
const headerBuffer = await this.#synchronizedHeader.getAsync();
|
|
20
|
+
const headerBuffer = await this.#store.transactionAsync(()=>this.#synchronizedHeader.getAsync());
|
|
21
21
|
if (!headerBuffer) {
|
|
22
22
|
throw new Error(`Trying to get block header with a not-yet-synchronized PXE - this should never happen`);
|
|
23
23
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
import type { CapsuleStore } from './capsule_store.js';
|
|
5
|
+
/**
|
|
6
|
+
* Wraps a CapsuleStore with scope-based access control. Each operation asserts that the requested scope is in the
|
|
7
|
+
* allowed scopes list before delegating to the underlying store.
|
|
8
|
+
*/
|
|
9
|
+
export declare class CapsuleService {
|
|
10
|
+
private readonly capsuleStore;
|
|
11
|
+
private readonly allowedScopes;
|
|
12
|
+
constructor(capsuleStore: CapsuleStore, allowedScopes: AztecAddress[]);
|
|
13
|
+
setCapsule(contractAddress: AztecAddress, slot: Fr, capsule: Fr[], jobId: string, scope: AztecAddress): void;
|
|
14
|
+
getCapsule(contractAddress: AztecAddress, slot: Fr, jobId: string, scope: AztecAddress, transientCapsules?: Capsule[]): Promise<Fr[] | null>;
|
|
15
|
+
deleteCapsule(contractAddress: AztecAddress, slot: Fr, jobId: string, scope: AztecAddress): void;
|
|
16
|
+
copyCapsule(contractAddress: AztecAddress, srcSlot: Fr, dstSlot: Fr, numEntries: number, jobId: string, scope: AztecAddress): Promise<void>;
|
|
17
|
+
appendToCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr, content: Fr[][], jobId: string, scope: AztecAddress): Promise<void>;
|
|
18
|
+
readCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr, jobId: string, scope: AztecAddress): Promise<Fr[][]>;
|
|
19
|
+
setCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr, content: Fr[][], jobId: string, scope: AztecAddress): Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2Fwc3VsZV9zZXJ2aWNlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvc3RvcmFnZS9jYXBzdWxlX3N0b3JlL2NhcHN1bGVfc2VydmljZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxFQUFFLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUN6RCxPQUFPLEVBQUUsWUFBWSxFQUFFLE1BQU0sNkJBQTZCLENBQUM7QUFDM0QsT0FBTyxLQUFLLEVBQUUsT0FBTyxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFFaEQsT0FBTyxLQUFLLEVBQUUsWUFBWSxFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFFdkQ7OztHQUdHO0FBQ0gscUJBQWEsY0FBYztJQUV2QixPQUFPLENBQUMsUUFBUSxDQUFDLFlBQVk7SUFDN0IsT0FBTyxDQUFDLFFBQVEsQ0FBQyxhQUFhO0lBRmhDLFlBQ21CLFlBQVksRUFBRSxZQUFZLEVBQzFCLGFBQWEsRUFBRSxZQUFZLEVBQUUsRUFDNUM7SUFFSixVQUFVLENBQUMsZUFBZSxFQUFFLFlBQVksRUFBRSxJQUFJLEVBQUUsRUFBRSxFQUFFLE9BQU8sRUFBRSxFQUFFLEVBQUUsRUFBRSxLQUFLLEVBQUUsTUFBTSxFQUFFLEtBQUssRUFBRSxZQUFZLFFBR3BHO0lBRUssVUFBVSxDQUNkLGVBQWUsRUFBRSxZQUFZLEVBQzdCLElBQUksRUFBRSxFQUFFLEVBQ1IsS0FBSyxFQUFFLE1BQU0sRUFDYixLQUFLLEVBQUUsWUFBWSxFQUNuQixpQkFBaUIsQ0FBQyxFQUFFLE9BQU8sRUFBRSxHQUM1QixPQUFPLENBQUMsRUFBRSxFQUFFLEdBQUcsSUFBSSxDQUFDLENBWXRCO0lBRUQsYUFBYSxDQUFDLGVBQWUsRUFBRSxZQUFZLEVBQUUsSUFBSSxFQUFFLEVBQUUsRUFBRSxLQUFLLEVBQUUsTUFBTSxFQUFFLEtBQUssRUFBRSxZQUFZLFFBR3hGO0lBRUQsV0FBVyxDQUNULGVBQWUsRUFBRSxZQUFZLEVBQzdCLE9BQU8sRUFBRSxFQUFFLEVBQ1gsT0FBTyxFQUFFLEVBQUUsRUFDWCxVQUFVLEVBQUUsTUFBTSxFQUNsQixLQUFLLEVBQUUsTUFBTSxFQUNiLEtBQUssRUFBRSxZQUFZLEdBQ2xCLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FHZjtJQUVELG9CQUFvQixDQUNsQixlQUFlLEVBQUUsWUFBWSxFQUM3QixRQUFRLEVBQUUsRUFBRSxFQUNaLE9BQU8sRUFBRSxFQUFFLEVBQUUsRUFBRSxFQUNmLEtBQUssRUFBRSxNQUFNLEVBQ2IsS0FBSyxFQUFFLFlBQVksR0FDbEIsT0FBTyxDQUFDLElBQUksQ0FBQyxDQUdmO0lBRUQsZ0JBQWdCLENBQUMsZUFBZSxFQUFFLFlBQVksRUFBRSxRQUFRLEVBQUUsRUFBRSxFQUFFLEtBQUssRUFBRSxNQUFNLEVBQUUsS0FBSyxFQUFFLFlBQVksR0FBRyxPQUFPLENBQUMsRUFBRSxFQUFFLEVBQUUsQ0FBQyxDQUdqSDtJQUVELGVBQWUsQ0FBQyxlQUFlLEVBQUUsWUFBWSxFQUFFLFFBQVEsRUFBRSxFQUFFLEVBQUUsT0FBTyxFQUFFLEVBQUUsRUFBRSxFQUFFLEVBQUUsS0FBSyxFQUFFLE1BQU0sRUFBRSxLQUFLLEVBQUUsWUFBWSxpQkFHL0c7Q0FDRiJ9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capsule_service.d.ts","sourceRoot":"","sources":["../../../src/storage/capsule_store/capsule_service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD;;;GAGG;AACH,qBAAa,cAAc;IAEvB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,aAAa;IAFhC,YACmB,YAAY,EAAE,YAAY,EAC1B,aAAa,EAAE,YAAY,EAAE,EAC5C;IAEJ,UAAU,CAAC,eAAe,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,QAGpG;IAEK,UAAU,CACd,eAAe,EAAE,YAAY,EAC7B,IAAI,EAAE,EAAE,EACR,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,YAAY,EACnB,iBAAiB,CAAC,EAAE,OAAO,EAAE,GAC5B,OAAO,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC,CAYtB;IAED,aAAa,CAAC,eAAe,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,QAGxF;IAED,WAAW,CACT,eAAe,EAAE,YAAY,EAC7B,OAAO,EAAE,EAAE,EACX,OAAO,EAAE,EAAE,EACX,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,YAAY,GAClB,OAAO,CAAC,IAAI,CAAC,CAGf;IAED,oBAAoB,CAClB,eAAe,EAAE,YAAY,EAC7B,QAAQ,EAAE,EAAE,EACZ,OAAO,EAAE,EAAE,EAAE,EAAE,EACf,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,YAAY,GAClB,OAAO,CAAC,IAAI,CAAC,CAGf;IAED,gBAAgB,CAAC,eAAe,EAAE,YAAY,EAAE,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC,CAGjH;IAED,eAAe,CAAC,eAAe,EAAE,YAAY,EAAE,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,iBAG/G;CACF"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
2
|
+
/**
|
|
3
|
+
* Wraps a CapsuleStore with scope-based access control. Each operation asserts that the requested scope is in the
|
|
4
|
+
* allowed scopes list before delegating to the underlying store.
|
|
5
|
+
*/ export class CapsuleService {
|
|
6
|
+
capsuleStore;
|
|
7
|
+
allowedScopes;
|
|
8
|
+
constructor(capsuleStore, allowedScopes){
|
|
9
|
+
this.capsuleStore = capsuleStore;
|
|
10
|
+
this.allowedScopes = allowedScopes;
|
|
11
|
+
}
|
|
12
|
+
setCapsule(contractAddress, slot, capsule, jobId, scope) {
|
|
13
|
+
assertAllowedScope(scope, this.allowedScopes);
|
|
14
|
+
this.capsuleStore.setCapsule(contractAddress, slot, capsule, jobId, scope);
|
|
15
|
+
}
|
|
16
|
+
async getCapsule(contractAddress, slot, jobId, scope, transientCapsules) {
|
|
17
|
+
assertAllowedScope(scope, this.allowedScopes);
|
|
18
|
+
// TODO(#12425): On the following line, the pertinent capsule gets overshadowed by the transient one. Tackle this.
|
|
19
|
+
const maybeTransientCapsule = transientCapsules?.find((c)=>c.contractAddress.equals(contractAddress) && c.storageSlot.equals(slot) && (c.scope ?? AztecAddress.ZERO).equals(scope))?.data;
|
|
20
|
+
return maybeTransientCapsule ?? await this.capsuleStore.getCapsule(contractAddress, slot, jobId, scope);
|
|
21
|
+
}
|
|
22
|
+
deleteCapsule(contractAddress, slot, jobId, scope) {
|
|
23
|
+
assertAllowedScope(scope, this.allowedScopes);
|
|
24
|
+
this.capsuleStore.deleteCapsule(contractAddress, slot, jobId, scope);
|
|
25
|
+
}
|
|
26
|
+
copyCapsule(contractAddress, srcSlot, dstSlot, numEntries, jobId, scope) {
|
|
27
|
+
assertAllowedScope(scope, this.allowedScopes);
|
|
28
|
+
return this.capsuleStore.copyCapsule(contractAddress, srcSlot, dstSlot, numEntries, jobId, scope);
|
|
29
|
+
}
|
|
30
|
+
appendToCapsuleArray(contractAddress, baseSlot, content, jobId, scope) {
|
|
31
|
+
assertAllowedScope(scope, this.allowedScopes);
|
|
32
|
+
return this.capsuleStore.appendToCapsuleArray(contractAddress, baseSlot, content, jobId, scope);
|
|
33
|
+
}
|
|
34
|
+
readCapsuleArray(contractAddress, baseSlot, jobId, scope) {
|
|
35
|
+
assertAllowedScope(scope, this.allowedScopes);
|
|
36
|
+
return this.capsuleStore.readCapsuleArray(contractAddress, baseSlot, jobId, scope);
|
|
37
|
+
}
|
|
38
|
+
setCapsuleArray(contractAddress, baseSlot, content, jobId, scope) {
|
|
39
|
+
assertAllowedScope(scope, this.allowedScopes);
|
|
40
|
+
return this.capsuleStore.setCapsuleArray(contractAddress, baseSlot, content, jobId, scope);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function assertAllowedScope(scope, allowedScopes) {
|
|
44
|
+
if (scope.equals(AztecAddress.ZERO)) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (!allowedScopes.some((allowed)=>allowed.equals(scope))) {
|
|
48
|
+
throw new Error(`Scope ${scope.toString()} is not in the allowed scopes list: [${allowedScopes.map((s)=>s.toString()).join(', ')}]. See https://docs.aztec.network/errors/10`);
|
|
49
|
+
}
|
|
50
|
+
}
|