@aztec/pxe 0.0.1-commit.c2595eba → 0.0.1-commit.c2eed6949
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/access_scopes.d.ts +9 -0
- package/dest/access_scopes.d.ts.map +1 -0
- package/dest/access_scopes.js +6 -0
- package/dest/block_synchronizer/block_synchronizer.d.ts +4 -2
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +7 -1
- package/dest/config/index.d.ts +2 -2
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +1 -1
- package/dest/config/package_info.js +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +61 -31
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +200 -74
- 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 +2 -3
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/event_validation_request.js +5 -4
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +1 -3
- package/dest/contract_function_simulator/noir-structs/message_tx_context.d.ts +16 -0
- package/dest/contract_function_simulator/noir-structs/message_tx_context.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/message_tx_context.js +57 -0
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +2 -4
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/note_validation_request.js +3 -5
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +50 -45
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts +9 -0
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.js +42 -0
- package/dest/contract_function_simulator/oracle/oracle.d.ts +45 -44
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +187 -106
- package/dest/contract_function_simulator/oracle/private_execution.js +5 -3
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +54 -79
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +100 -87
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +95 -53
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +205 -106
- package/dest/contract_logging.d.ts +22 -0
- package/dest/contract_logging.d.ts.map +1 -0
- package/dest/contract_logging.js +23 -0
- package/dest/contract_sync/contract_sync_service.d.ts +45 -0
- package/dest/contract_sync/contract_sync_service.d.ts.map +1 -0
- package/dest/contract_sync/contract_sync_service.js +114 -0
- package/dest/contract_sync/helpers.d.ts +29 -0
- package/dest/contract_sync/helpers.d.ts.map +1 -0
- package/dest/contract_sync/{index.js → helpers.js} +13 -12
- 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 +4 -1
- package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.js +3 -0
- package/dest/entrypoints/client/bundle/utils.d.ts +1 -1
- package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/utils.js +11 -2
- package/dest/entrypoints/client/lazy/index.d.ts +4 -1
- package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/index.js +3 -0
- package/dest/entrypoints/client/lazy/utils.d.ts +1 -1
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +11 -2
- package/dest/entrypoints/server/index.d.ts +4 -2
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +3 -1
- package/dest/entrypoints/server/utils.js +9 -1
- package/dest/events/event_service.d.ts +4 -5
- package/dest/events/event_service.d.ts.map +1 -1
- package/dest/events/event_service.js +5 -6
- package/dest/logs/log_service.d.ts +6 -5
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +18 -28
- 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 +7 -7
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +9 -9
- package/dest/notes_filter.d.ts +25 -0
- package/dest/notes_filter.d.ts.map +1 -0
- package/dest/notes_filter.js +4 -0
- package/dest/oracle_version.d.ts +3 -3
- package/dest/oracle_version.d.ts.map +1 -1
- package/dest/oracle_version.js +3 -3
- 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 +19 -11
- package/dest/private_kernel/private_kernel_oracle.d.ts +6 -2
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle.js +7 -3
- package/dest/pxe.d.ts +74 -24
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +124 -74
- package/dest/storage/address_store/address_store.d.ts +1 -1
- package/dest/storage/address_store/address_store.d.ts.map +1 -1
- package/dest/storage/address_store/address_store.js +12 -11
- package/dest/storage/anchor_block_store/anchor_block_store.d.ts +9 -1
- package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -1
- package/dest/storage/anchor_block_store/anchor_block_store.js +8 -1
- package/dest/storage/capsule_store/capsule_store.js +6 -8
- 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 +157 -72
- package/dest/storage/metadata.d.ts +1 -1
- package/dest/storage/metadata.js +1 -1
- package/dest/storage/note_store/note_store.d.ts +13 -3
- package/dest/storage/note_store/note_store.d.ts.map +1 -1
- package/dest/storage/note_store/note_store.js +173 -131
- 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 +126 -101
- 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/recipient_tagging_store.js +31 -19
- package/dest/storage/tagging_store/sender_address_book_store.d.ts +1 -1
- package/dest/storage/tagging_store/sender_address_book_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_address_book_store.js +20 -14
- 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 +233 -137
- 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 +7 -7
- 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/access_scopes.ts +9 -0
- package/src/block_synchronizer/block_synchronizer.ts +6 -0
- package/src/config/index.ts +1 -1
- package/src/config/package_info.ts +1 -1
- package/src/contract_function_simulator/contract_function_simulator.ts +360 -137
- 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 +8 -5
- package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +1 -4
- package/src/contract_function_simulator/noir-structs/message_tx_context.ts +55 -0
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +3 -6
- package/src/contract_function_simulator/oracle/interfaces.ts +60 -60
- package/src/contract_function_simulator/oracle/legacy_oracle_mappings.ts +135 -0
- package/src/contract_function_simulator/oracle/oracle.ts +198 -143
- package/src/contract_function_simulator/oracle/private_execution.ts +4 -4
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +126 -184
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +308 -122
- package/src/contract_logging.ts +39 -0
- package/src/contract_sync/contract_sync_service.ts +181 -0
- package/src/contract_sync/{index.ts → helpers.ts} +21 -21
- package/src/debug/pxe_debug_utils.ts +48 -18
- package/src/entrypoints/client/bundle/index.ts +3 -0
- package/src/entrypoints/client/bundle/utils.ts +12 -2
- package/src/entrypoints/client/lazy/index.ts +3 -0
- package/src/entrypoints/client/lazy/utils.ts +12 -2
- package/src/entrypoints/server/index.ts +3 -1
- package/src/entrypoints/server/utils.ts +7 -7
- package/src/events/event_service.ts +4 -6
- package/src/logs/log_service.ts +25 -35
- package/src/messages/message_context_service.ts +45 -0
- package/src/notes/note_service.ts +9 -10
- package/src/notes_filter.ts +26 -0
- package/src/oracle_version.ts +3 -3
- 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 +19 -12
- package/src/private_kernel/private_kernel_oracle.ts +7 -7
- package/src/pxe.ts +228 -125
- package/src/storage/address_store/address_store.ts +15 -15
- package/src/storage/anchor_block_store/anchor_block_store.ts +8 -0
- package/src/storage/capsule_store/capsule_store.ts +8 -8
- package/src/storage/contract_store/contract_store.ts +186 -76
- package/src/storage/metadata.ts +1 -1
- package/src/storage/note_store/note_store.ts +195 -153
- package/src/storage/private_event_store/private_event_store.ts +151 -128
- package/src/storage/tagging_store/recipient_tagging_store.ts +38 -24
- package/src/storage/tagging_store/sender_address_book_store.ts +20 -14
- package/src/storage/tagging_store/sender_tagging_store.ts +287 -156
- 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 +7 -10
- 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,8 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
45
49
|
recipientTaggingStore;
|
|
46
50
|
addressStore;
|
|
47
51
|
privateEventStore;
|
|
52
|
+
contractSyncService;
|
|
53
|
+
messageContextService;
|
|
48
54
|
simulator;
|
|
49
55
|
proverEnabled;
|
|
50
56
|
proofCreator;
|
|
@@ -53,8 +59,9 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
53
59
|
jobQueue;
|
|
54
60
|
jobCoordinator;
|
|
55
61
|
debug;
|
|
56
|
-
constructor(node, blockStateSynchronizer, keyStore, contractStore, noteStore, capsuleStore, anchorBlockStore, senderTaggingStore, senderAddressBookStore, recipientTaggingStore, addressStore, privateEventStore, simulator, proverEnabled, proofCreator, protocolContractsProvider, log, jobQueue, jobCoordinator, debug){
|
|
62
|
+
constructor(node, db, blockStateSynchronizer, keyStore, contractStore, noteStore, capsuleStore, anchorBlockStore, senderTaggingStore, senderAddressBookStore, recipientTaggingStore, addressStore, privateEventStore, contractSyncService, messageContextService, simulator, proverEnabled, proofCreator, protocolContractsProvider, log, jobQueue, jobCoordinator, debug){
|
|
57
63
|
this.node = node;
|
|
64
|
+
this.db = db;
|
|
58
65
|
this.blockStateSynchronizer = blockStateSynchronizer;
|
|
59
66
|
this.keyStore = keyStore;
|
|
60
67
|
this.contractStore = contractStore;
|
|
@@ -66,6 +73,8 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
66
73
|
this.recipientTaggingStore = recipientTaggingStore;
|
|
67
74
|
this.addressStore = addressStore;
|
|
68
75
|
this.privateEventStore = privateEventStore;
|
|
76
|
+
this.contractSyncService = contractSyncService;
|
|
77
|
+
this.messageContextService = messageContextService;
|
|
69
78
|
this.simulator = simulator;
|
|
70
79
|
this.proverEnabled = proverEnabled;
|
|
71
80
|
this.proofCreator = proofCreator;
|
|
@@ -81,11 +90,12 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
81
90
|
* can be contacted.
|
|
82
91
|
*
|
|
83
92
|
* @returns A promise that resolves PXE is ready to be used.
|
|
84
|
-
*/ static async create(node, store, proofCreator, simulator, protocolContractsProvider, config, loggerOrSuffix) {
|
|
93
|
+
*/ static async create({ node, store, proofCreator, simulator, protocolContractsProvider, config, loggerOrSuffix }) {
|
|
85
94
|
// Extract bindings from the logger, or use empty bindings if a string suffix is provided.
|
|
86
95
|
const bindings = loggerOrSuffix && typeof loggerOrSuffix !== 'string' ? loggerOrSuffix.getBindings() : undefined;
|
|
87
96
|
const log = !loggerOrSuffix || typeof loggerOrSuffix === 'string' ? createLogger(loggerOrSuffix ? `pxe:service:${loggerOrSuffix}` : `pxe:service`) : loggerOrSuffix;
|
|
88
|
-
const
|
|
97
|
+
const info = await node.getNodeInfo();
|
|
98
|
+
const proverEnabled = config.proverEnabled !== undefined ? config.proverEnabled : info.realProofs;
|
|
89
99
|
const addressStore = new AddressStore(store);
|
|
90
100
|
const privateEventStore = new PrivateEventStore(store);
|
|
91
101
|
const contractStore = new ContractStore(store);
|
|
@@ -97,29 +107,45 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
97
107
|
const capsuleStore = new CapsuleStore(store);
|
|
98
108
|
const keyStore = new KeyStore(store);
|
|
99
109
|
const tipsStore = new L2TipsKVStore(store, 'pxe');
|
|
100
|
-
const
|
|
110
|
+
const contractSyncService = new ContractSyncService(node, contractStore, noteStore, createLogger('pxe:contract_sync', bindings));
|
|
111
|
+
const messageContextService = new MessageContextService(node);
|
|
112
|
+
const synchronizer = new BlockSynchronizer(node, store, anchorBlockStore, noteStore, privateEventStore, tipsStore, contractSyncService, config, bindings);
|
|
101
113
|
const jobCoordinator = new JobCoordinator(store, bindings);
|
|
102
114
|
jobCoordinator.registerStores([
|
|
103
115
|
capsuleStore,
|
|
104
116
|
senderTaggingStore,
|
|
105
117
|
recipientTaggingStore,
|
|
106
118
|
privateEventStore,
|
|
107
|
-
noteStore
|
|
119
|
+
noteStore,
|
|
120
|
+
contractSyncService
|
|
108
121
|
]);
|
|
109
|
-
const debugUtils = new PXEDebugUtils(
|
|
122
|
+
const debugUtils = new PXEDebugUtils(contractSyncService, noteStore, synchronizer, anchorBlockStore);
|
|
110
123
|
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.
|
|
124
|
+
const pxe = new PXE(node, store, synchronizer, keyStore, contractStore, noteStore, capsuleStore, anchorBlockStore, senderTaggingStore, senderAddressBookStore, recipientTaggingStore, addressStore, privateEventStore, contractSyncService, messageContextService, simulator, proverEnabled, proofCreator, protocolContractsProvider, log, jobQueue, jobCoordinator, debugUtils);
|
|
125
|
+
debugUtils.setPXEHelpers(pxe.#putInJobQueue.bind(pxe), pxe.#getSimulatorForTx.bind(pxe), pxe.#executeUtility.bind(pxe));
|
|
113
126
|
pxe.jobQueue.start();
|
|
114
127
|
await pxe.#registerProtocolContracts();
|
|
115
|
-
const info = await node.getNodeInfo();
|
|
116
128
|
log.info(`Started PXE connected to chain ${info.l1ChainId} version ${info.rollupVersion}`);
|
|
117
129
|
return pxe;
|
|
118
130
|
}
|
|
119
131
|
// Internal methods
|
|
120
132
|
#getSimulatorForTx(overrides) {
|
|
121
133
|
const proxyContractStore = ProxiedContractStoreFactory.create(this.contractStore, overrides?.contracts);
|
|
122
|
-
return new ContractFunctionSimulator(
|
|
134
|
+
return new ContractFunctionSimulator({
|
|
135
|
+
contractStore: proxyContractStore,
|
|
136
|
+
noteStore: this.noteStore,
|
|
137
|
+
keyStore: this.keyStore,
|
|
138
|
+
addressStore: this.addressStore,
|
|
139
|
+
aztecNode: BenchmarkedNodeFactory.create(this.node),
|
|
140
|
+
senderTaggingStore: this.senderTaggingStore,
|
|
141
|
+
recipientTaggingStore: this.recipientTaggingStore,
|
|
142
|
+
senderAddressBookStore: this.senderAddressBookStore,
|
|
143
|
+
capsuleStore: this.capsuleStore,
|
|
144
|
+
privateEventStore: this.privateEventStore,
|
|
145
|
+
simulator: this.simulator,
|
|
146
|
+
contractSyncService: this.contractSyncService,
|
|
147
|
+
messageContextService: this.messageContextService
|
|
148
|
+
});
|
|
123
149
|
}
|
|
124
150
|
#contextualizeError(err, ...context) {
|
|
125
151
|
let contextStr = '';
|
|
@@ -162,8 +188,8 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
162
188
|
async #registerProtocolContracts() {
|
|
163
189
|
const registered = {};
|
|
164
190
|
for (const name of protocolContractNames){
|
|
165
|
-
const { address,
|
|
166
|
-
await this.contractStore.addContractArtifact(
|
|
191
|
+
const { address, instance, artifact } = await this.protocolContractsProvider.getProtocolContractArtifact(name);
|
|
192
|
+
await this.contractStore.addContractArtifact(artifact);
|
|
167
193
|
await this.contractStore.addContractInstance(instance);
|
|
168
194
|
registered[name] = address.toString();
|
|
169
195
|
}
|
|
@@ -175,10 +201,14 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
175
201
|
const { origin: contractAddress, functionSelector } = txRequest;
|
|
176
202
|
try {
|
|
177
203
|
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
178
|
-
await ensureContractSynced(contractAddress, functionSelector, (privateSyncCall)=>this.#
|
|
179
|
-
const result = await contractFunctionSimulator.run(txRequest,
|
|
180
|
-
|
|
181
|
-
|
|
204
|
+
await this.contractSyncService.ensureContractSynced(contractAddress, functionSelector, (privateSyncCall, execScopes)=>this.#executeUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId), anchorBlockHeader, jobId, scopes);
|
|
205
|
+
const result = await contractFunctionSimulator.run(txRequest, {
|
|
206
|
+
contractAddress,
|
|
207
|
+
selector: functionSelector,
|
|
208
|
+
anchorBlockHeader,
|
|
209
|
+
scopes,
|
|
210
|
+
jobId
|
|
211
|
+
});
|
|
182
212
|
this.log.debug(`Private simulation completed for ${contractAddress.toString()}:${functionSelector}`);
|
|
183
213
|
return result;
|
|
184
214
|
} catch (err) {
|
|
@@ -189,18 +219,22 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
189
219
|
}
|
|
190
220
|
}
|
|
191
221
|
/**
|
|
192
|
-
*
|
|
222
|
+
* Execute a utility function call on the given contract.
|
|
193
223
|
* @param contractFunctionSimulator - The simulator to use for the function call.
|
|
194
224
|
* @param call - The function call to execute.
|
|
195
225
|
* @param authWitnesses - Authentication witnesses required for the function call.
|
|
196
226
|
* @param scopes - Optional array of account addresses whose notes can be accessed in this call. Defaults to all
|
|
197
227
|
* accounts if not specified.
|
|
198
228
|
* @param jobId - The job ID for staged writes.
|
|
199
|
-
* @returns The
|
|
200
|
-
*/ async #
|
|
229
|
+
* @returns The execution result containing the outputs of the utility function.
|
|
230
|
+
*/ async #executeUtility(contractFunctionSimulator, call, authWitnesses, scopes, jobId) {
|
|
201
231
|
try {
|
|
202
232
|
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
203
|
-
|
|
233
|
+
const { result, offchainEffects } = await contractFunctionSimulator.runUtility(call, authWitnesses ?? [], anchorBlockHeader, scopes, jobId);
|
|
234
|
+
return {
|
|
235
|
+
result,
|
|
236
|
+
offchainEffects
|
|
237
|
+
};
|
|
204
238
|
} catch (err) {
|
|
205
239
|
if (err instanceof SimulationError) {
|
|
206
240
|
await enrichSimulationError(err, this.contractStore, this.log);
|
|
@@ -252,7 +286,17 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
252
286
|
return await kernelTraceProver.proveWithKernels(txExecutionRequest.toTxRequest(), privateExecutionResult, config);
|
|
253
287
|
}
|
|
254
288
|
// Public API
|
|
255
|
-
|
|
289
|
+
/**
|
|
290
|
+
* Returns the block header up to which the PXE has synced.
|
|
291
|
+
* @returns The synced block header
|
|
292
|
+
*/ getSyncedBlockHeader() {
|
|
293
|
+
return this.anchorBlockStore.getBlockHeader();
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Returns the contract instance for a given address, if it's registered in the PXE.
|
|
297
|
+
* @param address - The contract address.
|
|
298
|
+
* @returns The contract instance if found, undefined otherwise.
|
|
299
|
+
*/ getContractInstance(address) {
|
|
256
300
|
return this.contractStore.getContractInstance(address);
|
|
257
301
|
}
|
|
258
302
|
/**
|
|
@@ -302,6 +346,9 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
302
346
|
const wasAdded = await this.senderAddressBookStore.addSender(sender);
|
|
303
347
|
if (wasAdded) {
|
|
304
348
|
this.log.info(`Added sender:\n ${sender.toString()}`);
|
|
349
|
+
// Wipe the entire sync cache: the new sender's tagged logs could contain notes/events for any contract, so
|
|
350
|
+
// all contracts must re-sync to discover them.
|
|
351
|
+
this.contractSyncService.wipe();
|
|
305
352
|
} else {
|
|
306
353
|
this.log.info(`Sender:\n "${sender.toString()}"\n already registered.`);
|
|
307
354
|
}
|
|
@@ -339,8 +386,7 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
339
386
|
*
|
|
340
387
|
* @param artifact - The build artifact for the contract class.
|
|
341
388
|
*/ async registerContractClass(artifact) {
|
|
342
|
-
const
|
|
343
|
-
await this.contractStore.addContractArtifact(contractClassId, artifact);
|
|
389
|
+
const contractClassId = await this.contractStore.addContractArtifact(artifact);
|
|
344
390
|
this.log.info(`Added contract class ${artifact.name} with id ${contractClassId}`);
|
|
345
391
|
}
|
|
346
392
|
/**
|
|
@@ -356,15 +402,14 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
356
402
|
if (artifact) {
|
|
357
403
|
// If the user provides an artifact, validate it against the expected class id and register it
|
|
358
404
|
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})`);
|
|
405
|
+
if (!contractClass.id.equals(instance.currentContractClassId)) {
|
|
406
|
+
throw new Error(`Artifact does not match expected class id (computed ${contractClass.id} but instance refers to ${instance.currentContractClassId})`);
|
|
362
407
|
}
|
|
363
408
|
const computedAddress = await computeContractAddressFromInstance(instance);
|
|
364
409
|
if (!computedAddress.equals(instance.address)) {
|
|
365
410
|
throw new Error('Added a contract in which the address does not match the contract instance.');
|
|
366
411
|
}
|
|
367
|
-
await this.contractStore.addContractArtifact(
|
|
412
|
+
await this.contractStore.addContractArtifact(artifact, contractClass);
|
|
368
413
|
const publicFunctionSignatures = artifact.functions.filter((fn)=>fn.functionType === FunctionType.PUBLIC).map((fn)=>decodeFunctionSignature(fn.name, fn.parameters));
|
|
369
414
|
await this.node.registerContractFunctionSignatures(publicFunctionSignatures);
|
|
370
415
|
} else {
|
|
@@ -400,11 +445,13 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
400
445
|
if (!contractClass.id.equals(currentClassId)) {
|
|
401
446
|
throw new Error('Could not update contract to a class different from the current one.');
|
|
402
447
|
}
|
|
403
|
-
await this.contractStore.addContractArtifact(contractClass.id, artifact);
|
|
404
448
|
const publicFunctionSignatures = artifact.functions.filter((fn)=>fn.functionType === FunctionType.PUBLIC).map((fn)=>decodeFunctionSignature(fn.name, fn.parameters));
|
|
405
449
|
await this.node.registerContractFunctionSignatures(publicFunctionSignatures);
|
|
406
450
|
currentInstance.currentContractClassId = contractClass.id;
|
|
407
|
-
await
|
|
451
|
+
await Promise.all([
|
|
452
|
+
this.contractStore.addContractArtifact(artifact, contractClass),
|
|
453
|
+
this.contractStore.addContractInstance(currentInstance)
|
|
454
|
+
]);
|
|
408
455
|
this.log.info(`Updated contract ${artifact.name} at ${contractAddress.toString()} to class ${contractClass.id}`);
|
|
409
456
|
});
|
|
410
457
|
}
|
|
@@ -419,10 +466,11 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
419
466
|
* (where validators prove the public portion).
|
|
420
467
|
*
|
|
421
468
|
* @param txRequest - An authenticated tx request ready for proving
|
|
469
|
+
* @param scopes - Addresses whose private state and keys are accessible during private execution.
|
|
422
470
|
* @returns A result containing the proof and public inputs of the tail circuit.
|
|
423
471
|
* @throws If contract code not found, or public simulation reverts.
|
|
424
472
|
* Also throws if simulatePublic is true and public simulation reverts.
|
|
425
|
-
*/ proveTx(txRequest) {
|
|
473
|
+
*/ proveTx(txRequest, scopes) {
|
|
426
474
|
let privateExecutionResult;
|
|
427
475
|
// We disable proving concurrently mostly out of caution, since it accesses some of our stores. Proving is so
|
|
428
476
|
// computationally demanding that it'd be rare for someone to try to do it concurrently regardless.
|
|
@@ -433,7 +481,7 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
433
481
|
await this.blockStateSynchronizer.sync();
|
|
434
482
|
const syncTime = syncTimer.ms();
|
|
435
483
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
436
|
-
privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest,
|
|
484
|
+
privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest, scopes, jobId);
|
|
437
485
|
const { publicInputs, chonkProof, executionSteps, timings: { proving } = {} } = await this.#prove(txRequest, this.proofCreator, privateExecutionResult, {
|
|
438
486
|
simulate: false,
|
|
439
487
|
skipFeeEnforcement: false,
|
|
@@ -464,16 +512,16 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
464
512
|
// transaction before this one is included in a block from this PXE, and that transaction contains a log with
|
|
465
513
|
// a tag derived from the same secret, we would reuse the tag and the transactions would be linked. Hence
|
|
466
514
|
// storing the tags here prevents linkage of txs sent from the same PXE.
|
|
467
|
-
const
|
|
468
|
-
if (
|
|
515
|
+
const taggingIndexRangesUsedInTheTx = privateExecutionResult.entrypoint.taggingIndexRanges;
|
|
516
|
+
if (taggingIndexRangesUsedInTheTx.length > 0) {
|
|
469
517
|
// TODO(benesjan): The following is an expensive operation. Figure out a way to avoid it.
|
|
470
518
|
const txHash = (await txProvingResult.toTx()).txHash;
|
|
471
|
-
await this.senderTaggingStore.storePendingIndexes(
|
|
472
|
-
this.log.debug(`Stored used
|
|
473
|
-
|
|
519
|
+
await this.senderTaggingStore.storePendingIndexes(taggingIndexRangesUsedInTheTx, txHash, jobId);
|
|
520
|
+
this.log.debug(`Stored used tagging index ranges as sender for the tx`, {
|
|
521
|
+
taggingIndexRangesUsedInTheTx
|
|
474
522
|
});
|
|
475
523
|
} else {
|
|
476
|
-
this.log.debug(`No
|
|
524
|
+
this.log.debug(`No tagging index ranges used in the tx`);
|
|
477
525
|
}
|
|
478
526
|
return txProvingResult;
|
|
479
527
|
} catch (err) {
|
|
@@ -483,13 +531,10 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
483
531
|
}
|
|
484
532
|
/**
|
|
485
533
|
* 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.
|
|
534
|
+
* @param txRequest - An authenticated tx request ready for simulation.
|
|
490
535
|
* @returns A trace of the program execution with gate counts.
|
|
491
536
|
* @throws If the code for the functions executed in this transaction have not been made available via `addContracts`.
|
|
492
|
-
*/ profileTx(txRequest, profileMode, skipProofGeneration = true) {
|
|
537
|
+
*/ profileTx(txRequest, { profileMode, skipProofGeneration = true, scopes }) {
|
|
493
538
|
// We disable concurrent profiles for consistency with simulateTx.
|
|
494
539
|
return this.#putInJobQueue(async (jobId)=>{
|
|
495
540
|
const totalTimer = new Timer();
|
|
@@ -507,7 +552,7 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
507
552
|
await this.blockStateSynchronizer.sync();
|
|
508
553
|
const syncTime = syncTimer.ms();
|
|
509
554
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
510
|
-
const privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest,
|
|
555
|
+
const privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest, scopes, jobId);
|
|
511
556
|
const { executionSteps, timings: { proving } = {} } = await this.#prove(txRequest, this.proofCreator, privateExecutionResult, {
|
|
512
557
|
simulate: skipProofGeneration,
|
|
513
558
|
skipFeeEnforcement: false,
|
|
@@ -552,18 +597,13 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
552
597
|
* In that case, the transaction returned is only potentially ready to be sent to the network for execution.
|
|
553
598
|
*
|
|
554
599
|
*
|
|
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.
|
|
600
|
+
* @param txRequest - An authenticated tx request ready for simulation.
|
|
561
601
|
* @returns A simulated transaction result object that includes public and private return values.
|
|
562
602
|
* @throws If the code for the functions executed in this transaction have not been made available via `addContracts`.
|
|
563
603
|
* Also throws if simulatePublic is true and public simulation reverts.
|
|
564
604
|
*
|
|
565
605
|
* TODO(#7456) Prevent msgSender being defined here for the first call
|
|
566
|
-
*/ simulateTx(txRequest, simulatePublic, skipTxValidation = false, skipFeeEnforcement = false, overrides, scopes) {
|
|
606
|
+
*/ simulateTx(txRequest, { simulatePublic, skipTxValidation = false, skipFeeEnforcement = false, skipKernels = true, overrides, scopes }) {
|
|
567
607
|
// We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
|
|
568
608
|
// to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
|
|
569
609
|
// delete the same read value, or reading values that another simulation is currently modifying).
|
|
@@ -582,17 +622,23 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
582
622
|
const syncTimer = new Timer();
|
|
583
623
|
await this.blockStateSynchronizer.sync();
|
|
584
624
|
const syncTime = syncTimer.ms();
|
|
625
|
+
const overriddenContracts = overrides?.contracts ? new Set(Object.keys(overrides.contracts)) : undefined;
|
|
626
|
+
const hasOverriddenContracts = overriddenContracts !== undefined && overriddenContracts.size > 0;
|
|
627
|
+
if (hasOverriddenContracts && !skipKernels) {
|
|
628
|
+
throw new Error('Simulating with overridden contracts is not compatible with kernel execution. Please set skipKernels to true when simulating with overridden contracts.');
|
|
629
|
+
}
|
|
585
630
|
const contractFunctionSimulator = this.#getSimulatorForTx(overrides);
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
631
|
+
if (hasOverriddenContracts) {
|
|
632
|
+
// Overridden contracts don't have a sync function, so calling sync on them would fail.
|
|
633
|
+
// We exclude them so the sync service skips them entirely.
|
|
634
|
+
this.contractSyncService.setExcludedFromSync(jobId, overriddenContracts);
|
|
635
|
+
}
|
|
590
636
|
// Execution of private functions only; no proving, and no kernel logic.
|
|
591
637
|
const privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest, scopes, jobId);
|
|
592
638
|
let publicInputs;
|
|
593
639
|
let executionSteps = [];
|
|
594
640
|
if (skipKernels) {
|
|
595
|
-
({ publicInputs, executionSteps } = await generateSimulatedProvingResult(privateExecutionResult, this.contractStore));
|
|
641
|
+
({ publicInputs, executionSteps } = await generateSimulatedProvingResult(privateExecutionResult, (addr, sel)=>this.contractStore.getDebugFunctionName(addr, sel), this.node));
|
|
596
642
|
} else {
|
|
597
643
|
// Kernel logic, plus proving of all private functions and kernels.
|
|
598
644
|
({ publicInputs, executionSteps } = await this.#prove(txRequest, this.proofCreator, privateExecutionResult, {
|
|
@@ -609,6 +655,9 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
609
655
|
const publicSimulationTimer = new Timer();
|
|
610
656
|
publicOutput = await this.#simulatePublicCalls(simulatedTx, skipFeeEnforcement);
|
|
611
657
|
publicSimulationTime = publicSimulationTimer.ms();
|
|
658
|
+
if (publicOutput?.debugLogs?.length) {
|
|
659
|
+
await displayDebugLogs(publicOutput.debugLogs, (addr)=>this.contractStore.getDebugContractName(addr));
|
|
660
|
+
}
|
|
612
661
|
}
|
|
613
662
|
let validationTime;
|
|
614
663
|
if (!skipTxValidation) {
|
|
@@ -619,7 +668,8 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
619
668
|
});
|
|
620
669
|
validationTime = validationTimer.ms();
|
|
621
670
|
if (validationResult.result === 'invalid') {
|
|
622
|
-
|
|
671
|
+
const reason = validationResult.reason.length > 0 ? ` Reason: ${validationResult.reason.join(', ')}` : '';
|
|
672
|
+
throw new Error(`The simulated transaction is unable to be added to state and is invalid.${reason}`);
|
|
623
673
|
}
|
|
624
674
|
}
|
|
625
675
|
const txHash = simulatedTx.getTxHash();
|
|
@@ -652,22 +702,19 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
652
702
|
nodeRPCCalls: simulatorStats.nodeRPCCalls
|
|
653
703
|
});
|
|
654
704
|
} catch (err) {
|
|
655
|
-
throw this.#contextualizeError(err, inspect(txRequest), `simulatePublic=${simulatePublic}`, `skipTxValidation=${skipTxValidation}`, `scopes=${scopes
|
|
705
|
+
throw this.#contextualizeError(err, inspect(txRequest), `simulatePublic=${simulatePublic}`, `skipTxValidation=${skipTxValidation}`, `scopes=${scopes === 'ALL_SCOPES' ? scopes : scopes.map((s)=>s.toString()).join(', ')}`);
|
|
656
706
|
}
|
|
657
707
|
});
|
|
658
708
|
}
|
|
659
709
|
/**
|
|
660
|
-
*
|
|
661
|
-
*
|
|
710
|
+
* Executes a contract utility function.
|
|
662
711
|
* @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.
|
|
712
|
+
*/ executeUtility(call, { authwits, scopes } = {
|
|
713
|
+
scopes: 'ALL_SCOPES'
|
|
714
|
+
}) {
|
|
715
|
+
// We disable concurrent executions since those might execute oracles which read and write to the PXE stores (e.g.
|
|
669
716
|
// 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
|
|
717
|
+
// delete the same read value, or reading values that another execution is currently modifying).
|
|
671
718
|
return this.#putInJobQueue(async (jobId)=>{
|
|
672
719
|
try {
|
|
673
720
|
const totalTimer = new Timer();
|
|
@@ -677,8 +724,8 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
677
724
|
const functionTimer = new Timer();
|
|
678
725
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
679
726
|
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
680
|
-
await ensureContractSynced(call.to, call.selector, (privateSyncCall)=>this.#
|
|
681
|
-
const executionResult = await this.#
|
|
727
|
+
await this.contractSyncService.ensureContractSynced(call.to, call.selector, (privateSyncCall, execScopes)=>this.#executeUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId), anchorBlockHeader, jobId, scopes);
|
|
728
|
+
const { result: executionResult, offchainEffects } = await this.#executeUtility(contractFunctionSimulator, call, authwits ?? [], scopes, jobId);
|
|
682
729
|
const functionTime = functionTimer.ms();
|
|
683
730
|
const totalTime = totalTimer.ms();
|
|
684
731
|
const perFunction = [
|
|
@@ -696,6 +743,8 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
696
743
|
const simulationStats = contractFunctionSimulator.getStats();
|
|
697
744
|
return {
|
|
698
745
|
result: executionResult,
|
|
746
|
+
offchainEffects,
|
|
747
|
+
anchorBlockTimestamp: anchorBlockHeader.globalVariables.timestamp,
|
|
699
748
|
stats: {
|
|
700
749
|
timings,
|
|
701
750
|
nodeRPCCalls: simulationStats.nodeRPCCalls
|
|
@@ -704,7 +753,7 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
704
753
|
} catch (err) {
|
|
705
754
|
const { to, name, args } = call;
|
|
706
755
|
const stringifiedArgs = args.map((arg)=>arg.toString()).join(', ');
|
|
707
|
-
throw this.#contextualizeError(err, `
|
|
756
|
+
throw this.#contextualizeError(err, `executeUtility ${to}:${name}(${stringifiedArgs})`, `scopes=${scopes === 'ALL_SCOPES' ? scopes : scopes.map((s)=>s.toString()).join(', ')}`);
|
|
708
757
|
}
|
|
709
758
|
});
|
|
710
759
|
}
|
|
@@ -727,7 +776,7 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
727
776
|
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
728
777
|
anchorBlockNumber = anchorBlockHeader.getBlockNumber();
|
|
729
778
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
730
|
-
await ensureContractSynced(filter.contractAddress, null, async (privateSyncCall)=>await this.#
|
|
779
|
+
await this.contractSyncService.ensureContractSynced(filter.contractAddress, null, async (privateSyncCall, execScopes)=>await this.#executeUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId), anchorBlockHeader, jobId, filter.scopes);
|
|
731
780
|
});
|
|
732
781
|
// anchorBlockNumber is set during the job and fixed to whatever it is after a block sync
|
|
733
782
|
const sanitizedFilter = new PrivateEventFilterValidator(anchorBlockNumber).validate(filter);
|
|
@@ -735,8 +784,9 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
735
784
|
return this.privateEventStore.getPrivateEvents(eventSelector, sanitizedFilter);
|
|
736
785
|
}
|
|
737
786
|
/**
|
|
738
|
-
* Stops the PXE's job queue.
|
|
739
|
-
*/ stop() {
|
|
740
|
-
|
|
787
|
+
* Stops the PXE's job queue and closes the backing store.
|
|
788
|
+
*/ async stop() {
|
|
789
|
+
await this.jobQueue.end();
|
|
790
|
+
await this.db.close();
|
|
741
791
|
}
|
|
742
792
|
}
|
|
@@ -8,4 +8,4 @@ export declare class AddressStore {
|
|
|
8
8
|
getCompleteAddress(account: AztecAddress): Promise<CompleteAddress | undefined>;
|
|
9
9
|
getCompleteAddresses(): Promise<CompleteAddress[]>;
|
|
10
10
|
}
|
|
11
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
11
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWRkcmVzc19zdG9yZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3N0b3JhZ2UvYWRkcmVzc19zdG9yZS9hZGRyZXNzX3N0b3JlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sS0FBSyxFQUFtQixpQkFBaUIsRUFBaUIsTUFBTSxpQkFBaUIsQ0FBQztBQUN6RixPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUNoRSxPQUFPLEVBQUUsZUFBZSxFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFFekQscUJBQWEsWUFBWTs7SUFLdkIsWUFBWSxLQUFLLEVBQUUsaUJBQWlCLEVBS25DO0lBRUQsa0JBQWtCLENBQUMsZUFBZSxFQUFFLGVBQWUsR0FBRyxPQUFPLENBQUMsT0FBTyxDQUFDLENBMEJyRTtJQUVELGtCQUFrQixDQUFDLE9BQU8sRUFBRSxZQUFZLEdBQUcsT0FBTyxDQUFDLGVBQWUsR0FBRyxTQUFTLENBQUMsQ0FVOUU7SUFFRCxvQkFBb0IsSUFBSSxPQUFPLENBQUMsZUFBZSxFQUFFLENBQUMsQ0FNakQ7Q0FDRiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"address_store.d.ts","sourceRoot":"","sources":["../../../src/storage/address_store/address_store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAmB,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACzF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,qBAAa,YAAY;;IAKvB,YAAY,KAAK,EAAE,iBAAiB,EAKnC;IAED,kBAAkB,CAAC,eAAe,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,CA0BrE;
|
|
1
|
+
{"version":3,"file":"address_store.d.ts","sourceRoot":"","sources":["../../../src/storage/address_store/address_store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAmB,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACzF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,qBAAa,YAAY;;IAKvB,YAAY,KAAK,EAAE,iBAAiB,EAKnC;IAED,kBAAkB,CAAC,eAAe,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,CA0BrE;IAED,kBAAkB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC,CAU9E;IAED,oBAAoB,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC,CAMjD;CACF"}
|
|
@@ -30,18 +30,19 @@ export class AddressStore {
|
|
|
30
30
|
}
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
|
-
async #getCompleteAddress(address) {
|
|
34
|
-
const index = await this.#completeAddressIndex.getAsync(address.toString());
|
|
35
|
-
if (index === undefined) {
|
|
36
|
-
return undefined;
|
|
37
|
-
}
|
|
38
|
-
const value = await this.#completeAddresses.atAsync(index);
|
|
39
|
-
return value ? await CompleteAddress.fromBuffer(value) : undefined;
|
|
40
|
-
}
|
|
41
33
|
getCompleteAddress(account) {
|
|
42
|
-
return this.#
|
|
34
|
+
return this.#store.transactionAsync(async ()=>{
|
|
35
|
+
const index = await this.#completeAddressIndex.getAsync(account.toString());
|
|
36
|
+
if (index === undefined) {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
const value = await this.#completeAddresses.atAsync(index);
|
|
40
|
+
return value ? await CompleteAddress.fromBuffer(value) : undefined;
|
|
41
|
+
});
|
|
43
42
|
}
|
|
44
|
-
|
|
45
|
-
return
|
|
43
|
+
getCompleteAddresses() {
|
|
44
|
+
return this.#store.transactionAsync(async ()=>{
|
|
45
|
+
return await Promise.all((await toArray(this.#completeAddresses.valuesAsync())).map((v)=>CompleteAddress.fromBuffer(v)));
|
|
46
|
+
});
|
|
46
47
|
}
|
|
47
48
|
}
|
|
@@ -3,7 +3,15 @@ import { BlockHeader } from '@aztec/stdlib/tx';
|
|
|
3
3
|
export declare class AnchorBlockStore {
|
|
4
4
|
#private;
|
|
5
5
|
constructor(store: AztecAsyncKVStore);
|
|
6
|
+
/**
|
|
7
|
+
* Sets the currently synchronized block
|
|
8
|
+
*
|
|
9
|
+
* Important: this method is only called from BlockSynchronizer, and since we need it to run atomically with other
|
|
10
|
+
* stores in the case of a reorg, it MUST NOT be wrapped in a `transactionAsync` call. Doing so would result in a
|
|
11
|
+
* deadlock when the backend is IndexedDB, because `transactionAsync` is not designed to support reentrancy.
|
|
12
|
+
*
|
|
13
|
+
*/
|
|
6
14
|
setHeader(header: BlockHeader): Promise<void>;
|
|
7
15
|
getBlockHeader(): Promise<BlockHeader>;
|
|
8
16
|
}
|
|
9
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
17
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYW5jaG9yX2Jsb2NrX3N0b3JlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvc3RvcmFnZS9hbmNob3JfYmxvY2tfc3RvcmUvYW5jaG9yX2Jsb2NrX3N0b3JlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLGlCQUFpQixFQUF1QixNQUFNLGlCQUFpQixDQUFDO0FBQzlFLE9BQU8sRUFBRSxXQUFXLEVBQUUsTUFBTSxrQkFBa0IsQ0FBQztBQUUvQyxxQkFBYSxnQkFBZ0I7O0lBSTNCLFlBQVksS0FBSyxFQUFFLGlCQUFpQixFQUduQztJQUVEOzs7Ozs7O09BT0c7SUFDRyxTQUFTLENBQUMsTUFBTSxFQUFFLFdBQVcsR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLENBRWxEO0lBRUssY0FBYyxJQUFJLE9BQU8sQ0FBQyxXQUFXLENBQUMsQ0FPM0M7Q0FDRiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anchor_block_store.d.ts","sourceRoot":"","sources":["../../../src/storage/anchor_block_store/anchor_block_store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAuB,MAAM,iBAAiB,CAAC;AAC9E,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,qBAAa,gBAAgB;;IAI3B,YAAY,KAAK,EAAE,iBAAiB,EAGnC;
|
|
1
|
+
{"version":3,"file":"anchor_block_store.d.ts","sourceRoot":"","sources":["../../../src/storage/anchor_block_store/anchor_block_store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAuB,MAAM,iBAAiB,CAAC;AAC9E,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,qBAAa,gBAAgB;;IAI3B,YAAY,KAAK,EAAE,iBAAiB,EAGnC;IAED;;;;;;;OAOG;IACG,SAAS,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAElD;IAEK,cAAc,IAAI,OAAO,CAAC,WAAW,CAAC,CAO3C;CACF"}
|
|
@@ -6,7 +6,14 @@ export class AnchorBlockStore {
|
|
|
6
6
|
this.#store = store;
|
|
7
7
|
this.#synchronizedHeader = this.#store.openSingleton('header');
|
|
8
8
|
}
|
|
9
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Sets the currently synchronized block
|
|
11
|
+
*
|
|
12
|
+
* Important: this method is only called from BlockSynchronizer, and since we need it to run atomically with other
|
|
13
|
+
* stores in the case of a reorg, it MUST NOT be wrapped in a `transactionAsync` call. Doing so would result in a
|
|
14
|
+
* deadlock when the backend is IndexedDB, because `transactionAsync` is not designed to support reentrancy.
|
|
15
|
+
*
|
|
16
|
+
*/ async setHeader(header) {
|
|
10
17
|
await this.#synchronizedHeader.set(header.toBuffer());
|
|
11
18
|
}
|
|
12
19
|
async getBlockHeader() {
|
|
@@ -40,14 +40,12 @@ export class CapsuleStore {
|
|
|
40
40
|
* If it is not there, it reads it from the KV store.
|
|
41
41
|
*/ async #getFromStage(jobId, dbSlotKey) {
|
|
42
42
|
const jobStagedCapsules = this.#getJobStagedCapsules(jobId);
|
|
43
|
-
|
|
44
|
-
//
|
|
45
|
-
//
|
|
46
|
-
if (
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
return staged;
|
|
43
|
+
const staged = jobStagedCapsules.get(dbSlotKey);
|
|
44
|
+
// Always issue DB read to keep IndexedDB transaction alive, even if the value is in the job staged data. This
|
|
45
|
+
// keeps IndexedDB transactions alive (they auto-commit when a new micro-task starts and there are no pending read
|
|
46
|
+
// requests). The staged value still takes precedence if it exists (including null for deletions).
|
|
47
|
+
const dbValue = await this.#loadCapsuleFromDb(dbSlotKey);
|
|
48
|
+
return staged !== undefined ? staged : dbValue;
|
|
51
49
|
}
|
|
52
50
|
/**
|
|
53
51
|
* Writes a capsule to the stage of a job.
|