@aztec/pxe 0.0.1-commit.d431d1c → 0.0.1-commit.dbf9cec
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/bin/check_oracle_version.js +1 -1
- package/dest/block_synchronizer/block_synchronizer.d.ts +9 -5
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +62 -16
- package/dest/config/index.d.ts +3 -1
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +17 -0
- package/dest/config/package_info.js +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +54 -30
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +175 -74
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +5 -5
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_tagging_index_cache.js +3 -3
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +1 -1
- package/dest/contract_function_simulator/noir-structs/event_validation_request.js +2 -2
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +3 -3
- 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 +2 -2
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +15 -12
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.d.ts +7 -5
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +51 -29
- package/dest/contract_function_simulator/oracle/private_execution.d.ts +2 -22
- package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution.js +0 -37
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +44 -36
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +86 -30
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +62 -30
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +107 -88
- 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 +43 -0
- package/dest/contract_sync/contract_sync_service.d.ts.map +1 -0
- package/dest/contract_sync/contract_sync_service.js +97 -0
- package/dest/contract_sync/helpers.d.ts +29 -0
- package/dest/contract_sync/helpers.d.ts.map +1 -0
- package/dest/contract_sync/helpers.js +55 -0
- package/dest/debug/pxe_debug_utils.d.ts +24 -10
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
- package/dest/debug/pxe_debug_utils.js +28 -17
- 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 +21 -7
- 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 +2 -2
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +22 -8
- package/dest/entrypoints/pxe_creation_options.d.ts +3 -2
- package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
- package/dest/entrypoints/server/index.d.ts +4 -1
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +3 -0
- package/dest/entrypoints/server/utils.d.ts +1 -1
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +28 -9
- package/dest/events/event_service.d.ts +5 -6
- package/dest/events/event_service.d.ts.map +1 -1
- package/dest/events/event_service.js +6 -7
- package/dest/job_coordinator/job_coordinator.d.ts +3 -2
- package/dest/job_coordinator/job_coordinator.d.ts.map +1 -1
- package/dest/job_coordinator/job_coordinator.js +3 -2
- package/dest/logs/log_service.d.ts +7 -5
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +28 -32
- package/dest/notes/note_service.d.ts +9 -8
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +17 -16
- 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 +4 -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 +3 -2
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.js +21 -13
- package/dest/private_kernel/private_kernel_oracle.d.ts +8 -4
- 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 +69 -23
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +104 -67
- 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 -16
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
- package/dest/storage/contract_store/contract_store.js +157 -84
- package/dest/storage/metadata.d.ts +1 -1
- package/dest/storage/metadata.js +1 -1
- package/dest/storage/note_store/note_store.d.ts +47 -49
- package/dest/storage/note_store/note_store.d.ts.map +1 -1
- package/dest/storage/note_store/note_store.js +278 -252
- package/dest/storage/note_store/stored_note.d.ts +16 -0
- package/dest/storage/note_store/stored_note.d.ts.map +1 -0
- package/dest/storage/note_store/stored_note.js +43 -0
- package/dest/storage/private_event_store/private_event_store.d.ts +17 -4
- package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
- package/dest/storage/private_event_store/private_event_store.js +198 -147
- package/dest/storage/private_event_store/stored_private_event.d.ts +23 -0
- package/dest/storage/private_event_store/stored_private_event.d.ts.map +1 -0
- package/dest/storage/private_event_store/stored_private_event.js +56 -0
- 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 +5 -5
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.js +184 -114
- package/dest/tagging/get_all_logs_by_tags.d.ts +24 -0
- package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -0
- package/dest/tagging/get_all_logs_by_tags.js +60 -0
- package/dest/tagging/index.d.ts +3 -2
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/index.js +2 -1
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +5 -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 +7 -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 +16 -12
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +5 -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 +3 -6
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +1 -1
- 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 +5 -8
- 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 +20 -18
- package/package.json +25 -16
- package/src/access_scopes.ts +9 -0
- package/src/bin/check_oracle_version.ts +1 -0
- package/src/block_synchronizer/block_synchronizer.ts +76 -33
- package/src/config/index.ts +14 -0
- package/src/config/package_info.ts +1 -1
- package/src/contract_function_simulator/contract_function_simulator.ts +324 -137
- package/src/contract_function_simulator/execution_tagging_index_cache.ts +5 -5
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +2 -2
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +2 -2
- package/src/contract_function_simulator/oracle/interfaces.ts +20 -11
- package/src/contract_function_simulator/oracle/oracle.ts +56 -26
- package/src/contract_function_simulator/oracle/private_execution.ts +1 -60
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +126 -110
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +172 -95
- package/src/contract_logging.ts +39 -0
- package/src/contract_sync/contract_sync_service.ts +152 -0
- package/src/contract_sync/helpers.ts +98 -0
- package/src/debug/pxe_debug_utils.ts +63 -18
- package/src/entrypoints/client/bundle/index.ts +3 -0
- package/src/entrypoints/client/bundle/utils.ts +16 -15
- package/src/entrypoints/client/lazy/index.ts +3 -0
- package/src/entrypoints/client/lazy/utils.ts +17 -15
- package/src/entrypoints/pxe_creation_options.ts +2 -1
- package/src/entrypoints/server/index.ts +3 -0
- package/src/entrypoints/server/utils.ts +22 -26
- package/src/events/event_service.ts +5 -7
- package/src/job_coordinator/job_coordinator.ts +4 -3
- package/src/logs/log_service.ts +48 -39
- package/src/notes/note_service.ts +24 -22
- package/src/notes_filter.ts +26 -0
- package/src/oracle_version.ts +4 -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 +25 -15
- package/src/private_kernel/private_kernel_oracle.ts +9 -9
- package/src/pxe.ts +211 -112
- 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 -96
- package/src/storage/metadata.ts +1 -1
- package/src/storage/note_store/note_store.ts +321 -318
- package/src/storage/note_store/stored_note.ts +48 -0
- package/src/storage/private_event_store/private_event_store.ts +250 -190
- package/src/storage/private_event_store/stored_private_event.ts +73 -0
- 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 +214 -130
- package/src/tagging/get_all_logs_by_tags.ts +92 -0
- package/src/tagging/index.ts +2 -1
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +17 -10
- package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +2 -2
- package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +17 -16
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +6 -9
- package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +5 -17
- package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +23 -23
- 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/tree_membership/tree_membership_service.d.ts +0 -50
- package/dest/tree_membership/tree_membership_service.d.ts.map +0 -1
- package/dest/tree_membership/tree_membership_service.js +0 -75
- package/src/tree_membership/tree_membership_service.ts +0 -97
package/dest/pxe.js
CHANGED
|
@@ -5,7 +5,6 @@ import { KeyStore } from '@aztec/key-store';
|
|
|
5
5
|
import { L2TipsKVStore } from '@aztec/kv-store/stores';
|
|
6
6
|
import { protocolContractNames } from '@aztec/protocol-contracts';
|
|
7
7
|
import { FunctionType, decodeFunctionSignature } from '@aztec/stdlib/abi';
|
|
8
|
-
import { L2BlockHash } from '@aztec/stdlib/block';
|
|
9
8
|
import { computeContractAddressFromInstance, getContractClassFromArtifact } from '@aztec/stdlib/contract';
|
|
10
9
|
import { SimulationError } from '@aztec/stdlib/errors';
|
|
11
10
|
import { PrivateSimulationResult, TxProfileResult, TxProvingResult, TxSimulationResult } from '@aztec/stdlib/tx';
|
|
@@ -13,8 +12,10 @@ import { inspect } from 'util';
|
|
|
13
12
|
import { BlockSynchronizer } from './block_synchronizer/index.js';
|
|
14
13
|
import { BenchmarkedNodeFactory } from './contract_function_simulator/benchmarked_node.js';
|
|
15
14
|
import { ContractFunctionSimulator, generateSimulatedProvingResult } from './contract_function_simulator/contract_function_simulator.js';
|
|
16
|
-
import { readCurrentClassId } from './contract_function_simulator/oracle/private_execution.js';
|
|
17
15
|
import { ProxiedContractStoreFactory } from './contract_function_simulator/proxied_contract_data_source.js';
|
|
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';
|
|
18
19
|
import { PXEDebugUtils } from './debug/pxe_debug_utils.js';
|
|
19
20
|
import { enrichPublicSimulationError, enrichSimulationError } from './error_enriching.js';
|
|
20
21
|
import { PrivateEventFilterValidator } from './events/private_event_filter_validator.js';
|
|
@@ -46,6 +47,7 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
46
47
|
recipientTaggingStore;
|
|
47
48
|
addressStore;
|
|
48
49
|
privateEventStore;
|
|
50
|
+
contractSyncService;
|
|
49
51
|
simulator;
|
|
50
52
|
proverEnabled;
|
|
51
53
|
proofCreator;
|
|
@@ -54,7 +56,7 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
54
56
|
jobQueue;
|
|
55
57
|
jobCoordinator;
|
|
56
58
|
debug;
|
|
57
|
-
constructor(node, blockStateSynchronizer, keyStore, contractStore, noteStore, capsuleStore, anchorBlockStore, senderTaggingStore, senderAddressBookStore, recipientTaggingStore, addressStore, privateEventStore, simulator, proverEnabled, proofCreator, protocolContractsProvider, log, jobQueue, jobCoordinator, debug){
|
|
59
|
+
constructor(node, blockStateSynchronizer, keyStore, contractStore, noteStore, capsuleStore, anchorBlockStore, senderTaggingStore, senderAddressBookStore, recipientTaggingStore, addressStore, privateEventStore, contractSyncService, simulator, proverEnabled, proofCreator, protocolContractsProvider, log, jobQueue, jobCoordinator, debug){
|
|
58
60
|
this.node = node;
|
|
59
61
|
this.blockStateSynchronizer = blockStateSynchronizer;
|
|
60
62
|
this.keyStore = keyStore;
|
|
@@ -67,6 +69,7 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
67
69
|
this.recipientTaggingStore = recipientTaggingStore;
|
|
68
70
|
this.addressStore = addressStore;
|
|
69
71
|
this.privateEventStore = privateEventStore;
|
|
72
|
+
this.contractSyncService = contractSyncService;
|
|
70
73
|
this.simulator = simulator;
|
|
71
74
|
this.proverEnabled = proverEnabled;
|
|
72
75
|
this.proofCreator = proofCreator;
|
|
@@ -82,13 +85,16 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
82
85
|
* can be contacted.
|
|
83
86
|
*
|
|
84
87
|
* @returns A promise that resolves PXE is ready to be used.
|
|
85
|
-
*/ static async create(node, store, proofCreator, simulator, protocolContractsProvider, config, loggerOrSuffix) {
|
|
88
|
+
*/ static async create({ node, store, proofCreator, simulator, protocolContractsProvider, config, loggerOrSuffix }) {
|
|
89
|
+
// Extract bindings from the logger, or use empty bindings if a string suffix is provided.
|
|
90
|
+
const bindings = loggerOrSuffix && typeof loggerOrSuffix !== 'string' ? loggerOrSuffix.getBindings() : undefined;
|
|
86
91
|
const log = !loggerOrSuffix || typeof loggerOrSuffix === 'string' ? createLogger(loggerOrSuffix ? `pxe:service:${loggerOrSuffix}` : `pxe:service`) : loggerOrSuffix;
|
|
87
|
-
const
|
|
92
|
+
const info = await node.getNodeInfo();
|
|
93
|
+
const proverEnabled = config.proverEnabled !== undefined ? config.proverEnabled : info.realProofs;
|
|
88
94
|
const addressStore = new AddressStore(store);
|
|
89
95
|
const privateEventStore = new PrivateEventStore(store);
|
|
90
96
|
const contractStore = new ContractStore(store);
|
|
91
|
-
const noteStore =
|
|
97
|
+
const noteStore = new NoteStore(store);
|
|
92
98
|
const anchorBlockStore = new AnchorBlockStore(store);
|
|
93
99
|
const senderTaggingStore = new SenderTaggingStore(store);
|
|
94
100
|
const senderAddressBookStore = new SenderAddressBookStore(store);
|
|
@@ -96,28 +102,43 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
96
102
|
const capsuleStore = new CapsuleStore(store);
|
|
97
103
|
const keyStore = new KeyStore(store);
|
|
98
104
|
const tipsStore = new L2TipsKVStore(store, 'pxe');
|
|
99
|
-
const
|
|
100
|
-
const
|
|
105
|
+
const contractSyncService = new ContractSyncService(node, contractStore, noteStore, createLogger('pxe:contract_sync', bindings));
|
|
106
|
+
const synchronizer = new BlockSynchronizer(node, store, anchorBlockStore, noteStore, privateEventStore, tipsStore, contractSyncService, config, bindings);
|
|
107
|
+
const jobCoordinator = new JobCoordinator(store, bindings);
|
|
101
108
|
jobCoordinator.registerStores([
|
|
102
109
|
capsuleStore,
|
|
103
110
|
senderTaggingStore,
|
|
104
111
|
recipientTaggingStore,
|
|
105
|
-
privateEventStore
|
|
112
|
+
privateEventStore,
|
|
113
|
+
noteStore,
|
|
114
|
+
contractSyncService
|
|
106
115
|
]);
|
|
107
|
-
const debugUtils = new PXEDebugUtils(
|
|
116
|
+
const debugUtils = new PXEDebugUtils(contractSyncService, noteStore, synchronizer, anchorBlockStore);
|
|
108
117
|
const jobQueue = new SerialQueue();
|
|
109
|
-
const pxe = new PXE(node, synchronizer, keyStore, contractStore, noteStore, capsuleStore, anchorBlockStore, senderTaggingStore, senderAddressBookStore, recipientTaggingStore, addressStore, privateEventStore, simulator, proverEnabled, proofCreator, protocolContractsProvider, log, jobQueue, jobCoordinator, debugUtils);
|
|
110
|
-
debugUtils.
|
|
118
|
+
const pxe = new PXE(node, synchronizer, keyStore, contractStore, noteStore, capsuleStore, anchorBlockStore, senderTaggingStore, senderAddressBookStore, recipientTaggingStore, addressStore, privateEventStore, contractSyncService, simulator, proverEnabled, proofCreator, protocolContractsProvider, log, jobQueue, jobCoordinator, debugUtils);
|
|
119
|
+
debugUtils.setPXEHelpers(pxe.#putInJobQueue.bind(pxe), pxe.#getSimulatorForTx.bind(pxe), pxe.#executeUtility.bind(pxe));
|
|
111
120
|
pxe.jobQueue.start();
|
|
112
121
|
await pxe.#registerProtocolContracts();
|
|
113
|
-
const info = await node.getNodeInfo();
|
|
114
122
|
log.info(`Started PXE connected to chain ${info.l1ChainId} version ${info.rollupVersion}`);
|
|
115
123
|
return pxe;
|
|
116
124
|
}
|
|
117
125
|
// Internal methods
|
|
118
126
|
#getSimulatorForTx(overrides) {
|
|
119
127
|
const proxyContractStore = ProxiedContractStoreFactory.create(this.contractStore, overrides?.contracts);
|
|
120
|
-
return new ContractFunctionSimulator(
|
|
128
|
+
return new ContractFunctionSimulator({
|
|
129
|
+
contractStore: proxyContractStore,
|
|
130
|
+
noteStore: this.noteStore,
|
|
131
|
+
keyStore: this.keyStore,
|
|
132
|
+
addressStore: this.addressStore,
|
|
133
|
+
aztecNode: BenchmarkedNodeFactory.create(this.node),
|
|
134
|
+
senderTaggingStore: this.senderTaggingStore,
|
|
135
|
+
recipientTaggingStore: this.recipientTaggingStore,
|
|
136
|
+
senderAddressBookStore: this.senderAddressBookStore,
|
|
137
|
+
capsuleStore: this.capsuleStore,
|
|
138
|
+
privateEventStore: this.privateEventStore,
|
|
139
|
+
simulator: this.simulator,
|
|
140
|
+
contractSyncService: this.contractSyncService
|
|
141
|
+
});
|
|
121
142
|
}
|
|
122
143
|
#contextualizeError(err, ...context) {
|
|
123
144
|
let contextStr = '';
|
|
@@ -160,8 +181,8 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
160
181
|
async #registerProtocolContracts() {
|
|
161
182
|
const registered = {};
|
|
162
183
|
for (const name of protocolContractNames){
|
|
163
|
-
const { address,
|
|
164
|
-
await this.contractStore.addContractArtifact(
|
|
184
|
+
const { address, instance, artifact } = await this.protocolContractsProvider.getProtocolContractArtifact(name);
|
|
185
|
+
await this.contractStore.addContractArtifact(artifact);
|
|
165
186
|
await this.contractStore.addContractInstance(instance);
|
|
166
187
|
registered[name] = address.toString();
|
|
167
188
|
}
|
|
@@ -173,9 +194,14 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
173
194
|
const { origin: contractAddress, functionSelector } = txRequest;
|
|
174
195
|
try {
|
|
175
196
|
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
197
|
+
await this.contractSyncService.ensureContractSynced(contractAddress, functionSelector, (privateSyncCall, execScopes)=>this.#executeUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId), anchorBlockHeader, jobId, scopes);
|
|
198
|
+
const result = await contractFunctionSimulator.run(txRequest, {
|
|
199
|
+
contractAddress,
|
|
200
|
+
selector: functionSelector,
|
|
201
|
+
anchorBlockHeader,
|
|
202
|
+
scopes,
|
|
203
|
+
jobId
|
|
204
|
+
});
|
|
179
205
|
this.log.debug(`Private simulation completed for ${contractAddress.toString()}:${functionSelector}`);
|
|
180
206
|
return result;
|
|
181
207
|
} catch (err) {
|
|
@@ -186,15 +212,15 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
186
212
|
}
|
|
187
213
|
}
|
|
188
214
|
/**
|
|
189
|
-
*
|
|
215
|
+
* Execute a utility function call on the given contract.
|
|
190
216
|
* @param contractFunctionSimulator - The simulator to use for the function call.
|
|
191
217
|
* @param call - The function call to execute.
|
|
192
218
|
* @param authWitnesses - Authentication witnesses required for the function call.
|
|
193
219
|
* @param scopes - Optional array of account addresses whose notes can be accessed in this call. Defaults to all
|
|
194
220
|
* accounts if not specified.
|
|
195
221
|
* @param jobId - The job ID for staged writes.
|
|
196
|
-
* @returns The
|
|
197
|
-
*/ async #
|
|
222
|
+
* @returns The execution result containing the outputs of the utility function.
|
|
223
|
+
*/ async #executeUtility(contractFunctionSimulator, call, authWitnesses, scopes, jobId) {
|
|
198
224
|
try {
|
|
199
225
|
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
200
226
|
return contractFunctionSimulator.runUtility(call, authWitnesses ?? [], anchorBlockHeader, scopes, jobId);
|
|
@@ -242,14 +268,24 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
242
268
|
* @returns An object that contains the output of the kernel execution, including the ChonkProof if proving is enabled.
|
|
243
269
|
*/ async #prove(txExecutionRequest, proofCreator, privateExecutionResult, config) {
|
|
244
270
|
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
245
|
-
const anchorBlockHash =
|
|
271
|
+
const anchorBlockHash = await anchorBlockHeader.hash();
|
|
246
272
|
const kernelOracle = new PrivateKernelOracle(this.contractStore, this.keyStore, this.node, anchorBlockHash);
|
|
247
|
-
const kernelTraceProver = new PrivateKernelExecutionProver(kernelOracle, proofCreator, !this.proverEnabled);
|
|
273
|
+
const kernelTraceProver = new PrivateKernelExecutionProver(kernelOracle, proofCreator, !this.proverEnabled, this.log.getBindings());
|
|
248
274
|
this.log.debug(`Executing kernel trace prover (${JSON.stringify(config)})...`);
|
|
249
275
|
return await kernelTraceProver.proveWithKernels(txExecutionRequest.toTxRequest(), privateExecutionResult, config);
|
|
250
276
|
}
|
|
251
277
|
// Public API
|
|
252
|
-
|
|
278
|
+
/**
|
|
279
|
+
* Returns the block header up to which the PXE has synced.
|
|
280
|
+
* @returns The synced block header
|
|
281
|
+
*/ getSyncedBlockHeader() {
|
|
282
|
+
return this.anchorBlockStore.getBlockHeader();
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Returns the contract instance for a given address, if it's registered in the PXE.
|
|
286
|
+
* @param address - The contract address.
|
|
287
|
+
* @returns The contract instance if found, undefined otherwise.
|
|
288
|
+
*/ getContractInstance(address) {
|
|
253
289
|
return this.contractStore.getContractInstance(address);
|
|
254
290
|
}
|
|
255
291
|
/**
|
|
@@ -279,7 +315,6 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
279
315
|
this.log.debug(`Registered account\n ${accountCompleteAddress.toReadableString()}`);
|
|
280
316
|
}
|
|
281
317
|
await this.addressStore.addCompleteAddress(accountCompleteAddress);
|
|
282
|
-
await this.noteStore.addScope(accountCompleteAddress.address);
|
|
283
318
|
return accountCompleteAddress;
|
|
284
319
|
}
|
|
285
320
|
/**
|
|
@@ -337,8 +372,7 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
337
372
|
*
|
|
338
373
|
* @param artifact - The build artifact for the contract class.
|
|
339
374
|
*/ async registerContractClass(artifact) {
|
|
340
|
-
const
|
|
341
|
-
await this.contractStore.addContractArtifact(contractClassId, artifact);
|
|
375
|
+
const contractClassId = await this.contractStore.addContractArtifact(artifact);
|
|
342
376
|
this.log.info(`Added contract class ${artifact.name} with id ${contractClassId}`);
|
|
343
377
|
}
|
|
344
378
|
/**
|
|
@@ -354,15 +388,14 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
354
388
|
if (artifact) {
|
|
355
389
|
// If the user provides an artifact, validate it against the expected class id and register it
|
|
356
390
|
const contractClass = await getContractClassFromArtifact(artifact);
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
throw new Error(`Artifact does not match expected class id (computed ${contractClassId} but instance refers to ${instance.currentContractClassId})`);
|
|
391
|
+
if (!contractClass.id.equals(instance.currentContractClassId)) {
|
|
392
|
+
throw new Error(`Artifact does not match expected class id (computed ${contractClass.id} but instance refers to ${instance.currentContractClassId})`);
|
|
360
393
|
}
|
|
361
394
|
const computedAddress = await computeContractAddressFromInstance(instance);
|
|
362
395
|
if (!computedAddress.equals(instance.address)) {
|
|
363
396
|
throw new Error('Added a contract in which the address does not match the contract instance.');
|
|
364
397
|
}
|
|
365
|
-
await this.contractStore.addContractArtifact(
|
|
398
|
+
await this.contractStore.addContractArtifact(artifact, contractClass);
|
|
366
399
|
const publicFunctionSignatures = artifact.functions.filter((fn)=>fn.functionType === FunctionType.PUBLIC).map((fn)=>decodeFunctionSignature(fn.name, fn.parameters));
|
|
367
400
|
await this.node.registerContractFunctionSignatures(publicFunctionSignatures);
|
|
368
401
|
} else {
|
|
@@ -398,11 +431,13 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
398
431
|
if (!contractClass.id.equals(currentClassId)) {
|
|
399
432
|
throw new Error('Could not update contract to a class different from the current one.');
|
|
400
433
|
}
|
|
401
|
-
await this.contractStore.addContractArtifact(contractClass.id, artifact);
|
|
402
434
|
const publicFunctionSignatures = artifact.functions.filter((fn)=>fn.functionType === FunctionType.PUBLIC).map((fn)=>decodeFunctionSignature(fn.name, fn.parameters));
|
|
403
435
|
await this.node.registerContractFunctionSignatures(publicFunctionSignatures);
|
|
404
436
|
currentInstance.currentContractClassId = contractClass.id;
|
|
405
|
-
await
|
|
437
|
+
await Promise.all([
|
|
438
|
+
this.contractStore.addContractArtifact(artifact, contractClass),
|
|
439
|
+
this.contractStore.addContractInstance(currentInstance)
|
|
440
|
+
]);
|
|
406
441
|
this.log.info(`Updated contract ${artifact.name} at ${contractAddress.toString()} to class ${contractClass.id}`);
|
|
407
442
|
});
|
|
408
443
|
}
|
|
@@ -417,10 +452,11 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
417
452
|
* (where validators prove the public portion).
|
|
418
453
|
*
|
|
419
454
|
* @param txRequest - An authenticated tx request ready for proving
|
|
455
|
+
* @param scopes - Addresses whose private state and keys are accessible during private execution.
|
|
420
456
|
* @returns A result containing the proof and public inputs of the tail circuit.
|
|
421
457
|
* @throws If contract code not found, or public simulation reverts.
|
|
422
458
|
* Also throws if simulatePublic is true and public simulation reverts.
|
|
423
|
-
*/ proveTx(txRequest) {
|
|
459
|
+
*/ proveTx(txRequest, scopes) {
|
|
424
460
|
let privateExecutionResult;
|
|
425
461
|
// We disable proving concurrently mostly out of caution, since it accesses some of our stores. Proving is so
|
|
426
462
|
// computationally demanding that it'd be rare for someone to try to do it concurrently regardless.
|
|
@@ -431,7 +467,7 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
431
467
|
await this.blockStateSynchronizer.sync();
|
|
432
468
|
const syncTime = syncTimer.ms();
|
|
433
469
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
434
|
-
privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest,
|
|
470
|
+
privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest, scopes, jobId);
|
|
435
471
|
const { publicInputs, chonkProof, executionSteps, timings: { proving } = {} } = await this.#prove(txRequest, this.proofCreator, privateExecutionResult, {
|
|
436
472
|
simulate: false,
|
|
437
473
|
skipFeeEnforcement: false,
|
|
@@ -481,13 +517,10 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
481
517
|
}
|
|
482
518
|
/**
|
|
483
519
|
* Profiles a transaction, reporting gate counts (unless disabled) and returns an execution trace.
|
|
484
|
-
*
|
|
485
|
-
* @param txRequest - An authenticated tx request ready for simulation
|
|
486
|
-
* @param msgSender - (Optional) The message sender to use for the simulation.
|
|
487
|
-
* @param skipTxValidation - (Optional) If false, this function throws if the transaction is unable to be included in a block at the current state.
|
|
520
|
+
* @param txRequest - An authenticated tx request ready for simulation.
|
|
488
521
|
* @returns A trace of the program execution with gate counts.
|
|
489
522
|
* @throws If the code for the functions executed in this transaction have not been made available via `addContracts`.
|
|
490
|
-
*/ profileTx(txRequest, profileMode, skipProofGeneration = true) {
|
|
523
|
+
*/ profileTx(txRequest, { profileMode, skipProofGeneration = true, scopes }) {
|
|
491
524
|
// We disable concurrent profiles for consistency with simulateTx.
|
|
492
525
|
return this.#putInJobQueue(async (jobId)=>{
|
|
493
526
|
const totalTimer = new Timer();
|
|
@@ -505,7 +538,7 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
505
538
|
await this.blockStateSynchronizer.sync();
|
|
506
539
|
const syncTime = syncTimer.ms();
|
|
507
540
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
508
|
-
const privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest,
|
|
541
|
+
const privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest, scopes, jobId);
|
|
509
542
|
const { executionSteps, timings: { proving } = {} } = await this.#prove(txRequest, this.proofCreator, privateExecutionResult, {
|
|
510
543
|
simulate: skipProofGeneration,
|
|
511
544
|
skipFeeEnforcement: false,
|
|
@@ -550,18 +583,13 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
550
583
|
* In that case, the transaction returned is only potentially ready to be sent to the network for execution.
|
|
551
584
|
*
|
|
552
585
|
*
|
|
553
|
-
* @param txRequest - An authenticated tx request ready for simulation
|
|
554
|
-
* @param simulatePublic - Whether to simulate the public part of the transaction.
|
|
555
|
-
* @param skipTxValidation - (Optional) If false, this function throws if the transaction is unable to be included in a block at the current state.
|
|
556
|
-
* @param skipFeeEnforcement - (Optional) If false, fees are enforced.
|
|
557
|
-
* @param overrides - (Optional) State overrides for the simulation, such as msgSender, contract instances and artifacts.
|
|
558
|
-
* @param scopes - (Optional) The accounts whose notes we can access in this call. Currently optional and will default to all.
|
|
586
|
+
* @param txRequest - An authenticated tx request ready for simulation.
|
|
559
587
|
* @returns A simulated transaction result object that includes public and private return values.
|
|
560
588
|
* @throws If the code for the functions executed in this transaction have not been made available via `addContracts`.
|
|
561
589
|
* Also throws if simulatePublic is true and public simulation reverts.
|
|
562
590
|
*
|
|
563
591
|
* TODO(#7456) Prevent msgSender being defined here for the first call
|
|
564
|
-
*/ simulateTx(txRequest, simulatePublic, skipTxValidation = false, skipFeeEnforcement = false, overrides, scopes) {
|
|
592
|
+
*/ simulateTx(txRequest, { simulatePublic, skipTxValidation = false, skipFeeEnforcement = false, overrides, scopes }) {
|
|
565
593
|
// We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
|
|
566
594
|
// to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
|
|
567
595
|
// delete the same read value, or reading values that another simulation is currently modifying).
|
|
@@ -584,13 +612,19 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
584
612
|
// Temporary: in case there are overrides, we have to skip the kernels or validations
|
|
585
613
|
// will fail. Consider handing control to the user/wallet on whether they want to run them
|
|
586
614
|
// or not.
|
|
587
|
-
const
|
|
615
|
+
const overriddenContracts = overrides?.contracts ? new Set(Object.keys(overrides.contracts)) : undefined;
|
|
616
|
+
const hasOverriddenContracts = overriddenContracts !== undefined && overriddenContracts.size > 0;
|
|
617
|
+
const skipKernels = hasOverriddenContracts;
|
|
618
|
+
// Set overridden contracts on the sync service so it knows to skip syncing them
|
|
619
|
+
if (hasOverriddenContracts) {
|
|
620
|
+
this.contractSyncService.setOverriddenContracts(jobId, overriddenContracts);
|
|
621
|
+
}
|
|
588
622
|
// Execution of private functions only; no proving, and no kernel logic.
|
|
589
623
|
const privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest, scopes, jobId);
|
|
590
624
|
let publicInputs;
|
|
591
625
|
let executionSteps = [];
|
|
592
626
|
if (skipKernels) {
|
|
593
|
-
({ publicInputs, executionSteps } = await generateSimulatedProvingResult(privateExecutionResult, this.contractStore));
|
|
627
|
+
({ publicInputs, executionSteps } = await generateSimulatedProvingResult(privateExecutionResult, (addr, sel)=>this.contractStore.getDebugFunctionName(addr, sel), this.node));
|
|
594
628
|
} else {
|
|
595
629
|
// Kernel logic, plus proving of all private functions and kernels.
|
|
596
630
|
({ publicInputs, executionSteps } = await this.#prove(txRequest, this.proofCreator, privateExecutionResult, {
|
|
@@ -607,6 +641,9 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
607
641
|
const publicSimulationTimer = new Timer();
|
|
608
642
|
publicOutput = await this.#simulatePublicCalls(simulatedTx, skipFeeEnforcement);
|
|
609
643
|
publicSimulationTime = publicSimulationTimer.ms();
|
|
644
|
+
if (publicOutput?.debugLogs?.length) {
|
|
645
|
+
await displayDebugLogs(publicOutput.debugLogs, (addr)=>this.contractStore.getDebugContractName(addr));
|
|
646
|
+
}
|
|
610
647
|
}
|
|
611
648
|
let validationTime;
|
|
612
649
|
if (!skipTxValidation) {
|
|
@@ -617,7 +654,8 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
617
654
|
});
|
|
618
655
|
validationTime = validationTimer.ms();
|
|
619
656
|
if (validationResult.result === 'invalid') {
|
|
620
|
-
|
|
657
|
+
const reason = validationResult.reason.length > 0 ? ` Reason: ${validationResult.reason.join(', ')}` : '';
|
|
658
|
+
throw new Error(`The simulated transaction is unable to be added to state and is invalid.${reason}`);
|
|
621
659
|
}
|
|
622
660
|
}
|
|
623
661
|
const txHash = simulatedTx.getTxHash();
|
|
@@ -650,22 +688,19 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
650
688
|
nodeRPCCalls: simulatorStats.nodeRPCCalls
|
|
651
689
|
});
|
|
652
690
|
} catch (err) {
|
|
653
|
-
throw this.#contextualizeError(err, inspect(txRequest), `simulatePublic=${simulatePublic}`, `skipTxValidation=${skipTxValidation}`, `scopes=${scopes
|
|
691
|
+
throw this.#contextualizeError(err, inspect(txRequest), `simulatePublic=${simulatePublic}`, `skipTxValidation=${skipTxValidation}`, `scopes=${scopes === 'ALL_SCOPES' ? scopes : scopes.map((s)=>s.toString()).join(', ')}`);
|
|
654
692
|
}
|
|
655
693
|
});
|
|
656
694
|
}
|
|
657
695
|
/**
|
|
658
|
-
*
|
|
659
|
-
*
|
|
696
|
+
* Executes a contract utility function.
|
|
660
697
|
* @param call - The function call containing the function details, arguments, and target contract address.
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
*/ simulateUtility(call, authwits, scopes) {
|
|
666
|
-
// We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
|
|
698
|
+
*/ executeUtility(call, { authwits, scopes } = {
|
|
699
|
+
scopes: 'ALL_SCOPES'
|
|
700
|
+
}) {
|
|
701
|
+
// We disable concurrent executions since those might execute oracles which read and write to the PXE stores (e.g.
|
|
667
702
|
// to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
|
|
668
|
-
// delete the same read value, or reading values that another
|
|
703
|
+
// delete the same read value, or reading values that another execution is currently modifying).
|
|
669
704
|
return this.#putInJobQueue(async (jobId)=>{
|
|
670
705
|
try {
|
|
671
706
|
const totalTimer = new Timer();
|
|
@@ -674,8 +709,9 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
674
709
|
const syncTime = syncTimer.ms();
|
|
675
710
|
const functionTimer = new Timer();
|
|
676
711
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
677
|
-
await this.
|
|
678
|
-
|
|
712
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
713
|
+
await this.contractSyncService.ensureContractSynced(call.to, call.selector, (privateSyncCall, execScopes)=>this.#executeUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId), anchorBlockHeader, jobId, scopes);
|
|
714
|
+
const executionResult = await this.#executeUtility(contractFunctionSimulator, call, authwits ?? [], scopes, jobId);
|
|
679
715
|
const functionTime = functionTimer.ms();
|
|
680
716
|
const totalTime = totalTimer.ms();
|
|
681
717
|
const perFunction = [
|
|
@@ -701,7 +737,7 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
701
737
|
} catch (err) {
|
|
702
738
|
const { to, name, args } = call;
|
|
703
739
|
const stringifiedArgs = args.map((arg)=>arg.toString()).join(', ');
|
|
704
|
-
throw this.#contextualizeError(err, `
|
|
740
|
+
throw this.#contextualizeError(err, `executeUtility ${to}:${name}(${stringifiedArgs})`, `scopes=${scopes === 'ALL_SCOPES' ? scopes : scopes.map((s)=>s.toString()).join(', ')}`);
|
|
705
741
|
}
|
|
706
742
|
});
|
|
707
743
|
}
|
|
@@ -721,9 +757,10 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
721
757
|
let anchorBlockNumber;
|
|
722
758
|
await this.#putInJobQueue(async (jobId)=>{
|
|
723
759
|
await this.blockStateSynchronizer.sync();
|
|
724
|
-
|
|
760
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
761
|
+
anchorBlockNumber = anchorBlockHeader.getBlockNumber();
|
|
725
762
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
726
|
-
await this.
|
|
763
|
+
await this.contractSyncService.ensureContractSynced(filter.contractAddress, null, async (privateSyncCall, execScopes)=>await this.#executeUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId), anchorBlockHeader, jobId, filter.scopes);
|
|
727
764
|
});
|
|
728
765
|
// anchorBlockNumber is set during the job and fixed to whatever it is after a block sync
|
|
729
766
|
const sanitizedFilter = new PrivateEventFilterValidator(anchorBlockNumber).validate(filter);
|
|
@@ -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.
|