@aztec/pxe 0.0.1-commit.1142ef1 → 0.0.1-commit.11bf3dd6e
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 +16 -6
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +91 -22
- package/dest/config/index.d.ts +4 -2
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +12 -2
- 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 +66 -36
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +230 -89
- 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_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 +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/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 +67 -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 +47 -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 +75 -42
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +327 -119
- 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 +59 -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 +125 -90
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +140 -73
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +347 -162
- 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 -17
- 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 +5 -2
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +4 -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 +7 -6
- package/dest/events/event_service.d.ts.map +1 -1
- package/dest/events/event_service.js +33 -24
- package/dest/events/private_event_filter_validator.d.ts +6 -5
- package/dest/events/private_event_filter_validator.d.ts.map +1 -1
- package/dest/events/private_event_filter_validator.js +20 -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 +11 -9
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +52 -64
- 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 +9 -9
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +45 -40
- 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 -9
- 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 +21 -16
- package/dest/private_kernel/private_kernel_oracle.d.ts +24 -25
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle.js +91 -2
- package/dest/pxe.d.ts +80 -59
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +163 -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 +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 +25 -10
- package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -1
- package/dest/storage/capsule_store/capsule_store.js +143 -28
- package/dest/storage/capsule_store/index.d.ts +2 -1
- package/dest/storage/capsule_store/index.d.ts.map +1 -1
- package/dest/storage/capsule_store/index.js +1 -0
- package/dest/storage/contract_store/contract_store.d.ts +42 -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 +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 +229 -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 +12 -26
- 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/bin/check_oracle_version.ts +5 -4
- package/src/block_synchronizer/block_synchronizer.ts +113 -35
- package/src/config/index.ts +9 -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 +392 -154
- package/src/contract_function_simulator/ephemeral_array_service.ts +110 -0
- 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 +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/noir-structs/utility_context.ts +6 -25
- package/src/contract_function_simulator/oracle/interfaces.ts +97 -59
- package/src/contract_function_simulator/oracle/legacy_oracle_mappings.ts +104 -0
- package/src/contract_function_simulator/oracle/note_packing_utils.ts +10 -10
- package/src/contract_function_simulator/oracle/oracle.ts +422 -166
- package/src/contract_function_simulator/oracle/private_execution.ts +5 -71
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +169 -185
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +578 -193
- 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 -18
- 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 +4 -1
- package/src/entrypoints/server/utils.ts +24 -29
- package/src/events/event_service.ts +31 -26
- package/src/events/private_event_filter_validator.ts +23 -5
- package/src/job_coordinator/job_coordinator.ts +4 -3
- package/src/logs/log_service.ts +94 -104
- package/src/messages/message_context_service.ts +44 -0
- package/src/notes/note_service.ts +54 -48
- package/src/notes_filter.ts +24 -0
- package/src/oracle_version.ts +20 -9
- 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 +25 -20
- package/src/private_kernel/private_kernel_oracle.ts +116 -37
- package/src/pxe.ts +297 -223
- 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 +183 -29
- 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 +323 -320
- package/src/storage/note_store/stored_note.ts +48 -0
- package/src/storage/private_event_store/private_event_store.ts +296 -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 +27 -29
- 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,9 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
47
49
|
recipientTaggingStore;
|
|
48
50
|
addressStore;
|
|
49
51
|
privateEventStore;
|
|
52
|
+
contractSyncService;
|
|
53
|
+
messageContextService;
|
|
54
|
+
l2TipsStore;
|
|
50
55
|
simulator;
|
|
51
56
|
proverEnabled;
|
|
52
57
|
proofCreator;
|
|
@@ -55,8 +60,9 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
55
60
|
jobQueue;
|
|
56
61
|
jobCoordinator;
|
|
57
62
|
debug;
|
|
58
|
-
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){
|
|
59
64
|
this.node = node;
|
|
65
|
+
this.db = db;
|
|
60
66
|
this.blockStateSynchronizer = blockStateSynchronizer;
|
|
61
67
|
this.keyStore = keyStore;
|
|
62
68
|
this.contractStore = contractStore;
|
|
@@ -68,6 +74,9 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
68
74
|
this.recipientTaggingStore = recipientTaggingStore;
|
|
69
75
|
this.addressStore = addressStore;
|
|
70
76
|
this.privateEventStore = privateEventStore;
|
|
77
|
+
this.contractSyncService = contractSyncService;
|
|
78
|
+
this.messageContextService = messageContextService;
|
|
79
|
+
this.l2TipsStore = l2TipsStore;
|
|
71
80
|
this.simulator = simulator;
|
|
72
81
|
this.proverEnabled = proverEnabled;
|
|
73
82
|
this.proofCreator = proofCreator;
|
|
@@ -83,13 +92,16 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
83
92
|
* can be contacted.
|
|
84
93
|
*
|
|
85
94
|
* @returns A promise that resolves PXE is ready to be used.
|
|
86
|
-
*/ 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;
|
|
87
98
|
const log = !loggerOrSuffix || typeof loggerOrSuffix === 'string' ? createLogger(loggerOrSuffix ? `pxe:service:${loggerOrSuffix}` : `pxe:service`) : loggerOrSuffix;
|
|
88
|
-
const
|
|
99
|
+
const info = await node.getNodeInfo();
|
|
100
|
+
const proverEnabled = config.proverEnabled !== undefined ? config.proverEnabled : info.realProofs;
|
|
89
101
|
const addressStore = new AddressStore(store);
|
|
90
102
|
const privateEventStore = new PrivateEventStore(store);
|
|
91
103
|
const contractStore = new ContractStore(store);
|
|
92
|
-
const noteStore =
|
|
104
|
+
const noteStore = new NoteStore(store);
|
|
93
105
|
const anchorBlockStore = new AnchorBlockStore(store);
|
|
94
106
|
const senderTaggingStore = new SenderTaggingStore(store);
|
|
95
107
|
const senderAddressBookStore = new SenderAddressBookStore(store);
|
|
@@ -97,22 +109,46 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
97
109
|
const capsuleStore = new CapsuleStore(store);
|
|
98
110
|
const keyStore = new KeyStore(store);
|
|
99
111
|
const tipsStore = new L2TipsKVStore(store, 'pxe');
|
|
100
|
-
const
|
|
101
|
-
const
|
|
102
|
-
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);
|
|
116
|
+
jobCoordinator.registerStores([
|
|
117
|
+
capsuleStore,
|
|
118
|
+
senderTaggingStore,
|
|
119
|
+
recipientTaggingStore,
|
|
120
|
+
privateEventStore,
|
|
121
|
+
noteStore,
|
|
122
|
+
contractSyncService
|
|
123
|
+
]);
|
|
124
|
+
const debugUtils = new PXEDebugUtils(contractSyncService, noteStore, synchronizer, anchorBlockStore);
|
|
103
125
|
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.
|
|
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));
|
|
106
128
|
pxe.jobQueue.start();
|
|
107
129
|
await pxe.#registerProtocolContracts();
|
|
108
|
-
const info = await node.getNodeInfo();
|
|
109
130
|
log.info(`Started PXE connected to chain ${info.l1ChainId} version ${info.rollupVersion}`);
|
|
110
131
|
return pxe;
|
|
111
132
|
}
|
|
112
133
|
// Internal methods
|
|
113
134
|
#getSimulatorForTx(overrides) {
|
|
114
135
|
const proxyContractStore = ProxiedContractStoreFactory.create(this.contractStore, overrides?.contracts);
|
|
115
|
-
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
|
+
});
|
|
116
152
|
}
|
|
117
153
|
#contextualizeError(err, ...context) {
|
|
118
154
|
let contextStr = '';
|
|
@@ -155,32 +191,27 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
155
191
|
async #registerProtocolContracts() {
|
|
156
192
|
const registered = {};
|
|
157
193
|
for (const name of protocolContractNames){
|
|
158
|
-
const { address,
|
|
159
|
-
await this.contractStore.addContractArtifact(
|
|
194
|
+
const { address, instance, artifact } = await this.protocolContractsProvider.getProtocolContractArtifact(name);
|
|
195
|
+
await this.contractStore.addContractArtifact(artifact);
|
|
160
196
|
await this.contractStore.addContractInstance(instance);
|
|
161
197
|
registered[name] = address.toString();
|
|
162
198
|
}
|
|
163
199
|
this.log.verbose(`Registered protocol contracts in pxe`, registered);
|
|
164
200
|
}
|
|
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
201
|
// Executes the entrypoint private function, as well as all nested private
|
|
176
202
|
// functions that might arise.
|
|
177
203
|
async #executePrivate(contractFunctionSimulator, txRequest, scopes, jobId) {
|
|
178
204
|
const { origin: contractAddress, functionSelector } = txRequest;
|
|
179
205
|
try {
|
|
180
206
|
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
207
|
+
await this.contractSyncService.ensureContractSynced(contractAddress, functionSelector, (privateSyncCall, execScopes)=>this.#executeUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId), anchorBlockHeader, jobId, scopes);
|
|
208
|
+
const result = await contractFunctionSimulator.run(txRequest, {
|
|
209
|
+
contractAddress,
|
|
210
|
+
selector: functionSelector,
|
|
211
|
+
anchorBlockHeader,
|
|
212
|
+
scopes,
|
|
213
|
+
jobId
|
|
214
|
+
});
|
|
184
215
|
this.log.debug(`Private simulation completed for ${contractAddress.toString()}:${functionSelector}`);
|
|
185
216
|
return result;
|
|
186
217
|
} catch (err) {
|
|
@@ -191,18 +222,22 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
191
222
|
}
|
|
192
223
|
}
|
|
193
224
|
/**
|
|
194
|
-
*
|
|
225
|
+
* Execute a utility function call on the given contract.
|
|
195
226
|
* @param contractFunctionSimulator - The simulator to use for the function call.
|
|
196
227
|
* @param call - The function call to execute.
|
|
197
228
|
* @param authWitnesses - Authentication witnesses required for the function call.
|
|
198
229
|
* @param scopes - Optional array of account addresses whose notes can be accessed in this call. Defaults to all
|
|
199
230
|
* accounts if not specified.
|
|
200
231
|
* @param jobId - The job ID for staged writes.
|
|
201
|
-
* @returns The
|
|
202
|
-
*/ async #
|
|
232
|
+
* @returns The execution result containing the outputs of the utility function.
|
|
233
|
+
*/ async #executeUtility(contractFunctionSimulator, call, authWitnesses, scopes, jobId) {
|
|
203
234
|
try {
|
|
204
235
|
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
205
|
-
|
|
236
|
+
const { result, offchainEffects } = await contractFunctionSimulator.runUtility(call, authWitnesses ?? [], anchorBlockHeader, scopes, jobId);
|
|
237
|
+
return {
|
|
238
|
+
result,
|
|
239
|
+
offchainEffects
|
|
240
|
+
};
|
|
206
241
|
} catch (err) {
|
|
207
242
|
if (err instanceof SimulationError) {
|
|
208
243
|
await enrichSimulationError(err, this.contractStore, this.log);
|
|
@@ -246,62 +281,34 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
246
281
|
* @param config - The configuration for the kernel execution prover.
|
|
247
282
|
* @returns An object that contains the output of the kernel execution, including the ChonkProof if proving is enabled.
|
|
248
283
|
*/ async #prove(txExecutionRequest, proofCreator, privateExecutionResult, config) {
|
|
249
|
-
const
|
|
250
|
-
const kernelOracle = new
|
|
251
|
-
const kernelTraceProver = new PrivateKernelExecutionProver(kernelOracle, proofCreator, !this.proverEnabled);
|
|
284
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
285
|
+
const kernelOracle = new PrivateKernelOracle(this.contractStore, this.keyStore, this.node, anchorBlockHeader);
|
|
286
|
+
const kernelTraceProver = new PrivateKernelExecutionProver(kernelOracle, proofCreator, !this.proverEnabled, this.log.getBindings());
|
|
252
287
|
this.log.debug(`Executing kernel trace prover (${JSON.stringify(config)})...`);
|
|
253
288
|
return await kernelTraceProver.proveWithKernels(txExecutionRequest.toTxRequest(), privateExecutionResult, config);
|
|
254
289
|
}
|
|
255
290
|
// Public API
|
|
256
|
-
|
|
257
|
-
|
|
291
|
+
/**
|
|
292
|
+
* Returns the block header up to which the PXE has synced.
|
|
293
|
+
* @returns The synced block header
|
|
294
|
+
*/ getSyncedBlockHeader() {
|
|
295
|
+
return this.#putInJobQueue(()=>{
|
|
296
|
+
return this.anchorBlockStore.getBlockHeader();
|
|
297
|
+
});
|
|
258
298
|
}
|
|
259
299
|
/**
|
|
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
|
-
};
|
|
300
|
+
* Returns the contract instance for a given address, if it's registered in the PXE.
|
|
301
|
+
* @param address - The contract address.
|
|
302
|
+
* @returns The contract instance if found, undefined otherwise.
|
|
303
|
+
*/ getContractInstance(address) {
|
|
304
|
+
return this.contractStore.getContractInstance(address);
|
|
282
305
|
}
|
|
283
306
|
/**
|
|
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
|
-
};
|
|
307
|
+
* Returns the contract artifact for a given contract class id, if it's registered in the PXE.
|
|
308
|
+
* @param id - Identifier of the contract class.
|
|
309
|
+
* @returns The contract artifact if found, undefined otherwise.
|
|
310
|
+
*/ async getContractArtifact(id) {
|
|
311
|
+
return await this.contractStore.getContractArtifact(id);
|
|
305
312
|
}
|
|
306
313
|
/**
|
|
307
314
|
* Registers a user account in PXE given its master encryption private key.
|
|
@@ -323,7 +330,6 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
323
330
|
this.log.debug(`Registered account\n ${accountCompleteAddress.toReadableString()}`);
|
|
324
331
|
}
|
|
325
332
|
await this.addressStore.addCompleteAddress(accountCompleteAddress);
|
|
326
|
-
await this.noteStore.addScope(accountCompleteAddress.address);
|
|
327
333
|
return accountCompleteAddress;
|
|
328
334
|
}
|
|
329
335
|
/**
|
|
@@ -336,6 +342,9 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
336
342
|
* @returns The address of the sender.
|
|
337
343
|
* TODO: It's strange that we return the address here and I (benesjan) think we should drop the return value.
|
|
338
344
|
*/ async registerSender(sender) {
|
|
345
|
+
if (!await sender.isValid()) {
|
|
346
|
+
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.`);
|
|
347
|
+
}
|
|
339
348
|
const accounts = await this.keyStore.getAccounts();
|
|
340
349
|
if (accounts.includes(sender)) {
|
|
341
350
|
this.log.info(`Sender:\n "${sender.toString()}"\n already registered.`);
|
|
@@ -344,6 +353,9 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
344
353
|
const wasAdded = await this.senderAddressBookStore.addSender(sender);
|
|
345
354
|
if (wasAdded) {
|
|
346
355
|
this.log.info(`Added sender:\n ${sender.toString()}`);
|
|
356
|
+
// Wipe the entire sync cache: the new sender's tagged logs could contain notes/events for any contract, so
|
|
357
|
+
// all contracts must re-sync to discover them. Queued to avoid wiping while a job is in flight.
|
|
358
|
+
await this.#putInJobQueue(()=>Promise.resolve(this.contractSyncService.wipe()));
|
|
347
359
|
} else {
|
|
348
360
|
this.log.info(`Sender:\n "${sender.toString()}"\n already registered.`);
|
|
349
361
|
}
|
|
@@ -381,8 +393,7 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
381
393
|
*
|
|
382
394
|
* @param artifact - The build artifact for the contract class.
|
|
383
395
|
*/ async registerContractClass(artifact) {
|
|
384
|
-
const
|
|
385
|
-
await this.contractStore.addContractArtifact(contractClassId, artifact);
|
|
396
|
+
const contractClassId = await this.contractStore.addContractArtifact(artifact);
|
|
386
397
|
this.log.info(`Added contract class ${artifact.name} with id ${contractClassId}`);
|
|
387
398
|
}
|
|
388
399
|
/**
|
|
@@ -398,15 +409,14 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
398
409
|
if (artifact) {
|
|
399
410
|
// If the user provides an artifact, validate it against the expected class id and register it
|
|
400
411
|
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})`);
|
|
412
|
+
if (!contractClass.id.equals(instance.currentContractClassId)) {
|
|
413
|
+
throw new Error(`Artifact does not match expected class id (computed ${contractClass.id} but instance refers to ${instance.currentContractClassId})`);
|
|
404
414
|
}
|
|
405
415
|
const computedAddress = await computeContractAddressFromInstance(instance);
|
|
406
416
|
if (!computedAddress.equals(instance.address)) {
|
|
407
417
|
throw new Error('Added a contract in which the address does not match the contract instance.');
|
|
408
418
|
}
|
|
409
|
-
await this.contractStore.addContractArtifact(
|
|
419
|
+
await this.contractStore.addContractArtifact(artifact, contractClass);
|
|
410
420
|
const publicFunctionSignatures = artifact.functions.filter((fn)=>fn.functionType === FunctionType.PUBLIC).map((fn)=>decodeFunctionSignature(fn.name, fn.parameters));
|
|
411
421
|
await this.node.registerContractFunctionSignatures(publicFunctionSignatures);
|
|
412
422
|
} else {
|
|
@@ -438,15 +448,17 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
438
448
|
const contractClass = await getContractClassFromArtifact(artifact);
|
|
439
449
|
await this.blockStateSynchronizer.sync();
|
|
440
450
|
const header = await this.anchorBlockStore.getBlockHeader();
|
|
441
|
-
const currentClassId = await readCurrentClassId(contractAddress, currentInstance, this.node, header
|
|
451
|
+
const currentClassId = await readCurrentClassId(contractAddress, currentInstance, this.node, header);
|
|
442
452
|
if (!contractClass.id.equals(currentClassId)) {
|
|
443
453
|
throw new Error('Could not update contract to a class different from the current one.');
|
|
444
454
|
}
|
|
445
|
-
await this.contractStore.addContractArtifact(contractClass.id, artifact);
|
|
446
455
|
const publicFunctionSignatures = artifact.functions.filter((fn)=>fn.functionType === FunctionType.PUBLIC).map((fn)=>decodeFunctionSignature(fn.name, fn.parameters));
|
|
447
456
|
await this.node.registerContractFunctionSignatures(publicFunctionSignatures);
|
|
448
457
|
currentInstance.currentContractClassId = contractClass.id;
|
|
449
|
-
await
|
|
458
|
+
await Promise.all([
|
|
459
|
+
this.contractStore.addContractArtifact(artifact, contractClass),
|
|
460
|
+
this.contractStore.addContractInstance(currentInstance)
|
|
461
|
+
]);
|
|
450
462
|
this.log.info(`Updated contract ${artifact.name} at ${contractAddress.toString()} to class ${contractClass.id}`);
|
|
451
463
|
});
|
|
452
464
|
}
|
|
@@ -461,10 +473,11 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
461
473
|
* (where validators prove the public portion).
|
|
462
474
|
*
|
|
463
475
|
* @param txRequest - An authenticated tx request ready for proving
|
|
476
|
+
* @param scopes - Addresses whose private state and keys are accessible during private execution.
|
|
464
477
|
* @returns A result containing the proof and public inputs of the tail circuit.
|
|
465
478
|
* @throws If contract code not found, or public simulation reverts.
|
|
466
479
|
* Also throws if simulatePublic is true and public simulation reverts.
|
|
467
|
-
*/ proveTx(txRequest) {
|
|
480
|
+
*/ proveTx(txRequest, scopes) {
|
|
468
481
|
let privateExecutionResult;
|
|
469
482
|
// We disable proving concurrently mostly out of caution, since it accesses some of our stores. Proving is so
|
|
470
483
|
// computationally demanding that it'd be rare for someone to try to do it concurrently regardless.
|
|
@@ -475,7 +488,7 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
475
488
|
await this.blockStateSynchronizer.sync();
|
|
476
489
|
const syncTime = syncTimer.ms();
|
|
477
490
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
478
|
-
privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest,
|
|
491
|
+
privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest, scopes, jobId);
|
|
479
492
|
const { publicInputs, chonkProof, executionSteps, timings: { proving } = {} } = await this.#prove(txRequest, this.proofCreator, privateExecutionResult, {
|
|
480
493
|
simulate: false,
|
|
481
494
|
skipFeeEnforcement: false,
|
|
@@ -506,16 +519,16 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
506
519
|
// transaction before this one is included in a block from this PXE, and that transaction contains a log with
|
|
507
520
|
// a tag derived from the same secret, we would reuse the tag and the transactions would be linked. Hence
|
|
508
521
|
// storing the tags here prevents linkage of txs sent from the same PXE.
|
|
509
|
-
const
|
|
510
|
-
if (
|
|
522
|
+
const taggingIndexRangesUsedInTheTx = privateExecutionResult.entrypoint.taggingIndexRanges;
|
|
523
|
+
if (taggingIndexRangesUsedInTheTx.length > 0) {
|
|
511
524
|
// TODO(benesjan): The following is an expensive operation. Figure out a way to avoid it.
|
|
512
525
|
const txHash = (await txProvingResult.toTx()).txHash;
|
|
513
|
-
await this.senderTaggingStore.storePendingIndexes(
|
|
514
|
-
this.log.debug(`Stored used
|
|
515
|
-
|
|
526
|
+
await this.senderTaggingStore.storePendingIndexes(taggingIndexRangesUsedInTheTx, txHash, jobId);
|
|
527
|
+
this.log.debug(`Stored used tagging index ranges as sender for the tx`, {
|
|
528
|
+
taggingIndexRangesUsedInTheTx
|
|
516
529
|
});
|
|
517
530
|
} else {
|
|
518
|
-
this.log.debug(`No
|
|
531
|
+
this.log.debug(`No tagging index ranges used in the tx`);
|
|
519
532
|
}
|
|
520
533
|
return txProvingResult;
|
|
521
534
|
} catch (err) {
|
|
@@ -525,13 +538,10 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
525
538
|
}
|
|
526
539
|
/**
|
|
527
540
|
* 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.
|
|
541
|
+
* @param txRequest - An authenticated tx request ready for simulation.
|
|
532
542
|
* @returns A trace of the program execution with gate counts.
|
|
533
543
|
* @throws If the code for the functions executed in this transaction have not been made available via `addContracts`.
|
|
534
|
-
*/ profileTx(txRequest, profileMode, skipProofGeneration = true) {
|
|
544
|
+
*/ profileTx(txRequest, { profileMode, skipProofGeneration = true, scopes }) {
|
|
535
545
|
// We disable concurrent profiles for consistency with simulateTx.
|
|
536
546
|
return this.#putInJobQueue(async (jobId)=>{
|
|
537
547
|
const totalTimer = new Timer();
|
|
@@ -549,7 +559,7 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
549
559
|
await this.blockStateSynchronizer.sync();
|
|
550
560
|
const syncTime = syncTimer.ms();
|
|
551
561
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
552
|
-
const privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest,
|
|
562
|
+
const privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest, scopes, jobId);
|
|
553
563
|
const { executionSteps, timings: { proving } = {} } = await this.#prove(txRequest, this.proofCreator, privateExecutionResult, {
|
|
554
564
|
simulate: skipProofGeneration,
|
|
555
565
|
skipFeeEnforcement: false,
|
|
@@ -594,18 +604,13 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
594
604
|
* In that case, the transaction returned is only potentially ready to be sent to the network for execution.
|
|
595
605
|
*
|
|
596
606
|
*
|
|
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.
|
|
607
|
+
* @param txRequest - An authenticated tx request ready for simulation.
|
|
603
608
|
* @returns A simulated transaction result object that includes public and private return values.
|
|
604
609
|
* @throws If the code for the functions executed in this transaction have not been made available via `addContracts`.
|
|
605
610
|
* Also throws if simulatePublic is true and public simulation reverts.
|
|
606
611
|
*
|
|
607
612
|
* TODO(#7456) Prevent msgSender being defined here for the first call
|
|
608
|
-
*/ simulateTx(txRequest, simulatePublic, skipTxValidation = false, skipFeeEnforcement = false, overrides, scopes) {
|
|
613
|
+
*/ simulateTx(txRequest, { simulatePublic, skipTxValidation = false, skipFeeEnforcement = false, skipKernels = true, overrides, scopes }) {
|
|
609
614
|
// We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
|
|
610
615
|
// to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
|
|
611
616
|
// delete the same read value, or reading values that another simulation is currently modifying).
|
|
@@ -624,20 +629,23 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
624
629
|
const syncTimer = new Timer();
|
|
625
630
|
await this.blockStateSynchronizer.sync();
|
|
626
631
|
const syncTime = syncTimer.ms();
|
|
632
|
+
const overriddenContracts = overrides?.contracts ? new Set(Object.keys(overrides.contracts)) : undefined;
|
|
633
|
+
const hasOverriddenContracts = overriddenContracts !== undefined && overriddenContracts.size > 0;
|
|
634
|
+
if (hasOverriddenContracts && !skipKernels) {
|
|
635
|
+
throw new Error('Simulating with overridden contracts is not compatible with kernel execution. Please set skipKernels to true when simulating with overridden contracts.');
|
|
636
|
+
}
|
|
627
637
|
const contractFunctionSimulator = this.#getSimulatorForTx(overrides);
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
638
|
+
if (hasOverriddenContracts) {
|
|
639
|
+
// Overridden contracts don't have a sync function, so calling sync on them would fail.
|
|
640
|
+
// We exclude them so the sync service skips them entirely.
|
|
641
|
+
this.contractSyncService.setExcludedFromSync(jobId, overriddenContracts);
|
|
642
|
+
}
|
|
632
643
|
// Execution of private functions only; no proving, and no kernel logic.
|
|
633
644
|
const privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest, scopes, jobId);
|
|
634
645
|
let publicInputs;
|
|
635
646
|
let executionSteps = [];
|
|
636
647
|
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));
|
|
648
|
+
({ publicInputs, executionSteps } = await generateSimulatedProvingResult(privateExecutionResult, (addr, sel)=>this.contractStore.getDebugFunctionName(addr, sel), this.node));
|
|
641
649
|
} else {
|
|
642
650
|
// Kernel logic, plus proving of all private functions and kernels.
|
|
643
651
|
({ publicInputs, executionSteps } = await this.#prove(txRequest, this.proofCreator, privateExecutionResult, {
|
|
@@ -654,6 +662,9 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
654
662
|
const publicSimulationTimer = new Timer();
|
|
655
663
|
publicOutput = await this.#simulatePublicCalls(simulatedTx, skipFeeEnforcement);
|
|
656
664
|
publicSimulationTime = publicSimulationTimer.ms();
|
|
665
|
+
if (publicOutput?.debugLogs?.length) {
|
|
666
|
+
await displayDebugLogs(publicOutput.debugLogs, (addr)=>this.contractStore.getDebugContractName(addr));
|
|
667
|
+
}
|
|
657
668
|
}
|
|
658
669
|
let validationTime;
|
|
659
670
|
if (!skipTxValidation) {
|
|
@@ -664,7 +675,8 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
664
675
|
});
|
|
665
676
|
validationTime = validationTimer.ms();
|
|
666
677
|
if (validationResult.result === 'invalid') {
|
|
667
|
-
|
|
678
|
+
const reason = validationResult.reason.length > 0 ? ` Reason: ${validationResult.reason.join(', ')}` : '';
|
|
679
|
+
throw new Error(`The simulated transaction is unable to be added to state and is invalid.${reason}`);
|
|
668
680
|
}
|
|
669
681
|
}
|
|
670
682
|
const txHash = simulatedTx.getTxHash();
|
|
@@ -697,22 +709,19 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
697
709
|
nodeRPCCalls: simulatorStats.nodeRPCCalls
|
|
698
710
|
});
|
|
699
711
|
} catch (err) {
|
|
700
|
-
throw this.#contextualizeError(err, inspect(txRequest), `simulatePublic=${simulatePublic}`, `skipTxValidation=${skipTxValidation}`, `scopes=${scopes
|
|
712
|
+
throw this.#contextualizeError(err, inspect(txRequest), `simulatePublic=${simulatePublic}`, `skipTxValidation=${skipTxValidation}`, `scopes=${scopes.map((s)=>s.toString()).join(', ')}`);
|
|
701
713
|
}
|
|
702
714
|
});
|
|
703
715
|
}
|
|
704
716
|
/**
|
|
705
|
-
*
|
|
706
|
-
*
|
|
717
|
+
* Executes a contract utility function.
|
|
707
718
|
* @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.
|
|
719
|
+
*/ executeUtility(call, { authwits, scopes } = {
|
|
720
|
+
scopes: []
|
|
721
|
+
}) {
|
|
722
|
+
// We disable concurrent executions since those might execute oracles which read and write to the PXE stores (e.g.
|
|
714
723
|
// 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
|
|
724
|
+
// delete the same read value, or reading values that another execution is currently modifying).
|
|
716
725
|
return this.#putInJobQueue(async (jobId)=>{
|
|
717
726
|
try {
|
|
718
727
|
const totalTimer = new Timer();
|
|
@@ -721,8 +730,9 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
721
730
|
const syncTime = syncTimer.ms();
|
|
722
731
|
const functionTimer = new Timer();
|
|
723
732
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
724
|
-
await this.
|
|
725
|
-
|
|
733
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
734
|
+
await this.contractSyncService.ensureContractSynced(call.to, call.selector, (privateSyncCall, execScopes)=>this.#executeUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId), anchorBlockHeader, jobId, scopes);
|
|
735
|
+
const { result: executionResult, offchainEffects } = await this.#executeUtility(contractFunctionSimulator, call, authwits ?? [], scopes, jobId);
|
|
726
736
|
const functionTime = functionTimer.ms();
|
|
727
737
|
const totalTime = totalTimer.ms();
|
|
728
738
|
const perFunction = [
|
|
@@ -740,6 +750,8 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
740
750
|
const simulationStats = contractFunctionSimulator.getStats();
|
|
741
751
|
return {
|
|
742
752
|
result: executionResult,
|
|
753
|
+
offchainEffects,
|
|
754
|
+
anchorBlockTimestamp: anchorBlockHeader.globalVariables.timestamp,
|
|
743
755
|
stats: {
|
|
744
756
|
timings,
|
|
745
757
|
nodeRPCCalls: simulationStats.nodeRPCCalls
|
|
@@ -748,7 +760,7 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
748
760
|
} catch (err) {
|
|
749
761
|
const { to, name, args } = call;
|
|
750
762
|
const stringifiedArgs = args.map((arg)=>arg.toString()).join(', ');
|
|
751
|
-
throw this.#contextualizeError(err, `
|
|
763
|
+
throw this.#contextualizeError(err, `executeUtility ${to}:${name}(${stringifiedArgs})`, `scopes=${scopes.map((s)=>s.toString()).join(', ')}`);
|
|
752
764
|
}
|
|
753
765
|
});
|
|
754
766
|
}
|
|
@@ -764,19 +776,25 @@ import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store
|
|
|
764
776
|
* toBlock - The block number to search up to (exclusive). Optional. If provided, it must be > 0.
|
|
765
777
|
* Defaults to the latest known block to PXE + 1.
|
|
766
778
|
* @returns - The packed events with block and tx metadata.
|
|
767
|
-
*/ getPrivateEvents(eventSelector, filter) {
|
|
768
|
-
|
|
779
|
+
*/ async getPrivateEvents(eventSelector, filter) {
|
|
780
|
+
let anchorBlockNumber;
|
|
781
|
+
await this.#putInJobQueue(async (jobId)=>{
|
|
769
782
|
await this.blockStateSynchronizer.sync();
|
|
783
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
784
|
+
anchorBlockNumber = anchorBlockHeader.getBlockNumber();
|
|
770
785
|
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);
|
|
786
|
+
await this.contractSyncService.ensureContractSynced(filter.contractAddress, null, async (privateSyncCall, execScopes)=>await this.#executeUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId), anchorBlockHeader, jobId, filter.scopes);
|
|
775
787
|
});
|
|
788
|
+
// anchorBlockNumber is set during the job and fixed to whatever it is after a block sync
|
|
789
|
+
const sanitizedFilter = new PrivateEventFilterValidator(anchorBlockNumber).validate(filter);
|
|
790
|
+
this.log.debug(`Getting private events for ${sanitizedFilter.contractAddress.toString()} from ${sanitizedFilter.fromBlock} to ${sanitizedFilter.toBlock}`);
|
|
791
|
+
return this.privateEventStore.getPrivateEvents(eventSelector, sanitizedFilter);
|
|
776
792
|
}
|
|
777
793
|
/**
|
|
778
|
-
* Stops the PXE's job queue.
|
|
779
|
-
*/ stop() {
|
|
780
|
-
|
|
794
|
+
* Stops the PXE's job queue and closes the backing store.
|
|
795
|
+
*/ async stop() {
|
|
796
|
+
await this.jobQueue.end();
|
|
797
|
+
await this.blockStateSynchronizer.stop();
|
|
798
|
+
await this.db.close();
|
|
781
799
|
}
|
|
782
800
|
}
|
|
@@ -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"}
|