@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
|
@@ -1,44 +1,74 @@
|
|
|
1
|
+
import type { ARCHIVE_HEIGHT, NOTE_HASH_TREE_HEIGHT } from '@aztec/constants';
|
|
1
2
|
import type { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
3
|
import { Aes128 } from '@aztec/foundation/crypto/aes128';
|
|
3
4
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
5
|
import { Point } from '@aztec/foundation/curves/grumpkin';
|
|
5
|
-
import { LogLevels,
|
|
6
|
+
import { LogLevels, type Logger, createLogger } from '@aztec/foundation/log';
|
|
7
|
+
import type { MembershipWitness } from '@aztec/foundation/trees';
|
|
6
8
|
import type { KeyStore } from '@aztec/key-store';
|
|
9
|
+
import { isProtocolContract } from '@aztec/protocol-contracts';
|
|
7
10
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
8
11
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
9
|
-
import
|
|
12
|
+
import { BlockHash } from '@aztec/stdlib/block';
|
|
13
|
+
import type { CompleteAddress, ContractInstance, PartialAddress } from '@aztec/stdlib/contract';
|
|
10
14
|
import { siloNullifier } from '@aztec/stdlib/hash';
|
|
11
15
|
import type { AztecNode } from '@aztec/stdlib/interfaces/server';
|
|
12
16
|
import type { KeyValidationRequest } from '@aztec/stdlib/kernel';
|
|
13
|
-
import { computeAddressSecret } from '@aztec/stdlib/keys';
|
|
17
|
+
import { type PublicKeys, computeAddressSecret } from '@aztec/stdlib/keys';
|
|
14
18
|
import { deriveEcdhSharedSecret } from '@aztec/stdlib/logs';
|
|
19
|
+
import { getNonNullifiedL1ToL2MessageWitness } from '@aztec/stdlib/messaging';
|
|
15
20
|
import type { NoteStatus } from '@aztec/stdlib/note';
|
|
16
21
|
import { MerkleTreeId, type NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
|
|
17
|
-
import type { BlockHeader, Capsule } from '@aztec/stdlib/tx';
|
|
22
|
+
import type { BlockHeader, Capsule, OffchainEffect } from '@aztec/stdlib/tx';
|
|
18
23
|
|
|
24
|
+
import type { AccessScopes } from '../../access_scopes.js';
|
|
25
|
+
import { createContractLogger, logContractMessage } from '../../contract_logging.js';
|
|
26
|
+
import type { ContractSyncService } from '../../contract_sync/contract_sync_service.js';
|
|
19
27
|
import { EventService } from '../../events/event_service.js';
|
|
20
28
|
import { LogService } from '../../logs/log_service.js';
|
|
29
|
+
import { MessageContextService } from '../../messages/message_context_service.js';
|
|
21
30
|
import { NoteService } from '../../notes/note_service.js';
|
|
22
31
|
import { ORACLE_VERSION } from '../../oracle_version.js';
|
|
23
|
-
import { PublicStorageService } from '../../public_storage/public_storage_service.js';
|
|
24
32
|
import type { AddressStore } from '../../storage/address_store/address_store.js';
|
|
25
|
-
import type { AnchorBlockStore } from '../../storage/anchor_block_store/anchor_block_store.js';
|
|
26
33
|
import type { CapsuleStore } from '../../storage/capsule_store/capsule_store.js';
|
|
27
34
|
import type { ContractStore } from '../../storage/contract_store/contract_store.js';
|
|
28
35
|
import type { NoteStore } from '../../storage/note_store/note_store.js';
|
|
29
36
|
import type { PrivateEventStore } from '../../storage/private_event_store/private_event_store.js';
|
|
30
37
|
import type { RecipientTaggingStore } from '../../storage/tagging_store/recipient_tagging_store.js';
|
|
31
38
|
import type { SenderAddressBookStore } from '../../storage/tagging_store/sender_address_book_store.js';
|
|
32
|
-
import { TreeMembershipService } from '../../tree_membership/tree_membership_service.js';
|
|
33
39
|
import { EventValidationRequest } from '../noir-structs/event_validation_request.js';
|
|
34
40
|
import { LogRetrievalRequest } from '../noir-structs/log_retrieval_request.js';
|
|
35
41
|
import { LogRetrievalResponse } from '../noir-structs/log_retrieval_response.js';
|
|
42
|
+
import { MessageTxContext } from '../noir-structs/message_tx_context.js';
|
|
36
43
|
import { NoteValidationRequest } from '../noir-structs/note_validation_request.js';
|
|
37
44
|
import { UtilityContext } from '../noir-structs/utility_context.js';
|
|
38
45
|
import { pickNotes } from '../pick_notes.js';
|
|
39
46
|
import type { IMiscOracle, IUtilityExecutionOracle, NoteData } from './interfaces.js';
|
|
40
47
|
import { MessageLoadOracleInputs } from './message_load_oracle_inputs.js';
|
|
41
48
|
|
|
49
|
+
/** Args for UtilityExecutionOracle constructor. */
|
|
50
|
+
export type UtilityExecutionOracleArgs = {
|
|
51
|
+
contractAddress: AztecAddress;
|
|
52
|
+
/** List of transient auth witnesses to be used during this simulation */
|
|
53
|
+
authWitnesses: AuthWitness[];
|
|
54
|
+
capsules: Capsule[]; // TODO(#12425): Rename to transientCapsules
|
|
55
|
+
anchorBlockHeader: BlockHeader;
|
|
56
|
+
contractStore: ContractStore;
|
|
57
|
+
noteStore: NoteStore;
|
|
58
|
+
keyStore: KeyStore;
|
|
59
|
+
addressStore: AddressStore;
|
|
60
|
+
aztecNode: AztecNode;
|
|
61
|
+
recipientTaggingStore: RecipientTaggingStore;
|
|
62
|
+
senderAddressBookStore: SenderAddressBookStore;
|
|
63
|
+
capsuleStore: CapsuleStore;
|
|
64
|
+
privateEventStore: PrivateEventStore;
|
|
65
|
+
messageContextService: MessageContextService;
|
|
66
|
+
contractSyncService: ContractSyncService;
|
|
67
|
+
jobId: string;
|
|
68
|
+
log?: ReturnType<typeof createLogger>;
|
|
69
|
+
scopes: AccessScopes;
|
|
70
|
+
};
|
|
71
|
+
|
|
42
72
|
/**
|
|
43
73
|
* The oracle for an execution of utility contract functions.
|
|
44
74
|
*/
|
|
@@ -46,47 +76,76 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
|
|
|
46
76
|
isMisc = true as const;
|
|
47
77
|
isUtility = true as const;
|
|
48
78
|
|
|
49
|
-
private
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
79
|
+
private contractLogger: Logger | undefined;
|
|
80
|
+
private offchainEffects: OffchainEffect[] = [];
|
|
81
|
+
|
|
82
|
+
protected readonly contractAddress: AztecAddress;
|
|
83
|
+
protected readonly authWitnesses: AuthWitness[];
|
|
84
|
+
protected readonly capsules: Capsule[];
|
|
85
|
+
protected readonly anchorBlockHeader: BlockHeader;
|
|
86
|
+
protected readonly contractStore: ContractStore;
|
|
87
|
+
protected readonly noteStore: NoteStore;
|
|
88
|
+
protected readonly keyStore: KeyStore;
|
|
89
|
+
protected readonly addressStore: AddressStore;
|
|
90
|
+
protected readonly aztecNode: AztecNode;
|
|
91
|
+
protected readonly recipientTaggingStore: RecipientTaggingStore;
|
|
92
|
+
protected readonly senderAddressBookStore: SenderAddressBookStore;
|
|
93
|
+
protected readonly capsuleStore: CapsuleStore;
|
|
94
|
+
protected readonly privateEventStore: PrivateEventStore;
|
|
95
|
+
protected readonly messageContextService: MessageContextService;
|
|
96
|
+
protected readonly contractSyncService: ContractSyncService;
|
|
97
|
+
protected readonly jobId: string;
|
|
98
|
+
protected logger: ReturnType<typeof createLogger>;
|
|
99
|
+
protected readonly scopes: AccessScopes;
|
|
100
|
+
|
|
101
|
+
constructor(args: UtilityExecutionOracleArgs) {
|
|
102
|
+
this.contractAddress = args.contractAddress;
|
|
103
|
+
this.authWitnesses = args.authWitnesses;
|
|
104
|
+
this.capsules = args.capsules;
|
|
105
|
+
this.anchorBlockHeader = args.anchorBlockHeader;
|
|
106
|
+
this.contractStore = args.contractStore;
|
|
107
|
+
this.noteStore = args.noteStore;
|
|
108
|
+
this.keyStore = args.keyStore;
|
|
109
|
+
this.addressStore = args.addressStore;
|
|
110
|
+
this.aztecNode = args.aztecNode;
|
|
111
|
+
this.recipientTaggingStore = args.recipientTaggingStore;
|
|
112
|
+
this.senderAddressBookStore = args.senderAddressBookStore;
|
|
113
|
+
this.capsuleStore = args.capsuleStore;
|
|
114
|
+
this.privateEventStore = args.privateEventStore;
|
|
115
|
+
this.messageContextService = args.messageContextService;
|
|
116
|
+
this.contractSyncService = args.contractSyncService;
|
|
117
|
+
this.jobId = args.jobId;
|
|
118
|
+
this.logger = args.log ?? createLogger('simulator:client_view_context');
|
|
119
|
+
this.scopes = args.scopes;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
public assertCompatibleOracleVersion(version: number): void {
|
|
123
|
+
// TODO(F-416): Remove this hack on v5 when protocol contracts are redeployed.
|
|
124
|
+
// Protocol contracts/canonical contracts shipped with committed bytecode that cannot be changed. Assert they use
|
|
125
|
+
// the expected pinned version or the current one. We want to allow for both the pinned and the current versions
|
|
126
|
+
// because we want this code to work with both the pinned and unpinned version since some branches do not have the
|
|
127
|
+
// pinned contracts (like e.g. next)
|
|
128
|
+
const LEGACY_ORACLE_VERSION = 12;
|
|
129
|
+
if (isProtocolContract(this.contractAddress)) {
|
|
130
|
+
if (version !== LEGACY_ORACLE_VERSION && version !== ORACLE_VERSION) {
|
|
131
|
+
throw new Error(
|
|
132
|
+
`Expected legacy oracle version ${LEGACY_ORACLE_VERSION} or current oracle version ${ORACLE_VERSION} for alpha payload contract at ${this.contractAddress}, got ${version}.`,
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
|
|
73
138
|
if (version !== ORACLE_VERSION) {
|
|
74
139
|
throw new Error(`Incompatible oracle version. Expected version ${ORACLE_VERSION}, got ${version}.`);
|
|
75
140
|
}
|
|
76
141
|
}
|
|
77
142
|
|
|
78
|
-
public
|
|
143
|
+
public getRandomField(): Fr {
|
|
79
144
|
return Fr.random();
|
|
80
145
|
}
|
|
81
146
|
|
|
82
|
-
public
|
|
83
|
-
return UtilityContext.
|
|
84
|
-
blockNumber: this.anchorBlockHeader.globalVariables.blockNumber,
|
|
85
|
-
timestamp: this.anchorBlockHeader.globalVariables.timestamp,
|
|
86
|
-
contractAddress: this.contractAddress,
|
|
87
|
-
version: this.anchorBlockHeader.globalVariables.version,
|
|
88
|
-
chainId: this.anchorBlockHeader.globalVariables.chainId,
|
|
89
|
-
});
|
|
147
|
+
public getUtilityContext(): UtilityContext {
|
|
148
|
+
return new UtilityContext(this.anchorBlockHeader, this.contractAddress);
|
|
90
149
|
}
|
|
91
150
|
|
|
92
151
|
/**
|
|
@@ -94,65 +153,93 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
|
|
|
94
153
|
* @param pkMHash - The master public key hash.
|
|
95
154
|
* @returns A Promise that resolves to nullifier keys.
|
|
96
155
|
* @throws If the keys are not registered in the key store.
|
|
156
|
+
* @throws If scopes are defined and the account is not in the scopes.
|
|
97
157
|
*/
|
|
98
|
-
public
|
|
158
|
+
public async getKeyValidationRequest(pkMHash: Fr): Promise<KeyValidationRequest> {
|
|
159
|
+
// If scopes are defined, check that the key belongs to an account in the scopes.
|
|
160
|
+
if (this.scopes !== 'ALL_SCOPES' && this.scopes.length > 0) {
|
|
161
|
+
let hasAccess = false;
|
|
162
|
+
for (let i = 0; i < this.scopes.length && !hasAccess; i++) {
|
|
163
|
+
if (await this.keyStore.accountHasKey(this.scopes[i], pkMHash)) {
|
|
164
|
+
hasAccess = true;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
if (!hasAccess) {
|
|
168
|
+
throw new Error(`Key validation request denied: no scoped account has a key with hash ${pkMHash.toString()}.`);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
99
171
|
return this.keyStore.getKeyValidationRequest(pkMHash, this.contractAddress);
|
|
100
172
|
}
|
|
101
173
|
|
|
102
174
|
/**
|
|
103
|
-
* Fetches the index and sibling path of a leaf at a given block from
|
|
104
|
-
* @param
|
|
105
|
-
*
|
|
106
|
-
* @param
|
|
107
|
-
* @returns The index and sibling path
|
|
175
|
+
* Fetches the index and sibling path of a leaf at a given block from the note hash tree.
|
|
176
|
+
* @param anchorBlockHash - The hash of a block that contains the note hash tree root in which to find the membership
|
|
177
|
+
* witness.
|
|
178
|
+
* @param noteHash - The note hash to find in the note hash tree.
|
|
179
|
+
* @returns The membership witness containing the leaf index and sibling path
|
|
180
|
+
*/
|
|
181
|
+
public getNoteHashMembershipWitness(
|
|
182
|
+
anchorBlockHash: BlockHash,
|
|
183
|
+
noteHash: Fr,
|
|
184
|
+
): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT> | undefined> {
|
|
185
|
+
return this.aztecNode.getNoteHashMembershipWitness(anchorBlockHash, noteHash);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Fetches the index and sibling path of a block hash in the archive tree.
|
|
190
|
+
*
|
|
191
|
+
* Block hashes are the leaves of the archive tree. Each time a new block is added to the chain,
|
|
192
|
+
* its block hash is appended as a new leaf to the archive tree.
|
|
193
|
+
*
|
|
194
|
+
* @param anchorBlockHash - The hash of a block that contains the archive tree root in which to find the membership
|
|
195
|
+
* witness.
|
|
196
|
+
* @param blockHash - The block hash to find in the archive tree.
|
|
197
|
+
* @returns The membership witness containing the leaf index and sibling path
|
|
108
198
|
*/
|
|
109
|
-
public
|
|
110
|
-
|
|
111
|
-
|
|
199
|
+
public getBlockHashMembershipWitness(
|
|
200
|
+
anchorBlockHash: BlockHash,
|
|
201
|
+
blockHash: BlockHash,
|
|
202
|
+
): Promise<MembershipWitness<typeof ARCHIVE_HEIGHT> | undefined> {
|
|
203
|
+
return this.aztecNode.getBlockHashMembershipWitness(anchorBlockHash, blockHash);
|
|
112
204
|
}
|
|
113
205
|
|
|
114
206
|
/**
|
|
115
207
|
* Returns a nullifier membership witness for a given nullifier at a given block.
|
|
116
|
-
* @param
|
|
208
|
+
* @param blockHash - The block hash at which to get the index.
|
|
117
209
|
* @param nullifier - Nullifier we try to find witness for.
|
|
118
210
|
* @returns The nullifier membership witness (if found).
|
|
119
211
|
*/
|
|
120
|
-
public
|
|
121
|
-
|
|
212
|
+
public getNullifierMembershipWitness(
|
|
213
|
+
blockHash: BlockHash,
|
|
122
214
|
nullifier: Fr,
|
|
123
215
|
): Promise<NullifierMembershipWitness | undefined> {
|
|
124
|
-
return
|
|
216
|
+
return this.aztecNode.getNullifierMembershipWitness(blockHash, nullifier);
|
|
125
217
|
}
|
|
126
218
|
|
|
127
219
|
/**
|
|
128
220
|
* Returns a low nullifier membership witness for a given nullifier at a given block.
|
|
129
|
-
* @param
|
|
221
|
+
* @param blockHash - The block hash at which to get the index.
|
|
130
222
|
* @param nullifier - Nullifier we try to find the low nullifier witness for.
|
|
131
223
|
* @returns The low nullifier membership witness (if found).
|
|
132
224
|
* @remarks Low nullifier witness can be used to perform a nullifier non-inclusion proof by leveraging the "linked
|
|
133
225
|
* list structure" of leaves and proving that a lower nullifier is pointing to a bigger next value than the nullifier
|
|
134
226
|
* we are trying to prove non-inclusion for.
|
|
135
227
|
*/
|
|
136
|
-
public
|
|
137
|
-
|
|
228
|
+
public getLowNullifierMembershipWitness(
|
|
229
|
+
blockHash: BlockHash,
|
|
138
230
|
nullifier: Fr,
|
|
139
231
|
): Promise<NullifierMembershipWitness | undefined> {
|
|
140
|
-
|
|
141
|
-
return await treeMembershipService.getLowNullifierMembershipWitness(blockNumber, nullifier);
|
|
232
|
+
return this.aztecNode.getLowNullifierMembershipWitness(blockHash, nullifier);
|
|
142
233
|
}
|
|
143
234
|
|
|
144
235
|
/**
|
|
145
236
|
* Returns a public data tree witness for a given leaf slot at a given block.
|
|
146
|
-
* @param
|
|
237
|
+
* @param blockHash - The block hash at which to get the index.
|
|
147
238
|
* @param leafSlot - The slot of the public data tree to get the witness for.
|
|
148
239
|
* @returns - The witness
|
|
149
240
|
*/
|
|
150
|
-
public
|
|
151
|
-
|
|
152
|
-
leafSlot: Fr,
|
|
153
|
-
): Promise<PublicDataWitness | undefined> {
|
|
154
|
-
const treeMembershipService = new TreeMembershipService(this.aztecNode, this.anchorBlockStore);
|
|
155
|
-
return await treeMembershipService.getPublicDataWitness(blockNumber, leafSlot);
|
|
241
|
+
public getPublicDataWitness(blockHash: BlockHash, leafSlot: Fr): Promise<PublicDataWitness | undefined> {
|
|
242
|
+
return this.aztecNode.getPublicDataWitness(blockHash, leafSlot);
|
|
156
243
|
}
|
|
157
244
|
|
|
158
245
|
/**
|
|
@@ -160,27 +247,32 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
|
|
|
160
247
|
* @param blockNumber - The number of a block of which to get the block header.
|
|
161
248
|
* @returns Block extracted from a block with block number `blockNumber`.
|
|
162
249
|
*/
|
|
163
|
-
public async
|
|
164
|
-
const anchorBlockNumber =
|
|
250
|
+
public async getBlockHeader(blockNumber: BlockNumber): Promise<BlockHeader | undefined> {
|
|
251
|
+
const anchorBlockNumber = this.anchorBlockHeader.getBlockNumber();
|
|
165
252
|
if (blockNumber > anchorBlockNumber) {
|
|
166
253
|
throw new Error(`Block number ${blockNumber} is higher than current block ${anchorBlockNumber}`);
|
|
167
254
|
}
|
|
168
255
|
|
|
169
256
|
const block = await this.aztecNode.getBlock(blockNumber);
|
|
170
|
-
return block?.
|
|
257
|
+
return block?.header;
|
|
171
258
|
}
|
|
172
259
|
|
|
173
260
|
/**
|
|
174
|
-
* Retrieve the
|
|
261
|
+
* Retrieve the public keys and partial address associated to a given address.
|
|
175
262
|
* @param account - The account address.
|
|
176
|
-
* @returns
|
|
177
|
-
* @throws An error if the account is not registered in the database.
|
|
263
|
+
* @returns The public keys and partial address, or `undefined` if the account is not registered.
|
|
178
264
|
*/
|
|
179
|
-
public
|
|
180
|
-
|
|
265
|
+
public async tryGetPublicKeysAndPartialAddress(
|
|
266
|
+
account: AztecAddress,
|
|
267
|
+
): Promise<{ publicKeys: PublicKeys; partialAddress: PartialAddress } | undefined> {
|
|
268
|
+
const completeAddress = await this.addressStore.getCompleteAddress(account);
|
|
269
|
+
if (!completeAddress) {
|
|
270
|
+
return undefined;
|
|
271
|
+
}
|
|
272
|
+
return { publicKeys: completeAddress.publicKeys, partialAddress: completeAddress.partialAddress };
|
|
181
273
|
}
|
|
182
274
|
|
|
183
|
-
protected async
|
|
275
|
+
protected async getCompleteAddressOrFail(account: AztecAddress): Promise<CompleteAddress> {
|
|
184
276
|
const completeAddress = await this.addressStore.getCompleteAddress(account);
|
|
185
277
|
if (!completeAddress) {
|
|
186
278
|
throw new Error(
|
|
@@ -196,11 +288,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
|
|
|
196
288
|
* @param address - Address.
|
|
197
289
|
* @returns A contract instance.
|
|
198
290
|
*/
|
|
199
|
-
public
|
|
200
|
-
return this.getContractInstance(address);
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
protected async getContractInstance(address: AztecAddress): Promise<ContractInstance> {
|
|
291
|
+
public async getContractInstance(address: AztecAddress): Promise<ContractInstance> {
|
|
204
292
|
const instance = await this.contractStore.getContractInstance(address);
|
|
205
293
|
if (!instance) {
|
|
206
294
|
throw new Error(`No contract instance found for address ${address.toString()}`);
|
|
@@ -214,7 +302,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
|
|
|
214
302
|
* @param messageHash - Hash of the message to authenticate.
|
|
215
303
|
* @returns Authentication witness for the requested message hash.
|
|
216
304
|
*/
|
|
217
|
-
public
|
|
305
|
+
public getAuthWitness(messageHash: Fr): Promise<Fr[] | undefined> {
|
|
218
306
|
return Promise.resolve(this.authWitnesses.find(w => w.requestHash.equals(messageHash))?.witness);
|
|
219
307
|
}
|
|
220
308
|
|
|
@@ -240,7 +328,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
|
|
|
240
328
|
* @param status - The status of notes to fetch.
|
|
241
329
|
* @returns Array of note data.
|
|
242
330
|
*/
|
|
243
|
-
public async
|
|
331
|
+
public async getNotes(
|
|
244
332
|
owner: AztecAddress | undefined,
|
|
245
333
|
storageSlot: Fr,
|
|
246
334
|
numSelects: number,
|
|
@@ -257,7 +345,7 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
|
|
|
257
345
|
offset: number,
|
|
258
346
|
status: NoteStatus,
|
|
259
347
|
): Promise<NoteData[]> {
|
|
260
|
-
const noteService = new NoteService(this.noteStore, this.aztecNode, this.
|
|
348
|
+
const noteService = new NoteService(this.noteStore, this.aztecNode, this.anchorBlockHeader, this.jobId);
|
|
261
349
|
|
|
262
350
|
const dbNotes = await noteService.getNotes(this.contractAddress, owner, storageSlot, status, this.scopes);
|
|
263
351
|
return pickNotes<NoteData>(dbNotes, {
|
|
@@ -280,11 +368,15 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
|
|
|
280
368
|
* @param innerNullifier - The inner nullifier.
|
|
281
369
|
* @returns A boolean indicating whether the nullifier exists in the tree or not.
|
|
282
370
|
*/
|
|
283
|
-
public async
|
|
284
|
-
const nullifier = await
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
371
|
+
public async checkNullifierExists(innerNullifier: Fr) {
|
|
372
|
+
const [nullifier, anchorBlockHash] = await Promise.all([
|
|
373
|
+
siloNullifier(this.contractAddress, innerNullifier!),
|
|
374
|
+
this.anchorBlockHeader.hash(),
|
|
375
|
+
]);
|
|
376
|
+
const [leafIndex] = await this.aztecNode.findLeavesIndexes(anchorBlockHash, MerkleTreeId.NULLIFIER_TREE, [
|
|
377
|
+
nullifier,
|
|
378
|
+
]);
|
|
379
|
+
return leafIndex?.data !== undefined;
|
|
288
380
|
}
|
|
289
381
|
|
|
290
382
|
/**
|
|
@@ -295,71 +387,83 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
|
|
|
295
387
|
* @dev Contract address and secret are only used to compute the nullifier to get non-nullified messages
|
|
296
388
|
* @returns The l1 to l2 membership witness (index of message in the tree and sibling path).
|
|
297
389
|
*/
|
|
298
|
-
public async
|
|
299
|
-
const
|
|
300
|
-
|
|
390
|
+
public async getL1ToL2MembershipWitness(contractAddress: AztecAddress, messageHash: Fr, secret: Fr) {
|
|
391
|
+
const [messageIndex, siblingPath] = await getNonNullifiedL1ToL2MessageWitness(
|
|
392
|
+
this.aztecNode,
|
|
301
393
|
contractAddress,
|
|
302
394
|
messageHash,
|
|
303
395
|
secret,
|
|
304
396
|
);
|
|
305
397
|
|
|
306
|
-
// Assuming messageIndex is what you intended to use for the index in MessageLoadOracleInputs
|
|
307
398
|
return new MessageLoadOracleInputs(messageIndex, siblingPath);
|
|
308
399
|
}
|
|
309
400
|
|
|
310
401
|
/**
|
|
311
402
|
* Read the public storage data.
|
|
403
|
+
* @param blockHash - The block hash to read storage at.
|
|
312
404
|
* @param contractAddress - The address to read storage from.
|
|
313
405
|
* @param startStorageSlot - The starting storage slot.
|
|
314
|
-
* @param blockNumber - The block number to read storage at.
|
|
315
406
|
* @param numberOfElements - Number of elements to read from the starting storage slot.
|
|
316
407
|
*/
|
|
317
|
-
public async
|
|
408
|
+
public async storageRead(
|
|
409
|
+
blockHash: BlockHash,
|
|
318
410
|
contractAddress: AztecAddress,
|
|
319
411
|
startStorageSlot: Fr,
|
|
320
|
-
blockNumber: BlockNumber,
|
|
321
412
|
numberOfElements: number,
|
|
322
413
|
) {
|
|
323
|
-
const
|
|
324
|
-
|
|
414
|
+
const slots = Array(numberOfElements)
|
|
415
|
+
.fill(0)
|
|
416
|
+
.map((_, i) => new Fr(startStorageSlot.value + BigInt(i)));
|
|
325
417
|
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
const storageSlot = new Fr(startStorageSlot.value + i);
|
|
330
|
-
const value = await publicStorageService.getPublicStorageAt(blockNumber, contractAddress, storageSlot);
|
|
418
|
+
const values = await Promise.all(
|
|
419
|
+
slots.map(storageSlot => this.aztecNode.getPublicStorageAt(blockHash, contractAddress, storageSlot)),
|
|
420
|
+
);
|
|
331
421
|
|
|
332
|
-
|
|
333
|
-
|
|
422
|
+
this.logger.debug(
|
|
423
|
+
`Oracle storage read: slots=[${slots.map(slot => slot.toString()).join(', ')}] address=${contractAddress.toString()} values=[${values.join(', ')}]`,
|
|
424
|
+
);
|
|
425
|
+
|
|
426
|
+
return values;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* Returns a per-contract logger whose output is prefixed with `contract_log::<name>(<addrAbbrev>)`.
|
|
431
|
+
*/
|
|
432
|
+
async #getContractLogger(): Promise<Logger> {
|
|
433
|
+
if (!this.contractLogger) {
|
|
434
|
+
// Purpose of instanceId is to distinguish logs from different instances of the same component. It makes sense
|
|
435
|
+
// to re-use jobId as instanceId here as executions of different PXE jobs are isolated.
|
|
436
|
+
this.contractLogger = await createContractLogger(
|
|
437
|
+
this.contractAddress,
|
|
438
|
+
addr => this.contractStore.getDebugContractName(addr),
|
|
439
|
+
{ instanceId: this.jobId },
|
|
334
440
|
);
|
|
335
|
-
values.push(value);
|
|
336
441
|
}
|
|
337
|
-
return
|
|
442
|
+
return this.contractLogger;
|
|
338
443
|
}
|
|
339
444
|
|
|
340
|
-
public
|
|
445
|
+
public async log(level: number, message: string, fields: Fr[]): Promise<void> {
|
|
341
446
|
if (!LogLevels[level]) {
|
|
342
|
-
throw new Error(`Invalid
|
|
447
|
+
throw new Error(`Invalid log level: ${level}`);
|
|
343
448
|
}
|
|
344
|
-
const
|
|
345
|
-
|
|
449
|
+
const logger = await this.#getContractLogger();
|
|
450
|
+
logContractMessage(logger, LogLevels[level], message, fields);
|
|
346
451
|
}
|
|
347
452
|
|
|
348
|
-
public async
|
|
453
|
+
public async fetchTaggedLogs(pendingTaggedLogArrayBaseSlot: Fr) {
|
|
349
454
|
const logService = new LogService(
|
|
350
455
|
this.aztecNode,
|
|
351
|
-
this.
|
|
456
|
+
this.anchorBlockHeader,
|
|
352
457
|
this.keyStore,
|
|
353
458
|
this.capsuleStore,
|
|
354
459
|
this.recipientTaggingStore,
|
|
355
460
|
this.senderAddressBookStore,
|
|
356
461
|
this.addressStore,
|
|
462
|
+
this.jobId,
|
|
463
|
+
this.logger.getBindings(),
|
|
357
464
|
);
|
|
358
465
|
|
|
359
|
-
await logService.
|
|
360
|
-
|
|
361
|
-
const noteService = new NoteService(this.noteStore, this.aztecNode, this.anchorBlockStore);
|
|
362
|
-
await noteService.syncNoteNullifiers(this.contractAddress);
|
|
466
|
+
await logService.fetchTaggedLogs(this.contractAddress, pendingTaggedLogArrayBaseSlot, this.scopes);
|
|
363
467
|
}
|
|
364
468
|
|
|
365
469
|
/**
|
|
@@ -372,12 +476,14 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
|
|
|
372
476
|
* @param noteValidationRequestsArrayBaseSlot - The base slot of capsule array containing note validation requests.
|
|
373
477
|
* @param eventValidationRequestsArrayBaseSlot - The base slot of capsule array containing event validation requests.
|
|
374
478
|
*/
|
|
375
|
-
public async
|
|
479
|
+
public async validateAndStoreEnqueuedNotesAndEvents(
|
|
376
480
|
contractAddress: AztecAddress,
|
|
377
481
|
noteValidationRequestsArrayBaseSlot: Fr,
|
|
378
482
|
eventValidationRequestsArrayBaseSlot: Fr,
|
|
483
|
+
maxNotePackedLen: number,
|
|
484
|
+
maxEventSerializedLen: number,
|
|
379
485
|
) {
|
|
380
|
-
// TODO(#10727): allow other contracts to
|
|
486
|
+
// TODO(#10727): allow other contracts to store notes
|
|
381
487
|
if (!this.contractAddress.equals(contractAddress)) {
|
|
382
488
|
throw new Error(`Got a note validation request from ${contractAddress}, expected ${this.contractAddress}`);
|
|
383
489
|
}
|
|
@@ -385,16 +491,16 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
|
|
|
385
491
|
// We read all note and event validation requests and process them all concurrently. This makes the process much
|
|
386
492
|
// faster as we don't need to wait for the network round-trip.
|
|
387
493
|
const noteValidationRequests = (
|
|
388
|
-
await this.capsuleStore.readCapsuleArray(contractAddress, noteValidationRequestsArrayBaseSlot)
|
|
389
|
-
).map(NoteValidationRequest.fromFields);
|
|
494
|
+
await this.capsuleStore.readCapsuleArray(contractAddress, noteValidationRequestsArrayBaseSlot, this.jobId)
|
|
495
|
+
).map(fields => NoteValidationRequest.fromFields(fields, maxNotePackedLen));
|
|
390
496
|
|
|
391
497
|
const eventValidationRequests = (
|
|
392
|
-
await this.capsuleStore.readCapsuleArray(contractAddress, eventValidationRequestsArrayBaseSlot)
|
|
393
|
-
).map(EventValidationRequest.fromFields);
|
|
498
|
+
await this.capsuleStore.readCapsuleArray(contractAddress, eventValidationRequestsArrayBaseSlot, this.jobId)
|
|
499
|
+
).map(fields => EventValidationRequest.fromFields(fields, maxEventSerializedLen));
|
|
394
500
|
|
|
395
|
-
const noteService = new NoteService(this.noteStore, this.aztecNode, this.
|
|
396
|
-
const
|
|
397
|
-
noteService.
|
|
501
|
+
const noteService = new NoteService(this.noteStore, this.aztecNode, this.anchorBlockHeader, this.jobId);
|
|
502
|
+
const noteStorePromises = noteValidationRequests.map(request =>
|
|
503
|
+
noteService.validateAndStoreNote(
|
|
398
504
|
request.contractAddress,
|
|
399
505
|
request.owner,
|
|
400
506
|
request.storageSlot,
|
|
@@ -408,9 +514,9 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
|
|
|
408
514
|
),
|
|
409
515
|
);
|
|
410
516
|
|
|
411
|
-
const eventService = new EventService(this.
|
|
412
|
-
const
|
|
413
|
-
eventService.
|
|
517
|
+
const eventService = new EventService(this.anchorBlockHeader, this.aztecNode, this.privateEventStore, this.jobId);
|
|
518
|
+
const eventStorePromises = eventValidationRequests.map(request =>
|
|
519
|
+
eventService.validateAndStoreEvent(
|
|
414
520
|
request.contractAddress,
|
|
415
521
|
request.eventTypeId,
|
|
416
522
|
request.randomness,
|
|
@@ -421,14 +527,14 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
|
|
|
421
527
|
),
|
|
422
528
|
);
|
|
423
529
|
|
|
424
|
-
await Promise.all([...
|
|
530
|
+
await Promise.all([...noteStorePromises, ...eventStorePromises]);
|
|
425
531
|
|
|
426
532
|
// Requests are cleared once we're done.
|
|
427
|
-
await this.capsuleStore.setCapsuleArray(contractAddress, noteValidationRequestsArrayBaseSlot, []);
|
|
428
|
-
await this.capsuleStore.setCapsuleArray(contractAddress, eventValidationRequestsArrayBaseSlot, []);
|
|
533
|
+
await this.capsuleStore.setCapsuleArray(contractAddress, noteValidationRequestsArrayBaseSlot, [], this.jobId);
|
|
534
|
+
await this.capsuleStore.setCapsuleArray(contractAddress, eventValidationRequestsArrayBaseSlot, [], this.jobId);
|
|
429
535
|
}
|
|
430
536
|
|
|
431
|
-
public async
|
|
537
|
+
public async bulkRetrieveLogs(
|
|
432
538
|
contractAddress: AztecAddress,
|
|
433
539
|
logRetrievalRequestsArrayBaseSlot: Fr,
|
|
434
540
|
logRetrievalResponsesArrayBaseSlot: Fr,
|
|
@@ -441,41 +547,86 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
|
|
|
441
547
|
// We read all log retrieval requests and process them all concurrently. This makes the process much faster as we
|
|
442
548
|
// don't need to wait for the network round-trip.
|
|
443
549
|
const logRetrievalRequests = (
|
|
444
|
-
await this.capsuleStore.readCapsuleArray(contractAddress, logRetrievalRequestsArrayBaseSlot)
|
|
550
|
+
await this.capsuleStore.readCapsuleArray(contractAddress, logRetrievalRequestsArrayBaseSlot, this.jobId)
|
|
445
551
|
).map(LogRetrievalRequest.fromFields);
|
|
446
552
|
|
|
447
553
|
const logService = new LogService(
|
|
448
554
|
this.aztecNode,
|
|
449
|
-
this.
|
|
555
|
+
this.anchorBlockHeader,
|
|
450
556
|
this.keyStore,
|
|
451
557
|
this.capsuleStore,
|
|
452
558
|
this.recipientTaggingStore,
|
|
453
559
|
this.senderAddressBookStore,
|
|
454
560
|
this.addressStore,
|
|
561
|
+
this.jobId,
|
|
562
|
+
this.logger.getBindings(),
|
|
455
563
|
);
|
|
456
564
|
|
|
457
565
|
const maybeLogRetrievalResponses = await logService.bulkRetrieveLogs(logRetrievalRequests);
|
|
458
566
|
|
|
459
567
|
// Requests are cleared once we're done.
|
|
460
|
-
await this.capsuleStore.setCapsuleArray(contractAddress, logRetrievalRequestsArrayBaseSlot, []);
|
|
568
|
+
await this.capsuleStore.setCapsuleArray(contractAddress, logRetrievalRequestsArrayBaseSlot, [], this.jobId);
|
|
461
569
|
|
|
462
570
|
// The responses are stored as Option<LogRetrievalResponse> in a second CapsuleArray.
|
|
463
571
|
await this.capsuleStore.setCapsuleArray(
|
|
464
572
|
contractAddress,
|
|
465
573
|
logRetrievalResponsesArrayBaseSlot,
|
|
466
574
|
maybeLogRetrievalResponses.map(LogRetrievalResponse.toSerializedOption),
|
|
575
|
+
this.jobId,
|
|
467
576
|
);
|
|
468
577
|
}
|
|
469
578
|
|
|
470
|
-
public
|
|
579
|
+
public async utilityResolveMessageContexts(
|
|
580
|
+
contractAddress: AztecAddress,
|
|
581
|
+
messageContextRequestsArrayBaseSlot: Fr,
|
|
582
|
+
messageContextResponsesArrayBaseSlot: Fr,
|
|
583
|
+
) {
|
|
584
|
+
try {
|
|
585
|
+
if (!this.contractAddress.equals(contractAddress)) {
|
|
586
|
+
throw new Error(`Got a message context request from ${contractAddress}, expected ${this.contractAddress}`);
|
|
587
|
+
}
|
|
588
|
+
const requestCapsules = await this.capsuleStore.readCapsuleArray(
|
|
589
|
+
contractAddress,
|
|
590
|
+
messageContextRequestsArrayBaseSlot,
|
|
591
|
+
this.jobId,
|
|
592
|
+
);
|
|
593
|
+
|
|
594
|
+
const txHashes = requestCapsules.map((fields, i) => {
|
|
595
|
+
if (fields.length !== 1) {
|
|
596
|
+
throw new Error(
|
|
597
|
+
`Malformed message context request at index ${i}: expected 1 field (tx hash), got ${fields.length}`,
|
|
598
|
+
);
|
|
599
|
+
}
|
|
600
|
+
return fields[0];
|
|
601
|
+
});
|
|
602
|
+
|
|
603
|
+
const maybeMessageContexts = await this.messageContextService.resolveMessageContexts(
|
|
604
|
+
txHashes,
|
|
605
|
+
this.anchorBlockHeader.getBlockNumber(),
|
|
606
|
+
);
|
|
607
|
+
|
|
608
|
+
// Leave response in response capsule array.
|
|
609
|
+
await this.capsuleStore.setCapsuleArray(
|
|
610
|
+
contractAddress,
|
|
611
|
+
messageContextResponsesArrayBaseSlot,
|
|
612
|
+
maybeMessageContexts.map(MessageTxContext.toSerializedOption),
|
|
613
|
+
this.jobId,
|
|
614
|
+
);
|
|
615
|
+
} finally {
|
|
616
|
+
await this.capsuleStore.setCapsuleArray(contractAddress, messageContextRequestsArrayBaseSlot, [], this.jobId);
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
public storeCapsule(contractAddress: AztecAddress, slot: Fr, capsule: Fr[]): Promise<void> {
|
|
471
621
|
if (!contractAddress.equals(this.contractAddress)) {
|
|
472
622
|
// TODO(#10727): instead of this check that this.contractAddress is allowed to access the external DB
|
|
473
623
|
throw new Error(`Contract ${contractAddress} is not allowed to access ${this.contractAddress}'s PXE DB`);
|
|
474
624
|
}
|
|
475
|
-
|
|
625
|
+
this.capsuleStore.storeCapsule(this.contractAddress, slot, capsule, this.jobId);
|
|
626
|
+
return Promise.resolve();
|
|
476
627
|
}
|
|
477
628
|
|
|
478
|
-
public async
|
|
629
|
+
public async loadCapsule(contractAddress: AztecAddress, slot: Fr): Promise<Fr[] | null> {
|
|
479
630
|
if (!contractAddress.equals(this.contractAddress)) {
|
|
480
631
|
// TODO(#10727): instead of this check that this.contractAddress is allowed to access the external DB
|
|
481
632
|
throw new Error(`Contract ${contractAddress} is not allowed to access ${this.contractAddress}'s PXE DB`);
|
|
@@ -483,33 +634,40 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
|
|
|
483
634
|
return (
|
|
484
635
|
// TODO(#12425): On the following line, the pertinent capsule gets overshadowed by the transient one. Tackle this.
|
|
485
636
|
this.capsules.find(c => c.contractAddress.equals(contractAddress) && c.storageSlot.equals(slot))?.data ??
|
|
486
|
-
(await this.capsuleStore.loadCapsule(this.contractAddress, slot))
|
|
637
|
+
(await this.capsuleStore.loadCapsule(this.contractAddress, slot, this.jobId))
|
|
487
638
|
);
|
|
488
639
|
}
|
|
489
640
|
|
|
490
|
-
public
|
|
641
|
+
public deleteCapsule(contractAddress: AztecAddress, slot: Fr): Promise<void> {
|
|
491
642
|
if (!contractAddress.equals(this.contractAddress)) {
|
|
492
643
|
// TODO(#10727): instead of this check that this.contractAddress is allowed to access the external DB
|
|
493
644
|
throw new Error(`Contract ${contractAddress} is not allowed to access ${this.contractAddress}'s PXE DB`);
|
|
494
645
|
}
|
|
495
|
-
|
|
646
|
+
this.capsuleStore.deleteCapsule(this.contractAddress, slot, this.jobId);
|
|
647
|
+
return Promise.resolve();
|
|
496
648
|
}
|
|
497
649
|
|
|
498
|
-
public
|
|
499
|
-
contractAddress: AztecAddress,
|
|
500
|
-
srcSlot: Fr,
|
|
501
|
-
dstSlot: Fr,
|
|
502
|
-
numEntries: number,
|
|
503
|
-
): Promise<void> {
|
|
650
|
+
public copyCapsule(contractAddress: AztecAddress, srcSlot: Fr, dstSlot: Fr, numEntries: number): Promise<void> {
|
|
504
651
|
if (!contractAddress.equals(this.contractAddress)) {
|
|
505
652
|
// TODO(#10727): instead of this check that this.contractAddress is allowed to access the external DB
|
|
506
653
|
throw new Error(`Contract ${contractAddress} is not allowed to access ${this.contractAddress}'s PXE DB`);
|
|
507
654
|
}
|
|
508
|
-
return this.capsuleStore.copyCapsule(this.contractAddress, srcSlot, dstSlot, numEntries);
|
|
655
|
+
return this.capsuleStore.copyCapsule(this.contractAddress, srcSlot, dstSlot, numEntries, this.jobId);
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
/**
|
|
659
|
+
* Clears cached sync state for a contract for a set of scopes, forcing re-sync on the next query so that newly
|
|
660
|
+
* stored notes or events are discovered.
|
|
661
|
+
*/
|
|
662
|
+
public invalidateContractSyncCache(contractAddress: AztecAddress, scopes: AztecAddress[]): void {
|
|
663
|
+
if (!contractAddress.equals(this.contractAddress)) {
|
|
664
|
+
throw new Error(`Contract ${this.contractAddress} cannot invalidate sync cache of ${contractAddress}`);
|
|
665
|
+
}
|
|
666
|
+
this.contractSyncService.invalidateContractForScopes(contractAddress, scopes);
|
|
509
667
|
}
|
|
510
668
|
|
|
511
669
|
// TODO(#11849): consider replacing this oracle with a pure Noir implementation of aes decryption.
|
|
512
|
-
public
|
|
670
|
+
public aes128Decrypt(ciphertext: Buffer, iv: Buffer, symKey: Buffer): Promise<Buffer> {
|
|
513
671
|
const aes128 = new Aes128();
|
|
514
672
|
return aes128.decryptBufferCBC(ciphertext, iv, symKey);
|
|
515
673
|
}
|
|
@@ -520,17 +678,23 @@ export class UtilityExecutionOracle implements IMiscOracle, IUtilityExecutionOra
|
|
|
520
678
|
* @param ephPk - The ephemeral public key to get the secret for.
|
|
521
679
|
* @returns The secret for the given address.
|
|
522
680
|
*/
|
|
523
|
-
public
|
|
524
|
-
return this.getSharedSecret(address, ephPk);
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
protected async getSharedSecret(address: AztecAddress, ephPk: Point): Promise<Point> {
|
|
681
|
+
public async getSharedSecret(address: AztecAddress, ephPk: Point): Promise<Point> {
|
|
528
682
|
// TODO(#12656): return an app-siloed secret
|
|
529
|
-
const recipientCompleteAddress = await this.
|
|
683
|
+
const recipientCompleteAddress = await this.getCompleteAddressOrFail(address);
|
|
530
684
|
const ivskM = await this.keyStore.getMasterSecretKey(
|
|
531
685
|
recipientCompleteAddress.publicKeys.masterIncomingViewingPublicKey,
|
|
532
686
|
);
|
|
533
687
|
const addressSecret = await computeAddressSecret(await recipientCompleteAddress.getPreaddress(), ivskM);
|
|
534
688
|
return deriveEcdhSharedSecret(addressSecret, ephPk);
|
|
535
689
|
}
|
|
690
|
+
|
|
691
|
+
public emitOffchainEffect(data: Fr[]): Promise<void> {
|
|
692
|
+
this.offchainEffects.push({ data, contractAddress: this.contractAddress });
|
|
693
|
+
return Promise.resolve();
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
/** Returns offchain effects collected during execution. */
|
|
697
|
+
public getOffchainEffects(): OffchainEffect[] {
|
|
698
|
+
return this.offchainEffects;
|
|
699
|
+
}
|
|
536
700
|
}
|