@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,33 @@
|
|
|
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
|
+
|
|
6
|
+
import type { AnchorBlockStore } from '../storage/anchor_block_store/anchor_block_store.js';
|
|
7
|
+
|
|
8
|
+
export class PublicStorageService {
|
|
9
|
+
constructor(
|
|
10
|
+
private readonly anchorBlockStore: AnchorBlockStore,
|
|
11
|
+
private readonly aztecNode: AztecNode,
|
|
12
|
+
) {}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Gets the storage value at the given contract storage slot.
|
|
16
|
+
*
|
|
17
|
+
* @remarks The storage slot here refers to the slot as it is defined in Noir not the index in the merkle tree.
|
|
18
|
+
* Aztec's version of `eth_getStorageAt`.
|
|
19
|
+
*
|
|
20
|
+
* @param blockNumber - The block number at which to get the data.
|
|
21
|
+
* @param contract - Address of the contract to query.
|
|
22
|
+
* @param slot - Slot to query.
|
|
23
|
+
* @returns Storage value at the given contract slot.
|
|
24
|
+
* @throws If the contract is not deployed.
|
|
25
|
+
*/
|
|
26
|
+
public async getPublicStorageAt(blockNumber: BlockParameter, contract: AztecAddress, slot: Fr): Promise<Fr> {
|
|
27
|
+
const anchorBlockNumber = (await this.anchorBlockStore.getBlockHeader()).getBlockNumber();
|
|
28
|
+
if (blockNumber !== 'latest' && blockNumber > anchorBlockNumber) {
|
|
29
|
+
throw new Error(`Block number ${blockNumber} is higher than current block ${anchorBlockNumber}`);
|
|
30
|
+
}
|
|
31
|
+
return await this.aztecNode.getPublicStorageAt(blockNumber, contract, slot);
|
|
32
|
+
}
|
|
33
|
+
}
|
package/src/pxe.ts
CHANGED
|
@@ -12,10 +12,8 @@ import {
|
|
|
12
12
|
type ContractArtifact,
|
|
13
13
|
EventSelector,
|
|
14
14
|
FunctionCall,
|
|
15
|
-
FunctionSelector,
|
|
16
15
|
FunctionType,
|
|
17
16
|
decodeFunctionSignature,
|
|
18
|
-
encodeArguments,
|
|
19
17
|
} from '@aztec/stdlib/abi';
|
|
20
18
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
21
19
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
@@ -35,8 +33,6 @@ import type {
|
|
|
35
33
|
PrivateKernelExecutionProofOutput,
|
|
36
34
|
PrivateKernelTailCircuitPublicInputs,
|
|
37
35
|
} from '@aztec/stdlib/kernel';
|
|
38
|
-
import type { NotesFilter } from '@aztec/stdlib/note';
|
|
39
|
-
import { NoteDao } from '@aztec/stdlib/note';
|
|
40
36
|
import {
|
|
41
37
|
type ContractOverrides,
|
|
42
38
|
type InTx,
|
|
@@ -56,15 +52,15 @@ import {
|
|
|
56
52
|
|
|
57
53
|
import { inspect } from 'util';
|
|
58
54
|
|
|
55
|
+
import { BlockSynchronizer } from './block_synchronizer/index.js';
|
|
59
56
|
import type { PXEConfig } from './config/index.js';
|
|
60
57
|
import {
|
|
61
58
|
ContractFunctionSimulator,
|
|
62
59
|
generateSimulatedProvingResult,
|
|
63
60
|
} from './contract_function_simulator/contract_function_simulator.js';
|
|
64
61
|
import { readCurrentClassId } from './contract_function_simulator/oracle/private_execution.js';
|
|
65
|
-
import {
|
|
66
|
-
import {
|
|
67
|
-
import { PXEOracleInterface } from './contract_function_simulator/pxe_oracle_interface.js';
|
|
62
|
+
import { ProxiedContractStoreFactory } from './contract_function_simulator/proxied_contract_data_source.js';
|
|
63
|
+
import { PXEDebugUtils } from './debug/pxe_debug_utils.js';
|
|
68
64
|
import { enrichPublicSimulationError, enrichSimulationError } from './error_enriching.js';
|
|
69
65
|
import { PrivateEventFilterValidator } from './events/private_event_filter_validator.js';
|
|
70
66
|
import {
|
|
@@ -72,14 +68,15 @@ import {
|
|
|
72
68
|
type PrivateKernelExecutionProverConfig,
|
|
73
69
|
} from './private_kernel/private_kernel_execution_prover.js';
|
|
74
70
|
import { PrivateKernelOracleImpl } from './private_kernel/private_kernel_oracle_impl.js';
|
|
75
|
-
import {
|
|
76
|
-
import {
|
|
77
|
-
import {
|
|
78
|
-
import {
|
|
79
|
-
import {
|
|
80
|
-
import {
|
|
81
|
-
import {
|
|
82
|
-
import {
|
|
71
|
+
import { AddressStore } from './storage/address_store/address_store.js';
|
|
72
|
+
import { AnchorBlockStore } from './storage/anchor_block_store/anchor_block_store.js';
|
|
73
|
+
import { CapsuleStore } from './storage/capsule_store/capsule_store.js';
|
|
74
|
+
import { ContractStore } from './storage/contract_store/contract_store.js';
|
|
75
|
+
import { NoteStore } from './storage/note_store/note_store.js';
|
|
76
|
+
import { PrivateEventStore } from './storage/private_event_store/private_event_store.js';
|
|
77
|
+
import { RecipientTaggingStore } from './storage/tagging_store/recipient_tagging_store.js';
|
|
78
|
+
import { SenderAddressBookStore } from './storage/tagging_store/sender_address_book_store.js';
|
|
79
|
+
import { SenderTaggingStore } from './storage/tagging_store/sender_tagging_store.js';
|
|
83
80
|
|
|
84
81
|
export type PackedPrivateEvent = InTx & {
|
|
85
82
|
packedEvent: Fr[];
|
|
@@ -93,21 +90,24 @@ export type PackedPrivateEvent = InTx & {
|
|
|
93
90
|
export class PXE {
|
|
94
91
|
private constructor(
|
|
95
92
|
private node: AztecNode,
|
|
96
|
-
private
|
|
93
|
+
private blockStateSynchronizer: BlockSynchronizer,
|
|
97
94
|
private keyStore: KeyStore,
|
|
98
|
-
private
|
|
99
|
-
private
|
|
100
|
-
private
|
|
101
|
-
private
|
|
102
|
-
private
|
|
103
|
-
private
|
|
104
|
-
private
|
|
95
|
+
private contractStore: ContractStore,
|
|
96
|
+
private noteStore: NoteStore,
|
|
97
|
+
private capsuleStore: CapsuleStore,
|
|
98
|
+
private anchorBlockStore: AnchorBlockStore,
|
|
99
|
+
private senderTaggingStore: SenderTaggingStore,
|
|
100
|
+
private senderAddressBookStore: SenderAddressBookStore,
|
|
101
|
+
private recipientTaggingStore: RecipientTaggingStore,
|
|
102
|
+
private addressStore: AddressStore,
|
|
103
|
+
private privateEventStore: PrivateEventStore,
|
|
105
104
|
private simulator: CircuitSimulator,
|
|
106
105
|
private proverEnabled: boolean,
|
|
107
106
|
private proofCreator: PrivateKernelProver,
|
|
108
107
|
private protocolContractsProvider: ProtocolContractsProvider,
|
|
109
108
|
private log: Logger,
|
|
110
109
|
private jobQueue: SerialQueue,
|
|
110
|
+
public debug: PXEDebugUtils,
|
|
111
111
|
) {}
|
|
112
112
|
|
|
113
113
|
/**
|
|
@@ -132,46 +132,55 @@ export class PXE {
|
|
|
132
132
|
: loggerOrSuffix;
|
|
133
133
|
|
|
134
134
|
const proverEnabled = !!config.proverEnabled;
|
|
135
|
-
const
|
|
136
|
-
const
|
|
137
|
-
const
|
|
138
|
-
const
|
|
139
|
-
const
|
|
140
|
-
const
|
|
141
|
-
const
|
|
135
|
+
const addressStore = new AddressStore(store);
|
|
136
|
+
const privateEventStore = new PrivateEventStore(store);
|
|
137
|
+
const contractStore = new ContractStore(store);
|
|
138
|
+
const noteStore = await NoteStore.create(store);
|
|
139
|
+
const anchorBlockStore = new AnchorBlockStore(store);
|
|
140
|
+
const senderTaggingStore = new SenderTaggingStore(store);
|
|
141
|
+
const senderAddressBookStore = new SenderAddressBookStore(store);
|
|
142
|
+
const recipientTaggingStore = new RecipientTaggingStore(store);
|
|
143
|
+
const capsuleStore = new CapsuleStore(store);
|
|
142
144
|
const keyStore = new KeyStore(store);
|
|
143
145
|
const tipsStore = new L2TipsKVStore(store, 'pxe');
|
|
144
|
-
const synchronizer = new
|
|
146
|
+
const synchronizer = new BlockSynchronizer(
|
|
145
147
|
node,
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
148
|
+
anchorBlockStore,
|
|
149
|
+
noteStore,
|
|
150
|
+
privateEventStore,
|
|
149
151
|
tipsStore,
|
|
150
152
|
config,
|
|
151
153
|
loggerOrSuffix,
|
|
152
154
|
);
|
|
153
155
|
|
|
156
|
+
const debugUtils = new PXEDebugUtils(contractStore, noteStore);
|
|
157
|
+
|
|
154
158
|
const jobQueue = new SerialQueue();
|
|
155
159
|
|
|
156
160
|
const pxe = new PXE(
|
|
157
161
|
node,
|
|
158
162
|
synchronizer,
|
|
159
163
|
keyStore,
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
164
|
+
contractStore,
|
|
165
|
+
noteStore,
|
|
166
|
+
capsuleStore,
|
|
167
|
+
anchorBlockStore,
|
|
168
|
+
senderTaggingStore,
|
|
169
|
+
senderAddressBookStore,
|
|
170
|
+
recipientTaggingStore,
|
|
171
|
+
addressStore,
|
|
172
|
+
privateEventStore,
|
|
167
173
|
simulator,
|
|
168
174
|
proverEnabled,
|
|
169
175
|
proofCreator,
|
|
170
176
|
protocolContractsProvider,
|
|
171
177
|
log,
|
|
172
178
|
jobQueue,
|
|
179
|
+
debugUtils,
|
|
173
180
|
);
|
|
174
181
|
|
|
182
|
+
debugUtils.setPXE(pxe);
|
|
183
|
+
|
|
175
184
|
pxe.jobQueue.start();
|
|
176
185
|
|
|
177
186
|
await pxe.#registerProtocolContracts();
|
|
@@ -183,19 +192,22 @@ export class PXE {
|
|
|
183
192
|
// Internal methods
|
|
184
193
|
|
|
185
194
|
#getSimulatorForTx(overrides?: { contracts?: ContractOverrides }) {
|
|
186
|
-
const
|
|
187
|
-
|
|
195
|
+
const proxyContractStore = ProxiedContractStoreFactory.create(this.contractStore, overrides?.contracts);
|
|
196
|
+
|
|
197
|
+
return new ContractFunctionSimulator(
|
|
198
|
+
proxyContractStore,
|
|
199
|
+
this.noteStore,
|
|
188
200
|
this.keyStore,
|
|
189
|
-
|
|
190
|
-
this.
|
|
191
|
-
this.
|
|
192
|
-
this.
|
|
193
|
-
this.
|
|
194
|
-
this.
|
|
195
|
-
this.
|
|
196
|
-
this.
|
|
201
|
+
this.addressStore,
|
|
202
|
+
this.node,
|
|
203
|
+
this.anchorBlockStore,
|
|
204
|
+
this.senderTaggingStore,
|
|
205
|
+
this.recipientTaggingStore,
|
|
206
|
+
this.senderAddressBookStore,
|
|
207
|
+
this.capsuleStore,
|
|
208
|
+
this.privateEventStore,
|
|
209
|
+
this.simulator,
|
|
197
210
|
);
|
|
198
|
-
return new ContractFunctionSimulator(pxeOracleInterface, this.simulator);
|
|
199
211
|
}
|
|
200
212
|
|
|
201
213
|
#contextualizeError(err: Error, ...context: string[]): Error {
|
|
@@ -234,8 +246,8 @@ export class PXE {
|
|
|
234
246
|
for (const name of protocolContractNames) {
|
|
235
247
|
const { address, contractClass, instance, artifact } =
|
|
236
248
|
await this.protocolContractsProvider.getProtocolContractArtifact(name);
|
|
237
|
-
await this.
|
|
238
|
-
await this.
|
|
249
|
+
await this.contractStore.addContractArtifact(contractClass.id, artifact);
|
|
250
|
+
await this.contractStore.addContractInstance(instance);
|
|
239
251
|
registered[name] = address.toString();
|
|
240
252
|
}
|
|
241
253
|
this.log.verbose(`Registered protocol contracts in pxe`, registered);
|
|
@@ -254,31 +266,6 @@ export class PXE {
|
|
|
254
266
|
return !!(await this.node.getNullifierMembershipWitness('latest', initNullifier));
|
|
255
267
|
}
|
|
256
268
|
|
|
257
|
-
async #getFunctionCall(functionName: string, args: any[], to: AztecAddress): Promise<FunctionCall> {
|
|
258
|
-
const contract = await this.contractDataProvider.getContract(to);
|
|
259
|
-
if (!contract) {
|
|
260
|
-
throw new Error(
|
|
261
|
-
`Unknown contract ${to}: add it to PXE by calling server.addContracts(...).\nSee docs for context: https://docs.aztec.network/developers/resources/debugging/aztecnr-errors#unknown-contract-0x0-add-it-to-pxe-by-calling-serveraddcontracts`,
|
|
262
|
-
);
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
const functionDao = contract.functions.find(f => f.name === functionName);
|
|
266
|
-
if (!functionDao) {
|
|
267
|
-
throw new Error(`Unknown function ${functionName} in contract ${contract.name}.`);
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
return {
|
|
271
|
-
name: functionDao.name,
|
|
272
|
-
args: encodeArguments(functionDao, args),
|
|
273
|
-
selector: await FunctionSelector.fromNameAndParameters(functionDao.name, functionDao.parameters),
|
|
274
|
-
type: functionDao.functionType,
|
|
275
|
-
to,
|
|
276
|
-
hideMsgSender: false,
|
|
277
|
-
isStatic: functionDao.isStatic,
|
|
278
|
-
returnTypes: functionDao.returnTypes,
|
|
279
|
-
};
|
|
280
|
-
}
|
|
281
|
-
|
|
282
269
|
// Executes the entrypoint private function, as well as all nested private
|
|
283
270
|
// functions that might arise.
|
|
284
271
|
async #executePrivate(
|
|
@@ -289,11 +276,14 @@ export class PXE {
|
|
|
289
276
|
const { origin: contractAddress, functionSelector } = txRequest;
|
|
290
277
|
|
|
291
278
|
try {
|
|
279
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
280
|
+
|
|
292
281
|
const result = await contractFunctionSimulator.run(
|
|
293
282
|
txRequest,
|
|
294
283
|
contractAddress,
|
|
295
284
|
functionSelector,
|
|
296
285
|
undefined,
|
|
286
|
+
anchorBlockHeader,
|
|
297
287
|
// The sender for tags is set by contracts, typically by an account
|
|
298
288
|
// contract entrypoint
|
|
299
289
|
undefined, // senderForTags
|
|
@@ -303,7 +293,7 @@ export class PXE {
|
|
|
303
293
|
return result;
|
|
304
294
|
} catch (err) {
|
|
305
295
|
if (err instanceof SimulationError) {
|
|
306
|
-
await enrichSimulationError(err, this.
|
|
296
|
+
await enrichSimulationError(err, this.contractStore, this.log);
|
|
307
297
|
}
|
|
308
298
|
throw err;
|
|
309
299
|
}
|
|
@@ -325,10 +315,11 @@ export class PXE {
|
|
|
325
315
|
scopes?: AztecAddress[],
|
|
326
316
|
) {
|
|
327
317
|
try {
|
|
328
|
-
|
|
318
|
+
const anchorBlockHeader = await this.anchorBlockStore.getBlockHeader();
|
|
319
|
+
return contractFunctionSimulator.runUtility(call, authWitnesses ?? [], anchorBlockHeader, scopes);
|
|
329
320
|
} catch (err) {
|
|
330
321
|
if (err instanceof SimulationError) {
|
|
331
|
-
await enrichSimulationError(err, this.
|
|
322
|
+
await enrichSimulationError(err, this.contractStore, this.log);
|
|
332
323
|
}
|
|
333
324
|
throw err;
|
|
334
325
|
}
|
|
@@ -352,7 +343,7 @@ export class PXE {
|
|
|
352
343
|
} catch (err) {
|
|
353
344
|
if (err instanceof SimulationError) {
|
|
354
345
|
try {
|
|
355
|
-
await enrichPublicSimulationError(err, this.
|
|
346
|
+
await enrichPublicSimulationError(err, this.contractStore, this.log);
|
|
356
347
|
} catch (enrichErr) {
|
|
357
348
|
this.log.error(`Failed to enrich public simulation error: ${enrichErr}`);
|
|
358
349
|
}
|
|
@@ -380,7 +371,7 @@ export class PXE {
|
|
|
380
371
|
): Promise<PrivateKernelExecutionProofOutput<PrivateKernelTailCircuitPublicInputs>> {
|
|
381
372
|
const simulationAnchorBlock = privateExecutionResult.getSimulationAnchorBlockNumber();
|
|
382
373
|
const kernelOracle = new PrivateKernelOracleImpl(
|
|
383
|
-
this.
|
|
374
|
+
this.contractStore,
|
|
384
375
|
this.keyStore,
|
|
385
376
|
this.node,
|
|
386
377
|
simulationAnchorBlock,
|
|
@@ -393,7 +384,7 @@ export class PXE {
|
|
|
393
384
|
// Public API
|
|
394
385
|
|
|
395
386
|
public getContractInstance(address: AztecAddress): Promise<ContractInstanceWithAddress | undefined> {
|
|
396
|
-
return this.
|
|
387
|
+
return this.contractStore.getContractInstance(address);
|
|
397
388
|
}
|
|
398
389
|
|
|
399
390
|
/**
|
|
@@ -418,7 +409,7 @@ export class PXE {
|
|
|
418
409
|
isContractClassPubliclyRegistered: boolean;
|
|
419
410
|
artifact: ContractArtifact | undefined;
|
|
420
411
|
}> {
|
|
421
|
-
const artifact = await this.
|
|
412
|
+
const artifact = await this.contractStore.getContractArtifact(id);
|
|
422
413
|
if (!artifact) {
|
|
423
414
|
this.log.warn(`No artifact found for contract class ${id.toString()} when looking for its metadata`);
|
|
424
415
|
}
|
|
@@ -448,7 +439,7 @@ export class PXE {
|
|
|
448
439
|
}> {
|
|
449
440
|
let instance;
|
|
450
441
|
try {
|
|
451
|
-
instance = await this.
|
|
442
|
+
instance = await this.contractStore.getContractInstance(address);
|
|
452
443
|
} catch {
|
|
453
444
|
this.log.warn(`No instance found for contract ${address.toString()} when looking for its metadata`);
|
|
454
445
|
}
|
|
@@ -480,56 +471,58 @@ export class PXE {
|
|
|
480
471
|
this.log.debug(`Registered account\n ${accountCompleteAddress.toReadableString()}`);
|
|
481
472
|
}
|
|
482
473
|
|
|
483
|
-
await this.
|
|
484
|
-
await this.
|
|
474
|
+
await this.addressStore.addCompleteAddress(accountCompleteAddress);
|
|
475
|
+
await this.noteStore.addScope(accountCompleteAddress.address);
|
|
485
476
|
return accountCompleteAddress;
|
|
486
477
|
}
|
|
487
478
|
|
|
488
479
|
/**
|
|
489
|
-
* Registers a
|
|
480
|
+
* Registers a sender in this PXE.
|
|
490
481
|
*
|
|
491
|
-
*
|
|
492
|
-
* Will do nothing if the
|
|
482
|
+
* After registering a new sender, the PXE will sync private logs that are tagged with this sender's address.
|
|
483
|
+
* Will do nothing if the address is already registered.
|
|
493
484
|
*
|
|
494
|
-
* @param
|
|
495
|
-
* @returns The address
|
|
485
|
+
* @param sender - Address of the sender to register.
|
|
486
|
+
* @returns The address of the sender.
|
|
487
|
+
* TODO: It's strange that we return the address here and I (benesjan) think we should drop the return value.
|
|
496
488
|
*/
|
|
497
|
-
public async registerSender(
|
|
489
|
+
public async registerSender(sender: AztecAddress): Promise<AztecAddress> {
|
|
498
490
|
const accounts = await this.keyStore.getAccounts();
|
|
499
|
-
if (accounts.includes(
|
|
500
|
-
this.log.info(`Sender:\n "${
|
|
501
|
-
return
|
|
491
|
+
if (accounts.includes(sender)) {
|
|
492
|
+
this.log.info(`Sender:\n "${sender.toString()}"\n already registered.`);
|
|
493
|
+
return sender;
|
|
502
494
|
}
|
|
503
495
|
|
|
504
|
-
const wasAdded = await this.
|
|
496
|
+
const wasAdded = await this.senderAddressBookStore.addSender(sender);
|
|
505
497
|
|
|
506
498
|
if (wasAdded) {
|
|
507
|
-
this.log.info(`Added sender:\n ${
|
|
499
|
+
this.log.info(`Added sender:\n ${sender.toString()}`);
|
|
508
500
|
} else {
|
|
509
|
-
this.log.info(`Sender:\n "${
|
|
501
|
+
this.log.info(`Sender:\n "${sender.toString()}"\n already registered.`);
|
|
510
502
|
}
|
|
511
503
|
|
|
512
|
-
return
|
|
504
|
+
return sender;
|
|
513
505
|
}
|
|
514
506
|
|
|
515
507
|
/**
|
|
516
|
-
* Retrieves
|
|
517
|
-
* @returns
|
|
508
|
+
* Retrieves senders registered in this PXE.
|
|
509
|
+
* @returns Senders registered in this PXE.
|
|
518
510
|
*/
|
|
519
511
|
public getSenders(): Promise<AztecAddress[]> {
|
|
520
|
-
return this.
|
|
512
|
+
return this.senderAddressBookStore.getSenders();
|
|
521
513
|
}
|
|
522
514
|
|
|
523
515
|
/**
|
|
524
|
-
* Removes a sender in
|
|
516
|
+
* Removes a sender registered in this PXE.
|
|
517
|
+
* @param sender - The address of the sender to remove.
|
|
525
518
|
*/
|
|
526
|
-
public async removeSender(
|
|
527
|
-
const wasRemoved = await this.
|
|
519
|
+
public async removeSender(sender: AztecAddress): Promise<void> {
|
|
520
|
+
const wasRemoved = await this.senderAddressBookStore.removeSender(sender);
|
|
528
521
|
|
|
529
522
|
if (wasRemoved) {
|
|
530
|
-
this.log.info(`Removed sender:\n ${
|
|
523
|
+
this.log.info(`Removed sender:\n ${sender.toString()}`);
|
|
531
524
|
} else {
|
|
532
|
-
this.log.info(`Sender:\n "${
|
|
525
|
+
this.log.info(`Sender:\n "${sender.toString()}"\n not registered in PXE.`);
|
|
533
526
|
}
|
|
534
527
|
}
|
|
535
528
|
|
|
@@ -539,7 +532,7 @@ export class PXE {
|
|
|
539
532
|
*/
|
|
540
533
|
public async getRegisteredAccounts(): Promise<CompleteAddress[]> {
|
|
541
534
|
// Get complete addresses of both the recipients and the accounts
|
|
542
|
-
const completeAddresses = await this.
|
|
535
|
+
const completeAddresses = await this.addressStore.getCompleteAddresses();
|
|
543
536
|
// Filter out the addresses not corresponding to accounts
|
|
544
537
|
const accounts = await this.keyStore.getAccounts();
|
|
545
538
|
return completeAddresses.filter(completeAddress =>
|
|
@@ -554,7 +547,7 @@ export class PXE {
|
|
|
554
547
|
*/
|
|
555
548
|
public async registerContractClass(artifact: ContractArtifact): Promise<void> {
|
|
556
549
|
const { id: contractClassId } = await getContractClassFromArtifact(artifact);
|
|
557
|
-
await this.
|
|
550
|
+
await this.contractStore.addContractArtifact(contractClassId, artifact);
|
|
558
551
|
this.log.info(`Added contract class ${artifact.name} with id ${contractClassId}`);
|
|
559
552
|
}
|
|
560
553
|
|
|
@@ -583,7 +576,7 @@ export class PXE {
|
|
|
583
576
|
if (!computedAddress.equals(instance.address)) {
|
|
584
577
|
throw new Error('Added a contract in which the address does not match the contract instance.');
|
|
585
578
|
}
|
|
586
|
-
await this.
|
|
579
|
+
await this.contractStore.addContractArtifact(contractClass.id, artifact);
|
|
587
580
|
|
|
588
581
|
const publicFunctionSignatures = artifact.functions
|
|
589
582
|
.filter(fn => fn.functionType === FunctionType.PUBLIC)
|
|
@@ -591,7 +584,7 @@ export class PXE {
|
|
|
591
584
|
await this.node.registerContractFunctionSignatures(publicFunctionSignatures);
|
|
592
585
|
} else {
|
|
593
586
|
// Otherwise, make sure there is an artifact already registered for that class id
|
|
594
|
-
artifact = await this.
|
|
587
|
+
artifact = await this.contractStore.getContractArtifact(instance.currentContractClassId);
|
|
595
588
|
if (!artifact) {
|
|
596
589
|
throw new Error(
|
|
597
590
|
`Artifact not found when registering an instance. Contract class: ${instance.currentContractClassId}.`,
|
|
@@ -599,7 +592,7 @@ export class PXE {
|
|
|
599
592
|
}
|
|
600
593
|
}
|
|
601
594
|
|
|
602
|
-
await this.
|
|
595
|
+
await this.contractStore.addContractInstance(instance);
|
|
603
596
|
this.log.info(
|
|
604
597
|
`Added contract ${artifact.name} at ${instance.address.toString()} with class ${instance.currentContractClassId}`,
|
|
605
598
|
);
|
|
@@ -618,14 +611,14 @@ export class PXE {
|
|
|
618
611
|
// We disable concurrently updating contracts to avoid concurrently syncing with the node, or changing a contract's
|
|
619
612
|
// class while we're simulating it.
|
|
620
613
|
return this.#putInJobQueue(async () => {
|
|
621
|
-
const currentInstance = await this.
|
|
614
|
+
const currentInstance = await this.contractStore.getContractInstance(contractAddress);
|
|
622
615
|
if (!currentInstance) {
|
|
623
616
|
throw new Error(`Instance not found when updating a contract. Contract address: ${contractAddress}.`);
|
|
624
617
|
}
|
|
625
618
|
const contractClass = await getContractClassFromArtifact(artifact);
|
|
626
|
-
await this.
|
|
619
|
+
await this.blockStateSynchronizer.sync();
|
|
627
620
|
|
|
628
|
-
const header = await this.
|
|
621
|
+
const header = await this.anchorBlockStore.getBlockHeader();
|
|
629
622
|
|
|
630
623
|
const currentClassId = await readCurrentClassId(
|
|
631
624
|
contractAddress,
|
|
@@ -638,7 +631,7 @@ export class PXE {
|
|
|
638
631
|
throw new Error('Could not update contract to a class different from the current one.');
|
|
639
632
|
}
|
|
640
633
|
|
|
641
|
-
await this.
|
|
634
|
+
await this.contractStore.addContractArtifact(contractClass.id, artifact);
|
|
642
635
|
|
|
643
636
|
const publicFunctionSignatures = artifact.functions
|
|
644
637
|
.filter(fn => fn.functionType === FunctionType.PUBLIC)
|
|
@@ -646,7 +639,7 @@ export class PXE {
|
|
|
646
639
|
await this.node.registerContractFunctionSignatures(publicFunctionSignatures);
|
|
647
640
|
|
|
648
641
|
currentInstance.currentContractClassId = contractClass.id;
|
|
649
|
-
await this.
|
|
642
|
+
await this.contractStore.addContractInstance(currentInstance);
|
|
650
643
|
this.log.info(`Updated contract ${artifact.name} at ${contractAddress.toString()} to class ${contractClass.id}`);
|
|
651
644
|
});
|
|
652
645
|
}
|
|
@@ -656,26 +649,7 @@ export class PXE {
|
|
|
656
649
|
* @returns An array of contracts addresses registered on this PXE.
|
|
657
650
|
*/
|
|
658
651
|
public getContracts(): Promise<AztecAddress[]> {
|
|
659
|
-
return this.
|
|
660
|
-
}
|
|
661
|
-
|
|
662
|
-
/**
|
|
663
|
-
* A debugging utility to get notes based on the provided filter.
|
|
664
|
-
*
|
|
665
|
-
* Note that this should not be used in production code because the structure of notes is considered to be
|
|
666
|
-
* an implementation detail of contracts. This is only meant to be used for debugging purposes. If you need to obtain
|
|
667
|
-
* note-related information in production code, please implement a custom utility function on your contract and call
|
|
668
|
-
* that function instead (e.g. `get_balance(owner: AztecAddress) -> u128` utility function on a Token contract).
|
|
669
|
-
*
|
|
670
|
-
* @param filter - The filter to apply to the notes.
|
|
671
|
-
* @returns The requested notes.
|
|
672
|
-
*/
|
|
673
|
-
public async getNotes(filter: NotesFilter): Promise<NoteDao[]> {
|
|
674
|
-
// We need to manually trigger private state sync to have a guarantee that all the notes are available.
|
|
675
|
-
const call = await this.#getFunctionCall('sync_private_state', [], filter.contractAddress);
|
|
676
|
-
await this.simulateUtility(call);
|
|
677
|
-
|
|
678
|
-
return this.noteDataProvider.getNotes(filter);
|
|
652
|
+
return this.contractStore.getContractsAddresses();
|
|
679
653
|
}
|
|
680
654
|
|
|
681
655
|
/**
|
|
@@ -695,7 +669,7 @@ export class PXE {
|
|
|
695
669
|
const totalTimer = new Timer();
|
|
696
670
|
try {
|
|
697
671
|
const syncTimer = new Timer();
|
|
698
|
-
await this.
|
|
672
|
+
await this.blockStateSynchronizer.sync();
|
|
699
673
|
const syncTime = syncTimer.ms();
|
|
700
674
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
701
675
|
privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest);
|
|
@@ -735,14 +709,22 @@ export class PXE {
|
|
|
735
709
|
nodeRPCCalls: contractFunctionSimulator?.getStats().nodeRPCCalls,
|
|
736
710
|
});
|
|
737
711
|
|
|
712
|
+
// While not strictly necessary to store tagging cache contents in the DB since we sync tagging indexes from
|
|
713
|
+
// chain before sending new logs, the sync can only see logs already included in blocks. If we send another
|
|
714
|
+
// transaction before this one is included in a block from this PXE, and that transaction contains a log with
|
|
715
|
+
// a tag derived from the same secret, we would reuse the tag and the transactions would be linked. Hence
|
|
716
|
+
// storing the tags here prevents linkage of txs sent from the same PXE.
|
|
738
717
|
const preTagsUsedInTheTx = privateExecutionResult.entrypoint.preTags;
|
|
739
718
|
if (preTagsUsedInTheTx.length > 0) {
|
|
740
|
-
|
|
741
|
-
|
|
719
|
+
// TODO(benesjan): The following is an expensive operation. Figure out a way to avoid it.
|
|
720
|
+
const txHash = (await txProvingResult.toTx()).txHash;
|
|
721
|
+
|
|
722
|
+
await this.senderTaggingStore.storePendingIndexes(preTagsUsedInTheTx, txHash);
|
|
723
|
+
this.log.debug(`Stored used pre-tags as sender for the tx`, {
|
|
742
724
|
preTagsUsedInTheTx,
|
|
743
725
|
});
|
|
744
726
|
} else {
|
|
745
|
-
this.log.debug(`No pre
|
|
727
|
+
this.log.debug(`No pre-tags used in the tx`);
|
|
746
728
|
}
|
|
747
729
|
|
|
748
730
|
return txProvingResult;
|
|
@@ -783,7 +765,7 @@ export class PXE {
|
|
|
783
765
|
txInfo,
|
|
784
766
|
);
|
|
785
767
|
const syncTimer = new Timer();
|
|
786
|
-
await this.
|
|
768
|
+
await this.blockStateSynchronizer.sync();
|
|
787
769
|
const syncTime = syncTimer.ms();
|
|
788
770
|
|
|
789
771
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
@@ -883,7 +865,7 @@ export class PXE {
|
|
|
883
865
|
txInfo,
|
|
884
866
|
);
|
|
885
867
|
const syncTimer = new Timer();
|
|
886
|
-
await this.
|
|
868
|
+
await this.blockStateSynchronizer.sync();
|
|
887
869
|
const syncTime = syncTimer.ms();
|
|
888
870
|
|
|
889
871
|
const contractFunctionSimulator = this.#getSimulatorForTx(overrides);
|
|
@@ -907,7 +889,7 @@ export class PXE {
|
|
|
907
889
|
({ publicInputs, executionSteps } = await generateSimulatedProvingResult(
|
|
908
890
|
privateExecutionResult,
|
|
909
891
|
nonceGenerator,
|
|
910
|
-
this.
|
|
892
|
+
this.contractStore,
|
|
911
893
|
));
|
|
912
894
|
} else {
|
|
913
895
|
// Kernel logic, plus proving of all private functions and kernels.
|
|
@@ -1012,10 +994,15 @@ export class PXE {
|
|
|
1012
994
|
try {
|
|
1013
995
|
const totalTimer = new Timer();
|
|
1014
996
|
const syncTimer = new Timer();
|
|
1015
|
-
await this.
|
|
997
|
+
await this.blockStateSynchronizer.sync();
|
|
1016
998
|
const syncTime = syncTimer.ms();
|
|
1017
999
|
const functionTimer = new Timer();
|
|
1018
1000
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
1001
|
+
|
|
1002
|
+
await this.contractStore.syncPrivateState(call.to, call.selector, privateSyncCall =>
|
|
1003
|
+
this.#simulateUtility(contractFunctionSimulator, privateSyncCall),
|
|
1004
|
+
);
|
|
1005
|
+
|
|
1019
1006
|
const executionResult = await this.#simulateUtility(contractFunctionSimulator, call, authwits ?? [], scopes);
|
|
1020
1007
|
const functionTime = functionTimer.ms();
|
|
1021
1008
|
|
|
@@ -1057,21 +1044,25 @@ export class PXE {
|
|
|
1057
1044
|
* Defaults to the latest known block to PXE + 1.
|
|
1058
1045
|
* @returns - The packed events with block and tx metadata.
|
|
1059
1046
|
*/
|
|
1060
|
-
public
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
this.log.error(
|
|
1071
|
-
`Getting private events for ${sanitizedFilter.contractAddress.toString()} from ${sanitizedFilter.fromBlock} to ${sanitizedFilter.toBlock}`,
|
|
1072
|
-
);
|
|
1047
|
+
public getPrivateEvents(eventSelector: EventSelector, filter: PrivateEventFilter): Promise<PackedPrivateEvent[]> {
|
|
1048
|
+
return this.#putInJobQueue(async () => {
|
|
1049
|
+
await this.blockStateSynchronizer.sync();
|
|
1050
|
+
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
1051
|
+
|
|
1052
|
+
await this.contractStore.syncPrivateState(
|
|
1053
|
+
filter.contractAddress,
|
|
1054
|
+
null,
|
|
1055
|
+
async privateSyncCall => await this.#simulateUtility(contractFunctionSimulator, privateSyncCall),
|
|
1056
|
+
);
|
|
1073
1057
|
|
|
1074
|
-
|
|
1058
|
+
const sanitizedFilter = await new PrivateEventFilterValidator(this.anchorBlockStore).validate(filter);
|
|
1059
|
+
|
|
1060
|
+
this.log.debug(
|
|
1061
|
+
`Getting private events for ${sanitizedFilter.contractAddress.toString()} from ${sanitizedFilter.fromBlock} to ${sanitizedFilter.toBlock}`,
|
|
1062
|
+
);
|
|
1063
|
+
|
|
1064
|
+
return this.privateEventStore.getPrivateEvents(eventSelector, sanitizedFilter);
|
|
1065
|
+
});
|
|
1075
1066
|
}
|
|
1076
1067
|
|
|
1077
1068
|
/**
|