@aztec/pxe 0.0.1-commit.6d3c34e → 0.0.1-commit.7035c9bd6
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 +11 -5
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +72 -21
- package/dest/config/index.d.ts +4 -2
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +18 -1
- package/dest/config/package_info.js +1 -1
- package/dest/contract_function_simulator/benchmarked_node.d.ts +9 -0
- package/dest/contract_function_simulator/benchmarked_node.d.ts.map +1 -0
- package/dest/contract_function_simulator/benchmarked_node.js +77 -0
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +64 -36
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +224 -88
- package/dest/contract_function_simulator/execution_note_cache.d.ts +18 -9
- package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_note_cache.js +45 -28
- 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 +3 -2
- package/dest/contract_function_simulator/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.js +2 -1
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +3 -4
- 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 +6 -5
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +1 -3
- package/dest/contract_function_simulator/noir-structs/message_tx_context.d.ts +16 -0
- package/dest/contract_function_simulator/noir-structs/message_tx_context.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/message_tx_context.js +57 -0
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +3 -5
- 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 +4 -6
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +4 -10
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/utility_context.js +7 -18
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +56 -47
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts +9 -0
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.js +42 -0
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +3 -1
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +6 -6
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/note_packing_utils.js +8 -8
- package/dest/contract_function_simulator/oracle/oracle.d.ts +45 -42
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +209 -117
- package/dest/contract_function_simulator/oracle/private_execution.d.ts +2 -26
- package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution.js +5 -38
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +60 -76
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +113 -88
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +107 -56
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +214 -137
- package/dest/contract_logging.d.ts +22 -0
- package/dest/contract_logging.d.ts.map +1 -0
- package/dest/contract_logging.js +23 -0
- package/dest/contract_sync/contract_sync_service.d.ts +45 -0
- package/dest/contract_sync/contract_sync_service.d.ts.map +1 -0
- package/dest/contract_sync/contract_sync_service.js +114 -0
- package/dest/contract_sync/helpers.d.ts +29 -0
- package/dest/contract_sync/helpers.d.ts.map +1 -0
- package/dest/contract_sync/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 +5 -1
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +4 -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 +6 -6
- package/dest/events/event_service.d.ts.map +1 -1
- package/dest/events/event_service.js +19 -22
- package/dest/events/private_event_filter_validator.d.ts +5 -5
- package/dest/events/private_event_filter_validator.d.ts.map +1 -1
- package/dest/events/private_event_filter_validator.js +5 -6
- 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 +8 -5
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +31 -33
- 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 +10 -9
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +34 -38
- 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 +5 -4
- 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 +3 -3
- package/dest/private_kernel/hints/index.d.ts.map +1 -1
- package/dest/private_kernel/hints/index.js +2 -2
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +29 -0
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -0
- package/dest/private_kernel/hints/{build_private_kernel_reset_private_inputs.js → private_kernel_reset_private_inputs_builder.js} +140 -73
- 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 +22 -14
- package/dest/private_kernel/private_kernel_oracle.d.ts +23 -24
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle.js +94 -2
- package/dest/pxe.d.ts +80 -59
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +155 -145
- 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.d.ts +24 -9
- package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -1
- package/dest/storage/capsule_store/capsule_store.js +130 -23
- 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 +50 -51
- package/dest/storage/note_store/note_store.d.ts.map +1 -1
- package/dest/storage/note_store/note_store.js +284 -263
- 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 +43 -8
- package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
- package/dest/storage/private_event_store/private_event_store.js +226 -111
- 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 +16 -9
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/recipient_tagging_store.js +88 -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 +43 -32
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.js +300 -122
- 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 +4 -3
- 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 +11 -11
- 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 +18 -12
- 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 +23 -16
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +8 -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 +44 -27
- package/package.json +27 -18
- package/src/access_scopes.ts +9 -0
- package/src/bin/check_oracle_version.ts +1 -0
- package/src/block_synchronizer/block_synchronizer.ts +91 -33
- package/src/config/index.ts +15 -1
- package/src/config/package_info.ts +1 -1
- package/src/contract_function_simulator/benchmarked_node.ts +103 -0
- package/src/contract_function_simulator/contract_function_simulator.ts +386 -153
- package/src/contract_function_simulator/execution_note_cache.ts +44 -25
- package/src/contract_function_simulator/execution_tagging_index_cache.ts +19 -14
- package/src/contract_function_simulator/index.ts +2 -1
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +9 -6
- package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +1 -4
- package/src/contract_function_simulator/noir-structs/message_tx_context.ts +55 -0
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +4 -7
- package/src/contract_function_simulator/noir-structs/utility_context.ts +6 -25
- package/src/contract_function_simulator/oracle/interfaces.ts +69 -59
- package/src/contract_function_simulator/oracle/legacy_oracle_mappings.ts +135 -0
- package/src/contract_function_simulator/oracle/note_packing_utils.ts +10 -10
- package/src/contract_function_simulator/oracle/oracle.ts +235 -165
- package/src/contract_function_simulator/oracle/private_execution.ts +5 -71
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +153 -184
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +318 -154
- package/src/contract_logging.ts +39 -0
- package/src/contract_sync/contract_sync_service.ts +181 -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 +4 -0
- package/src/entrypoints/server/utils.ts +22 -26
- package/src/events/event_service.ts +17 -25
- package/src/events/private_event_filter_validator.ts +3 -5
- package/src/job_coordinator/job_coordinator.ts +4 -3
- package/src/logs/log_service.ts +51 -40
- package/src/messages/message_context_service.ts +45 -0
- package/src/notes/note_service.ts +41 -45
- package/src/notes_filter.ts +26 -0
- package/src/oracle_version.ts +5 -4
- 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 +2 -2
- package/src/private_kernel/hints/{build_private_kernel_reset_private_inputs.ts → private_kernel_reset_private_inputs_builder.ts} +195 -136
- package/src/private_kernel/hints/test_utils.ts +325 -0
- package/src/private_kernel/private_kernel_execution_prover.ts +26 -16
- package/src/private_kernel/private_kernel_oracle.ts +116 -37
- package/src/pxe.ts +286 -223
- 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 +159 -23
- 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 +326 -320
- package/src/storage/note_store/stored_note.ts +48 -0
- package/src/storage/private_event_store/private_event_store.ts +292 -124
- package/src/storage/private_event_store/stored_private_event.ts +73 -0
- package/src/storage/tagging_store/recipient_tagging_store.ts +111 -21
- package/src/storage/tagging_store/sender_address_book_store.ts +20 -14
- package/src/storage/tagging_store/sender_tagging_store.ts +366 -134
- package/src/tagging/get_all_logs_by_tags.ts +92 -0
- package/src/tagging/index.ts +3 -2
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +22 -14
- 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 +31 -15
- package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +29 -26
- package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +42 -29
- package/dest/contract_function_simulator/proxied_node.d.ts +0 -9
- package/dest/contract_function_simulator/proxied_node.d.ts.map +0 -1
- package/dest/contract_function_simulator/proxied_node.js +0 -27
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts +0 -28
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts.map +0 -1
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +0 -4
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts.map +0 -1
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts +0 -46
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +0 -1
- package/dest/private_kernel/private_kernel_oracle_impl.js +0 -85
- package/dest/public_storage/public_storage_service.d.ts +0 -24
- package/dest/public_storage/public_storage_service.d.ts.map +0 -1
- package/dest/public_storage/public_storage_service.js +0 -26
- package/dest/tree_membership/tree_membership_service.d.ts +0 -52
- package/dest/tree_membership/tree_membership_service.d.ts.map +0 -1
- package/dest/tree_membership/tree_membership_service.js +0 -84
- package/src/contract_function_simulator/proxied_node.ts +0 -33
- package/src/private_kernel/private_kernel_oracle_impl.ts +0 -127
- package/src/public_storage/public_storage_service.ts +0 -33
- package/src/tree_membership/tree_membership_service.ts +0 -112
package/dest/pxe.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
1
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
2
|
import { SerialQueue } from '@aztec/foundation/queue';
|
|
4
3
|
import { Timer } from '@aztec/foundation/timer';
|
|
@@ -8,20 +7,22 @@ import { protocolContractNames } from '@aztec/protocol-contracts';
|
|
|
8
7
|
import { FunctionType, decodeFunctionSignature } from '@aztec/stdlib/abi';
|
|
9
8
|
import { computeContractAddressFromInstance, getContractClassFromArtifact } from '@aztec/stdlib/contract';
|
|
10
9
|
import { SimulationError } from '@aztec/stdlib/errors';
|
|
11
|
-
import { computeProtocolNullifier, siloNullifier } from '@aztec/stdlib/hash';
|
|
12
10
|
import { PrivateSimulationResult, TxProfileResult, TxProvingResult, TxSimulationResult } from '@aztec/stdlib/tx';
|
|
13
11
|
import { inspect } from 'util';
|
|
14
12
|
import { BlockSynchronizer } from './block_synchronizer/index.js';
|
|
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';
|
|
18
|
-
import {
|
|
16
|
+
import { displayDebugLogs } from './contract_logging.js';
|
|
17
|
+
import { ContractSyncService } from './contract_sync/contract_sync_service.js';
|
|
18
|
+
import { readCurrentClassId } from './contract_sync/helpers.js';
|
|
19
19
|
import { PXEDebugUtils } from './debug/pxe_debug_utils.js';
|
|
20
20
|
import { enrichPublicSimulationError, enrichSimulationError } from './error_enriching.js';
|
|
21
21
|
import { PrivateEventFilterValidator } from './events/private_event_filter_validator.js';
|
|
22
22
|
import { JobCoordinator } from './job_coordinator/job_coordinator.js';
|
|
23
|
+
import { MessageContextService } from './messages/message_context_service.js';
|
|
23
24
|
import { PrivateKernelExecutionProver } from './private_kernel/private_kernel_execution_prover.js';
|
|
24
|
-
import {
|
|
25
|
+
import { PrivateKernelOracle } from './private_kernel/private_kernel_oracle.js';
|
|
25
26
|
import { AddressStore } from './storage/address_store/address_store.js';
|
|
26
27
|
import { AnchorBlockStore } from './storage/anchor_block_store/anchor_block_store.js';
|
|
27
28
|
import { CapsuleStore } from './storage/capsule_store/capsule_store.js';
|
|
@@ -36,6 +37,7 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
36
37
|
* manage private state of users.
|
|
37
38
|
*/ export class PXE {
|
|
38
39
|
node;
|
|
40
|
+
db;
|
|
39
41
|
blockStateSynchronizer;
|
|
40
42
|
keyStore;
|
|
41
43
|
contractStore;
|
|
@@ -47,6 +49,8 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
47
49
|
recipientTaggingStore;
|
|
48
50
|
addressStore;
|
|
49
51
|
privateEventStore;
|
|
52
|
+
contractSyncService;
|
|
53
|
+
messageContextService;
|
|
50
54
|
simulator;
|
|
51
55
|
proverEnabled;
|
|
52
56
|
proofCreator;
|
|
@@ -55,8 +59,9 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
55
59
|
jobQueue;
|
|
56
60
|
jobCoordinator;
|
|
57
61
|
debug;
|
|
58
|
-
constructor(node, blockStateSynchronizer, keyStore, contractStore, noteStore, capsuleStore, anchorBlockStore, senderTaggingStore, senderAddressBookStore, recipientTaggingStore, addressStore, privateEventStore, simulator, proverEnabled, proofCreator, protocolContractsProvider, log, jobQueue, jobCoordinator, debug){
|
|
62
|
+
constructor(node, db, blockStateSynchronizer, keyStore, contractStore, noteStore, capsuleStore, anchorBlockStore, senderTaggingStore, senderAddressBookStore, recipientTaggingStore, addressStore, privateEventStore, contractSyncService, messageContextService, simulator, proverEnabled, proofCreator, protocolContractsProvider, log, jobQueue, jobCoordinator, debug){
|
|
59
63
|
this.node = node;
|
|
64
|
+
this.db = db;
|
|
60
65
|
this.blockStateSynchronizer = blockStateSynchronizer;
|
|
61
66
|
this.keyStore = keyStore;
|
|
62
67
|
this.contractStore = contractStore;
|
|
@@ -68,6 +73,8 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
68
73
|
this.recipientTaggingStore = recipientTaggingStore;
|
|
69
74
|
this.addressStore = addressStore;
|
|
70
75
|
this.privateEventStore = privateEventStore;
|
|
76
|
+
this.contractSyncService = contractSyncService;
|
|
77
|
+
this.messageContextService = messageContextService;
|
|
71
78
|
this.simulator = simulator;
|
|
72
79
|
this.proverEnabled = proverEnabled;
|
|
73
80
|
this.proofCreator = proofCreator;
|
|
@@ -83,13 +90,16 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
83
90
|
* can be contacted.
|
|
84
91
|
*
|
|
85
92
|
* @returns A promise that resolves PXE is ready to be used.
|
|
86
|
-
*/ static async create(node, store, proofCreator, simulator, protocolContractsProvider, config, loggerOrSuffix) {
|
|
93
|
+
*/ static async create({ node, store, proofCreator, simulator, protocolContractsProvider, config, loggerOrSuffix }) {
|
|
94
|
+
// Extract bindings from the logger, or use empty bindings if a string suffix is provided.
|
|
95
|
+
const bindings = loggerOrSuffix && typeof loggerOrSuffix !== 'string' ? loggerOrSuffix.getBindings() : undefined;
|
|
87
96
|
const log = !loggerOrSuffix || typeof loggerOrSuffix === 'string' ? createLogger(loggerOrSuffix ? `pxe:service:${loggerOrSuffix}` : `pxe:service`) : loggerOrSuffix;
|
|
88
|
-
const
|
|
97
|
+
const info = await node.getNodeInfo();
|
|
98
|
+
const proverEnabled = config.proverEnabled !== undefined ? config.proverEnabled : info.realProofs;
|
|
89
99
|
const addressStore = new AddressStore(store);
|
|
90
100
|
const privateEventStore = new PrivateEventStore(store);
|
|
91
101
|
const contractStore = new ContractStore(store);
|
|
92
|
-
const noteStore =
|
|
102
|
+
const noteStore = new NoteStore(store);
|
|
93
103
|
const anchorBlockStore = new AnchorBlockStore(store);
|
|
94
104
|
const senderTaggingStore = new SenderTaggingStore(store);
|
|
95
105
|
const senderAddressBookStore = new SenderAddressBookStore(store);
|
|
@@ -97,22 +107,45 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
97
107
|
const capsuleStore = new CapsuleStore(store);
|
|
98
108
|
const keyStore = new KeyStore(store);
|
|
99
109
|
const tipsStore = new L2TipsKVStore(store, 'pxe');
|
|
100
|
-
const
|
|
101
|
-
const
|
|
102
|
-
const
|
|
110
|
+
const contractSyncService = new ContractSyncService(node, contractStore, noteStore, createLogger('pxe:contract_sync', bindings));
|
|
111
|
+
const messageContextService = new MessageContextService(node);
|
|
112
|
+
const synchronizer = new BlockSynchronizer(node, store, anchorBlockStore, noteStore, privateEventStore, tipsStore, contractSyncService, config, bindings);
|
|
113
|
+
const jobCoordinator = new JobCoordinator(store, bindings);
|
|
114
|
+
jobCoordinator.registerStores([
|
|
115
|
+
capsuleStore,
|
|
116
|
+
senderTaggingStore,
|
|
117
|
+
recipientTaggingStore,
|
|
118
|
+
privateEventStore,
|
|
119
|
+
noteStore,
|
|
120
|
+
contractSyncService
|
|
121
|
+
]);
|
|
122
|
+
const debugUtils = new PXEDebugUtils(contractSyncService, noteStore, synchronizer, anchorBlockStore);
|
|
103
123
|
const jobQueue = new SerialQueue();
|
|
104
|
-
const pxe = new PXE(node, synchronizer, keyStore, contractStore, noteStore, capsuleStore, anchorBlockStore, senderTaggingStore, senderAddressBookStore, recipientTaggingStore, addressStore, privateEventStore, simulator, proverEnabled, proofCreator, protocolContractsProvider, log, jobQueue, jobCoordinator, debugUtils);
|
|
105
|
-
debugUtils.
|
|
124
|
+
const pxe = new PXE(node, store, synchronizer, keyStore, contractStore, noteStore, capsuleStore, anchorBlockStore, senderTaggingStore, senderAddressBookStore, recipientTaggingStore, addressStore, privateEventStore, contractSyncService, messageContextService, simulator, proverEnabled, proofCreator, protocolContractsProvider, log, jobQueue, jobCoordinator, debugUtils);
|
|
125
|
+
debugUtils.setPXEHelpers(pxe.#putInJobQueue.bind(pxe), pxe.#getSimulatorForTx.bind(pxe), pxe.#executeUtility.bind(pxe));
|
|
106
126
|
pxe.jobQueue.start();
|
|
107
127
|
await pxe.#registerProtocolContracts();
|
|
108
|
-
const info = await node.getNodeInfo();
|
|
109
128
|
log.info(`Started PXE connected to chain ${info.l1ChainId} version ${info.rollupVersion}`);
|
|
110
129
|
return pxe;
|
|
111
130
|
}
|
|
112
131
|
// Internal methods
|
|
113
132
|
#getSimulatorForTx(overrides) {
|
|
114
133
|
const proxyContractStore = ProxiedContractStoreFactory.create(this.contractStore, overrides?.contracts);
|
|
115
|
-
return new ContractFunctionSimulator(
|
|
134
|
+
return new ContractFunctionSimulator({
|
|
135
|
+
contractStore: proxyContractStore,
|
|
136
|
+
noteStore: this.noteStore,
|
|
137
|
+
keyStore: this.keyStore,
|
|
138
|
+
addressStore: this.addressStore,
|
|
139
|
+
aztecNode: BenchmarkedNodeFactory.create(this.node),
|
|
140
|
+
senderTaggingStore: this.senderTaggingStore,
|
|
141
|
+
recipientTaggingStore: this.recipientTaggingStore,
|
|
142
|
+
senderAddressBookStore: this.senderAddressBookStore,
|
|
143
|
+
capsuleStore: this.capsuleStore,
|
|
144
|
+
privateEventStore: this.privateEventStore,
|
|
145
|
+
simulator: this.simulator,
|
|
146
|
+
contractSyncService: this.contractSyncService,
|
|
147
|
+
messageContextService: this.messageContextService
|
|
148
|
+
});
|
|
116
149
|
}
|
|
117
150
|
#contextualizeError(err, ...context) {
|
|
118
151
|
let contextStr = '';
|
|
@@ -155,32 +188,27 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
155
188
|
async #registerProtocolContracts() {
|
|
156
189
|
const registered = {};
|
|
157
190
|
for (const name of protocolContractNames){
|
|
158
|
-
const { address,
|
|
159
|
-
await this.contractStore.addContractArtifact(
|
|
191
|
+
const { address, instance, artifact } = await this.protocolContractsProvider.getProtocolContractArtifact(name);
|
|
192
|
+
await this.contractStore.addContractArtifact(artifact);
|
|
160
193
|
await this.contractStore.addContractInstance(instance);
|
|
161
194
|
registered[name] = address.toString();
|
|
162
195
|
}
|
|
163
196
|
this.log.verbose(`Registered protocol contracts in pxe`, registered);
|
|
164
197
|
}
|
|
165
|
-
async #isContractClassPubliclyRegistered(id) {
|
|
166
|
-
return !!await this.node.getContractClass(id);
|
|
167
|
-
}
|
|
168
|
-
async #isContractPublished(address) {
|
|
169
|
-
return !!await this.node.getContract(address);
|
|
170
|
-
}
|
|
171
|
-
async #isContractInitialized(address) {
|
|
172
|
-
const initNullifier = await siloNullifier(address, address.toField());
|
|
173
|
-
return !!await this.node.getNullifierMembershipWitness('latest', initNullifier);
|
|
174
|
-
}
|
|
175
198
|
// Executes the entrypoint private function, as well as all nested private
|
|
176
199
|
// functions that might arise.
|
|
177
200
|
async #executePrivate(contractFunctionSimulator, txRequest, scopes, jobId) {
|
|
178
201
|
const { origin: contractAddress, functionSelector } = txRequest;
|
|
179
202
|
try {
|
|
180
203
|
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
204
|
+
await this.contractSyncService.ensureContractSynced(contractAddress, functionSelector, (privateSyncCall, execScopes)=>this.#executeUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId), anchorBlockHeader, jobId, scopes);
|
|
205
|
+
const result = await contractFunctionSimulator.run(txRequest, {
|
|
206
|
+
contractAddress,
|
|
207
|
+
selector: functionSelector,
|
|
208
|
+
anchorBlockHeader,
|
|
209
|
+
scopes,
|
|
210
|
+
jobId
|
|
211
|
+
});
|
|
184
212
|
this.log.debug(`Private simulation completed for ${contractAddress.toString()}:${functionSelector}`);
|
|
185
213
|
return result;
|
|
186
214
|
} catch (err) {
|
|
@@ -191,18 +219,22 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
191
219
|
}
|
|
192
220
|
}
|
|
193
221
|
/**
|
|
194
|
-
*
|
|
222
|
+
* Execute a utility function call on the given contract.
|
|
195
223
|
* @param contractFunctionSimulator - The simulator to use for the function call.
|
|
196
224
|
* @param call - The function call to execute.
|
|
197
225
|
* @param authWitnesses - Authentication witnesses required for the function call.
|
|
198
226
|
* @param scopes - Optional array of account addresses whose notes can be accessed in this call. Defaults to all
|
|
199
227
|
* accounts if not specified.
|
|
200
228
|
* @param jobId - The job ID for staged writes.
|
|
201
|
-
* @returns The
|
|
202
|
-
*/ async #
|
|
229
|
+
* @returns The execution result containing the outputs of the utility function.
|
|
230
|
+
*/ async #executeUtility(contractFunctionSimulator, call, authWitnesses, scopes, jobId) {
|
|
203
231
|
try {
|
|
204
232
|
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
205
|
-
|
|
233
|
+
const { result, offchainEffects } = await contractFunctionSimulator.runUtility(call, authWitnesses ?? [], anchorBlockHeader, scopes, jobId);
|
|
234
|
+
return {
|
|
235
|
+
result,
|
|
236
|
+
offchainEffects
|
|
237
|
+
};
|
|
206
238
|
} catch (err) {
|
|
207
239
|
if (err instanceof SimulationError) {
|
|
208
240
|
await enrichSimulationError(err, this.contractStore, this.log);
|
|
@@ -246,62 +278,33 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
246
278
|
* @param config - The configuration for the kernel execution prover.
|
|
247
279
|
* @returns An object that contains the output of the kernel execution, including the ChonkProof if proving is enabled.
|
|
248
280
|
*/ async #prove(txExecutionRequest, proofCreator, privateExecutionResult, config) {
|
|
249
|
-
const
|
|
250
|
-
const
|
|
251
|
-
const
|
|
281
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
282
|
+
const anchorBlockHash = await anchorBlockHeader.hash();
|
|
283
|
+
const kernelOracle = new PrivateKernelOracle(this.contractStore, this.keyStore, this.node, anchorBlockHash);
|
|
284
|
+
const kernelTraceProver = new PrivateKernelExecutionProver(kernelOracle, proofCreator, !this.proverEnabled, this.log.getBindings());
|
|
252
285
|
this.log.debug(`Executing kernel trace prover (${JSON.stringify(config)})...`);
|
|
253
286
|
return await kernelTraceProver.proveWithKernels(txExecutionRequest.toTxRequest(), privateExecutionResult, config);
|
|
254
287
|
}
|
|
255
288
|
// Public API
|
|
256
|
-
|
|
257
|
-
|
|
289
|
+
/**
|
|
290
|
+
* Returns the block header up to which the PXE has synced.
|
|
291
|
+
* @returns The synced block header
|
|
292
|
+
*/ getSyncedBlockHeader() {
|
|
293
|
+
return this.anchorBlockStore.getBlockHeader();
|
|
258
294
|
}
|
|
259
295
|
/**
|
|
260
|
-
* Returns the contract
|
|
261
|
-
*
|
|
262
|
-
* @
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
* @returns - It returns the contract class metadata, with the artifact field being optional, and will only be returned if true is passed in
|
|
266
|
-
* for `includeArtifact`
|
|
267
|
-
* TODO(@spalladino): The PXE actually holds artifacts and not classes, what should we return? Also,
|
|
268
|
-
* should the pxe query the node for contract public info, and merge it with its own definitions?
|
|
269
|
-
* TODO(@spalladino): This method is strictly needed to decide whether to publicly register a class or not
|
|
270
|
-
* during a public deployment. We probably want a nicer and more general API for this, but it'll have to
|
|
271
|
-
* do for the time being.
|
|
272
|
-
*/ async getContractClassMetadata(id, includeArtifact = false) {
|
|
273
|
-
const artifact = await this.contractStore.getContractArtifact(id);
|
|
274
|
-
if (!artifact) {
|
|
275
|
-
this.log.warn(`No artifact found for contract class ${id.toString()} when looking for its metadata`);
|
|
276
|
-
}
|
|
277
|
-
return {
|
|
278
|
-
contractClass: artifact && await getContractClassFromArtifact(artifact),
|
|
279
|
-
isContractClassPubliclyRegistered: await this.#isContractClassPubliclyRegistered(id),
|
|
280
|
-
artifact: includeArtifact ? artifact : undefined
|
|
281
|
-
};
|
|
296
|
+
* Returns the contract instance for a given address, if it's registered in the PXE.
|
|
297
|
+
* @param address - The contract address.
|
|
298
|
+
* @returns The contract instance if found, undefined otherwise.
|
|
299
|
+
*/ getContractInstance(address) {
|
|
300
|
+
return this.contractStore.getContractInstance(address);
|
|
282
301
|
}
|
|
283
302
|
/**
|
|
284
|
-
* Returns the contract
|
|
285
|
-
*
|
|
286
|
-
*
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
* This query is not dependent on the PXE.
|
|
290
|
-
* @param address - The address that the contract instance resides at.
|
|
291
|
-
* @returns - It returns the contract metadata
|
|
292
|
-
* TODO(@spalladino): Should we return the public keys in plain as well here?
|
|
293
|
-
*/ async getContractMetadata(address) {
|
|
294
|
-
let instance;
|
|
295
|
-
try {
|
|
296
|
-
instance = await this.contractStore.getContractInstance(address);
|
|
297
|
-
} catch {
|
|
298
|
-
this.log.warn(`No instance found for contract ${address.toString()} when looking for its metadata`);
|
|
299
|
-
}
|
|
300
|
-
return {
|
|
301
|
-
contractInstance: instance,
|
|
302
|
-
isContractInitialized: await this.#isContractInitialized(address),
|
|
303
|
-
isContractPublished: await this.#isContractPublished(address)
|
|
304
|
-
};
|
|
303
|
+
* Returns the contract artifact for a given contract class id, if it's registered in the PXE.
|
|
304
|
+
* @param id - Identifier of the contract class.
|
|
305
|
+
* @returns The contract artifact if found, undefined otherwise.
|
|
306
|
+
*/ async getContractArtifact(id) {
|
|
307
|
+
return await this.contractStore.getContractArtifact(id);
|
|
305
308
|
}
|
|
306
309
|
/**
|
|
307
310
|
* Registers a user account in PXE given its master encryption private key.
|
|
@@ -323,7 +326,6 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
323
326
|
this.log.debug(`Registered account\n ${accountCompleteAddress.toReadableString()}`);
|
|
324
327
|
}
|
|
325
328
|
await this.addressStore.addCompleteAddress(accountCompleteAddress);
|
|
326
|
-
await this.noteStore.addScope(accountCompleteAddress.address);
|
|
327
329
|
return accountCompleteAddress;
|
|
328
330
|
}
|
|
329
331
|
/**
|
|
@@ -344,6 +346,9 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
344
346
|
const wasAdded = await this.senderAddressBookStore.addSender(sender);
|
|
345
347
|
if (wasAdded) {
|
|
346
348
|
this.log.info(`Added sender:\n ${sender.toString()}`);
|
|
349
|
+
// Wipe the entire sync cache: the new sender's tagged logs could contain notes/events for any contract, so
|
|
350
|
+
// all contracts must re-sync to discover them.
|
|
351
|
+
this.contractSyncService.wipe();
|
|
347
352
|
} else {
|
|
348
353
|
this.log.info(`Sender:\n "${sender.toString()}"\n already registered.`);
|
|
349
354
|
}
|
|
@@ -381,8 +386,7 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
381
386
|
*
|
|
382
387
|
* @param artifact - The build artifact for the contract class.
|
|
383
388
|
*/ async registerContractClass(artifact) {
|
|
384
|
-
const
|
|
385
|
-
await this.contractStore.addContractArtifact(contractClassId, artifact);
|
|
389
|
+
const contractClassId = await this.contractStore.addContractArtifact(artifact);
|
|
386
390
|
this.log.info(`Added contract class ${artifact.name} with id ${contractClassId}`);
|
|
387
391
|
}
|
|
388
392
|
/**
|
|
@@ -398,15 +402,14 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
398
402
|
if (artifact) {
|
|
399
403
|
// If the user provides an artifact, validate it against the expected class id and register it
|
|
400
404
|
const contractClass = await getContractClassFromArtifact(artifact);
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
throw new Error(`Artifact does not match expected class id (computed ${contractClassId} but instance refers to ${instance.currentContractClassId})`);
|
|
405
|
+
if (!contractClass.id.equals(instance.currentContractClassId)) {
|
|
406
|
+
throw new Error(`Artifact does not match expected class id (computed ${contractClass.id} but instance refers to ${instance.currentContractClassId})`);
|
|
404
407
|
}
|
|
405
408
|
const computedAddress = await computeContractAddressFromInstance(instance);
|
|
406
409
|
if (!computedAddress.equals(instance.address)) {
|
|
407
410
|
throw new Error('Added a contract in which the address does not match the contract instance.');
|
|
408
411
|
}
|
|
409
|
-
await this.contractStore.addContractArtifact(
|
|
412
|
+
await this.contractStore.addContractArtifact(artifact, contractClass);
|
|
410
413
|
const publicFunctionSignatures = artifact.functions.filter((fn)=>fn.functionType === FunctionType.PUBLIC).map((fn)=>decodeFunctionSignature(fn.name, fn.parameters));
|
|
411
414
|
await this.node.registerContractFunctionSignatures(publicFunctionSignatures);
|
|
412
415
|
} else {
|
|
@@ -438,15 +441,17 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
438
441
|
const contractClass = await getContractClassFromArtifact(artifact);
|
|
439
442
|
await this.blockStateSynchronizer.sync();
|
|
440
443
|
const header = await this.anchorBlockStore.getBlockHeader();
|
|
441
|
-
const currentClassId = await readCurrentClassId(contractAddress, currentInstance, this.node, header
|
|
444
|
+
const currentClassId = await readCurrentClassId(contractAddress, currentInstance, this.node, header);
|
|
442
445
|
if (!contractClass.id.equals(currentClassId)) {
|
|
443
446
|
throw new Error('Could not update contract to a class different from the current one.');
|
|
444
447
|
}
|
|
445
|
-
await this.contractStore.addContractArtifact(contractClass.id, artifact);
|
|
446
448
|
const publicFunctionSignatures = artifact.functions.filter((fn)=>fn.functionType === FunctionType.PUBLIC).map((fn)=>decodeFunctionSignature(fn.name, fn.parameters));
|
|
447
449
|
await this.node.registerContractFunctionSignatures(publicFunctionSignatures);
|
|
448
450
|
currentInstance.currentContractClassId = contractClass.id;
|
|
449
|
-
await
|
|
451
|
+
await Promise.all([
|
|
452
|
+
this.contractStore.addContractArtifact(artifact, contractClass),
|
|
453
|
+
this.contractStore.addContractInstance(currentInstance)
|
|
454
|
+
]);
|
|
450
455
|
this.log.info(`Updated contract ${artifact.name} at ${contractAddress.toString()} to class ${contractClass.id}`);
|
|
451
456
|
});
|
|
452
457
|
}
|
|
@@ -461,10 +466,11 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
461
466
|
* (where validators prove the public portion).
|
|
462
467
|
*
|
|
463
468
|
* @param txRequest - An authenticated tx request ready for proving
|
|
469
|
+
* @param scopes - Addresses whose private state and keys are accessible during private execution.
|
|
464
470
|
* @returns A result containing the proof and public inputs of the tail circuit.
|
|
465
471
|
* @throws If contract code not found, or public simulation reverts.
|
|
466
472
|
* Also throws if simulatePublic is true and public simulation reverts.
|
|
467
|
-
*/ proveTx(txRequest) {
|
|
473
|
+
*/ proveTx(txRequest, scopes) {
|
|
468
474
|
let privateExecutionResult;
|
|
469
475
|
// We disable proving concurrently mostly out of caution, since it accesses some of our stores. Proving is so
|
|
470
476
|
// computationally demanding that it'd be rare for someone to try to do it concurrently regardless.
|
|
@@ -475,7 +481,7 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
475
481
|
await this.blockStateSynchronizer.sync();
|
|
476
482
|
const syncTime = syncTimer.ms();
|
|
477
483
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
478
|
-
privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest,
|
|
484
|
+
privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest, scopes, jobId);
|
|
479
485
|
const { publicInputs, chonkProof, executionSteps, timings: { proving } = {} } = await this.#prove(txRequest, this.proofCreator, privateExecutionResult, {
|
|
480
486
|
simulate: false,
|
|
481
487
|
skipFeeEnforcement: false,
|
|
@@ -506,16 +512,16 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
506
512
|
// transaction before this one is included in a block from this PXE, and that transaction contains a log with
|
|
507
513
|
// a tag derived from the same secret, we would reuse the tag and the transactions would be linked. Hence
|
|
508
514
|
// storing the tags here prevents linkage of txs sent from the same PXE.
|
|
509
|
-
const
|
|
510
|
-
if (
|
|
515
|
+
const taggingIndexRangesUsedInTheTx = privateExecutionResult.entrypoint.taggingIndexRanges;
|
|
516
|
+
if (taggingIndexRangesUsedInTheTx.length > 0) {
|
|
511
517
|
// TODO(benesjan): The following is an expensive operation. Figure out a way to avoid it.
|
|
512
518
|
const txHash = (await txProvingResult.toTx()).txHash;
|
|
513
|
-
await this.senderTaggingStore.storePendingIndexes(
|
|
514
|
-
this.log.debug(`Stored used
|
|
515
|
-
|
|
519
|
+
await this.senderTaggingStore.storePendingIndexes(taggingIndexRangesUsedInTheTx, txHash, jobId);
|
|
520
|
+
this.log.debug(`Stored used tagging index ranges as sender for the tx`, {
|
|
521
|
+
taggingIndexRangesUsedInTheTx
|
|
516
522
|
});
|
|
517
523
|
} else {
|
|
518
|
-
this.log.debug(`No
|
|
524
|
+
this.log.debug(`No tagging index ranges used in the tx`);
|
|
519
525
|
}
|
|
520
526
|
return txProvingResult;
|
|
521
527
|
} catch (err) {
|
|
@@ -525,13 +531,10 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
525
531
|
}
|
|
526
532
|
/**
|
|
527
533
|
* Profiles a transaction, reporting gate counts (unless disabled) and returns an execution trace.
|
|
528
|
-
*
|
|
529
|
-
* @param txRequest - An authenticated tx request ready for simulation
|
|
530
|
-
* @param msgSender - (Optional) The message sender to use for the simulation.
|
|
531
|
-
* @param skipTxValidation - (Optional) If false, this function throws if the transaction is unable to be included in a block at the current state.
|
|
534
|
+
* @param txRequest - An authenticated tx request ready for simulation.
|
|
532
535
|
* @returns A trace of the program execution with gate counts.
|
|
533
536
|
* @throws If the code for the functions executed in this transaction have not been made available via `addContracts`.
|
|
534
|
-
*/ profileTx(txRequest, profileMode, skipProofGeneration = true) {
|
|
537
|
+
*/ profileTx(txRequest, { profileMode, skipProofGeneration = true, scopes }) {
|
|
535
538
|
// We disable concurrent profiles for consistency with simulateTx.
|
|
536
539
|
return this.#putInJobQueue(async (jobId)=>{
|
|
537
540
|
const totalTimer = new Timer();
|
|
@@ -549,7 +552,7 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
549
552
|
await this.blockStateSynchronizer.sync();
|
|
550
553
|
const syncTime = syncTimer.ms();
|
|
551
554
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
552
|
-
const privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest,
|
|
555
|
+
const privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest, scopes, jobId);
|
|
553
556
|
const { executionSteps, timings: { proving } = {} } = await this.#prove(txRequest, this.proofCreator, privateExecutionResult, {
|
|
554
557
|
simulate: skipProofGeneration,
|
|
555
558
|
skipFeeEnforcement: false,
|
|
@@ -594,18 +597,13 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
594
597
|
* In that case, the transaction returned is only potentially ready to be sent to the network for execution.
|
|
595
598
|
*
|
|
596
599
|
*
|
|
597
|
-
* @param txRequest - An authenticated tx request ready for simulation
|
|
598
|
-
* @param simulatePublic - Whether to simulate the public part of the transaction.
|
|
599
|
-
* @param skipTxValidation - (Optional) If false, this function throws if the transaction is unable to be included in a block at the current state.
|
|
600
|
-
* @param skipFeeEnforcement - (Optional) If false, fees are enforced.
|
|
601
|
-
* @param overrides - (Optional) State overrides for the simulation, such as msgSender, contract instances and artifacts.
|
|
602
|
-
* @param scopes - (Optional) The accounts whose notes we can access in this call. Currently optional and will default to all.
|
|
600
|
+
* @param txRequest - An authenticated tx request ready for simulation.
|
|
603
601
|
* @returns A simulated transaction result object that includes public and private return values.
|
|
604
602
|
* @throws If the code for the functions executed in this transaction have not been made available via `addContracts`.
|
|
605
603
|
* Also throws if simulatePublic is true and public simulation reverts.
|
|
606
604
|
*
|
|
607
605
|
* TODO(#7456) Prevent msgSender being defined here for the first call
|
|
608
|
-
*/ simulateTx(txRequest, simulatePublic, skipTxValidation = false, skipFeeEnforcement = false, overrides, scopes) {
|
|
606
|
+
*/ simulateTx(txRequest, { simulatePublic, skipTxValidation = false, skipFeeEnforcement = false, skipKernels = true, overrides, scopes }) {
|
|
609
607
|
// We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
|
|
610
608
|
// to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
|
|
611
609
|
// delete the same read value, or reading values that another simulation is currently modifying).
|
|
@@ -624,20 +622,23 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
624
622
|
const syncTimer = new Timer();
|
|
625
623
|
await this.blockStateSynchronizer.sync();
|
|
626
624
|
const syncTime = syncTimer.ms();
|
|
625
|
+
const overriddenContracts = overrides?.contracts ? new Set(Object.keys(overrides.contracts)) : undefined;
|
|
626
|
+
const hasOverriddenContracts = overriddenContracts !== undefined && overriddenContracts.size > 0;
|
|
627
|
+
if (hasOverriddenContracts && !skipKernels) {
|
|
628
|
+
throw new Error('Simulating with overridden contracts is not compatible with kernel execution. Please set skipKernels to true when simulating with overridden contracts.');
|
|
629
|
+
}
|
|
627
630
|
const contractFunctionSimulator = this.#getSimulatorForTx(overrides);
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
631
|
+
if (hasOverriddenContracts) {
|
|
632
|
+
// Overridden contracts don't have a sync function, so calling sync on them would fail.
|
|
633
|
+
// We exclude them so the sync service skips them entirely.
|
|
634
|
+
this.contractSyncService.setExcludedFromSync(jobId, overriddenContracts);
|
|
635
|
+
}
|
|
632
636
|
// Execution of private functions only; no proving, and no kernel logic.
|
|
633
637
|
const privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest, scopes, jobId);
|
|
634
638
|
let publicInputs;
|
|
635
639
|
let executionSteps = [];
|
|
636
640
|
if (skipKernels) {
|
|
637
|
-
|
|
638
|
-
// can either be the first nullifier in the tx or the protocol nullifier if there are none.
|
|
639
|
-
const nonceGenerator = privateExecutionResult.firstNullifier.equals(Fr.ZERO) ? await computeProtocolNullifier(await txRequest.toTxRequest().hash()) : privateExecutionResult.firstNullifier;
|
|
640
|
-
({ publicInputs, executionSteps } = await generateSimulatedProvingResult(privateExecutionResult, nonceGenerator, this.contractStore));
|
|
641
|
+
({ publicInputs, executionSteps } = await generateSimulatedProvingResult(privateExecutionResult, (addr, sel)=>this.contractStore.getDebugFunctionName(addr, sel), this.node));
|
|
641
642
|
} else {
|
|
642
643
|
// Kernel logic, plus proving of all private functions and kernels.
|
|
643
644
|
({ publicInputs, executionSteps } = await this.#prove(txRequest, this.proofCreator, privateExecutionResult, {
|
|
@@ -654,6 +655,9 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
654
655
|
const publicSimulationTimer = new Timer();
|
|
655
656
|
publicOutput = await this.#simulatePublicCalls(simulatedTx, skipFeeEnforcement);
|
|
656
657
|
publicSimulationTime = publicSimulationTimer.ms();
|
|
658
|
+
if (publicOutput?.debugLogs?.length) {
|
|
659
|
+
await displayDebugLogs(publicOutput.debugLogs, (addr)=>this.contractStore.getDebugContractName(addr));
|
|
660
|
+
}
|
|
657
661
|
}
|
|
658
662
|
let validationTime;
|
|
659
663
|
if (!skipTxValidation) {
|
|
@@ -664,7 +668,8 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
664
668
|
});
|
|
665
669
|
validationTime = validationTimer.ms();
|
|
666
670
|
if (validationResult.result === 'invalid') {
|
|
667
|
-
|
|
671
|
+
const reason = validationResult.reason.length > 0 ? ` Reason: ${validationResult.reason.join(', ')}` : '';
|
|
672
|
+
throw new Error(`The simulated transaction is unable to be added to state and is invalid.${reason}`);
|
|
668
673
|
}
|
|
669
674
|
}
|
|
670
675
|
const txHash = simulatedTx.getTxHash();
|
|
@@ -697,22 +702,19 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
697
702
|
nodeRPCCalls: simulatorStats.nodeRPCCalls
|
|
698
703
|
});
|
|
699
704
|
} catch (err) {
|
|
700
|
-
throw this.#contextualizeError(err, inspect(txRequest), `simulatePublic=${simulatePublic}`, `skipTxValidation=${skipTxValidation}`, `scopes=${scopes
|
|
705
|
+
throw this.#contextualizeError(err, inspect(txRequest), `simulatePublic=${simulatePublic}`, `skipTxValidation=${skipTxValidation}`, `scopes=${scopes === 'ALL_SCOPES' ? scopes : scopes.map((s)=>s.toString()).join(', ')}`);
|
|
701
706
|
}
|
|
702
707
|
});
|
|
703
708
|
}
|
|
704
709
|
/**
|
|
705
|
-
*
|
|
706
|
-
*
|
|
710
|
+
* Executes a contract utility function.
|
|
707
711
|
* @param call - The function call containing the function details, arguments, and target contract address.
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
*/ simulateUtility(call, authwits, scopes) {
|
|
713
|
-
// We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
|
|
712
|
+
*/ executeUtility(call, { authwits, scopes } = {
|
|
713
|
+
scopes: 'ALL_SCOPES'
|
|
714
|
+
}) {
|
|
715
|
+
// We disable concurrent executions since those might execute oracles which read and write to the PXE stores (e.g.
|
|
714
716
|
// to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
|
|
715
|
-
// delete the same read value, or reading values that another
|
|
717
|
+
// delete the same read value, or reading values that another execution is currently modifying).
|
|
716
718
|
return this.#putInJobQueue(async (jobId)=>{
|
|
717
719
|
try {
|
|
718
720
|
const totalTimer = new Timer();
|
|
@@ -721,8 +723,9 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
721
723
|
const syncTime = syncTimer.ms();
|
|
722
724
|
const functionTimer = new Timer();
|
|
723
725
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
724
|
-
await this.
|
|
725
|
-
|
|
726
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
727
|
+
await this.contractSyncService.ensureContractSynced(call.to, call.selector, (privateSyncCall, execScopes)=>this.#executeUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId), anchorBlockHeader, jobId, scopes);
|
|
728
|
+
const { result: executionResult, offchainEffects } = await this.#executeUtility(contractFunctionSimulator, call, authwits ?? [], scopes, jobId);
|
|
726
729
|
const functionTime = functionTimer.ms();
|
|
727
730
|
const totalTime = totalTimer.ms();
|
|
728
731
|
const perFunction = [
|
|
@@ -740,6 +743,8 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
740
743
|
const simulationStats = contractFunctionSimulator.getStats();
|
|
741
744
|
return {
|
|
742
745
|
result: executionResult,
|
|
746
|
+
offchainEffects,
|
|
747
|
+
anchorBlockTimestamp: anchorBlockHeader.globalVariables.timestamp,
|
|
743
748
|
stats: {
|
|
744
749
|
timings,
|
|
745
750
|
nodeRPCCalls: simulationStats.nodeRPCCalls
|
|
@@ -748,7 +753,7 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
748
753
|
} catch (err) {
|
|
749
754
|
const { to, name, args } = call;
|
|
750
755
|
const stringifiedArgs = args.map((arg)=>arg.toString()).join(', ');
|
|
751
|
-
throw this.#contextualizeError(err, `
|
|
756
|
+
throw this.#contextualizeError(err, `executeUtility ${to}:${name}(${stringifiedArgs})`, `scopes=${scopes === 'ALL_SCOPES' ? scopes : scopes.map((s)=>s.toString()).join(', ')}`);
|
|
752
757
|
}
|
|
753
758
|
});
|
|
754
759
|
}
|
|
@@ -764,19 +769,24 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
764
769
|
* toBlock - The block number to search up to (exclusive). Optional. If provided, it must be > 0.
|
|
765
770
|
* Defaults to the latest known block to PXE + 1.
|
|
766
771
|
* @returns - The packed events with block and tx metadata.
|
|
767
|
-
*/ getPrivateEvents(eventSelector, filter) {
|
|
768
|
-
|
|
772
|
+
*/ async getPrivateEvents(eventSelector, filter) {
|
|
773
|
+
let anchorBlockNumber;
|
|
774
|
+
await this.#putInJobQueue(async (jobId)=>{
|
|
769
775
|
await this.blockStateSynchronizer.sync();
|
|
776
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
777
|
+
anchorBlockNumber = anchorBlockHeader.getBlockNumber();
|
|
770
778
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
771
|
-
await this.
|
|
772
|
-
const sanitizedFilter = await new PrivateEventFilterValidator(this.anchorBlockStore).validate(filter);
|
|
773
|
-
this.log.debug(`Getting private events for ${sanitizedFilter.contractAddress.toString()} from ${sanitizedFilter.fromBlock} to ${sanitizedFilter.toBlock}`);
|
|
774
|
-
return this.privateEventStore.getPrivateEvents(eventSelector, sanitizedFilter);
|
|
779
|
+
await this.contractSyncService.ensureContractSynced(filter.contractAddress, null, async (privateSyncCall, execScopes)=>await this.#executeUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId), anchorBlockHeader, jobId, filter.scopes);
|
|
775
780
|
});
|
|
781
|
+
// anchorBlockNumber is set during the job and fixed to whatever it is after a block sync
|
|
782
|
+
const sanitizedFilter = new PrivateEventFilterValidator(anchorBlockNumber).validate(filter);
|
|
783
|
+
this.log.debug(`Getting private events for ${sanitizedFilter.contractAddress.toString()} from ${sanitizedFilter.fromBlock} to ${sanitizedFilter.toBlock}`);
|
|
784
|
+
return this.privateEventStore.getPrivateEvents(eventSelector, sanitizedFilter);
|
|
776
785
|
}
|
|
777
786
|
/**
|
|
778
|
-
* Stops the PXE's job queue.
|
|
779
|
-
*/ stop() {
|
|
780
|
-
|
|
787
|
+
* Stops the PXE's job queue and closes the backing store.
|
|
788
|
+
*/ async stop() {
|
|
789
|
+
await this.jobQueue.end();
|
|
790
|
+
await this.db.close();
|
|
781
791
|
}
|
|
782
792
|
}
|
|
@@ -8,4 +8,4 @@ export declare class AddressStore {
|
|
|
8
8
|
getCompleteAddress(account: AztecAddress): Promise<CompleteAddress | undefined>;
|
|
9
9
|
getCompleteAddresses(): Promise<CompleteAddress[]>;
|
|
10
10
|
}
|
|
11
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
11
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWRkcmVzc19zdG9yZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3N0b3JhZ2UvYWRkcmVzc19zdG9yZS9hZGRyZXNzX3N0b3JlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sS0FBSyxFQUFtQixpQkFBaUIsRUFBaUIsTUFBTSxpQkFBaUIsQ0FBQztBQUN6RixPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUNoRSxPQUFPLEVBQUUsZUFBZSxFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFFekQscUJBQWEsWUFBWTs7SUFLdkIsWUFBWSxLQUFLLEVBQUUsaUJBQWlCLEVBS25DO0lBRUQsa0JBQWtCLENBQUMsZUFBZSxFQUFFLGVBQWUsR0FBRyxPQUFPLENBQUMsT0FBTyxDQUFDLENBMEJyRTtJQUVELGtCQUFrQixDQUFDLE9BQU8sRUFBRSxZQUFZLEdBQUcsT0FBTyxDQUFDLGVBQWUsR0FBRyxTQUFTLENBQUMsQ0FVOUU7SUFFRCxvQkFBb0IsSUFBSSxPQUFPLENBQUMsZUFBZSxFQUFFLENBQUMsQ0FNakQ7Q0FDRiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"address_store.d.ts","sourceRoot":"","sources":["../../../src/storage/address_store/address_store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAmB,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACzF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,qBAAa,YAAY;;IAKvB,YAAY,KAAK,EAAE,iBAAiB,EAKnC;IAED,kBAAkB,CAAC,eAAe,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,CA0BrE;
|
|
1
|
+
{"version":3,"file":"address_store.d.ts","sourceRoot":"","sources":["../../../src/storage/address_store/address_store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAmB,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACzF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,qBAAa,YAAY;;IAKvB,YAAY,KAAK,EAAE,iBAAiB,EAKnC;IAED,kBAAkB,CAAC,eAAe,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,CA0BrE;IAED,kBAAkB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC,CAU9E;IAED,oBAAoB,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC,CAMjD;CACF"}
|