@aztec/pxe 0.0.1-commit.2448fdb → 0.0.1-commit.2606882
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 +40 -96
- package/dest/bin/index.d.ts +2 -0
- package/dest/bin/index.d.ts.map +1 -0
- package/dest/bin/index.js +1 -0
- package/dest/bin/oracle_version_helpers.d.ts +26 -0
- package/dest/bin/oracle_version_helpers.d.ts.map +1 -0
- package/dest/bin/oracle_version_helpers.js +93 -0
- package/dest/block_synchronizer/block_stream_source.d.ts +10 -0
- package/dest/block_synchronizer/block_stream_source.d.ts.map +1 -0
- package/dest/block_synchronizer/block_stream_source.js +62 -0
- package/dest/block_synchronizer/block_synchronizer.d.ts +5 -3
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +21 -11
- package/dest/config/index.d.ts +8 -2
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +13 -15
- package/dest/config/package_info.js +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +4 -1
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +20 -12
- package/dest/contract_function_simulator/execution_note_cache.d.ts +2 -2
- package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +5 -9
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_tagging_index_cache.js +3 -7
- package/dest/contract_function_simulator/index.d.ts +13 -2
- package/dest/contract_function_simulator/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.js +10 -0
- package/dest/contract_function_simulator/noir-structs/bounded_vec.d.ts +48 -0
- package/dest/contract_function_simulator/noir-structs/bounded_vec.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/bounded_vec.js +45 -0
- package/dest/contract_function_simulator/noir-structs/ephemeral_array.d.ts +37 -0
- package/dest/contract_function_simulator/noir-structs/ephemeral_array.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/ephemeral_array.js +59 -0
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +3 -2
- 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 +3 -2
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +12 -2
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +34 -3
- package/dest/contract_function_simulator/noir-structs/note_data.d.ts +27 -0
- package/dest/contract_function_simulator/noir-structs/note_data.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/note_data.js +3 -0
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +3 -2
- 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 +3 -2
- package/dest/contract_function_simulator/noir-structs/option.d.ts +61 -0
- package/dest/contract_function_simulator/noir-structs/option.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/option.js +62 -0
- package/dest/contract_function_simulator/noir-structs/provided_secret.d.ts +11 -0
- package/dest/contract_function_simulator/noir-structs/provided_secret.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/provided_secret.js +24 -0
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +16 -114
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/interfaces.js +2 -2
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +2 -2
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/note_packing_utils.js +2 -2
- package/dest/contract_function_simulator/oracle/oracle.d.ts +55 -57
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +343 -344
- package/dest/contract_function_simulator/oracle/oracle_registry.d.ts +127 -0
- package/dest/contract_function_simulator/oracle/oracle_registry.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/oracle_registry.js +786 -0
- package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts +139 -0
- package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/oracle_type_mappings.js +560 -0
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +27 -29
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +55 -47
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +59 -39
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +244 -149
- 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 +35 -67
- package/dest/contract_sync/contract_sync_service.d.ts +4 -6
- package/dest/contract_sync/contract_sync_service.d.ts.map +1 -1
- package/dest/contract_sync/contract_sync_service.js +43 -24
- package/dest/contract_sync/helpers.d.ts +2 -3
- package/dest/contract_sync/helpers.d.ts.map +1 -1
- package/dest/contract_sync/helpers.js +12 -19
- package/dest/debug/pxe_debug_utils.d.ts +1 -6
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
- package/dest/debug/pxe_debug_utils.js +0 -6
- 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 +11 -3
- package/dest/entrypoints/client/lazy/utils.d.ts +1 -1
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +11 -3
- package/dest/entrypoints/pxe_creation_options.d.ts +7 -1
- package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
- package/dest/entrypoints/server/index.d.ts +2 -1
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +1 -0
- package/dest/entrypoints/server/utils.d.ts +3 -2
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +11 -3
- package/dest/events/event_service.d.ts +13 -5
- package/dest/events/event_service.d.ts.map +1 -1
- package/dest/events/event_service.js +30 -9
- package/dest/hooks/authorize_utility_call.d.ts +41 -0
- package/dest/hooks/authorize_utility_call.d.ts.map +1 -0
- package/dest/hooks/authorize_utility_call.js +4 -0
- package/dest/hooks/execution_hooks.d.ts +42 -0
- package/dest/hooks/execution_hooks.d.ts.map +1 -0
- package/dest/hooks/execution_hooks.js +9 -0
- package/dest/hooks/index.d.ts +4 -0
- package/dest/hooks/index.d.ts.map +1 -0
- package/dest/hooks/index.js +1 -0
- package/dest/logs/log_service.d.ts +6 -5
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +112 -48
- package/dest/messages/message_context_service.d.ts +1 -1
- package/dest/messages/message_context_service.d.ts.map +1 -1
- package/dest/messages/message_context_service.js +28 -9
- package/dest/notes/note_service.d.ts +25 -3
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +80 -65
- package/dest/oracle_version.d.ts +3 -3
- package/dest/oracle_version.js +4 -4
- package/dest/private_kernel/batch_planner.d.ts +47 -0
- package/dest/private_kernel/batch_planner.d.ts.map +1 -0
- package/dest/private_kernel/batch_planner.js +104 -0
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.js +1 -1
- package/dest/private_kernel/hints/test_utils.d.ts +1 -1
- package/dest/private_kernel/hints/test_utils.d.ts.map +1 -1
- package/dest/private_kernel/hints/test_utils.js +2 -3
- package/dest/private_kernel/private_kernel_execution_prover.d.ts +6 -2
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.js +148 -52
- package/dest/private_kernel/private_kernel_oracle.d.ts +6 -6
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle.js +12 -7
- package/dest/pxe.d.ts +54 -7
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +126 -84
- package/dest/storage/backwards_compatibility_tests/kv_store_snapshot.d.ts +42 -0
- package/dest/storage/backwards_compatibility_tests/kv_store_snapshot.d.ts.map +1 -0
- package/dest/storage/backwards_compatibility_tests/kv_store_snapshot.js +93 -0
- package/dest/storage/backwards_compatibility_tests/schema_tests.d.ts +15 -0
- package/dest/storage/backwards_compatibility_tests/schema_tests.d.ts.map +1 -0
- package/dest/storage/backwards_compatibility_tests/schema_tests.js +591 -0
- package/dest/storage/backwards_compatibility_tests/store_spy.d.ts +19 -0
- package/dest/storage/backwards_compatibility_tests/store_spy.d.ts.map +1 -0
- package/dest/storage/backwards_compatibility_tests/store_spy.js +63 -0
- package/dest/storage/contract_store/contract_store.d.ts +1 -1
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
- package/dest/storage/contract_store/contract_store.js +5 -24
- package/dest/storage/metadata.d.ts +1 -1
- package/dest/storage/metadata.js +1 -1
- package/dest/storage/open_pxe_stores.d.ts +33 -0
- package/dest/storage/open_pxe_stores.d.ts.map +1 -0
- package/dest/storage/open_pxe_stores.js +27 -0
- package/dest/storage/private_event_store/stored_private_event.js +1 -1
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts +6 -6
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.d.ts +5 -5
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.js +3 -3
- package/dest/tagging/get_all_logs_by_tags.d.ts +34 -10
- package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -1
- package/dest/tagging/get_all_logs_by_tags.js +36 -37
- package/dest/tagging/index.d.ts +5 -4
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/index.js +4 -3
- package/dest/tagging/persist_sender_tagging_index_ranges.d.ts +29 -0
- package/dest/tagging/persist_sender_tagging_index_ranges.d.ts.map +1 -0
- package/dest/tagging/persist_sender_tagging_index_ranges.js +42 -0
- package/dest/tagging/recipient_sync/sync_tagged_private_logs.d.ts +56 -0
- package/dest/tagging/recipient_sync/sync_tagged_private_logs.d.ts.map +1 -0
- package/dest/tagging/recipient_sync/sync_tagged_private_logs.js +163 -0
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.d.ts +3 -3
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.d.ts.map +1 -1
- package/dest/tagging/reconcile_tagging_index_ranges.d.ts +36 -0
- package/dest/tagging/reconcile_tagging_index_ranges.d.ts.map +1 -0
- package/dest/tagging/reconcile_tagging_index_ranges.js +74 -0
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +4 -5
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +26 -14
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +11 -6
- 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 +21 -0
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +4 -4
- 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 +2 -2
- package/package.json +20 -17
- package/src/bin/check_oracle_version.ts +46 -119
- package/src/bin/index.ts +1 -0
- package/src/bin/oracle_version_helpers.ts +121 -0
- package/src/block_synchronizer/block_stream_source.ts +81 -0
- package/src/block_synchronizer/block_synchronizer.ts +22 -12
- package/src/config/index.ts +15 -9
- package/src/config/package_info.ts +1 -1
- package/src/contract_function_simulator/contract_function_simulator.ts +34 -11
- package/src/contract_function_simulator/execution_note_cache.ts +1 -1
- package/src/contract_function_simulator/execution_tagging_index_cache.ts +5 -9
- package/src/contract_function_simulator/index.ts +50 -1
- package/src/contract_function_simulator/noir-structs/bounded_vec.ts +55 -0
- package/src/contract_function_simulator/noir-structs/ephemeral_array.ts +66 -0
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +3 -2
- package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +35 -2
- package/src/contract_function_simulator/noir-structs/note_data.ts +27 -0
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +3 -2
- package/src/contract_function_simulator/noir-structs/option.ts +69 -0
- package/src/contract_function_simulator/noir-structs/provided_secret.ts +27 -0
- package/src/contract_function_simulator/oracle/interfaces.ts +12 -204
- package/src/contract_function_simulator/oracle/note_packing_utils.ts +3 -3
- package/src/contract_function_simulator/oracle/oracle.ts +406 -556
- package/src/contract_function_simulator/oracle/oracle_registry.ts +585 -0
- package/src/contract_function_simulator/oracle/oracle_type_mappings.ts +553 -0
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +74 -67
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +350 -304
- package/src/contract_function_simulator/proxied_contract_data_source.ts +40 -70
- package/src/contract_sync/contract_sync_service.ts +56 -43
- package/src/contract_sync/helpers.ts +11 -23
- package/src/debug/pxe_debug_utils.ts +0 -8
- package/src/entrypoints/client/bundle/utils.ts +8 -2
- package/src/entrypoints/client/lazy/utils.ts +8 -2
- package/src/entrypoints/pxe_creation_options.ts +7 -0
- package/src/entrypoints/server/index.ts +1 -0
- package/src/entrypoints/server/utils.ts +13 -3
- package/src/events/event_service.ts +54 -19
- package/src/hooks/authorize_utility_call.ts +44 -0
- package/src/hooks/execution_hooks.ts +48 -0
- package/src/hooks/index.ts +7 -0
- package/src/logs/log_service.ts +137 -92
- package/src/messages/message_context_service.ts +42 -24
- package/src/notes/note_service.ts +115 -91
- package/src/oracle_version.ts +4 -4
- package/src/private_kernel/batch_planner.ts +169 -0
- package/src/private_kernel/hints/private_kernel_reset_private_inputs_builder.ts +1 -1
- package/src/private_kernel/hints/test_utils.ts +2 -9
- package/src/private_kernel/private_kernel_execution_prover.ts +236 -73
- package/src/private_kernel/private_kernel_oracle.ts +21 -11
- package/src/pxe.ts +208 -85
- package/src/storage/backwards_compatibility_tests/__snapshots__/AddressStore.json +22 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/AnchorBlockStore.json +3 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/CapsuleStore.json +16 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/ContractStore.json +28 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/KeyStore.json +52 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/L2TipsKVStore.json +46 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/NoteStore.json +36 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/PrivateEventStore.json +44 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/RecipientTaggingStore.json +18 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/SenderAddressBookStore.json +16 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/SenderTaggingStore.json +22 -0
- package/src/storage/backwards_compatibility_tests/__snapshots__/opened_stores.json +97 -0
- package/src/storage/backwards_compatibility_tests/kv_store_snapshot.ts +122 -0
- package/src/storage/backwards_compatibility_tests/schema_tests.ts +712 -0
- package/src/storage/backwards_compatibility_tests/store_spy.ts +73 -0
- package/src/storage/contract_store/contract_store.ts +6 -29
- package/src/storage/metadata.ts +1 -1
- package/src/storage/open_pxe_stores.ts +49 -0
- package/src/storage/private_event_store/stored_private_event.ts +1 -1
- package/src/storage/tagging_store/recipient_tagging_store.ts +5 -9
- package/src/storage/tagging_store/sender_tagging_store.ts +6 -6
- package/src/tagging/get_all_logs_by_tags.ts +78 -50
- package/src/tagging/index.ts +4 -3
- package/src/tagging/persist_sender_tagging_index_ranges.ts +57 -0
- package/src/tagging/recipient_sync/sync_tagged_private_logs.ts +240 -0
- package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +2 -2
- package/src/tagging/reconcile_tagging_index_ranges.ts +102 -0
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +41 -19
- package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +23 -8
- package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +4 -5
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts +0 -9
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts.map +0 -1
- package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.js +0 -47
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +0 -14
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +0 -1
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +0 -85
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +0 -14
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +0 -1
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +0 -33
- package/src/contract_function_simulator/oracle/legacy_oracle_mappings.ts +0 -104
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +0 -130
- package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +0 -44
|
@@ -1,25 +1,29 @@
|
|
|
1
|
+
import { ARCHIVE_HEIGHT } from '@aztec/constants';
|
|
2
|
+
import { uniqueBy } from '@aztec/foundation/collection';
|
|
1
3
|
import { Aes128 } from '@aztec/foundation/crypto/aes128';
|
|
2
4
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
5
|
import { LogLevels, createLogger } from '@aztec/foundation/log';
|
|
4
|
-
import {
|
|
6
|
+
import { MembershipWitness } from '@aztec/foundation/trees';
|
|
7
|
+
import { ExecutionError, extractCallStack, resolveAssertionMessageFromError, toACVMWitness, witnessMapToFields } from '@aztec/simulator/client';
|
|
5
8
|
import { siloNullifier } from '@aztec/stdlib/hash';
|
|
6
|
-
import { computeAddressSecret } from '@aztec/stdlib/keys';
|
|
7
|
-
import { MessageContext, deriveAppSiloedSharedSecret } from '@aztec/stdlib/logs';
|
|
9
|
+
import { PublicKeys, computeAddressSecret, hashPublicKey } from '@aztec/stdlib/keys';
|
|
10
|
+
import { AppTaggingSecret, MessageContext, deriveAppSiloedSharedSecret } from '@aztec/stdlib/logs';
|
|
8
11
|
import { getNonNullifiedL1ToL2MessageWitness } from '@aztec/stdlib/messaging';
|
|
9
12
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
13
|
+
import { TxEffect } from '@aztec/stdlib/tx';
|
|
10
14
|
import { createContractLogger, logContractMessage, stripAztecnrLogPrefix } from '../../contract_logging.js';
|
|
11
15
|
import { EventService } from '../../events/event_service.js';
|
|
12
16
|
import { LogService } from '../../logs/log_service.js';
|
|
13
17
|
import { NoteService } from '../../notes/note_service.js';
|
|
14
18
|
import { ORACLE_VERSION_MAJOR } from '../../oracle_version.js';
|
|
15
19
|
import { EphemeralArrayService } from '../ephemeral_array_service.js';
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import { NoteValidationRequest } from '../noir-structs/note_validation_request.js';
|
|
20
|
+
import { BoundedVec } from '../noir-structs/bounded_vec.js';
|
|
21
|
+
import { EphemeralArray } from '../noir-structs/ephemeral_array.js';
|
|
22
|
+
import { Option } from '../noir-structs/option.js';
|
|
20
23
|
import { UtilityContext } from '../noir-structs/utility_context.js';
|
|
21
24
|
import { pickNotes } from '../pick_notes.js';
|
|
22
25
|
import { MessageLoadOracleInputs } from './message_load_oracle_inputs.js';
|
|
26
|
+
import { Oracle } from './oracle.js';
|
|
23
27
|
/**
|
|
24
28
|
* The oracle for an execution of utility contract functions.
|
|
25
29
|
*/ export class UtilityExecutionOracle {
|
|
@@ -50,6 +54,9 @@ import { MessageLoadOracleInputs } from './message_load_oracle_inputs.js';
|
|
|
50
54
|
jobId;
|
|
51
55
|
logger;
|
|
52
56
|
scopes;
|
|
57
|
+
simulator;
|
|
58
|
+
hooks;
|
|
59
|
+
utilityExecutor;
|
|
53
60
|
constructor(args){
|
|
54
61
|
this.contractAddress = args.contractAddress;
|
|
55
62
|
this.authWitnesses = args.authWitnesses;
|
|
@@ -70,30 +77,15 @@ import { MessageLoadOracleInputs } from './message_load_oracle_inputs.js';
|
|
|
70
77
|
this.jobId = args.jobId;
|
|
71
78
|
this.logger = args.log ?? createLogger('simulator:client_view_context');
|
|
72
79
|
this.scopes = args.scopes;
|
|
80
|
+
this.simulator = args.simulator;
|
|
81
|
+
this.hooks = args.hooks;
|
|
82
|
+
this.utilityExecutor = args.utilityExecutor;
|
|
73
83
|
}
|
|
74
84
|
assertCompatibleOracleVersion(major, minor) {
|
|
75
|
-
// TODO(F-416): Remove this hack on v5 when protocol contracts are redeployed.
|
|
76
|
-
// Protocol contracts/canonical contracts shipped with committed bytecode that cannot be changed. Assert they use
|
|
77
|
-
// the expected pinned version or the current one. We want to allow for both the pinned and the current versions
|
|
78
|
-
// because we want this code to work with both the pinned and unpinned version since some branches do not have the
|
|
79
|
-
// pinned contracts (like e.g. next)
|
|
80
|
-
const LEGACY_ORACLE_VERSION = 12;
|
|
81
|
-
if (isProtocolContract(this.contractAddress)) {
|
|
82
|
-
if (major !== LEGACY_ORACLE_VERSION && major !== ORACLE_VERSION_MAJOR) {
|
|
83
|
-
const hint = major > ORACLE_VERSION_MAJOR ? 'The contract was compiled with a newer version of Aztec.nr than your private environment supports. Upgrade your private environment to a compatible version.' : 'The contract was compiled with an older version of Aztec.nr than your private environment supports. Recompile the contract with a compatible version of Aztec.nr.';
|
|
84
|
-
throw new Error(`Incompatible private environment version: ${hint} See https://docs.aztec.network/errors/8 (expected oracle major version ${LEGACY_ORACLE_VERSION} or ${ORACLE_VERSION_MAJOR}, got ${major})`);
|
|
85
|
-
}
|
|
86
|
-
this.contractOracleVersion = {
|
|
87
|
-
major,
|
|
88
|
-
minor
|
|
89
|
-
};
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
85
|
if (major !== ORACLE_VERSION_MAJOR) {
|
|
93
86
|
const hint = major > ORACLE_VERSION_MAJOR ? 'The contract was compiled with a newer version of Aztec.nr than your private environment supports. Upgrade your private environment to a compatible version.' : 'The contract was compiled with an older version of Aztec.nr than your private environment supports. Recompile the contract with a compatible version of Aztec.nr.';
|
|
94
87
|
throw new Error(`Incompatible private environment version: ${hint} See https://docs.aztec.network/errors/8 (expected oracle major version ${ORACLE_VERSION_MAJOR}, got ${major})`);
|
|
95
88
|
}
|
|
96
|
-
// Major matches - store both major and minor for later diagnostics (e.g. when an oracle is not found)
|
|
97
89
|
this.contractOracleVersion = {
|
|
98
90
|
major,
|
|
99
91
|
minor
|
|
@@ -133,8 +125,12 @@ import { MessageLoadOracleInputs } from './message_load_oracle_inputs.js';
|
|
|
133
125
|
* membership witness.
|
|
134
126
|
* @param noteHash - The note hash to find in the note hash tree.
|
|
135
127
|
* @returns The membership witness containing the leaf index and sibling path
|
|
136
|
-
*/ getNoteHashMembershipWitness(blockHash, noteHash) {
|
|
137
|
-
|
|
128
|
+
*/ async getNoteHashMembershipWitness(blockHash, noteHash) {
|
|
129
|
+
const witness = await this.#queryWithBlockHashNotAfterAnchor(blockHash, ()=>this.aztecNode.getNoteHashMembershipWitness(blockHash, noteHash));
|
|
130
|
+
if (!witness) {
|
|
131
|
+
throw new Error(`Note hash ${noteHash} not found in the note hash tree at block ${blockHash.toString()}.`);
|
|
132
|
+
}
|
|
133
|
+
return witness;
|
|
138
134
|
}
|
|
139
135
|
/**
|
|
140
136
|
* Fetches the index and sibling path of a block hash in the archive tree.
|
|
@@ -146,19 +142,24 @@ import { MessageLoadOracleInputs } from './message_load_oracle_inputs.js';
|
|
|
146
142
|
* witness.
|
|
147
143
|
* @param blockHash - The block hash to find in the archive tree.
|
|
148
144
|
* @returns The membership witness containing the leaf index and sibling path
|
|
149
|
-
*/ getBlockHashMembershipWitness(referenceBlockHash, blockHash) {
|
|
145
|
+
*/ async getBlockHashMembershipWitness(referenceBlockHash, blockHash) {
|
|
150
146
|
// Note that we validate that the reference block hash is at or before the anchor block - we don't test the block
|
|
151
147
|
// hash at all. If the block hash did not exist by the reference block hash, then the node will not return the
|
|
152
148
|
// membership witness as there is none.
|
|
153
|
-
|
|
149
|
+
const witness = await this.#queryWithBlockHashNotAfterAnchor(referenceBlockHash, ()=>this.aztecNode.getBlockHashMembershipWitness(referenceBlockHash, blockHash));
|
|
150
|
+
return witness ? Option.some(witness) : Option.none(MembershipWitness.empty(ARCHIVE_HEIGHT));
|
|
154
151
|
}
|
|
155
152
|
/**
|
|
156
153
|
* Returns a nullifier membership witness for a given nullifier at a given block.
|
|
157
154
|
* @param blockHash - The block hash at which to get the index.
|
|
158
155
|
* @param nullifier - Nullifier we try to find witness for.
|
|
159
156
|
* @returns The nullifier membership witness (if found).
|
|
160
|
-
*/ getNullifierMembershipWitness(blockHash, nullifier) {
|
|
161
|
-
|
|
157
|
+
*/ async getNullifierMembershipWitness(blockHash, nullifier) {
|
|
158
|
+
const witness = await this.#queryWithBlockHashNotAfterAnchor(blockHash, ()=>this.aztecNode.getNullifierMembershipWitness(blockHash, nullifier));
|
|
159
|
+
if (!witness) {
|
|
160
|
+
throw new Error(`Nullifier membership witness not found at block ${blockHash.toString()}.`);
|
|
161
|
+
}
|
|
162
|
+
return witness;
|
|
162
163
|
}
|
|
163
164
|
/**
|
|
164
165
|
* Returns a low nullifier membership witness for a given nullifier at a given block.
|
|
@@ -168,16 +169,24 @@ import { MessageLoadOracleInputs } from './message_load_oracle_inputs.js';
|
|
|
168
169
|
* @remarks Low nullifier witness can be used to perform a nullifier non-inclusion proof by leveraging the "linked
|
|
169
170
|
* list structure" of leaves and proving that a lower nullifier is pointing to a bigger next value than the nullifier
|
|
170
171
|
* we are trying to prove non-inclusion for.
|
|
171
|
-
*/ getLowNullifierMembershipWitness(blockHash, nullifier) {
|
|
172
|
-
|
|
172
|
+
*/ async getLowNullifierMembershipWitness(blockHash, nullifier) {
|
|
173
|
+
const witness = await this.#queryWithBlockHashNotAfterAnchor(blockHash, ()=>this.aztecNode.getLowNullifierMembershipWitness(blockHash, nullifier));
|
|
174
|
+
if (!witness) {
|
|
175
|
+
throw new Error(`Low nullifier witness not found for nullifier ${nullifier} at block hash ${blockHash.toString()}.`);
|
|
176
|
+
}
|
|
177
|
+
return witness;
|
|
173
178
|
}
|
|
174
179
|
/**
|
|
175
180
|
* Returns a public data tree witness for a given leaf slot at a given block.
|
|
176
181
|
* @param blockHash - The block hash at which to get the index.
|
|
177
182
|
* @param leafSlot - The slot of the public data tree to get the witness for.
|
|
178
183
|
* @returns - The witness
|
|
179
|
-
*/ getPublicDataWitness(blockHash, leafSlot) {
|
|
180
|
-
|
|
184
|
+
*/ async getPublicDataWitness(blockHash, leafSlot) {
|
|
185
|
+
const witness = await this.#queryWithBlockHashNotAfterAnchor(blockHash, ()=>this.aztecNode.getPublicDataWitness(blockHash, leafSlot));
|
|
186
|
+
if (!witness) {
|
|
187
|
+
throw new Error(`Public data witness not found for slot ${leafSlot} at block hash ${blockHash.toString()}.`);
|
|
188
|
+
}
|
|
189
|
+
return witness;
|
|
181
190
|
}
|
|
182
191
|
/**
|
|
183
192
|
* Fetches a block header of a given block.
|
|
@@ -188,8 +197,15 @@ import { MessageLoadOracleInputs } from './message_load_oracle_inputs.js';
|
|
|
188
197
|
if (blockNumber > anchorBlockNumber) {
|
|
189
198
|
throw new Error(`Block number ${blockNumber} is higher than current block ${anchorBlockNumber}`);
|
|
190
199
|
}
|
|
200
|
+
// Most contracts query state at the "current" block, which is the anchor. Skip the RPC when we can.
|
|
201
|
+
if (blockNumber === anchorBlockNumber) {
|
|
202
|
+
return this.anchorBlockHeader;
|
|
203
|
+
}
|
|
191
204
|
const block = await this.aztecNode.getBlock(blockNumber);
|
|
192
|
-
|
|
205
|
+
if (!block?.header) {
|
|
206
|
+
throw new Error(`Block header not found for block ${blockNumber}.`);
|
|
207
|
+
}
|
|
208
|
+
return block.header;
|
|
193
209
|
}
|
|
194
210
|
/**
|
|
195
211
|
* Retrieve the public keys and partial address associated to a given address.
|
|
@@ -198,12 +214,15 @@ import { MessageLoadOracleInputs } from './message_load_oracle_inputs.js';
|
|
|
198
214
|
*/ async getPublicKeysAndPartialAddress(account) {
|
|
199
215
|
const completeAddress = await this.addressStore.getCompleteAddress(account);
|
|
200
216
|
if (!completeAddress) {
|
|
201
|
-
return
|
|
217
|
+
return Option.none({
|
|
218
|
+
publicKeys: PublicKeys.default(),
|
|
219
|
+
partialAddress: Fr.ZERO
|
|
220
|
+
});
|
|
202
221
|
}
|
|
203
|
-
return {
|
|
222
|
+
return Option.some({
|
|
204
223
|
publicKeys: completeAddress.publicKeys,
|
|
205
224
|
partialAddress: completeAddress.partialAddress
|
|
206
|
-
};
|
|
225
|
+
});
|
|
207
226
|
}
|
|
208
227
|
async getCompleteAddressOrFail(account) {
|
|
209
228
|
const completeAddress = await this.addressStore.getCompleteAddress(account);
|
|
@@ -229,7 +248,11 @@ import { MessageLoadOracleInputs } from './message_load_oracle_inputs.js';
|
|
|
229
248
|
* @param messageHash - Hash of the message to authenticate.
|
|
230
249
|
* @returns Authentication witness for the requested message hash, or undefined if not found.
|
|
231
250
|
*/ getAuthWitness(messageHash) {
|
|
232
|
-
|
|
251
|
+
const witness = this.authWitnesses.find((w)=>w.requestHash.equals(messageHash))?.witness;
|
|
252
|
+
if (!witness) {
|
|
253
|
+
throw new Error(`Unknown auth witness for message hash ${messageHash}`);
|
|
254
|
+
}
|
|
255
|
+
return Promise.resolve(witness);
|
|
233
256
|
}
|
|
234
257
|
/**
|
|
235
258
|
* Gets some notes for a contract address and storage slot.
|
|
@@ -252,10 +275,10 @@ import { MessageLoadOracleInputs } from './message_load_oracle_inputs.js';
|
|
|
252
275
|
* @param offset - The starting index for pagination.
|
|
253
276
|
* @param status - The status of notes to fetch.
|
|
254
277
|
* @returns Array of note data.
|
|
255
|
-
*/ async getNotes(owner, storageSlot, numSelects, selectByIndexes, selectByOffsets, selectByLengths, selectValues, selectComparators, sortByIndexes, sortByOffsets, sortByLengths, sortOrder, limit, offset, status) {
|
|
278
|
+
*/ async getNotes(owner, storageSlot, numSelects, selectByIndexes, selectByOffsets, selectByLengths, selectValues, selectComparators, sortByIndexes, sortByOffsets, sortByLengths, sortOrder, limit, offset, status, maxNotes, packedHintedNoteLength) {
|
|
256
279
|
const noteService = new NoteService(this.noteStore, this.aztecNode, this.anchorBlockHeader, this.jobId);
|
|
257
|
-
const dbNotes = await noteService.getNotes(this.contractAddress, owner, storageSlot, status, this.scopes);
|
|
258
|
-
|
|
280
|
+
const dbNotes = await noteService.getNotes(this.contractAddress, owner.value, storageSlot, status, this.scopes);
|
|
281
|
+
const picked = pickNotes(dbNotes, {
|
|
259
282
|
selects: selectByIndexes.slice(0, numSelects).map((index, i)=>({
|
|
260
283
|
selector: {
|
|
261
284
|
index,
|
|
@@ -276,6 +299,11 @@ import { MessageLoadOracleInputs } from './message_load_oracle_inputs.js';
|
|
|
276
299
|
limit,
|
|
277
300
|
offset
|
|
278
301
|
});
|
|
302
|
+
return BoundedVec.from({
|
|
303
|
+
data: picked,
|
|
304
|
+
maxLength: maxNotes,
|
|
305
|
+
elementSize: packedHintedNoteLength
|
|
306
|
+
});
|
|
279
307
|
}
|
|
280
308
|
/**
|
|
281
309
|
* Check if a nullifier exists in the nullifier tree.
|
|
@@ -340,7 +368,7 @@ import { MessageLoadOracleInputs } from './message_load_oracle_inputs.js';
|
|
|
340
368
|
}
|
|
341
369
|
return this.aztecnrLogger;
|
|
342
370
|
}
|
|
343
|
-
async log(level, message, fields) {
|
|
371
|
+
async log(level, message, _fieldsSize, fields) {
|
|
344
372
|
if (!LogLevels[level]) {
|
|
345
373
|
throw new Error(`Invalid log level: ${level}`);
|
|
346
374
|
}
|
|
@@ -348,110 +376,58 @@ import { MessageLoadOracleInputs } from './message_load_oracle_inputs.js';
|
|
|
348
376
|
const logger = kind == 'aztecnr' ? await this.#getAztecnrLogger() : await this.#getContractLogger();
|
|
349
377
|
logContractMessage(logger, LogLevels[level], strippedMessage, fields);
|
|
350
378
|
}
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
const logService = this.#createLogService();
|
|
354
|
-
const logs = await logService.fetchTaggedLogs(this.contractAddress, scope);
|
|
355
|
-
await this.capsuleService.appendToCapsuleArray(this.contractAddress, pendingTaggedLogArrayBaseSlot, logs.map((log)=>log.toFields()), this.jobId, scope);
|
|
356
|
-
}
|
|
357
|
-
/** Fetches pending tagged logs into a freshly allocated ephemeral array and returns its base slot. */ async getPendingTaggedLogsV2(scope) {
|
|
379
|
+
/** Fetches pending tagged logs into a freshly allocated ephemeral array and returns it. */ async getPendingTaggedLogs(scope, providedSecrets) {
|
|
380
|
+
const secrets = providedSecrets.readAll(this.ephemeralArrayService).map((ps)=>new AppTaggingSecret(ps.secret, this.contractAddress, ps.mode));
|
|
358
381
|
const logService = this.#createLogService();
|
|
359
|
-
const logs = await logService.fetchTaggedLogs(this.contractAddress, scope);
|
|
360
|
-
return this.ephemeralArrayService
|
|
382
|
+
const logs = await logService.fetchTaggedLogs(this.contractAddress, scope, secrets);
|
|
383
|
+
return EphemeralArray.fromValues(this.ephemeralArrayService, logs);
|
|
361
384
|
}
|
|
362
385
|
#createLogService() {
|
|
363
386
|
return new LogService(this.aztecNode, this.anchorBlockHeader, this.l2TipsStore, this.keyStore, this.recipientTaggingStore, this.senderAddressBookStore, this.addressStore, this.jobId, this.logger.getBindings());
|
|
364
387
|
}
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
*
|
|
368
|
-
* Deprecated, only kept for backwards compatibility until Alpha v5 rolls out.
|
|
369
|
-
*/ async validateAndStoreEnqueuedNotesAndEvents(contractAddress, noteValidationRequestsArrayBaseSlot, eventValidationRequestsArrayBaseSlot, maxNotePackedLen, maxEventSerializedLen, scope) {
|
|
370
|
-
// TODO(#10727): allow other contracts to store notes
|
|
371
|
-
if (!this.contractAddress.equals(contractAddress)) {
|
|
372
|
-
throw new Error(`Got a note validation request from ${contractAddress}, expected ${this.contractAddress}`);
|
|
373
|
-
}
|
|
374
|
-
const noteValidationRequests = (await this.capsuleService.readCapsuleArray(contractAddress, noteValidationRequestsArrayBaseSlot, this.jobId, scope)).map((fields)=>NoteValidationRequest.fromFields(fields, maxNotePackedLen));
|
|
375
|
-
const eventValidationRequests = (await this.capsuleService.readCapsuleArray(contractAddress, eventValidationRequestsArrayBaseSlot, this.jobId, scope)).map((fields)=>EventValidationRequest.fromFields(fields, maxEventSerializedLen));
|
|
376
|
-
await this.#processValidationRequests(noteValidationRequests, eventValidationRequests, scope);
|
|
377
|
-
await this.capsuleService.setCapsuleArray(contractAddress, noteValidationRequestsArrayBaseSlot, [], this.jobId, scope);
|
|
378
|
-
await this.capsuleService.setCapsuleArray(contractAddress, eventValidationRequestsArrayBaseSlot, [], this.jobId, scope);
|
|
379
|
-
}
|
|
380
|
-
async validateAndStoreEnqueuedNotesAndEventsV2(noteValidationRequestsArrayBaseSlot, eventValidationRequestsArrayBaseSlot, maxNotePackedLen, maxEventSerializedLen, scope) {
|
|
381
|
-
const noteValidationRequests = this.ephemeralArrayService.readArrayAt(noteValidationRequestsArrayBaseSlot).map((fields)=>NoteValidationRequest.fromFields(fields, maxNotePackedLen));
|
|
382
|
-
const eventValidationRequests = this.ephemeralArrayService.readArrayAt(eventValidationRequestsArrayBaseSlot).map((fields)=>EventValidationRequest.fromFields(fields, maxEventSerializedLen));
|
|
383
|
-
await this.#processValidationRequests(noteValidationRequests, eventValidationRequests, scope);
|
|
388
|
+
async validateAndStoreEnqueuedNotesAndEvents(noteValidationRequests, eventValidationRequests, scope) {
|
|
389
|
+
await this.#processValidationRequests(noteValidationRequests.readAll(this.ephemeralArrayService), eventValidationRequests.readAll(this.ephemeralArrayService), scope);
|
|
384
390
|
}
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
*/ async #processValidationRequests(noteValidationRequests, eventValidationRequests, scope) {
|
|
391
|
+
async #processValidationRequests(noteValidationRequests, eventValidationRequests, scope) {
|
|
392
|
+
const txEffects = await this.#fetchTxEffects([
|
|
393
|
+
...noteValidationRequests.map((r)=>r.txHash),
|
|
394
|
+
...eventValidationRequests.map((r)=>r.txHash)
|
|
395
|
+
]);
|
|
391
396
|
const noteService = new NoteService(this.noteStore, this.aztecNode, this.anchorBlockHeader, this.jobId);
|
|
392
|
-
const noteStorePromises = noteValidationRequests.map((request)=>noteService.validateAndStoreNote(request.contractAddress, request.owner, request.storageSlot, request.randomness, request.noteNonce, request.content, request.noteHash, request.nullifier, request.txHash, scope));
|
|
393
397
|
const eventService = new EventService(this.anchorBlockHeader, this.aztecNode, this.privateEventStore, this.jobId);
|
|
394
|
-
const eventStorePromises = eventValidationRequests.map((request)=>eventService.validateAndStoreEvent(request.contractAddress, request.eventTypeId, request.randomness, request.serializedEvent, request.eventCommitment, request.txHash, scope));
|
|
395
398
|
await Promise.all([
|
|
396
|
-
|
|
397
|
-
|
|
399
|
+
noteService.validateAndStoreNotes(noteValidationRequests, scope, txEffects),
|
|
400
|
+
eventService.validateAndStoreEvents(eventValidationRequests, scope, txEffects)
|
|
398
401
|
]);
|
|
399
402
|
}
|
|
400
|
-
async getLogsByTag(
|
|
401
|
-
|
|
402
|
-
if (!this.contractAddress.equals(contractAddress)) {
|
|
403
|
-
throw new Error(`Got a note validation request from ${contractAddress}, expected ${this.contractAddress}`);
|
|
404
|
-
}
|
|
405
|
-
// We read all log retrieval requests and process them all concurrently. This makes the process much faster as we
|
|
406
|
-
// don't need to wait for the network round-trip.
|
|
407
|
-
const logRetrievalRequests = (await this.capsuleService.readCapsuleArray(contractAddress, logRetrievalRequestsArrayBaseSlot, this.jobId, scope)).map(LogRetrievalRequest.fromFields);
|
|
408
|
-
const logService = this.#createLogService();
|
|
409
|
-
const maybeLogRetrievalResponses = await logService.fetchLogsByTag(contractAddress, logRetrievalRequests);
|
|
410
|
-
// Requests are cleared once we're done.
|
|
411
|
-
await this.capsuleService.setCapsuleArray(contractAddress, logRetrievalRequestsArrayBaseSlot, [], this.jobId, scope);
|
|
412
|
-
// The responses are stored as Option<LogRetrievalResponse> in a second CapsuleArray.
|
|
413
|
-
await this.capsuleService.setCapsuleArray(contractAddress, logRetrievalResponsesArrayBaseSlot, maybeLogRetrievalResponses.map(LogRetrievalResponse.toSerializedOption), this.jobId, scope);
|
|
414
|
-
}
|
|
415
|
-
async getLogsByTagV2(requestArrayBaseSlot) {
|
|
416
|
-
const logRetrievalRequests = this.ephemeralArrayService.readArrayAt(requestArrayBaseSlot).map(LogRetrievalRequest.fromFields);
|
|
403
|
+
async getLogsByTag(requests) {
|
|
404
|
+
const logRetrievalRequests = requests.readAll(this.ephemeralArrayService);
|
|
417
405
|
const logService = this.#createLogService();
|
|
418
|
-
const
|
|
419
|
-
|
|
406
|
+
const logRetrievalResponses = await logService.fetchLogsByTag(this.contractAddress, logRetrievalRequests);
|
|
407
|
+
// Create an inner ephemeral array for each request's matching logs, then wrap all slots in an outer array.
|
|
408
|
+
const innerArrays = logRetrievalResponses.map((responses)=>EphemeralArray.fromValues(this.ephemeralArrayService, responses));
|
|
409
|
+
return EphemeralArray.fromValues(this.ephemeralArrayService, innerArrays);
|
|
420
410
|
}
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
}
|
|
427
|
-
// TODO(@mverzilli): this is a prime example of where using an ephemeral array would make much more sense, we don't
|
|
428
|
-
// need scopes here, we just need a bit of shared memory to cross boundaries between Noir and TS.
|
|
429
|
-
// At the same time, we don't want to allow any global scope access other than where backwards compatibility
|
|
430
|
-
// forces us to. Hence we need the scope here to be artificial.
|
|
431
|
-
const requestCapsules = await this.capsuleService.readCapsuleArray(contractAddress, messageContextRequestsArrayBaseSlot, this.jobId, scope);
|
|
432
|
-
const txHashes = requestCapsules.map((fields, i)=>{
|
|
433
|
-
if (fields.length !== 1) {
|
|
434
|
-
throw new Error(`Malformed message context request at index ${i}: expected 1 field (tx hash), got ${fields.length}`);
|
|
435
|
-
}
|
|
436
|
-
return fields[0];
|
|
437
|
-
});
|
|
438
|
-
const maybeMessageContexts = await this.messageContextService.getMessageContextsByTxHash(txHashes, this.anchorBlockHeader.getBlockNumber());
|
|
439
|
-
// Leave response in response capsule array.
|
|
440
|
-
await this.capsuleService.setCapsuleArray(contractAddress, messageContextResponsesArrayBaseSlot, maybeMessageContexts.map(MessageContext.toSerializedOption), this.jobId, scope);
|
|
441
|
-
} finally{
|
|
442
|
-
await this.capsuleService.setCapsuleArray(contractAddress, messageContextRequestsArrayBaseSlot, [], this.jobId, scope);
|
|
443
|
-
}
|
|
411
|
+
/** Reads tx hash requests from an ephemeral array, resolves their contexts, and returns the response array. */ async getMessageContextsByTxHash(requests) {
|
|
412
|
+
const txHashes = requests.readAll(this.ephemeralArrayService);
|
|
413
|
+
const maybeMessageContexts = await this.messageContextService.getMessageContextsByTxHash(txHashes, this.anchorBlockHeader.getBlockNumber());
|
|
414
|
+
const options = maybeMessageContexts.map((mc)=>mc ? Option.some(mc) : Option.none(MessageContext.empty()));
|
|
415
|
+
return EphemeralArray.fromValues(this.ephemeralArrayService, options);
|
|
444
416
|
}
|
|
445
|
-
/**
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
417
|
+
/**
|
|
418
|
+
* Fetches the effects of a transaction by its hash. Returns null if the tx is not found or is beyond the anchor
|
|
419
|
+
* block.
|
|
420
|
+
*/ async getTxEffect(txHash) {
|
|
421
|
+
if (txHash.hash.isZero()) {
|
|
422
|
+
throw new Error('Invalid tx hash passed into aztec_utl_getTxEffect oracle handler');
|
|
423
|
+
}
|
|
424
|
+
const receipt = await this.aztecNode.getTxReceipt(txHash, {
|
|
425
|
+
includeTxEffect: true
|
|
452
426
|
});
|
|
453
|
-
|
|
454
|
-
|
|
427
|
+
if (!receipt.isMined() || !receipt.txEffect || receipt.blockNumber > this.anchorBlockHeader.getBlockNumber()) {
|
|
428
|
+
return Option.none(TxEffect.empty());
|
|
429
|
+
}
|
|
430
|
+
return Option.some(receipt.txEffect);
|
|
455
431
|
}
|
|
456
432
|
setCapsule(contractAddress, slot, capsule, scope) {
|
|
457
433
|
if (!contractAddress.equals(this.contractAddress)) {
|
|
@@ -460,12 +436,13 @@ import { MessageLoadOracleInputs } from './message_load_oracle_inputs.js';
|
|
|
460
436
|
}
|
|
461
437
|
this.capsuleService.setCapsule(contractAddress, slot, capsule, this.jobId, scope);
|
|
462
438
|
}
|
|
463
|
-
getCapsule(contractAddress, slot, scope) {
|
|
439
|
+
async getCapsule(contractAddress, slot, tSize, scope) {
|
|
464
440
|
if (!contractAddress.equals(this.contractAddress)) {
|
|
465
441
|
// TODO(#10727): instead of this check that this.contractAddress is allowed to access the external DB
|
|
466
442
|
throw new Error(`Contract ${contractAddress} is not allowed to access ${this.contractAddress}'s PXE DB`);
|
|
467
443
|
}
|
|
468
|
-
|
|
444
|
+
const values = await this.capsuleService.getCapsule(contractAddress, slot, this.jobId, scope, this.capsules);
|
|
445
|
+
return values ? Option.some(values) : Option.none(new Array(tSize).fill(Fr.ZERO));
|
|
469
446
|
}
|
|
470
447
|
deleteCapsule(contractAddress, slot, scope) {
|
|
471
448
|
if (!contractAddress.equals(this.contractAddress)) {
|
|
@@ -488,27 +465,43 @@ import { MessageLoadOracleInputs } from './message_load_oracle_inputs.js';
|
|
|
488
465
|
if (!contractAddress.equals(this.contractAddress)) {
|
|
489
466
|
throw new Error(`Contract ${this.contractAddress} cannot invalidate sync cache of ${contractAddress}`);
|
|
490
467
|
}
|
|
491
|
-
this.contractSyncService.invalidateContractForScopes(contractAddress, scopes);
|
|
468
|
+
this.contractSyncService.invalidateContractForScopes(contractAddress, scopes.data);
|
|
492
469
|
}
|
|
493
470
|
// TODO(#11849): consider replacing this oracle with a pure Noir implementation of aes decryption.
|
|
494
|
-
decryptAes128(ciphertext, iv, symKey) {
|
|
495
|
-
const
|
|
496
|
-
|
|
471
|
+
async decryptAes128(ciphertext, iv, symKey) {
|
|
472
|
+
const capacity = ciphertext.maxLength;
|
|
473
|
+
try {
|
|
474
|
+
const aes128 = new Aes128();
|
|
475
|
+
const plaintext = await aes128.decryptBufferCBC(Buffer.from(ciphertext.data), iv, symKey);
|
|
476
|
+
return Option.some(BoundedVec.from({
|
|
477
|
+
data: [
|
|
478
|
+
...plaintext
|
|
479
|
+
],
|
|
480
|
+
maxLength: capacity
|
|
481
|
+
}));
|
|
482
|
+
} catch {
|
|
483
|
+
return Option.none(BoundedVec.empty({
|
|
484
|
+
maxLength: capacity
|
|
485
|
+
}));
|
|
486
|
+
}
|
|
497
487
|
}
|
|
498
488
|
/**
|
|
499
|
-
* Retrieves
|
|
500
|
-
* @param address - The address
|
|
501
|
-
* @param
|
|
489
|
+
* Retrieves app-siloed shared secrets for multiple ephemeral public keys stored in an ephemeral array.
|
|
490
|
+
* @param address - The recipient address.
|
|
491
|
+
* @param ephPks - Ephemeral array containing the serialized Points.
|
|
502
492
|
* @param contractAddress - The contract address for app-siloing (validated against execution context).
|
|
503
|
-
* @returns
|
|
504
|
-
*/ async
|
|
493
|
+
* @returns A new ephemeral array containing the computed shared secrets.
|
|
494
|
+
*/ async getSharedSecrets(address, ephPks, contractAddress) {
|
|
505
495
|
if (!contractAddress.equals(this.contractAddress)) {
|
|
506
|
-
throw new Error(`
|
|
496
|
+
throw new Error(`getSharedSecrets called with contract address ${contractAddress}, expected ${this.contractAddress}`);
|
|
507
497
|
}
|
|
508
498
|
const recipientCompleteAddress = await this.getCompleteAddressOrFail(address);
|
|
509
|
-
const
|
|
499
|
+
const ivpkMHash = await hashPublicKey(recipientCompleteAddress.publicKeys.ivpkM);
|
|
500
|
+
const ivskM = await this.keyStore.getMasterSecretKey(ivpkMHash);
|
|
510
501
|
const addressSecret = await computeAddressSecret(await recipientCompleteAddress.getPreaddress(), ivskM);
|
|
511
|
-
|
|
502
|
+
const ephPkPoints = ephPks.readAll(this.ephemeralArrayService);
|
|
503
|
+
const secrets = await Promise.all(ephPkPoints.map((ephPk)=>deriveAppSiloedSharedSecret(addressSecret, ephPk, this.contractAddress)));
|
|
504
|
+
return EphemeralArray.fromValues(this.ephemeralArrayService, secrets);
|
|
512
505
|
}
|
|
513
506
|
pushEphemeral(slot, elements) {
|
|
514
507
|
return this.ephemeralArrayService.push(slot, elements);
|
|
@@ -538,22 +531,124 @@ import { MessageLoadOracleInputs } from './message_load_oracle_inputs.js';
|
|
|
538
531
|
});
|
|
539
532
|
return Promise.resolve();
|
|
540
533
|
}
|
|
534
|
+
/** Executes another utility function from within this one and returns its serialized return values. */ async callUtilityFunction(targetContractAddress, functionSelector, args) {
|
|
535
|
+
const targetArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(targetContractAddress, functionSelector);
|
|
536
|
+
if (!targetContractAddress.equals(this.contractAddress)) {
|
|
537
|
+
const [callerInstance, targetInstance] = await Promise.all([
|
|
538
|
+
this.getContractInstance(this.contractAddress),
|
|
539
|
+
this.getContractInstance(targetContractAddress)
|
|
540
|
+
]);
|
|
541
|
+
const request = {
|
|
542
|
+
caller: this.contractAddress,
|
|
543
|
+
callerClassId: callerInstance.currentContractClassId,
|
|
544
|
+
target: targetContractAddress,
|
|
545
|
+
targetClassId: targetInstance.currentContractClassId,
|
|
546
|
+
functionSelector,
|
|
547
|
+
functionName: targetArtifact.name,
|
|
548
|
+
args,
|
|
549
|
+
callerContext: this.callerContext
|
|
550
|
+
};
|
|
551
|
+
const response = this.hooks ? await this.hooks.authorizeUtilityCall(request) : {
|
|
552
|
+
authorized: false,
|
|
553
|
+
reason: 'No execution hooks configured'
|
|
554
|
+
};
|
|
555
|
+
if (!response.authorized) {
|
|
556
|
+
const reason = response.reason ? `: ${response.reason}` : '';
|
|
557
|
+
throw new Error(`Cross-contract utility call denied${reason}. ${this.contractAddress} attempted to call ` + `${targetContractAddress}:${functionSelector} (${targetArtifact.name}). ` + `See https://docs.aztec.network/errors/11`);
|
|
558
|
+
}
|
|
559
|
+
await this.contractSyncService.ensureContractSynced(targetContractAddress, functionSelector, this.utilityExecutor, this.anchorBlockHeader, this.jobId, this.scopes);
|
|
560
|
+
}
|
|
561
|
+
this.logger.debug(`Calling nested utility function ${targetContractAddress}:${functionSelector} from ${this.contractAddress}`);
|
|
562
|
+
const nestedOracle = new UtilityExecutionOracle({
|
|
563
|
+
contractAddress: targetContractAddress,
|
|
564
|
+
authWitnesses: this.authWitnesses,
|
|
565
|
+
capsules: this.capsules,
|
|
566
|
+
anchorBlockHeader: this.anchorBlockHeader,
|
|
567
|
+
contractStore: this.contractStore,
|
|
568
|
+
noteStore: this.noteStore,
|
|
569
|
+
keyStore: this.keyStore,
|
|
570
|
+
addressStore: this.addressStore,
|
|
571
|
+
aztecNode: this.aztecNode,
|
|
572
|
+
recipientTaggingStore: this.recipientTaggingStore,
|
|
573
|
+
senderAddressBookStore: this.senderAddressBookStore,
|
|
574
|
+
capsuleService: this.capsuleService,
|
|
575
|
+
privateEventStore: this.privateEventStore,
|
|
576
|
+
messageContextService: this.messageContextService,
|
|
577
|
+
contractSyncService: this.contractSyncService,
|
|
578
|
+
l2TipsStore: this.l2TipsStore,
|
|
579
|
+
jobId: this.jobId,
|
|
580
|
+
scopes: this.scopes,
|
|
581
|
+
simulator: this.simulator,
|
|
582
|
+
hooks: this.hooks,
|
|
583
|
+
utilityExecutor: this.utilityExecutor,
|
|
584
|
+
log: this.logger
|
|
585
|
+
});
|
|
586
|
+
const initialWitness = toACVMWitness(0, args);
|
|
587
|
+
const acvmCallback = new Oracle(nestedOracle);
|
|
588
|
+
const acirExecutionResult = await this.simulator.executeUserCircuit(initialWitness, targetArtifact, acvmCallback.toACIRCallback()).catch((err)=>{
|
|
589
|
+
err.message = resolveAssertionMessageFromError(err, targetArtifact);
|
|
590
|
+
throw new ExecutionError(err.message, {
|
|
591
|
+
contractAddress: targetContractAddress,
|
|
592
|
+
functionSelector
|
|
593
|
+
}, extractCallStack(err, targetArtifact.debug), {
|
|
594
|
+
cause: err
|
|
595
|
+
});
|
|
596
|
+
});
|
|
597
|
+
return witnessMapToFields(acirExecutionResult.returnWitness);
|
|
598
|
+
}
|
|
541
599
|
/** Returns offchain effects collected during execution. */ getOffchainEffects() {
|
|
542
600
|
return this.offchainEffects;
|
|
543
601
|
}
|
|
602
|
+
/**
|
|
603
|
+
* Fetches tx effects for the given hashes in parallel, deduplicating repeated hashes so each tx is only requested
|
|
604
|
+
* once. Returns a map keyed by `TxHash.toString()`; hashes for which the node has no tx effect are omitted.
|
|
605
|
+
*/ async #fetchTxEffects(txHashes) {
|
|
606
|
+
const uniqueTxHashes = uniqueBy(txHashes, (h)=>h.toString());
|
|
607
|
+
const fetched = await Promise.all(uniqueTxHashes.map((h)=>this.aztecNode.getTxReceipt(h, {
|
|
608
|
+
includeTxEffect: true
|
|
609
|
+
})));
|
|
610
|
+
return new Map(uniqueTxHashes.map((h, i)=>{
|
|
611
|
+
const receipt = fetched[i];
|
|
612
|
+
if (!receipt.isMined() || !receipt.txEffect) {
|
|
613
|
+
return [
|
|
614
|
+
h.toString(),
|
|
615
|
+
undefined
|
|
616
|
+
];
|
|
617
|
+
}
|
|
618
|
+
return [
|
|
619
|
+
h.toString(),
|
|
620
|
+
{
|
|
621
|
+
data: receipt.txEffect,
|
|
622
|
+
l2BlockNumber: receipt.blockNumber,
|
|
623
|
+
l2BlockHash: receipt.blockHash,
|
|
624
|
+
txIndexInBlock: receipt.txIndexInBlock,
|
|
625
|
+
slotNumber: receipt.slotNumber
|
|
626
|
+
}
|
|
627
|
+
];
|
|
628
|
+
}).filter((entry)=>entry[1] !== undefined));
|
|
629
|
+
}
|
|
544
630
|
/** Runs a query concurrently with a validation that the block hash is not ahead of the anchor block. */ async #queryWithBlockHashNotAfterAnchor(blockHash, query) {
|
|
631
|
+
// Most contracts query state at the "current" block, which is the anchor. Skip the validation when we can.
|
|
632
|
+
const anchorHash = await this.anchorBlockHeader.hash();
|
|
633
|
+
if (blockHash.equals(anchorHash)) {
|
|
634
|
+
return query();
|
|
635
|
+
}
|
|
545
636
|
const [response] = await Promise.all([
|
|
546
637
|
query(),
|
|
547
638
|
(async ()=>{
|
|
548
|
-
const
|
|
639
|
+
const block = await this.aztecNode.getBlock(blockHash);
|
|
640
|
+
const header = block?.header;
|
|
549
641
|
if (!header) {
|
|
550
642
|
throw new Error(`Could not find block header for block hash ${blockHash}`);
|
|
551
643
|
}
|
|
552
644
|
if (header.getBlockNumber() > this.anchorBlockHeader.getBlockNumber()) {
|
|
553
|
-
throw new Error(`Made a node query with a reference block hash ${blockHash} with block number ${header.getBlockNumber()}, which is ahead of the anchor block number ${this.anchorBlockHeader.getBlockNumber()} (from anchor block hash ${
|
|
645
|
+
throw new Error(`Made a node query with a reference block hash ${blockHash} with block number ${header.getBlockNumber()}, which is ahead of the anchor block number ${this.anchorBlockHeader.getBlockNumber()} (from anchor block hash ${anchorHash}).`);
|
|
554
646
|
}
|
|
555
647
|
})()
|
|
556
648
|
]);
|
|
557
649
|
return response;
|
|
558
650
|
}
|
|
651
|
+
/** The execution context of the current call. */ get callerContext() {
|
|
652
|
+
return 'utility';
|
|
653
|
+
}
|
|
559
654
|
}
|
|
@@ -3,4 +3,4 @@ import type { ContractStore } from '../storage/contract_store/contract_store.js'
|
|
|
3
3
|
export declare class ProxiedContractStoreFactory {
|
|
4
4
|
static create(contractStore: ContractStore, overrides?: ContractOverrides): ContractStore;
|
|
5
5
|
}
|
|
6
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
6
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJveGllZF9jb250cmFjdF9kYXRhX3NvdXJjZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2NvbnRyYWN0X2Z1bmN0aW9uX3NpbXVsYXRvci9wcm94aWVkX2NvbnRyYWN0X2RhdGFfc291cmNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUVBLE9BQU8sS0FBSyxFQUFFLGlCQUFpQixFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFFMUQsT0FBTyxLQUFLLEVBQUUsYUFBYSxFQUFFLE1BQU0sNkNBQTZDLENBQUM7QUFjakYscUJBQWEsMkJBQTJCO0lBQ3RDLE1BQU0sQ0FBQyxNQUFNLENBQUMsYUFBYSxFQUFFLGFBQWEsRUFBRSxTQUFTLENBQUMsRUFBRSxpQkFBaUIsaUJBdUN4RTtDQUNGIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxied_contract_data_source.d.ts","sourceRoot":"","sources":["../../src/contract_function_simulator/proxied_contract_data_source.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAE1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;
|
|
1
|
+
{"version":3,"file":"proxied_contract_data_source.d.ts","sourceRoot":"","sources":["../../src/contract_function_simulator/proxied_contract_data_source.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAE1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AAcjF,qBAAa,2BAA2B;IACtC,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,aAAa,EAAE,SAAS,CAAC,EAAE,iBAAiB,iBAuCxE;CACF"}
|