@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
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AztecAsyncArray,
|
|
3
|
+
AztecAsyncCounter,
|
|
4
|
+
AztecAsyncKVStore,
|
|
5
|
+
AztecAsyncMap,
|
|
6
|
+
AztecAsyncMultiMap,
|
|
7
|
+
AztecAsyncSet,
|
|
8
|
+
AztecAsyncSingleton,
|
|
9
|
+
Key,
|
|
10
|
+
} from '@aztec/kv-store';
|
|
11
|
+
|
|
12
|
+
type Value = NonNullable<any>;
|
|
13
|
+
|
|
14
|
+
/** The kind of named sub-store opened on an `AztecAsyncKVStore`. */
|
|
15
|
+
export type StoreKind = 'map' | 'multimap' | 'array' | 'singleton' | 'set' | 'counter';
|
|
16
|
+
|
|
17
|
+
/** A single recorded `open*()` call against a spied store. */
|
|
18
|
+
export interface OpenedStoreEntry {
|
|
19
|
+
name: string;
|
|
20
|
+
kind: StoreKind;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** A spied `AztecAsyncKVStore` together with a function that returns the sorted log of `open*()` calls. */
|
|
24
|
+
export interface StoreSpy {
|
|
25
|
+
store: AztecAsyncKVStore;
|
|
26
|
+
getOpenedStores: () => OpenedStoreEntry[];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Wraps an `AztecAsyncKVStore` so every `openMap`/`openMultiMap`/`openArray`/`openSingleton`/`openSet`/`openCounter`
|
|
31
|
+
* call is recorded before being delegated to the inner store.
|
|
32
|
+
*/
|
|
33
|
+
export function createStoreSpy(inner: AztecAsyncKVStore): StoreSpy {
|
|
34
|
+
const entries: OpenedStoreEntry[] = [];
|
|
35
|
+
|
|
36
|
+
const store: AztecAsyncKVStore = {
|
|
37
|
+
openMap<K extends Key, V extends Value>(name: string): AztecAsyncMap<K, V> {
|
|
38
|
+
entries.push({ name, kind: 'map' });
|
|
39
|
+
return inner.openMap<K, V>(name);
|
|
40
|
+
},
|
|
41
|
+
openMultiMap<K extends Key, V extends Value>(name: string): AztecAsyncMultiMap<K, V> {
|
|
42
|
+
entries.push({ name, kind: 'multimap' });
|
|
43
|
+
return inner.openMultiMap<K, V>(name);
|
|
44
|
+
},
|
|
45
|
+
openArray<T extends Value>(name: string): AztecAsyncArray<T> {
|
|
46
|
+
entries.push({ name, kind: 'array' });
|
|
47
|
+
return inner.openArray<T>(name);
|
|
48
|
+
},
|
|
49
|
+
openSingleton<T extends Value>(name: string): AztecAsyncSingleton<T> {
|
|
50
|
+
entries.push({ name, kind: 'singleton' });
|
|
51
|
+
return inner.openSingleton<T>(name);
|
|
52
|
+
},
|
|
53
|
+
openSet<K extends Key>(name: string): AztecAsyncSet<K> {
|
|
54
|
+
entries.push({ name, kind: 'set' });
|
|
55
|
+
return inner.openSet<K>(name);
|
|
56
|
+
},
|
|
57
|
+
openCounter<K extends Key>(name: string): AztecAsyncCounter<K> {
|
|
58
|
+
entries.push({ name, kind: 'counter' });
|
|
59
|
+
return inner.openCounter<K>(name);
|
|
60
|
+
},
|
|
61
|
+
transactionAsync: callback => inner.transactionAsync(callback),
|
|
62
|
+
clear: () => inner.clear(),
|
|
63
|
+
delete: () => inner.delete(),
|
|
64
|
+
estimateSize: () => inner.estimateSize(),
|
|
65
|
+
close: () => inner.close(),
|
|
66
|
+
backupTo: (dstPath, compact) => inner.backupTo(dstPath, compact),
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const getOpenedStores = () =>
|
|
70
|
+
[...entries].sort((a, b) => (a.name === b.name ? a.kind.localeCompare(b.kind) : a.name.localeCompare(b.name)));
|
|
71
|
+
|
|
72
|
+
return { store, getOpenedStores };
|
|
73
|
+
}
|
|
@@ -7,7 +7,6 @@ import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
|
|
|
7
7
|
import {
|
|
8
8
|
type ContractArtifact,
|
|
9
9
|
type FunctionAbi,
|
|
10
|
-
type FunctionArtifact,
|
|
11
10
|
type FunctionArtifactWithContractName,
|
|
12
11
|
FunctionCall,
|
|
13
12
|
type FunctionDebugMetadata,
|
|
@@ -16,6 +15,8 @@ import {
|
|
|
16
15
|
contractArtifactFromBuffer,
|
|
17
16
|
contractArtifactToBuffer,
|
|
18
17
|
encodeArguments,
|
|
18
|
+
findFunctionAbiBySelector,
|
|
19
|
+
findFunctionArtifactBySelector,
|
|
19
20
|
getFunctionDebugMetadata,
|
|
20
21
|
} from '@aztec/stdlib/abi';
|
|
21
22
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
@@ -290,7 +291,7 @@ export class ContractStore {
|
|
|
290
291
|
if (!artifact) {
|
|
291
292
|
return undefined;
|
|
292
293
|
}
|
|
293
|
-
const fn = await
|
|
294
|
+
const fn = await findFunctionArtifactBySelector(artifact, selector);
|
|
294
295
|
return fn && { ...fn, contractName: artifact.name };
|
|
295
296
|
}
|
|
296
297
|
|
|
@@ -322,7 +323,7 @@ export class ContractStore {
|
|
|
322
323
|
selector: FunctionSelector,
|
|
323
324
|
): Promise<FunctionAbi | undefined> {
|
|
324
325
|
const artifact = await this.#getArtifactByAddress(contractAddress);
|
|
325
|
-
return artifact && (await
|
|
326
|
+
return artifact && (await findFunctionAbiBySelector(artifact, selector));
|
|
326
327
|
}
|
|
327
328
|
|
|
328
329
|
/**
|
|
@@ -340,7 +341,7 @@ export class ContractStore {
|
|
|
340
341
|
if (!artifact) {
|
|
341
342
|
return undefined;
|
|
342
343
|
}
|
|
343
|
-
const fn = await
|
|
344
|
+
const fn = await findFunctionArtifactBySelector(artifact, selector);
|
|
344
345
|
return fn && getFunctionDebugMetadata(artifact, fn);
|
|
345
346
|
}
|
|
346
347
|
|
|
@@ -374,34 +375,10 @@ export class ContractStore {
|
|
|
374
375
|
|
|
375
376
|
public async getDebugFunctionName(contractAddress: AztecAddress, selector: FunctionSelector) {
|
|
376
377
|
const artifact = await this.#getArtifactByAddress(contractAddress);
|
|
377
|
-
const fn = artifact && (await
|
|
378
|
+
const fn = artifact && (await findFunctionAbiBySelector(artifact, selector));
|
|
378
379
|
return `${artifact?.name ?? contractAddress}:${fn?.name ?? selector}`;
|
|
379
380
|
}
|
|
380
381
|
|
|
381
|
-
async #findFunctionArtifactBySelector(
|
|
382
|
-
artifact: ContractArtifact,
|
|
383
|
-
selector: FunctionSelector,
|
|
384
|
-
): Promise<FunctionArtifact | undefined> {
|
|
385
|
-
for (const fn of artifact.functions) {
|
|
386
|
-
const fnSelector = await FunctionSelector.fromNameAndParameters(fn.name, fn.parameters);
|
|
387
|
-
if (fnSelector.equals(selector)) {
|
|
388
|
-
return fn;
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
async #findFunctionAbiBySelector(
|
|
394
|
-
artifact: ContractArtifact,
|
|
395
|
-
selector: FunctionSelector,
|
|
396
|
-
): Promise<FunctionAbi | undefined> {
|
|
397
|
-
for (const fn of [...artifact.functions, ...(artifact.nonDispatchPublicFunctions ?? [])]) {
|
|
398
|
-
const fnSelector = await FunctionSelector.fromNameAndParameters(fn.name, fn.parameters);
|
|
399
|
-
if (fnSelector.equals(selector)) {
|
|
400
|
-
return fn;
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
|
|
405
382
|
public async getFunctionCall(functionName: string, args: any[], to: AztecAddress): Promise<FunctionCall> {
|
|
406
383
|
const contract = await this.getContract(to);
|
|
407
384
|
if (!contract) {
|
package/src/storage/metadata.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const PXE_DATA_SCHEMA_VERSION =
|
|
1
|
+
export const PXE_DATA_SCHEMA_VERSION = 6;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { KeyStore } from '@aztec/key-store';
|
|
2
|
+
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
3
|
+
import { L2TipsKVStore } from '@aztec/kv-store/stores';
|
|
4
|
+
import type { BlockHash } from '@aztec/stdlib/block';
|
|
5
|
+
|
|
6
|
+
import { AddressStore } from './address_store/address_store.js';
|
|
7
|
+
import { AnchorBlockStore } from './anchor_block_store/anchor_block_store.js';
|
|
8
|
+
import { CapsuleStore } from './capsule_store/capsule_store.js';
|
|
9
|
+
import { ContractStore } from './contract_store/contract_store.js';
|
|
10
|
+
import { NoteStore } from './note_store/note_store.js';
|
|
11
|
+
import { PrivateEventStore } from './private_event_store/private_event_store.js';
|
|
12
|
+
import { RecipientTaggingStore, SenderAddressBookStore, SenderTaggingStore } from './tagging_store/index.js';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The set of sub-stores opened against a single `AztecAsyncKVStore` to back PXE state.
|
|
16
|
+
*/
|
|
17
|
+
export type PxeStores = {
|
|
18
|
+
addressStore: AddressStore;
|
|
19
|
+
privateEventStore: PrivateEventStore;
|
|
20
|
+
contractStore: ContractStore;
|
|
21
|
+
noteStore: NoteStore;
|
|
22
|
+
anchorBlockStore: AnchorBlockStore;
|
|
23
|
+
senderTaggingStore: SenderTaggingStore;
|
|
24
|
+
senderAddressBookStore: SenderAddressBookStore;
|
|
25
|
+
recipientTaggingStore: RecipientTaggingStore;
|
|
26
|
+
capsuleStore: CapsuleStore;
|
|
27
|
+
keyStore: KeyStore;
|
|
28
|
+
l2TipsStore: L2TipsKVStore;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Opens every PXE sub-store against the given backing store. The `initialBlockHash` seeds the
|
|
33
|
+
* `L2TipsKVStore` so it agrees with the node's archiver on the dynamic genesis header hash.
|
|
34
|
+
*/
|
|
35
|
+
export function openPxeStores(store: AztecAsyncKVStore, initialBlockHash: BlockHash): PxeStores {
|
|
36
|
+
return {
|
|
37
|
+
addressStore: new AddressStore(store),
|
|
38
|
+
privateEventStore: new PrivateEventStore(store),
|
|
39
|
+
contractStore: new ContractStore(store),
|
|
40
|
+
noteStore: new NoteStore(store),
|
|
41
|
+
anchorBlockStore: new AnchorBlockStore(store),
|
|
42
|
+
senderTaggingStore: new SenderTaggingStore(store),
|
|
43
|
+
senderAddressBookStore: new SenderAddressBookStore(store),
|
|
44
|
+
recipientTaggingStore: new RecipientTaggingStore(store),
|
|
45
|
+
capsuleStore: new CapsuleStore(store),
|
|
46
|
+
keyStore: new KeyStore(store),
|
|
47
|
+
l2TipsStore: new L2TipsKVStore(store, 'pxe', initialBlockHash),
|
|
48
|
+
};
|
|
49
|
+
}
|
|
@@ -49,7 +49,7 @@ export class StoredPrivateEvent {
|
|
|
49
49
|
const msgContentLength = reader.readNumber();
|
|
50
50
|
const msgContent = reader.readArray(msgContentLength, Fr);
|
|
51
51
|
const l2BlockNumber = reader.readNumber();
|
|
52
|
-
const l2BlockHash =
|
|
52
|
+
const l2BlockHash = BlockHash.fromBuffer(reader);
|
|
53
53
|
const txHash = TxHash.fromBuffer(reader);
|
|
54
54
|
const txIndexInBlock = reader.readNumber();
|
|
55
55
|
const eventIndexInTx = reader.readNumber();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
|
|
2
|
-
import type {
|
|
2
|
+
import type { AppTaggingSecret } from '@aztec/stdlib/logs';
|
|
3
3
|
|
|
4
4
|
import type { StagedStore } from '../../job_coordinator/job_coordinator.js';
|
|
5
5
|
|
|
@@ -106,11 +106,11 @@ export class RecipientTaggingStore implements StagedStore {
|
|
|
106
106
|
return Promise.resolve();
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
getHighestAgedIndex(secret:
|
|
109
|
+
getHighestAgedIndex(secret: AppTaggingSecret, jobId: string): Promise<number | undefined> {
|
|
110
110
|
return this.#store.transactionAsync(() => this.#readHighestAgedIndex(jobId, secret.toString()));
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
updateHighestAgedIndex(secret:
|
|
113
|
+
updateHighestAgedIndex(secret: AppTaggingSecret, index: number, jobId: string): Promise<void> {
|
|
114
114
|
return this.#store.transactionAsync(async () => {
|
|
115
115
|
const currentIndex = await this.#readHighestAgedIndex(jobId, secret.toString());
|
|
116
116
|
if (currentIndex !== undefined && index <= currentIndex) {
|
|
@@ -121,15 +121,11 @@ export class RecipientTaggingStore implements StagedStore {
|
|
|
121
121
|
});
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
getHighestFinalizedIndex(secret:
|
|
124
|
+
getHighestFinalizedIndex(secret: AppTaggingSecret, jobId: string): Promise<number | undefined> {
|
|
125
125
|
return this.#store.transactionAsync(() => this.#readHighestFinalizedIndex(jobId, secret.toString()));
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
-
updateHighestFinalizedIndex(
|
|
129
|
-
secret: ExtendedDirectionalAppTaggingSecret,
|
|
130
|
-
index: number,
|
|
131
|
-
jobId: string,
|
|
132
|
-
): Promise<void> {
|
|
128
|
+
updateHighestFinalizedIndex(secret: AppTaggingSecret, index: number, jobId: string): Promise<void> {
|
|
133
129
|
return this.#store.transactionAsync(async () => {
|
|
134
130
|
const currentIndex = await this.#readHighestFinalizedIndex(jobId, secret.toString());
|
|
135
131
|
if (currentIndex !== undefined && index < currentIndex) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
|
|
2
|
-
import {
|
|
2
|
+
import { AppTaggingSecret, SiloedTag, type TaggingIndexRange } from '@aztec/stdlib/logs';
|
|
3
3
|
import { TxEffect, TxHash } from '@aztec/stdlib/tx';
|
|
4
4
|
|
|
5
5
|
import type { StagedStore } from '../../job_coordinator/job_coordinator.js';
|
|
@@ -218,7 +218,7 @@ export class SenderTaggingStore implements StagedStore {
|
|
|
218
218
|
* [startIndex, endIndex). Returns an empty array if no pending indexes exist in the range.
|
|
219
219
|
*/
|
|
220
220
|
getTxHashesOfPendingIndexes(
|
|
221
|
-
secret:
|
|
221
|
+
secret: AppTaggingSecret,
|
|
222
222
|
startIndex: number,
|
|
223
223
|
endIndex: number,
|
|
224
224
|
jobId: string,
|
|
@@ -237,7 +237,7 @@ export class SenderTaggingStore implements StagedStore {
|
|
|
237
237
|
* @param secret - The secret to get the last finalized index for.
|
|
238
238
|
* @returns The last (highest) finalized index for the given secret.
|
|
239
239
|
*/
|
|
240
|
-
getLastFinalizedIndex(secret:
|
|
240
|
+
getLastFinalizedIndex(secret: AppTaggingSecret, jobId: string): Promise<number | undefined> {
|
|
241
241
|
return this.#store.transactionAsync(() => this.#readLastFinalizedIndex(jobId, secret.toString()));
|
|
242
242
|
}
|
|
243
243
|
|
|
@@ -247,7 +247,7 @@ export class SenderTaggingStore implements StagedStore {
|
|
|
247
247
|
* @param secret - The directional app tagging secret to query the last used index for.
|
|
248
248
|
* @returns The last used index.
|
|
249
249
|
*/
|
|
250
|
-
getLastUsedIndex(secret:
|
|
250
|
+
getLastUsedIndex(secret: AppTaggingSecret, jobId: string): Promise<number | undefined> {
|
|
251
251
|
const secretStr = secret.toString();
|
|
252
252
|
|
|
253
253
|
return this.#store.transactionAsync(async () => {
|
|
@@ -449,11 +449,11 @@ export class SenderTaggingStore implements StagedStore {
|
|
|
449
449
|
const pendingEntry = matchingEntries[0];
|
|
450
450
|
|
|
451
451
|
// Expand each matching entry's range and recompute siloed tags for each index.
|
|
452
|
-
const
|
|
452
|
+
const appTaggingSecret = AppTaggingSecret.fromString(secret);
|
|
453
453
|
let highestSurvivingIndex: number | undefined;
|
|
454
454
|
|
|
455
455
|
for (let index = pendingEntry.lowestIndex; index <= pendingEntry.highestIndex; index++) {
|
|
456
|
-
const siloedTag = await SiloedTag.compute({ extendedSecret, index });
|
|
456
|
+
const siloedTag = await SiloedTag.compute({ extendedSecret: appTaggingSecret, index });
|
|
457
457
|
if (onChainTags.has(siloedTag.value.toString())) {
|
|
458
458
|
highestSurvivingIndex = highestSurvivingIndex !== undefined ? Math.max(highestSurvivingIndex, index) : index;
|
|
459
459
|
}
|
|
@@ -1,49 +1,54 @@
|
|
|
1
|
+
import type { BlockNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
2
3
|
import type { BlockHash } from '@aztec/stdlib/block';
|
|
3
|
-
import {
|
|
4
|
+
import { MAX_RPC_LEN } from '@aztec/stdlib/interfaces/api-limit';
|
|
4
5
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
5
|
-
import
|
|
6
|
+
import {
|
|
7
|
+
type LogIncludeOptions,
|
|
8
|
+
type LogResult,
|
|
9
|
+
type SiloedTag,
|
|
10
|
+
type Tag,
|
|
11
|
+
queryAllPrivateLogsByTags,
|
|
12
|
+
queryAllPublicLogsByTags,
|
|
13
|
+
} from '@aztec/stdlib/logs';
|
|
14
|
+
|
|
15
|
+
/** Optional block-range, effects opt-in, and pagination cap shared by both wrappers. */
|
|
16
|
+
export type GetAllLogsByTagsOptions = {
|
|
17
|
+
/** Lower block bound, inclusive. */
|
|
18
|
+
fromBlock?: BlockNumber;
|
|
19
|
+
/** Upper block bound, exclusive. */
|
|
20
|
+
toBlock?: BlockNumber;
|
|
21
|
+
/**
|
|
22
|
+
* When set, each log also carries `noteHashes` and all `nullifiers` of its tx. Defaults to off — sender
|
|
23
|
+
* sync only needs `txHash`. The recipient-sync/log-service paths flip this on to build `PendingTaggedLog`
|
|
24
|
+
* / `LogRetrievalResponse` from note data.
|
|
25
|
+
*/
|
|
26
|
+
includeEffects?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Maximum number of logs returned per tag per round-trip. Capped at `MAX_LOGS_PER_TAG` on the node
|
|
29
|
+
* (rejected if higher). Defaults to `MAX_LOGS_PER_TAG`. Mainly useful for tests that need to force
|
|
30
|
+
* pagination at a small page size.
|
|
31
|
+
*/
|
|
32
|
+
limitPerTag?: number;
|
|
33
|
+
};
|
|
6
34
|
|
|
7
35
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* @param fetchPage - Function that fetches a single page of results given a page number.
|
|
11
|
-
* @returns An array of arrays, one per tag, containing all results across all pages.
|
|
36
|
+
* Splits tags into chunks of MAX_RPC_LEN, paginates each chunk via the stdlib per-tag cursor helper,
|
|
37
|
+
* then stitches the results back into a single array preserving the original tag order.
|
|
12
38
|
*/
|
|
13
|
-
async function
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const resultsPage = await fetchPage(page);
|
|
20
|
-
hasMore = false;
|
|
21
|
-
|
|
22
|
-
for (let i = 0; i < resultsPage.length; i++) {
|
|
23
|
-
allResultsPerTag[i].push(...resultsPage[i]);
|
|
24
|
-
if (resultsPage[i].length === MAX_LOGS_PER_TAG) {
|
|
25
|
-
hasMore = true;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
page++;
|
|
39
|
+
async function getAllPagesInBatches<T extends Tag | SiloedTag, Opts extends LogIncludeOptions>(
|
|
40
|
+
tags: T[],
|
|
41
|
+
fetchAllPagesForBatch: (batch: T[]) => Promise<LogResult<Opts>[][]>,
|
|
42
|
+
): Promise<LogResult<Opts>[][]> {
|
|
43
|
+
if (tags.length === 0) {
|
|
44
|
+
return [];
|
|
29
45
|
}
|
|
30
46
|
|
|
31
|
-
return allResultsPerTag;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Splits tags into chunks of MAX_RPC_LEN, fetches logs for each chunk using getAllPages, then stitches the results
|
|
36
|
-
* back into a single array preserving the original tag order.
|
|
37
|
-
*/
|
|
38
|
-
async function getAllPagesInBatches<Tag, T>(
|
|
39
|
-
tags: Tag[],
|
|
40
|
-
fetchAllPagesForBatch: (batch: Tag[]) => Promise<T[][]>,
|
|
41
|
-
): Promise<T[][]> {
|
|
42
47
|
if (tags.length <= MAX_RPC_LEN) {
|
|
43
48
|
return fetchAllPagesForBatch(tags);
|
|
44
49
|
}
|
|
45
50
|
|
|
46
|
-
const batches:
|
|
51
|
+
const batches: T[][] = [];
|
|
47
52
|
for (let i = 0; i < tags.length; i += MAX_RPC_LEN) {
|
|
48
53
|
batches.push(tags.slice(i, i + MAX_RPC_LEN));
|
|
49
54
|
}
|
|
@@ -52,41 +57,64 @@ async function getAllPagesInBatches<Tag, T>(
|
|
|
52
57
|
}
|
|
53
58
|
|
|
54
59
|
/**
|
|
55
|
-
* Fetches all private logs for the given tags, automatically paginating
|
|
60
|
+
* Fetches all private logs for the given tags, automatically paginating per-tag via `afterLog` cursors.
|
|
61
|
+
*
|
|
56
62
|
* @param aztecNode - The Aztec node to query.
|
|
57
63
|
* @param tags - The siloed tags to search for.
|
|
58
|
-
* @param anchorBlockHash -
|
|
59
|
-
*
|
|
64
|
+
* @param anchorBlockHash - Reference block for the Aztec node query, throws if block is not found there (typically
|
|
65
|
+
* because of reorgs).
|
|
66
|
+
* @param options - Optional `fromBlock`/`toBlock` range and `includeEffects` opt-in.
|
|
60
67
|
* @returns An array of log arrays, one per tag, containing all logs across all pages.
|
|
61
68
|
*/
|
|
62
|
-
export function getAllPrivateLogsByTags(
|
|
69
|
+
export function getAllPrivateLogsByTags<Opts extends GetAllLogsByTagsOptions = GetAllLogsByTagsOptions>(
|
|
63
70
|
aztecNode: AztecNode,
|
|
64
71
|
tags: SiloedTag[],
|
|
65
72
|
anchorBlockHash: BlockHash,
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
73
|
+
options: Opts = {} as Opts,
|
|
74
|
+
): Promise<LogResult<Opts>[][]> {
|
|
75
|
+
return getAllPagesInBatches<SiloedTag, Opts>(
|
|
76
|
+
tags,
|
|
77
|
+
batch =>
|
|
78
|
+
queryAllPrivateLogsByTags(aztecNode, {
|
|
79
|
+
tags: batch,
|
|
80
|
+
referenceBlock: anchorBlockHash,
|
|
81
|
+
fromBlock: options.fromBlock,
|
|
82
|
+
toBlock: options.toBlock,
|
|
83
|
+
includeEffects: options.includeEffects ?? false,
|
|
84
|
+
limitPerTag: options.limitPerTag,
|
|
85
|
+
}) as Promise<LogResult<Opts>[][]>,
|
|
69
86
|
);
|
|
70
87
|
}
|
|
71
88
|
|
|
72
89
|
/**
|
|
73
|
-
* Fetches all public logs for the given tags from a contract, automatically paginating
|
|
90
|
+
* Fetches all public logs for the given tags from a contract, automatically paginating per-tag via `afterLog` cursors.
|
|
91
|
+
*
|
|
74
92
|
* @param aztecNode - The Aztec node to query.
|
|
75
93
|
* @param contractAddress - The contract address to search logs for.
|
|
76
94
|
* @param tags - The tags to search for.
|
|
77
|
-
* @param anchorBlockHash -
|
|
78
|
-
*
|
|
95
|
+
* @param anchorBlockHash - Reference block for the Aztec node query, throws if block is not found there (typically
|
|
96
|
+
* because of reorgs).
|
|
97
|
+
* @param options - Optional `fromBlock`/`toBlock` range and `includeEffects` opt-in.
|
|
79
98
|
* @returns An array of log arrays, one per tag, containing all logs across all pages.
|
|
80
99
|
*/
|
|
81
|
-
export function getAllPublicLogsByTagsFromContract(
|
|
100
|
+
export function getAllPublicLogsByTagsFromContract<Opts extends GetAllLogsByTagsOptions = GetAllLogsByTagsOptions>(
|
|
82
101
|
aztecNode: AztecNode,
|
|
83
102
|
contractAddress: AztecAddress,
|
|
84
103
|
tags: Tag[],
|
|
85
104
|
anchorBlockHash: BlockHash,
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
105
|
+
options: Opts = {} as Opts,
|
|
106
|
+
): Promise<LogResult<Opts>[][]> {
|
|
107
|
+
return getAllPagesInBatches<Tag, Opts>(
|
|
108
|
+
tags,
|
|
109
|
+
batch =>
|
|
110
|
+
queryAllPublicLogsByTags(aztecNode, {
|
|
111
|
+
contractAddress,
|
|
112
|
+
tags: batch,
|
|
113
|
+
referenceBlock: anchorBlockHash,
|
|
114
|
+
fromBlock: options.fromBlock,
|
|
115
|
+
toBlock: options.toBlock,
|
|
116
|
+
includeEffects: options.includeEffects ?? false,
|
|
117
|
+
limitPerTag: options.limitPerTag,
|
|
118
|
+
}) as Promise<LogResult<Opts>[][]>,
|
|
91
119
|
);
|
|
92
120
|
}
|
package/src/tagging/index.ts
CHANGED
|
@@ -4,16 +4,17 @@
|
|
|
4
4
|
* The objective of the sender sync algorithm is to determine which tags have already been used by a sender, thereby
|
|
5
5
|
* deciding which tag should be used next.
|
|
6
6
|
*
|
|
7
|
-
* The objective of the recipient sync algorithm is to
|
|
7
|
+
* The objective of the recipient sync algorithm is to fetch and sync the corresponding logs.
|
|
8
8
|
*
|
|
9
9
|
* @module tagging
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
export {
|
|
12
|
+
export { syncTaggedPrivateLogs } from './recipient_sync/sync_tagged_private_logs.js';
|
|
13
13
|
export { syncSenderTaggingIndexes } from './sender_sync/sync_sender_tagging_indexes.js';
|
|
14
|
+
export { persistSenderTaggingIndexRangesForTx } from './persist_sender_tagging_index_ranges.js';
|
|
14
15
|
export { UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN } from './constants.js';
|
|
15
16
|
export { getAllPrivateLogsByTags, getAllPublicLogsByTagsFromContract } from './get_all_logs_by_tags.js';
|
|
16
17
|
|
|
17
18
|
// Re-export tagging-related types from stdlib
|
|
18
|
-
export {
|
|
19
|
+
export { AppTaggingSecret, Tag, SiloedTag } from '@aztec/stdlib/logs';
|
|
19
20
|
export { type PreTag, type TaggingIndexRange } from '@aztec/stdlib/logs';
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { Logger } from '@aztec/foundation/log';
|
|
2
|
+
import type { PrivateKernelTailCircuitPublicInputs } from '@aztec/stdlib/kernel';
|
|
3
|
+
import type { TaggingIndexRange } from '@aztec/stdlib/logs';
|
|
4
|
+
import type { TxHash } from '@aztec/stdlib/tx';
|
|
5
|
+
|
|
6
|
+
import type { SenderTaggingStore } from '../storage/tagging_store/sender_tagging_store.js';
|
|
7
|
+
import { reconcileTaggingIndexRangesAgainstSurvivingTags } from './reconcile_tagging_index_ranges.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Persists the tagging index ranges that a tx used as a sender, after reconciling them against the kernel's surviving
|
|
11
|
+
* private logs.
|
|
12
|
+
*
|
|
13
|
+
* The tagging index cache reserves an index for every log emission attempted during private execution, but the kernel
|
|
14
|
+
* may then squash some of those logs (e.g. when a note is created and nullified within the same tx). This function
|
|
15
|
+
* shrinks the recorded ranges to match the actual on-chain footprint before writing them, so that what we persist is
|
|
16
|
+
* consistent with what the network will see.
|
|
17
|
+
*
|
|
18
|
+
* @remarks Storing the recorded ranges in the DB may not be seen as necessary because we sync from chain before sending
|
|
19
|
+
* new logs, but the sync can only see logs already included in blocks. If we sent another transaction before this one
|
|
20
|
+
* was included from the same PXE, and that transaction contained a log with a tag derived from the same secret, we
|
|
21
|
+
* would reuse the tag and the transactions would be linked. Persisting in the DB prevents that linkage.
|
|
22
|
+
*
|
|
23
|
+
* @param store - The sender tagging store.
|
|
24
|
+
* @param recordedRanges - The tagging index ranges as recorded during private execution (pre-squash).
|
|
25
|
+
* @param publicInputs - The final kernel public inputs, used to determine which private logs survived squashing.
|
|
26
|
+
* @param getTxHash - Lazy accessor for the tx hash. Called only when there is something to persist, since computing
|
|
27
|
+
* the tx hash is expensive.
|
|
28
|
+
* @param jobId - Job context for staged writes to the store. See `JobCoordinator` for more details.
|
|
29
|
+
* @param log - Logger.
|
|
30
|
+
*/
|
|
31
|
+
export async function persistSenderTaggingIndexRangesForTx(
|
|
32
|
+
store: SenderTaggingStore,
|
|
33
|
+
recordedRanges: TaggingIndexRange[],
|
|
34
|
+
publicInputs: PrivateKernelTailCircuitPublicInputs,
|
|
35
|
+
getTxHash: () => Promise<TxHash>,
|
|
36
|
+
jobId: string,
|
|
37
|
+
log: Logger,
|
|
38
|
+
): Promise<void> {
|
|
39
|
+
if (recordedRanges.length === 0) {
|
|
40
|
+
log.debug(`No tagging index ranges used in the tx`);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const survivingTags = new Set(
|
|
45
|
+
publicInputs.getNonEmptyPrivateLogs().map(privateLog => privateLog.fields[0].toString()),
|
|
46
|
+
);
|
|
47
|
+
const reconciledRanges = await reconcileTaggingIndexRangesAgainstSurvivingTags(recordedRanges, survivingTags);
|
|
48
|
+
|
|
49
|
+
if (reconciledRanges.length === 0) {
|
|
50
|
+
log.debug(`All tagging index ranges used in the tx were squashed by the kernel`, { recordedRanges });
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const txHash = await getTxHash();
|
|
55
|
+
await store.storePendingIndexes(reconciledRanges, txHash, jobId);
|
|
56
|
+
log.debug(`Stored used tagging index ranges as sender for the tx`, { recordedRanges, reconciledRanges });
|
|
57
|
+
}
|