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