@aztec/pxe 3.0.0-rc.5 → 4.0.0-nightly.20260107
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/block_synchronizer/block_synchronizer.d.ts +39 -0
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -0
- package/dest/{synchronizer/synchronizer.js → block_synchronizer/block_synchronizer.js} +22 -22
- package/dest/block_synchronizer/index.d.ts +2 -0
- package/dest/block_synchronizer/index.d.ts.map +1 -0
- package/dest/block_synchronizer/index.js +1 -0
- package/dest/config/index.d.ts +4 -4
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/package_info.js +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +40 -11
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +47 -17
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +1 -1
- package/dest/contract_function_simulator/execution_tagging_index_cache.js +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +4 -3
- 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 +7 -6
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +3 -4
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.d.ts +1 -1
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +3 -3
- package/dest/contract_function_simulator/oracle/private_execution.d.ts +7 -9
- package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution.js +11 -11
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +22 -8
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +24 -12
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +47 -8
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +143 -37
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +4 -4
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -1
- package/dest/contract_function_simulator/proxied_contract_data_source.js +23 -5
- package/dest/debug/pxe_debug_utils.d.ts +31 -0
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -0
- package/dest/debug/pxe_debug_utils.js +37 -0
- package/dest/entrypoints/client/bundle/index.d.ts +1 -2
- package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.js +0 -1
- 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 +10 -1
- package/dest/entrypoints/client/lazy/index.d.ts +1 -2
- package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/index.js +0 -1
- 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 +10 -1
- package/dest/entrypoints/pxe_creation_options.d.ts +3 -2
- package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
- package/dest/entrypoints/server/index.d.ts +2 -2
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +1 -1
- package/dest/entrypoints/server/utils.d.ts +1 -1
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +11 -7
- package/dest/error_enriching.d.ts +4 -4
- package/dest/error_enriching.d.ts.map +1 -1
- package/dest/error_enriching.js +6 -6
- package/dest/events/event_service.d.ts +15 -0
- package/dest/events/event_service.d.ts.map +1 -0
- package/dest/events/event_service.js +47 -0
- package/dest/events/private_event_filter_validator.d.ts +6 -5
- package/dest/events/private_event_filter_validator.d.ts.map +1 -1
- package/dest/events/private_event_filter_validator.js +4 -4
- package/dest/logs/log_service.d.ts +26 -0
- package/dest/logs/log_service.d.ts.map +1 -0
- package/dest/logs/log_service.js +120 -0
- package/dest/notes/index.d.ts +2 -0
- package/dest/notes/index.d.ts.map +1 -0
- package/dest/notes/index.js +1 -0
- package/dest/notes/note_service.d.ts +48 -0
- package/dest/notes/note_service.d.ts.map +1 -0
- package/dest/notes/note_service.js +152 -0
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts +4 -4
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle_impl.js +7 -7
- package/dest/public_storage/public_storage_service.d.ts +24 -0
- package/dest/public_storage/public_storage_service.d.ts.map +1 -0
- package/dest/public_storage/public_storage_service.js +26 -0
- package/dest/pxe.d.ts +25 -33
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +125 -136
- package/dest/storage/address_store/address_store.d.ts +11 -0
- package/dest/storage/address_store/address_store.d.ts.map +1 -0
- package/dest/storage/{address_data_provider/address_data_provider.js → address_store/address_store.js} +1 -1
- package/dest/storage/address_store/index.d.ts +2 -0
- package/dest/storage/address_store/index.d.ts.map +1 -0
- package/dest/storage/address_store/index.js +1 -0
- package/dest/storage/{sync_data_provider/sync_data_provider.d.ts → anchor_block_store/anchor_block_store.d.ts} +2 -4
- package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -0
- package/dest/storage/{sync_data_provider/sync_data_provider.js → anchor_block_store/anchor_block_store.js} +2 -9
- package/dest/storage/{sync_data_provider → anchor_block_store}/index.d.ts +2 -2
- package/dest/storage/anchor_block_store/index.d.ts.map +1 -0
- package/dest/storage/anchor_block_store/index.js +1 -0
- package/dest/storage/capsule_store/capsule_store.d.ts +57 -0
- package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -0
- package/dest/storage/{capsule_data_provider/capsule_data_provider.js → capsule_store/capsule_store.js} +33 -5
- package/dest/storage/capsule_store/index.d.ts +2 -0
- package/dest/storage/capsule_store/index.d.ts.map +1 -0
- package/dest/storage/capsule_store/index.js +1 -0
- package/dest/storage/{contract_data_provider/contract_data_provider.d.ts → contract_store/contract_store.d.ts} +7 -4
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -0
- package/dest/storage/{contract_data_provider/contract_data_provider.js → contract_store/contract_store.js} +46 -3
- package/dest/storage/contract_store/index.d.ts +2 -0
- package/dest/storage/contract_store/index.d.ts.map +1 -0
- package/dest/storage/contract_store/index.js +1 -0
- package/dest/storage/{contract_data_provider → contract_store}/private_functions_tree.d.ts +1 -1
- package/dest/storage/contract_store/private_functions_tree.d.ts.map +1 -0
- package/dest/storage/index.d.ts +8 -8
- package/dest/storage/index.d.ts.map +1 -1
- package/dest/storage/index.js +7 -7
- package/dest/storage/note_store/index.d.ts +3 -0
- package/dest/storage/note_store/index.d.ts.map +1 -0
- package/dest/storage/note_store/index.js +2 -0
- package/dest/storage/{note_data_provider/note_data_provider.d.ts → note_store/note_store.d.ts} +7 -7
- package/dest/storage/note_store/note_store.d.ts.map +1 -0
- package/dest/storage/{note_data_provider/note_data_provider.js → note_store/note_store.js} +6 -6
- package/dest/storage/{private_event_data_provider/private_event_data_provider.d.ts → private_event_store/private_event_store.d.ts} +9 -4
- package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -0
- package/dest/storage/{private_event_data_provider/private_event_data_provider.js → private_event_store/private_event_store.js} +57 -15
- package/dest/storage/tagging_store/index.d.ts +4 -0
- package/dest/storage/tagging_store/index.d.ts.map +1 -0
- package/dest/storage/tagging_store/index.js +3 -0
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts +21 -0
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -0
- package/dest/storage/tagging_store/recipient_tagging_store.js +42 -0
- package/dest/storage/tagging_store/sender_address_book_store.d.ts +14 -0
- package/dest/storage/tagging_store/sender_address_book_store.d.ts.map +1 -0
- package/dest/storage/tagging_store/sender_address_book_store.js +30 -0
- package/dest/storage/tagging_store/sender_tagging_store.d.ts +67 -0
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -0
- package/dest/storage/tagging_store/sender_tagging_store.js +196 -0
- package/dest/tagging/index.d.ts +15 -6
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/index.js +23 -5
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +14 -0
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -0
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +99 -0
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.d.ts +12 -0
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.d.ts.map +1 -0
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +20 -0
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +14 -0
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -0
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +29 -0
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +20 -0
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -0
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +74 -0
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +11 -0
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -0
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +32 -0
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +18 -0
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -0
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +55 -0
- package/dest/tree_membership/tree_membership_service.d.ts +52 -0
- package/dest/tree_membership/tree_membership_service.d.ts.map +1 -0
- package/dest/tree_membership/tree_membership_service.js +84 -0
- package/package.json +16 -16
- package/src/{synchronizer/synchronizer.ts → block_synchronizer/block_synchronizer.ts} +21 -22
- package/src/block_synchronizer/index.ts +1 -0
- package/src/config/index.ts +3 -3
- package/src/config/package_info.ts +1 -1
- package/src/contract_function_simulator/contract_function_simulator.ts +84 -15
- package/src/contract_function_simulator/execution_tagging_index_cache.ts +1 -1
- package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +5 -4
- package/src/contract_function_simulator/oracle/interfaces.ts +2 -3
- package/src/contract_function_simulator/oracle/oracle.ts +3 -3
- package/src/contract_function_simulator/oracle/private_execution.ts +14 -13
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +89 -19
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +208 -45
- package/src/contract_function_simulator/proxied_contract_data_source.ts +24 -7
- package/src/debug/pxe_debug_utils.ts +48 -0
- package/src/entrypoints/client/bundle/index.ts +0 -1
- package/src/entrypoints/client/bundle/utils.ts +7 -1
- package/src/entrypoints/client/lazy/index.ts +0 -1
- package/src/entrypoints/client/lazy/utils.ts +7 -2
- package/src/entrypoints/pxe_creation_options.ts +2 -1
- package/src/entrypoints/server/index.ts +1 -1
- package/src/entrypoints/server/utils.ts +11 -15
- package/src/error_enriching.ts +7 -15
- package/src/events/event_service.ts +77 -0
- package/src/events/private_event_filter_validator.ts +5 -4
- package/src/logs/log_service.ts +202 -0
- package/src/notes/index.ts +1 -0
- package/src/notes/note_service.ts +200 -0
- package/src/private_kernel/private_kernel_oracle_impl.ts +6 -6
- package/src/public_storage/public_storage_service.ts +33 -0
- package/src/pxe.ts +153 -162
- package/src/storage/{address_data_provider/address_data_provider.ts → address_store/address_store.ts} +1 -1
- package/src/storage/address_store/index.ts +1 -0
- package/src/storage/{sync_data_provider/sync_data_provider.ts → anchor_block_store/anchor_block_store.ts} +2 -12
- package/src/storage/anchor_block_store/index.ts +1 -0
- package/src/storage/{capsule_data_provider/capsule_data_provider.ts → capsule_store/capsule_store.ts} +33 -1
- package/src/storage/capsule_store/index.ts +1 -0
- package/src/storage/{contract_data_provider/contract_data_provider.ts → contract_store/contract_store.ts} +64 -2
- package/src/storage/contract_store/index.ts +1 -0
- package/src/storage/index.ts +7 -7
- package/src/storage/note_store/index.ts +2 -0
- package/src/storage/{note_data_provider/note_data_provider.ts → note_store/note_store.ts} +7 -7
- package/src/storage/{private_event_data_provider/private_event_data_provider.ts → private_event_store/private_event_store.ts} +69 -18
- package/src/storage/tagging_store/index.ts +3 -0
- package/src/storage/tagging_store/recipient_tagging_store.ts +53 -0
- package/src/storage/tagging_store/sender_address_book_store.ts +42 -0
- package/src/storage/tagging_store/sender_tagging_store.ts +244 -0
- package/src/tagging/index.ts +27 -5
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +129 -0
- package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +34 -0
- package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +43 -0
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +96 -0
- package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +44 -0
- package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +72 -0
- package/src/tree_membership/tree_membership_service.ts +112 -0
- package/dest/contract_function_simulator/execution_data_provider.d.ts +0 -268
- package/dest/contract_function_simulator/execution_data_provider.d.ts.map +0 -1
- package/dest/contract_function_simulator/execution_data_provider.js +0 -14
- package/dest/contract_function_simulator/pxe_oracle_interface.d.ts +0 -124
- package/dest/contract_function_simulator/pxe_oracle_interface.d.ts.map +0 -1
- package/dest/contract_function_simulator/pxe_oracle_interface.js +0 -713
- package/dest/storage/address_data_provider/address_data_provider.d.ts +0 -11
- package/dest/storage/address_data_provider/address_data_provider.d.ts.map +0 -1
- package/dest/storage/address_data_provider/index.d.ts +0 -2
- package/dest/storage/address_data_provider/index.d.ts.map +0 -1
- package/dest/storage/address_data_provider/index.js +0 -1
- package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts +0 -25
- package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts.map +0 -1
- package/dest/storage/capsule_data_provider/index.d.ts +0 -2
- package/dest/storage/capsule_data_provider/index.d.ts.map +0 -1
- package/dest/storage/capsule_data_provider/index.js +0 -1
- package/dest/storage/contract_data_provider/contract_data_provider.d.ts.map +0 -1
- package/dest/storage/contract_data_provider/index.d.ts +0 -2
- package/dest/storage/contract_data_provider/index.d.ts.map +0 -1
- package/dest/storage/contract_data_provider/index.js +0 -1
- package/dest/storage/contract_data_provider/private_functions_tree.d.ts.map +0 -1
- package/dest/storage/note_data_provider/index.d.ts +0 -3
- package/dest/storage/note_data_provider/index.d.ts.map +0 -1
- package/dest/storage/note_data_provider/index.js +0 -2
- package/dest/storage/note_data_provider/note_data_provider.d.ts.map +0 -1
- package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts.map +0 -1
- package/dest/storage/sync_data_provider/index.d.ts.map +0 -1
- package/dest/storage/sync_data_provider/index.js +0 -1
- package/dest/storage/sync_data_provider/sync_data_provider.d.ts.map +0 -1
- package/dest/storage/tagging_data_provider/index.d.ts +0 -2
- package/dest/storage/tagging_data_provider/index.d.ts.map +0 -1
- package/dest/storage/tagging_data_provider/index.js +0 -1
- package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts +0 -40
- package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts.map +0 -1
- package/dest/storage/tagging_data_provider/tagging_data_provider.js +0 -89
- package/dest/synchronizer/index.d.ts +0 -2
- package/dest/synchronizer/index.d.ts.map +0 -1
- package/dest/synchronizer/index.js +0 -1
- package/dest/synchronizer/synchronizer.d.ts +0 -36
- package/dest/synchronizer/synchronizer.d.ts.map +0 -1
- package/dest/tagging/constants.d.ts +0 -2
- package/dest/tagging/constants.d.ts.map +0 -1
- package/dest/tagging/constants.js +0 -2
- package/dest/tagging/siloed_tag.d.ts +0 -14
- package/dest/tagging/siloed_tag.d.ts.map +0 -1
- package/dest/tagging/siloed_tag.js +0 -20
- package/dest/tagging/tag.d.ts +0 -12
- package/dest/tagging/tag.d.ts.map +0 -1
- package/dest/tagging/tag.js +0 -17
- package/dest/tagging/utils.d.ts +0 -18
- package/dest/tagging/utils.d.ts.map +0 -1
- package/dest/tagging/utils.js +0 -24
- package/src/contract_function_simulator/execution_data_provider.ts +0 -343
- package/src/contract_function_simulator/pxe_oracle_interface.ts +0 -1040
- package/src/storage/address_data_provider/index.ts +0 -1
- package/src/storage/capsule_data_provider/index.ts +0 -1
- package/src/storage/contract_data_provider/index.ts +0 -1
- package/src/storage/note_data_provider/index.ts +0 -2
- package/src/storage/sync_data_provider/index.ts +0 -1
- package/src/storage/tagging_data_provider/index.ts +0 -1
- package/src/storage/tagging_data_provider/tagging_data_provider.ts +0 -120
- package/src/synchronizer/index.ts +0 -1
- package/src/tagging/constants.ts +0 -2
- package/src/tagging/siloed_tag.ts +0 -22
- package/src/tagging/tag.ts +0 -16
- package/src/tagging/utils.ts +0 -31
- /package/dest/storage/{contract_data_provider → contract_store}/private_functions_tree.js +0 -0
- /package/src/storage/{contract_data_provider → contract_store}/private_functions_tree.ts +0 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
|
+
import { DirectionalAppTaggingSecret, PendingTaggedLog, SiloedTag } from '@aztec/stdlib/logs';
|
|
4
|
+
import { LogRetrievalResponse } from '../contract_function_simulator/noir-structs/log_retrieval_response.js';
|
|
5
|
+
import { loadPrivateLogsForSenderRecipientPair } from '../tagging/index.js';
|
|
6
|
+
export class LogService {
|
|
7
|
+
aztecNode;
|
|
8
|
+
anchorBlockStore;
|
|
9
|
+
keyStore;
|
|
10
|
+
capsuleStore;
|
|
11
|
+
recipientTaggingStore;
|
|
12
|
+
senderAddressBookStore;
|
|
13
|
+
addressStore;
|
|
14
|
+
log;
|
|
15
|
+
constructor(aztecNode, anchorBlockStore, keyStore, capsuleStore, recipientTaggingStore, senderAddressBookStore, addressStore){
|
|
16
|
+
this.aztecNode = aztecNode;
|
|
17
|
+
this.anchorBlockStore = anchorBlockStore;
|
|
18
|
+
this.keyStore = keyStore;
|
|
19
|
+
this.capsuleStore = capsuleStore;
|
|
20
|
+
this.recipientTaggingStore = recipientTaggingStore;
|
|
21
|
+
this.senderAddressBookStore = senderAddressBookStore;
|
|
22
|
+
this.addressStore = addressStore;
|
|
23
|
+
this.log = createLogger('log_service');
|
|
24
|
+
}
|
|
25
|
+
async bulkRetrieveLogs(logRetrievalRequests) {
|
|
26
|
+
return await Promise.all(logRetrievalRequests.map(async (request)=>{
|
|
27
|
+
const [publicLog, privateLog] = await Promise.all([
|
|
28
|
+
this.#getPublicLogByTag(request.tag, request.contractAddress),
|
|
29
|
+
this.#getPrivateLogByTag(await SiloedTag.compute(request.tag, request.contractAddress))
|
|
30
|
+
]);
|
|
31
|
+
if (publicLog !== null && privateLog !== null) {
|
|
32
|
+
throw new Error(`Found both a public and private log when searching for tag ${request.tag} from contract ${request.contractAddress}`);
|
|
33
|
+
}
|
|
34
|
+
return publicLog ?? privateLog;
|
|
35
|
+
}));
|
|
36
|
+
}
|
|
37
|
+
async #getPublicLogByTag(tag, contractAddress) {
|
|
38
|
+
const logs = await this.aztecNode.getPublicLogsByTagsFromContract(contractAddress, [
|
|
39
|
+
tag
|
|
40
|
+
]);
|
|
41
|
+
const logsForTag = logs[0];
|
|
42
|
+
if (logsForTag.length == 0) {
|
|
43
|
+
return null;
|
|
44
|
+
} else if (logsForTag.length > 1) {
|
|
45
|
+
// TODO(#11627): handle this case
|
|
46
|
+
throw new Error(`Got ${logsForTag.length} logs for tag ${tag} and contract ${contractAddress.toString()}. getPublicLogByTag currently only supports a single log per tag`);
|
|
47
|
+
}
|
|
48
|
+
const scopedLog = logsForTag[0];
|
|
49
|
+
return new LogRetrievalResponse(scopedLog.logData.slice(1), scopedLog.txHash, scopedLog.noteHashes, scopedLog.firstNullifier);
|
|
50
|
+
}
|
|
51
|
+
async #getPrivateLogByTag(siloedTag) {
|
|
52
|
+
const logs = await this.aztecNode.getPrivateLogsByTags([
|
|
53
|
+
siloedTag
|
|
54
|
+
]);
|
|
55
|
+
const logsForTag = logs[0];
|
|
56
|
+
if (logsForTag.length == 0) {
|
|
57
|
+
return null;
|
|
58
|
+
} else if (logsForTag.length > 1) {
|
|
59
|
+
// TODO(#11627): handle this case
|
|
60
|
+
throw new Error(`Got ${logsForTag.length} logs for tag ${siloedTag}. getPrivateLogByTag currently only supports a single log per tag`);
|
|
61
|
+
}
|
|
62
|
+
const scopedLog = logsForTag[0];
|
|
63
|
+
return new LogRetrievalResponse(scopedLog.logData.slice(1), scopedLog.txHash, scopedLog.noteHashes, scopedLog.firstNullifier);
|
|
64
|
+
}
|
|
65
|
+
async syncTaggedLogs(contractAddress, pendingTaggedLogArrayBaseSlot, scopes) {
|
|
66
|
+
this.log.verbose('Searching for tagged logs', {
|
|
67
|
+
contract: contractAddress
|
|
68
|
+
});
|
|
69
|
+
// We only load logs from block up to and including the anchor block number
|
|
70
|
+
const anchorBlockNumber = (await this.anchorBlockStore.getBlockHeader()).getBlockNumber();
|
|
71
|
+
// Determine recipients: use scopes if provided, otherwise get all accounts
|
|
72
|
+
const recipients = scopes && scopes.length > 0 ? scopes : await this.keyStore.getAccounts();
|
|
73
|
+
// For each recipient, fetch secrets, load logs, and store them.
|
|
74
|
+
// We run these per-recipient tasks in parallel so that logs are loaded for all recipients concurrently.
|
|
75
|
+
await Promise.all(recipients.map(async (recipient)=>{
|
|
76
|
+
// Get all secrets for this recipient (one per sender)
|
|
77
|
+
const secrets = await this.#getSecretsForSenders(contractAddress, recipient);
|
|
78
|
+
// Load logs for all sender-recipient pairs in parallel
|
|
79
|
+
const logArrays = await Promise.all(secrets.map((secret)=>loadPrivateLogsForSenderRecipientPair(secret, contractAddress, this.aztecNode, this.recipientTaggingStore, anchorBlockNumber)));
|
|
80
|
+
// Flatten all logs from all secrets
|
|
81
|
+
const allLogs = logArrays.flat();
|
|
82
|
+
// Store the logs for this recipient
|
|
83
|
+
if (allLogs.length > 0) {
|
|
84
|
+
await this.#storePendingTaggedLogs(contractAddress, pendingTaggedLogArrayBaseSlot, recipient, allLogs);
|
|
85
|
+
}
|
|
86
|
+
}));
|
|
87
|
+
}
|
|
88
|
+
async #getSecretsForSenders(contractAddress, recipient) {
|
|
89
|
+
const recipientCompleteAddress = await this.#getCompleteAddress(recipient);
|
|
90
|
+
const recipientIvsk = await this.keyStore.getMasterIncomingViewingSecretKey(recipient);
|
|
91
|
+
// We implicitly add all PXE accounts as senders, this helps us decrypt tags on notes that we send to ourselves
|
|
92
|
+
// (recipient = us, sender = us)
|
|
93
|
+
const allSenders = [
|
|
94
|
+
...await this.senderAddressBookStore.getSenders(),
|
|
95
|
+
...await this.keyStore.getAccounts()
|
|
96
|
+
];
|
|
97
|
+
// We deduplicate the senders by adding them to a set and then converting the set back to an array
|
|
98
|
+
const deduplicatedSenders = Array.from(new Set(allSenders.map((sender)=>sender.toString()))).map((sender)=>AztecAddress.fromString(sender));
|
|
99
|
+
return Promise.all(deduplicatedSenders.map((sender)=>{
|
|
100
|
+
return DirectionalAppTaggingSecret.compute(recipientCompleteAddress, recipientIvsk, sender, contractAddress, recipient);
|
|
101
|
+
}));
|
|
102
|
+
}
|
|
103
|
+
#storePendingTaggedLogs(contractAddress, capsuleArrayBaseSlot, recipient, privateLogs) {
|
|
104
|
+
// Build all pending tagged logs from the scoped logs
|
|
105
|
+
const pendingTaggedLogs = privateLogs.map((scopedLog)=>{
|
|
106
|
+
const pendingTaggedLog = new PendingTaggedLog(scopedLog.logData, scopedLog.txHash, scopedLog.noteHashes, scopedLog.firstNullifier, recipient);
|
|
107
|
+
return pendingTaggedLog.toFields();
|
|
108
|
+
});
|
|
109
|
+
// TODO: This looks like it could belong more at the oracle interface level
|
|
110
|
+
return this.capsuleStore.appendToCapsuleArray(contractAddress, capsuleArrayBaseSlot, pendingTaggedLogs);
|
|
111
|
+
}
|
|
112
|
+
async #getCompleteAddress(account) {
|
|
113
|
+
const completeAddress = await this.addressStore.getCompleteAddress(account);
|
|
114
|
+
if (!completeAddress) {
|
|
115
|
+
throw new Error(`No public key registered for address ${account}.
|
|
116
|
+
Register it by calling pxe.addAccount(...).\nSee docs for context: https://docs.aztec.network/developers/resources/debugging/aztecnr-errors#simulation-error-no-public-key-registered-for-address-0x0-register-it-by-calling-pxeregisterrecipient-or-pxeregisteraccount`);
|
|
117
|
+
}
|
|
118
|
+
return completeAddress;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { NoteService } from './note_service.js';
|
|
2
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ub3Rlcy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsV0FBVyxFQUFFLE1BQU0sbUJBQW1CLENBQUMifQ==
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/notes/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { NoteService } from './note_service.js';
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
|
+
import { type AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
4
|
+
import { Note, NoteStatus } from '@aztec/stdlib/note';
|
|
5
|
+
import type { TxHash } from '@aztec/stdlib/tx';
|
|
6
|
+
import type { AnchorBlockStore } from '../storage/anchor_block_store/anchor_block_store.js';
|
|
7
|
+
import type { NoteStore } from '../storage/note_store/note_store.js';
|
|
8
|
+
export declare class NoteService {
|
|
9
|
+
private readonly noteStore;
|
|
10
|
+
private readonly aztecNode;
|
|
11
|
+
private readonly anchorBlockStore;
|
|
12
|
+
constructor(noteStore: NoteStore, aztecNode: AztecNode, anchorBlockStore: AnchorBlockStore);
|
|
13
|
+
/**
|
|
14
|
+
* Retrieves a set of notes stored in the database for a given contract address and storage slot.
|
|
15
|
+
* The query result is paginated using 'limit' and 'offset' values.
|
|
16
|
+
* Returns an object containing an array of note data.
|
|
17
|
+
*
|
|
18
|
+
* @param owner - The owner of the notes. If undefined, returns notes for all known owners.
|
|
19
|
+
* @param status - The status of notes to fetch.
|
|
20
|
+
* @param scopes - The accounts whose notes we can access in this call. Currently optional and will default to all.
|
|
21
|
+
*/
|
|
22
|
+
getNotes(contractAddress: AztecAddress, owner: AztecAddress | undefined, storageSlot: Fr, status: NoteStatus, scopes?: AztecAddress[]): Promise<{
|
|
23
|
+
contractAddress: AztecAddress;
|
|
24
|
+
owner: AztecAddress;
|
|
25
|
+
storageSlot: Fr;
|
|
26
|
+
randomness: Fr;
|
|
27
|
+
noteNonce: Fr;
|
|
28
|
+
note: Note;
|
|
29
|
+
noteHash: Fr;
|
|
30
|
+
siloedNullifier: Fr;
|
|
31
|
+
index: bigint;
|
|
32
|
+
}[]>;
|
|
33
|
+
/**
|
|
34
|
+
* Looks for nullifiers of active contract notes and marks them as nullified if a nullifier is found.
|
|
35
|
+
*
|
|
36
|
+
* Fetches notes from the NoteStore and checks which nullifiers are present in the
|
|
37
|
+
* onchain nullifier Merkle tree - up to the latest locally synced block. We use the
|
|
38
|
+
* locally synced block instead of querying the chain's 'latest' block to ensure correctness:
|
|
39
|
+
* notes are only marked nullified once their corresponding nullifier has been included in a
|
|
40
|
+
* block up to which the PXE has synced.
|
|
41
|
+
* This allows recent nullifications to be processed even if the node is not an archive node.
|
|
42
|
+
*
|
|
43
|
+
* @param contractAddress - The contract whose notes should be checked and nullified.
|
|
44
|
+
*/
|
|
45
|
+
syncNoteNullifiers(contractAddress: AztecAddress): Promise<void>;
|
|
46
|
+
deliverNote(contractAddress: AztecAddress, owner: AztecAddress, storageSlot: Fr, randomness: Fr, noteNonce: Fr, content: Fr[], noteHash: Fr, nullifier: Fr, txHash: TxHash, recipient: AztecAddress): Promise<void>;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibm90ZV9zZXJ2aWNlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbm90ZXMvbm90ZV9zZXJ2aWNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxFQUFFLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUNwRCxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUdoRSxPQUFPLEVBQUUsS0FBSyxTQUFTLEVBQWUsTUFBTSxpQ0FBaUMsQ0FBQztBQUM5RSxPQUFPLEVBQUUsSUFBSSxFQUFXLFVBQVUsRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBRS9ELE9BQU8sS0FBSyxFQUFFLE1BQU0sRUFBRSxNQUFNLGtCQUFrQixDQUFDO0FBRS9DLE9BQU8sS0FBSyxFQUFFLGdCQUFnQixFQUFFLE1BQU0scURBQXFELENBQUM7QUFDNUYsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0scUNBQXFDLENBQUM7QUFFckUscUJBQWEsV0FBVztJQUVwQixPQUFPLENBQUMsUUFBUSxDQUFDLFNBQVM7SUFDMUIsT0FBTyxDQUFDLFFBQVEsQ0FBQyxTQUFTO0lBQzFCLE9BQU8sQ0FBQyxRQUFRLENBQUMsZ0JBQWdCO0lBSG5DLFlBQ21CLFNBQVMsRUFBRSxTQUFTLEVBQ3BCLFNBQVMsRUFBRSxTQUFTLEVBQ3BCLGdCQUFn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AAC;AAE/C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qDAAqD,CAAC;AAC5F,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAErE,qBAAa,WAAW;IAEpB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IAHnC,YACmB,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,SAAS,EACpB,gBAAgB,EAAE,gBAAgB,EACjD;IAEJ;;;;;;;;OAQG;IACU,QAAQ,CACnB,eAAe,EAAE,YAAY,EAC7B,KAAK,EAAE,YAAY,GAAG,SAAS,EAC/B,WAAW,EAAE,EAAE,EACf,MAAM,EAAE,UAAU,EAClB,MAAM,CAAC,EAAE,YAAY,EAAE;;;;;;;;;;SAuBxB;IAED;;;;;;;;;;;OAWG;IACU,kBAAkB,CAAC,eAAe,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAsC5E;IAEY,WAAW,CACtB,eAAe,EAAE,YAAY,EAC7B,KAAK,EAAE,YAAY,EACnB,WAAW,EAAE,EAAE,EACf,UAAU,EAAE,EAAE,EACd,SAAS,EAAE,EAAE,EACb,OAAO,EAAE,EAAE,EAAE,EACb,QAAQ,EAAE,EAAE,EACZ,SAAS,EAAE,EAAE,EACb,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,YAAY,GACtB,OAAO,CAAC,IAAI,CAAC,CA6Ef;CACF"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { computeUniqueNoteHash, siloNoteHash, siloNullifier } from '@aztec/stdlib/hash';
|
|
2
|
+
import { MAX_RPC_LEN } from '@aztec/stdlib/interfaces/client';
|
|
3
|
+
import { Note, NoteDao } from '@aztec/stdlib/note';
|
|
4
|
+
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
5
|
+
export class NoteService {
|
|
6
|
+
noteStore;
|
|
7
|
+
aztecNode;
|
|
8
|
+
anchorBlockStore;
|
|
9
|
+
constructor(noteStore, aztecNode, anchorBlockStore){
|
|
10
|
+
this.noteStore = noteStore;
|
|
11
|
+
this.aztecNode = aztecNode;
|
|
12
|
+
this.anchorBlockStore = anchorBlockStore;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Retrieves a set of notes stored in the database for a given contract address and storage slot.
|
|
16
|
+
* The query result is paginated using 'limit' and 'offset' values.
|
|
17
|
+
* Returns an object containing an array of note data.
|
|
18
|
+
*
|
|
19
|
+
* @param owner - The owner of the notes. If undefined, returns notes for all known owners.
|
|
20
|
+
* @param status - The status of notes to fetch.
|
|
21
|
+
* @param scopes - The accounts whose notes we can access in this call. Currently optional and will default to all.
|
|
22
|
+
*/ async getNotes(contractAddress, owner, storageSlot, status, scopes) {
|
|
23
|
+
const noteDaos = await this.noteStore.getNotes({
|
|
24
|
+
contractAddress,
|
|
25
|
+
owner,
|
|
26
|
+
storageSlot,
|
|
27
|
+
status,
|
|
28
|
+
scopes
|
|
29
|
+
});
|
|
30
|
+
return noteDaos.map(({ contractAddress, owner, storageSlot, randomness, noteNonce, note, noteHash, siloedNullifier, index })=>({
|
|
31
|
+
contractAddress,
|
|
32
|
+
owner,
|
|
33
|
+
storageSlot,
|
|
34
|
+
randomness,
|
|
35
|
+
noteNonce,
|
|
36
|
+
note,
|
|
37
|
+
noteHash,
|
|
38
|
+
siloedNullifier,
|
|
39
|
+
// PXE can use this index to get full MembershipWitness
|
|
40
|
+
index
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Looks for nullifiers of active contract notes and marks them as nullified if a nullifier is found.
|
|
45
|
+
*
|
|
46
|
+
* Fetches notes from the NoteStore and checks which nullifiers are present in the
|
|
47
|
+
* onchain nullifier Merkle tree - up to the latest locally synced block. We use the
|
|
48
|
+
* locally synced block instead of querying the chain's 'latest' block to ensure correctness:
|
|
49
|
+
* notes are only marked nullified once their corresponding nullifier has been included in a
|
|
50
|
+
* block up to which the PXE has synced.
|
|
51
|
+
* This allows recent nullifications to be processed even if the node is not an archive node.
|
|
52
|
+
*
|
|
53
|
+
* @param contractAddress - The contract whose notes should be checked and nullified.
|
|
54
|
+
*/ async syncNoteNullifiers(contractAddress) {
|
|
55
|
+
const syncedBlockNumber = (await this.anchorBlockStore.getBlockHeader()).getBlockNumber();
|
|
56
|
+
const contractNotes = await this.noteStore.getNotes({
|
|
57
|
+
contractAddress
|
|
58
|
+
});
|
|
59
|
+
if (contractNotes.length === 0) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const nullifiersToCheck = contractNotes.map((note)=>note.siloedNullifier);
|
|
63
|
+
const nullifierBatches = nullifiersToCheck.reduce((acc, nullifier)=>{
|
|
64
|
+
if (acc[acc.length - 1].length < MAX_RPC_LEN) {
|
|
65
|
+
acc[acc.length - 1].push(nullifier);
|
|
66
|
+
} else {
|
|
67
|
+
acc.push([
|
|
68
|
+
nullifier
|
|
69
|
+
]);
|
|
70
|
+
}
|
|
71
|
+
return acc;
|
|
72
|
+
}, [
|
|
73
|
+
[]
|
|
74
|
+
]);
|
|
75
|
+
const nullifierIndexes = (await Promise.all(nullifierBatches.map((batch)=>this.aztecNode.findLeavesIndexes(syncedBlockNumber, MerkleTreeId.NULLIFIER_TREE, batch)))).flat();
|
|
76
|
+
const foundNullifiers = nullifiersToCheck.map((nullifier, i)=>{
|
|
77
|
+
if (nullifierIndexes[i] !== undefined) {
|
|
78
|
+
return {
|
|
79
|
+
...nullifierIndexes[i],
|
|
80
|
+
...{
|
|
81
|
+
data: nullifier
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
}).filter((nullifier)=>nullifier !== undefined);
|
|
86
|
+
await this.noteStore.applyNullifiers(foundNullifiers);
|
|
87
|
+
}
|
|
88
|
+
async deliverNote(contractAddress, owner, storageSlot, randomness, noteNonce, content, noteHash, nullifier, txHash, recipient) {
|
|
89
|
+
// We are going to store the new note in the NoteStore, which will let us later return it via `getNotes`.
|
|
90
|
+
// There's two things we need to check before we do this however:
|
|
91
|
+
// - we must make sure the note does actually exist in the note hash tree
|
|
92
|
+
// - we need to check if the note has already been nullified
|
|
93
|
+
//
|
|
94
|
+
// Failing to do either of the above would result in circuits getting either non-existent notes and failing to
|
|
95
|
+
// produce inclusion proofs for them, or getting nullified notes and producing duplicate nullifiers, both of which
|
|
96
|
+
// are catastrophic failure modes.
|
|
97
|
+
//
|
|
98
|
+
// Note that adding a note and removing it is *not* equivalent to never adding it in the first place. A nullifier
|
|
99
|
+
// emitted in a block that comes after note creation might result in the note being de-nullified by a chain reorg,
|
|
100
|
+
// so we must store both the note hash and nullifier block information.
|
|
101
|
+
// We avoid making node queries at 'latest' since we don't want to process notes or nullifiers that only exist ahead
|
|
102
|
+
// in time of the locally synced state.
|
|
103
|
+
// Note that while this technically results in historical queries, we perform it at the latest locally synced block
|
|
104
|
+
// number which *should* be recent enough to be available, even for non-archive nodes.
|
|
105
|
+
// Also note that the note should never be ahead of the synced block here since `fetchTaggedLogs` only processes
|
|
106
|
+
// logs up to the synced block making this only an additional safety check.
|
|
107
|
+
const syncedBlockNumber = (await this.anchorBlockStore.getBlockHeader()).getBlockNumber();
|
|
108
|
+
// By computing siloed and unique note hashes ourselves we prevent contracts from interfering with the note storage
|
|
109
|
+
// of other contracts, which would constitute a security breach.
|
|
110
|
+
const uniqueNoteHash = await computeUniqueNoteHash(noteNonce, await siloNoteHash(contractAddress, noteHash));
|
|
111
|
+
const siloedNullifier = await siloNullifier(contractAddress, nullifier);
|
|
112
|
+
const txEffect = await this.aztecNode.getTxEffect(txHash);
|
|
113
|
+
if (!txEffect) {
|
|
114
|
+
throw new Error(`Could not find tx effect for tx hash ${txHash}`);
|
|
115
|
+
}
|
|
116
|
+
if (txEffect.l2BlockNumber > syncedBlockNumber) {
|
|
117
|
+
throw new Error(`Could not find tx effect for tx hash ${txHash} as of block number ${syncedBlockNumber}`);
|
|
118
|
+
}
|
|
119
|
+
const noteInTx = txEffect.data.noteHashes.some((nh)=>nh.equals(uniqueNoteHash));
|
|
120
|
+
if (!noteInTx) {
|
|
121
|
+
throw new Error(`Note hash ${noteHash} (uniqued as ${uniqueNoteHash}) is not present in tx ${txHash}`);
|
|
122
|
+
}
|
|
123
|
+
// We store notes by their index in the global note hash tree, which has the convenient side effect of validating
|
|
124
|
+
// note existence in said tree. We concurrently also check if the note's nullifier exists, performing all node
|
|
125
|
+
// queries in a single round-trip.
|
|
126
|
+
const [[uniqueNoteHashTreeIndexInBlock], [nullifierIndex]] = await Promise.all([
|
|
127
|
+
this.aztecNode.findLeavesIndexes(syncedBlockNumber, MerkleTreeId.NOTE_HASH_TREE, [
|
|
128
|
+
uniqueNoteHash
|
|
129
|
+
]),
|
|
130
|
+
this.aztecNode.findLeavesIndexes(syncedBlockNumber, MerkleTreeId.NULLIFIER_TREE, [
|
|
131
|
+
siloedNullifier
|
|
132
|
+
])
|
|
133
|
+
]);
|
|
134
|
+
if (uniqueNoteHashTreeIndexInBlock === undefined) {
|
|
135
|
+
throw new Error(`Note hash ${noteHash} (uniqued as ${uniqueNoteHash}) is not present on the tree at block ${syncedBlockNumber} (from tx ${txHash})`);
|
|
136
|
+
}
|
|
137
|
+
const noteDao = new NoteDao(new Note(content), contractAddress, owner, storageSlot, randomness, noteNonce, noteHash, siloedNullifier, txHash, uniqueNoteHashTreeIndexInBlock.l2BlockNumber, uniqueNoteHashTreeIndexInBlock.l2BlockHash.toString(), uniqueNoteHashTreeIndexInBlock.data);
|
|
138
|
+
// The note was found by `recipient`, so we use that as the scope when storing the note.
|
|
139
|
+
await this.noteStore.addNotes([
|
|
140
|
+
noteDao
|
|
141
|
+
], recipient);
|
|
142
|
+
if (nullifierIndex !== undefined) {
|
|
143
|
+
const { data: _, ...blockHashAndNum } = nullifierIndex;
|
|
144
|
+
await this.noteStore.applyNullifiers([
|
|
145
|
+
{
|
|
146
|
+
data: siloedNullifier,
|
|
147
|
+
...blockHashAndNum
|
|
148
|
+
}
|
|
149
|
+
]);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
@@ -10,18 +10,18 @@ import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
|
10
10
|
import { UpdatedClassIdHints } from '@aztec/stdlib/kernel';
|
|
11
11
|
import type { NullifierMembershipWitness } from '@aztec/stdlib/trees';
|
|
12
12
|
import type { VerificationKeyAsFields } from '@aztec/stdlib/vks';
|
|
13
|
-
import type {
|
|
13
|
+
import type { ContractStore } from '../storage/contract_store/contract_store.js';
|
|
14
14
|
import type { PrivateKernelOracle } from './private_kernel_oracle.js';
|
|
15
15
|
/**
|
|
16
16
|
* A data oracle that provides information needed for simulating a transaction.
|
|
17
17
|
*/
|
|
18
18
|
export declare class PrivateKernelOracleImpl implements PrivateKernelOracle {
|
|
19
|
-
private
|
|
19
|
+
private contractStore;
|
|
20
20
|
private keyStore;
|
|
21
21
|
private node;
|
|
22
22
|
private blockNumber;
|
|
23
23
|
private log;
|
|
24
|
-
constructor(
|
|
24
|
+
constructor(contractStore: ContractStore, keyStore: KeyStore, node: AztecNode, blockNumber?: BlockParameter, log?: import("@aztec/foundation/log").Logger);
|
|
25
25
|
getContractAddressPreimage(address: AztecAddress): Promise<{
|
|
26
26
|
version: 1;
|
|
27
27
|
salt: Fr;
|
|
@@ -43,4 +43,4 @@ export declare class PrivateKernelOracleImpl implements PrivateKernelOracle {
|
|
|
43
43
|
getDebugFunctionName(contractAddress: AztecAddress, selector: FunctionSelector): Promise<string>;
|
|
44
44
|
getUpdatedClassIdHints(contractAddress: AztecAddress): Promise<UpdatedClassIdHints>;
|
|
45
45
|
}
|
|
46
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
46
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJpdmF0ZV9rZXJuZWxfb3JhY2xlX2ltcGwuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpb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c0JBQXNCLENBQUMsZUFBZSxFQUFFLFlBQVksR0FBRyxPQUFPLENBQUMsbUJBQW1CLENBQUMsQ0E4Qi9GO0NBQ0YifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"private_kernel_oracle_impl.d.ts","sourceRoot":"","sources":["../../src/private_kernel/private_kernel_oracle_impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAA2C,MAAM,kBAAkB,CAAC;AAClG,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AAG/E,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAGjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAI1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAEjE,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"private_kernel_oracle_impl.d.ts","sourceRoot":"","sources":["../../src/private_kernel/private_kernel_oracle_impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAA2C,MAAM,kBAAkB,CAAC;AAClG,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM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AC,iBAAiB,CAAC,OAAO,qBAAqB,CAAC,CAAC,CAO9G;IAED,6BAA6B,CAAC,SAAS,EAAE,EAAE,GAAG,OAAO,CAAC,0BAA0B,GAAG,SAAS,CAAC,CAE5F;IAEK,mBAAmB,IAAI,OAAO,CAAC,EAAE,CAAC,CAMvC;IAEM,kBAAkB,CAAC,eAAe,EAAE,KAAK,GAAG,OAAO,CAAC,cAAc,CAAC,CAEzE;IAEM,oBAAoB,CAAC,eAAe,EAAE,YAAY,EAAE,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,CAEtG;IAEY,sBAAsB,CAAC,eAAe,EAAE,YAAY,GAAG,OAAO,CAAC,mBAAmB,CAAC,CA8B/F;CACF"}
|
|
@@ -12,20 +12,20 @@ import { UpdatedClassIdHints } from '@aztec/stdlib/kernel';
|
|
|
12
12
|
/**
|
|
13
13
|
* A data oracle that provides information needed for simulating a transaction.
|
|
14
14
|
*/ export class PrivateKernelOracleImpl {
|
|
15
|
-
|
|
15
|
+
contractStore;
|
|
16
16
|
keyStore;
|
|
17
17
|
node;
|
|
18
18
|
blockNumber;
|
|
19
19
|
log;
|
|
20
|
-
constructor(
|
|
21
|
-
this.
|
|
20
|
+
constructor(contractStore, keyStore, node, blockNumber = 'latest', log = createLogger('pxe:kernel_oracle')){
|
|
21
|
+
this.contractStore = contractStore;
|
|
22
22
|
this.keyStore = keyStore;
|
|
23
23
|
this.node = node;
|
|
24
24
|
this.blockNumber = blockNumber;
|
|
25
25
|
this.log = log;
|
|
26
26
|
}
|
|
27
27
|
async getContractAddressPreimage(address) {
|
|
28
|
-
const instance = await this.
|
|
28
|
+
const instance = await this.contractStore.getContractInstance(address);
|
|
29
29
|
if (!instance) {
|
|
30
30
|
throw new Error(`Contract instance not found when getting address preimage. Contract address: ${address}.`);
|
|
31
31
|
}
|
|
@@ -35,14 +35,14 @@ import { UpdatedClassIdHints } from '@aztec/stdlib/kernel';
|
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
37
|
async getContractClassIdPreimage(contractClassId) {
|
|
38
|
-
const contractClass = await this.
|
|
38
|
+
const contractClass = await this.contractStore.getContractClass(contractClassId);
|
|
39
39
|
if (!contractClass) {
|
|
40
40
|
throw new Error(`Contract class not found when getting class id preimage. Class id: ${contractClassId}.`);
|
|
41
41
|
}
|
|
42
42
|
return computeContractClassIdPreimage(contractClass);
|
|
43
43
|
}
|
|
44
44
|
async getFunctionMembershipWitness(contractClassId, selector) {
|
|
45
|
-
const membershipWitness = await this.
|
|
45
|
+
const membershipWitness = await this.contractStore.getFunctionMembershipWitness(contractClassId, selector);
|
|
46
46
|
if (!membershipWitness) {
|
|
47
47
|
throw new Error(`Membership witness not found for contract class id ${contractClassId} and selector ${selector}.`);
|
|
48
48
|
}
|
|
@@ -70,7 +70,7 @@ import { UpdatedClassIdHints } from '@aztec/stdlib/kernel';
|
|
|
70
70
|
return this.keyStore.getMasterSecretKey(masterPublicKey);
|
|
71
71
|
}
|
|
72
72
|
getDebugFunctionName(contractAddress, selector) {
|
|
73
|
-
return this.
|
|
73
|
+
return this.contractStore.getDebugFunctionName(contractAddress, selector);
|
|
74
74
|
}
|
|
75
75
|
async getUpdatedClassIdHints(contractAddress) {
|
|
76
76
|
const { delayedPublicMutableSlot, delayedPublicMutableHashSlot } = await DelayedPublicMutableValuesWithHash.getContractUpdateSlots(contractAddress);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
|
+
import type { BlockParameter } from '@aztec/stdlib/block';
|
|
4
|
+
import type { AztecNode } from '@aztec/stdlib/interfaces/server';
|
|
5
|
+
import type { AnchorBlockStore } from '../storage/anchor_block_store/anchor_block_store.js';
|
|
6
|
+
export declare class PublicStorageService {
|
|
7
|
+
private readonly anchorBlockStore;
|
|
8
|
+
private readonly aztecNode;
|
|
9
|
+
constructor(anchorBlockStore: AnchorBlockStore, aztecNode: AztecNode);
|
|
10
|
+
/**
|
|
11
|
+
* Gets the storage value at the given contract storage slot.
|
|
12
|
+
*
|
|
13
|
+
* @remarks The storage slot here refers to the slot as it is defined in Noir not the index in the merkle tree.
|
|
14
|
+
* Aztec's version of `eth_getStorageAt`.
|
|
15
|
+
*
|
|
16
|
+
* @param blockNumber - The block number at which to get the data.
|
|
17
|
+
* @param contract - Address of the contract to query.
|
|
18
|
+
* @param slot - Slot to query.
|
|
19
|
+
* @returns Storage value at the given contract slot.
|
|
20
|
+
* @throws If the contract is not deployed.
|
|
21
|
+
*/
|
|
22
|
+
getPublicStorageAt(blockNumber: BlockParameter, contract: AztecAddress, slot: Fr): Promise<Fr>;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljX3N0b3JhZ2Vfc2VydmljZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3B1YmxpY19zdG9yYWdlL3B1YmxpY19zdG9yYWdlX3NlcnZpY2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsRUFBRSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDekQsT0FBTyxLQUFLLEVBQUUsWUFBWSxFQUFFLE1BQU0sNkJBQTZCLENBQUM7QUFDaEUsT0FBTyxLQUFLLEVBQUUsY0FBYyxFQUFFLE1BQU0scUJBQXFCLENBQUM7QUFDMUQsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFFakUsT0FBTyxLQUFLLEVBQUUsZ0JBQWdCLEVBQUUsTUFBTSxxREFBcUQsQ0FBQztBQUU1RixxQkFBYSxvQkFBb0I7SUFFN0IsT0FBTyxDQUFDLFFBQVEsQ0FBQyxnQkFBZ0I7SUFDakMsT0FBTyxDQUFDLFFBQVEsQ0FBQyxTQUFTO0lBRjVCLFlBQ21CLGdCQUFnQixFQUFFLGdCQUFnQixFQUNsQyxTQUFTLEVBQUUsU0FBUyxFQUNuQztJQUVKOzs7Ozs7Ozs7OztPQVdHO0lBQ1Usa0JBQWtCLENBQUMsV0FBVyxFQUFFLGNBQWMsRUFBRSxRQUFRLEVBQUUsWUFBWSxFQUFFLElBQUksRUFBRSxFQUFFLEdBQUcsT0FBTyxDQUFDLEVBQUUsQ0FBQyxDQU0xRztDQUNGIn0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public_storage_service.d.ts","sourceRoot":"","sources":["../../src/public_storage/public_storage_service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAEjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qDAAqD,CAAC;AAE5F,qBAAa,oBAAoB;IAE7B,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IACjC,OAAO,CAAC,QAAQ,CAAC,SAAS;IAF5B,YACmB,gBAAgB,EAAE,gBAAgB,EAClC,SAAS,EAAE,SAAS,EACnC;IAEJ;;;;;;;;;;;OAWG;IACU,kBAAkB,CAAC,WAAW,EAAE,cAAc,EAAE,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,GAAG,OAAO,CAAC,EAAE,CAAC,CAM1G;CACF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export class PublicStorageService {
|
|
2
|
+
anchorBlockStore;
|
|
3
|
+
aztecNode;
|
|
4
|
+
constructor(anchorBlockStore, aztecNode){
|
|
5
|
+
this.anchorBlockStore = anchorBlockStore;
|
|
6
|
+
this.aztecNode = aztecNode;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Gets the storage value at the given contract storage slot.
|
|
10
|
+
*
|
|
11
|
+
* @remarks The storage slot here refers to the slot as it is defined in Noir not the index in the merkle tree.
|
|
12
|
+
* Aztec's version of `eth_getStorageAt`.
|
|
13
|
+
*
|
|
14
|
+
* @param blockNumber - The block number at which to get the data.
|
|
15
|
+
* @param contract - Address of the contract to query.
|
|
16
|
+
* @param slot - Slot to query.
|
|
17
|
+
* @returns Storage value at the given contract slot.
|
|
18
|
+
* @throws If the contract is not deployed.
|
|
19
|
+
*/ async getPublicStorageAt(blockNumber, contract, slot) {
|
|
20
|
+
const anchorBlockNumber = (await this.anchorBlockStore.getBlockHeader()).getBlockNumber();
|
|
21
|
+
if (blockNumber !== 'latest' && blockNumber > anchorBlockNumber) {
|
|
22
|
+
throw new Error(`Block number ${blockNumber} is higher than current block ${anchorBlockNumber}`);
|
|
23
|
+
}
|
|
24
|
+
return await this.aztecNode.getPublicStorageAt(blockNumber, contract, slot);
|
|
25
|
+
}
|
|
26
|
+
}
|
package/dest/pxe.d.ts
CHANGED
|
@@ -9,10 +9,9 @@ import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
|
9
9
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
10
10
|
import { CompleteAddress, type ContractClassWithId, type ContractInstanceWithAddress, type PartialAddress } from '@aztec/stdlib/contract';
|
|
11
11
|
import type { AztecNode, PrivateKernelProver } from '@aztec/stdlib/interfaces/client';
|
|
12
|
-
import type { NotesFilter } from '@aztec/stdlib/note';
|
|
13
|
-
import { NoteDao } from '@aztec/stdlib/note';
|
|
14
12
|
import { type InTx, SimulationOverrides, TxExecutionRequest, TxProfileResult, TxProvingResult, TxSimulationResult, UtilitySimulationResult } from '@aztec/stdlib/tx';
|
|
15
13
|
import type { PXEConfig } from './config/index.js';
|
|
14
|
+
import { PXEDebugUtils } from './debug/pxe_debug_utils.js';
|
|
16
15
|
export type PackedPrivateEvent = InTx & {
|
|
17
16
|
packedEvent: Fr[];
|
|
18
17
|
eventSelector: EventSelector;
|
|
@@ -24,21 +23,24 @@ export type PackedPrivateEvent = InTx & {
|
|
|
24
23
|
export declare class PXE {
|
|
25
24
|
#private;
|
|
26
25
|
private node;
|
|
27
|
-
private
|
|
26
|
+
private blockStateSynchronizer;
|
|
28
27
|
private keyStore;
|
|
29
|
-
private
|
|
30
|
-
private
|
|
31
|
-
private
|
|
32
|
-
private
|
|
33
|
-
private
|
|
34
|
-
private
|
|
35
|
-
private
|
|
28
|
+
private contractStore;
|
|
29
|
+
private noteStore;
|
|
30
|
+
private capsuleStore;
|
|
31
|
+
private anchorBlockStore;
|
|
32
|
+
private senderTaggingStore;
|
|
33
|
+
private senderAddressBookStore;
|
|
34
|
+
private recipientTaggingStore;
|
|
35
|
+
private addressStore;
|
|
36
|
+
private privateEventStore;
|
|
36
37
|
private simulator;
|
|
37
38
|
private proverEnabled;
|
|
38
39
|
private proofCreator;
|
|
39
40
|
private protocolContractsProvider;
|
|
40
41
|
private log;
|
|
41
42
|
private jobQueue;
|
|
43
|
+
debug: PXEDebugUtils;
|
|
42
44
|
private constructor();
|
|
43
45
|
/**
|
|
44
46
|
* Creates an instance of a PXE by instantiating all the necessary data providers and services.
|
|
@@ -96,24 +98,26 @@ export declare class PXE {
|
|
|
96
98
|
*/
|
|
97
99
|
registerAccount(secretKey: Fr, partialAddress: PartialAddress): Promise<CompleteAddress>;
|
|
98
100
|
/**
|
|
99
|
-
* Registers a
|
|
101
|
+
* Registers a sender in this PXE.
|
|
100
102
|
*
|
|
101
|
-
*
|
|
102
|
-
* Will do nothing if the
|
|
103
|
+
* After registering a new sender, the PXE will sync private logs that are tagged with this sender's address.
|
|
104
|
+
* Will do nothing if the address is already registered.
|
|
103
105
|
*
|
|
104
|
-
* @param
|
|
105
|
-
* @returns The address
|
|
106
|
+
* @param sender - Address of the sender to register.
|
|
107
|
+
* @returns The address of the sender.
|
|
108
|
+
* TODO: It's strange that we return the address here and I (benesjan) think we should drop the return value.
|
|
106
109
|
*/
|
|
107
|
-
registerSender(
|
|
110
|
+
registerSender(sender: AztecAddress): Promise<AztecAddress>;
|
|
108
111
|
/**
|
|
109
|
-
* Retrieves
|
|
110
|
-
* @returns
|
|
112
|
+
* Retrieves senders registered in this PXE.
|
|
113
|
+
* @returns Senders registered in this PXE.
|
|
111
114
|
*/
|
|
112
115
|
getSenders(): Promise<AztecAddress[]>;
|
|
113
116
|
/**
|
|
114
|
-
* Removes a sender in
|
|
117
|
+
* Removes a sender registered in this PXE.
|
|
118
|
+
* @param sender - The address of the sender to remove.
|
|
115
119
|
*/
|
|
116
|
-
removeSender(
|
|
120
|
+
removeSender(sender: AztecAddress): Promise<void>;
|
|
117
121
|
/**
|
|
118
122
|
* Retrieves the user accounts registered on this PXE.
|
|
119
123
|
* @returns An array of the accounts registered on this PXE.
|
|
@@ -152,18 +156,6 @@ export declare class PXE {
|
|
|
152
156
|
* @returns An array of contracts addresses registered on this PXE.
|
|
153
157
|
*/
|
|
154
158
|
getContracts(): Promise<AztecAddress[]>;
|
|
155
|
-
/**
|
|
156
|
-
* A debugging utility to get notes based on the provided filter.
|
|
157
|
-
*
|
|
158
|
-
* Note that this should not be used in production code because the structure of notes is considered to be
|
|
159
|
-
* an implementation detail of contracts. This is only meant to be used for debugging purposes. If you need to obtain
|
|
160
|
-
* note-related information in production code, please implement a custom utility function on your contract and call
|
|
161
|
-
* that function instead (e.g. `get_balance(owner: AztecAddress) -> u128` utility function on a Token contract).
|
|
162
|
-
*
|
|
163
|
-
* @param filter - The filter to apply to the notes.
|
|
164
|
-
* @returns The requested notes.
|
|
165
|
-
*/
|
|
166
|
-
getNotes(filter: NotesFilter): Promise<NoteDao[]>;
|
|
167
159
|
/**
|
|
168
160
|
* Proves the private portion of a simulated transaction, ready to send to the network
|
|
169
161
|
* (where validators prove the public portion).
|
|
@@ -237,4 +229,4 @@ export declare class PXE {
|
|
|
237
229
|
*/
|
|
238
230
|
stop(): Promise<void>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