@aztec/pxe 0.0.1-commit.c7c42ec → 0.0.1-commit.cf93bcc56
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/access_scopes.d.ts +9 -0
- package/dest/access_scopes.d.ts.map +1 -0
- package/dest/access_scopes.js +6 -0
- package/dest/bin/check_oracle_version.js +1 -1
- package/dest/block_synchronizer/block_synchronizer.d.ts +13 -5
- package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
- package/dest/block_synchronizer/block_synchronizer.js +74 -20
- package/dest/config/index.d.ts +3 -1
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +17 -0
- package/dest/config/package_info.js +1 -1
- package/dest/contract_function_simulator/benchmarked_node.d.ts +9 -0
- package/dest/contract_function_simulator/benchmarked_node.d.ts.map +1 -0
- package/dest/contract_function_simulator/benchmarked_node.js +77 -0
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +57 -34
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +195 -77
- package/dest/contract_function_simulator/execution_note_cache.d.ts +18 -9
- package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_note_cache.js +45 -28
- package/dest/contract_function_simulator/index.d.ts +2 -2
- package/dest/contract_function_simulator/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.js +1 -1
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +4 -3
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/event_validation_request.js +7 -4
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +3 -3
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/note_validation_request.js +2 -2
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +4 -10
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/utility_context.js +7 -18
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +17 -13
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +3 -1
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +6 -6
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/note_packing_utils.js +8 -8
- package/dest/contract_function_simulator/oracle/oracle.d.ts +12 -10
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +67 -44
- package/dest/contract_function_simulator/oracle/private_execution.d.ts +2 -26
- package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution.js +1 -37
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +45 -47
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +92 -53
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +67 -33
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +132 -108
- package/dest/contract_sync/contract_sync_service.d.ts +43 -0
- package/dest/contract_sync/contract_sync_service.d.ts.map +1 -0
- package/dest/contract_sync/contract_sync_service.js +97 -0
- package/dest/contract_sync/helpers.d.ts +29 -0
- package/dest/contract_sync/helpers.d.ts.map +1 -0
- package/dest/contract_sync/helpers.js +55 -0
- package/dest/debug/pxe_debug_utils.d.ts +24 -10
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
- package/dest/debug/pxe_debug_utils.js +28 -17
- package/dest/entrypoints/client/bundle/index.d.ts +3 -1
- package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.js +2 -0
- package/dest/entrypoints/client/bundle/utils.d.ts +1 -1
- package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/utils.js +31 -8
- package/dest/entrypoints/client/lazy/index.d.ts +3 -1
- package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/index.js +2 -0
- package/dest/entrypoints/client/lazy/utils.d.ts +2 -2
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +32 -9
- package/dest/entrypoints/pxe_creation_options.d.ts +5 -3
- package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
- package/dest/entrypoints/server/index.d.ts +5 -1
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +4 -0
- package/dest/entrypoints/server/utils.d.ts +1 -1
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +39 -16
- package/dest/events/event_service.d.ts +6 -6
- package/dest/events/event_service.d.ts.map +1 -1
- package/dest/events/event_service.js +19 -22
- package/dest/events/private_event_filter_validator.d.ts +5 -5
- package/dest/events/private_event_filter_validator.d.ts.map +1 -1
- package/dest/events/private_event_filter_validator.js +5 -6
- package/dest/job_coordinator/job_coordinator.d.ts +75 -0
- package/dest/job_coordinator/job_coordinator.d.ts.map +1 -0
- package/dest/job_coordinator/job_coordinator.js +94 -0
- package/dest/logs/log_service.d.ts +8 -5
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +28 -30
- package/dest/notes/note_service.d.ts +10 -9
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +34 -38
- package/dest/notes_filter.d.ts +25 -0
- package/dest/notes_filter.d.ts.map +1 -0
- package/dest/notes_filter.js +4 -0
- package/dest/oracle_version.d.ts +3 -3
- package/dest/oracle_version.d.ts.map +1 -1
- package/dest/oracle_version.js +4 -3
- package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts +4 -0
- package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts.map +1 -0
- package/dest/private_kernel/hints/{compute_tx_include_by_timestamp.js → compute_tx_expiration_timestamp.js} +12 -12
- package/dest/private_kernel/hints/index.d.ts +3 -3
- package/dest/private_kernel/hints/index.d.ts.map +1 -1
- package/dest/private_kernel/hints/index.js +2 -2
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +28 -0
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -0
- package/dest/private_kernel/hints/{build_private_kernel_reset_private_inputs.js → private_kernel_reset_private_inputs_builder.js} +16 -10
- package/dest/private_kernel/private_kernel_execution_prover.d.ts +3 -2
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.js +12 -13
- package/dest/private_kernel/private_kernel_oracle.d.ts +24 -28
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle.js +90 -2
- package/dest/pxe.d.ts +76 -58
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +131 -121
- package/dest/storage/address_store/address_store.d.ts +1 -1
- package/dest/storage/address_store/address_store.d.ts.map +1 -1
- package/dest/storage/address_store/address_store.js +12 -11
- package/dest/storage/anchor_block_store/anchor_block_store.d.ts +9 -1
- package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -1
- package/dest/storage/anchor_block_store/anchor_block_store.js +8 -1
- package/dest/storage/capsule_store/capsule_store.d.ts +24 -9
- package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -1
- package/dest/storage/capsule_store/capsule_store.js +130 -23
- package/dest/storage/contract_store/contract_store.d.ts +1 -1
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
- package/dest/storage/contract_store/contract_store.js +27 -18
- package/dest/storage/metadata.d.ts +1 -1
- package/dest/storage/metadata.js +1 -1
- package/dest/storage/note_store/note_store.d.ts +50 -51
- package/dest/storage/note_store/note_store.d.ts.map +1 -1
- package/dest/storage/note_store/note_store.js +284 -263
- package/dest/storage/note_store/stored_note.d.ts +16 -0
- package/dest/storage/note_store/stored_note.d.ts.map +1 -0
- package/dest/storage/note_store/stored_note.js +43 -0
- package/dest/storage/private_event_store/private_event_store.d.ts +47 -7
- package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
- package/dest/storage/private_event_store/private_event_store.js +231 -73
- package/dest/storage/private_event_store/stored_private_event.d.ts +23 -0
- package/dest/storage/private_event_store/stored_private_event.d.ts.map +1 -0
- package/dest/storage/private_event_store/stored_private_event.js +56 -0
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts +15 -8
- package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/recipient_tagging_store.js +88 -19
- package/dest/storage/tagging_store/sender_address_book_store.d.ts +1 -1
- package/dest/storage/tagging_store/sender_address_book_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_address_book_store.js +20 -14
- package/dest/storage/tagging_store/sender_tagging_store.d.ts +19 -9
- package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
- package/dest/storage/tagging_store/sender_tagging_store.js +253 -101
- package/dest/tagging/constants.d.ts +2 -0
- package/dest/tagging/constants.d.ts.map +1 -0
- package/dest/tagging/constants.js +10 -0
- package/dest/tagging/get_all_logs_by_tags.d.ts +24 -0
- package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -0
- package/dest/tagging/get_all_logs_by_tags.js +60 -0
- package/dest/tagging/index.d.ts +3 -2
- package/dest/tagging/index.d.ts.map +1 -1
- package/dest/tagging/index.js +2 -10
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +3 -2
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -1
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +12 -12
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +2 -2
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +3 -2
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -1
- package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +5 -2
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +3 -2
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +8 -8
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +1 -1
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -1
- package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +5 -8
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +5 -2
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
- package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +10 -5
- package/package.json +27 -18
- package/src/access_scopes.ts +9 -0
- package/src/bin/check_oracle_version.ts +1 -0
- package/src/block_synchronizer/block_synchronizer.ts +93 -32
- package/src/config/index.ts +14 -0
- package/src/config/package_info.ts +1 -1
- package/src/contract_function_simulator/benchmarked_node.ts +103 -0
- package/src/contract_function_simulator/contract_function_simulator.ts +348 -133
- package/src/contract_function_simulator/execution_note_cache.ts +44 -25
- package/src/contract_function_simulator/index.ts +1 -1
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +6 -2
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +2 -2
- package/src/contract_function_simulator/noir-structs/utility_context.ts +6 -25
- package/src/contract_function_simulator/oracle/interfaces.ts +22 -12
- package/src/contract_function_simulator/oracle/note_packing_utils.ts +10 -10
- package/src/contract_function_simulator/oracle/oracle.ts +79 -47
- package/src/contract_function_simulator/oracle/private_execution.ts +1 -69
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +129 -132
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +197 -115
- package/src/contract_sync/contract_sync_service.ts +152 -0
- package/src/contract_sync/helpers.ts +98 -0
- package/src/debug/pxe_debug_utils.ts +63 -18
- package/src/entrypoints/client/bundle/index.ts +2 -0
- package/src/entrypoints/client/bundle/utils.ts +23 -16
- package/src/entrypoints/client/lazy/index.ts +2 -0
- package/src/entrypoints/client/lazy/utils.ts +24 -17
- package/src/entrypoints/pxe_creation_options.ts +4 -2
- package/src/entrypoints/server/index.ts +4 -0
- package/src/entrypoints/server/utils.ts +33 -41
- package/src/events/event_service.ts +19 -25
- package/src/events/private_event_filter_validator.ts +3 -5
- package/src/job_coordinator/job_coordinator.ts +150 -0
- package/src/logs/log_service.ts +40 -34
- package/src/notes/note_service.ts +41 -45
- package/src/notes_filter.ts +26 -0
- package/src/oracle_version.ts +4 -3
- package/src/private_kernel/hints/{compute_tx_include_by_timestamp.ts → compute_tx_expiration_timestamp.ts} +13 -13
- package/src/private_kernel/hints/index.ts +2 -2
- package/src/private_kernel/hints/{build_private_kernel_reset_private_inputs.ts → private_kernel_reset_private_inputs_builder.ts} +39 -28
- package/src/private_kernel/private_kernel_execution_prover.ts +15 -14
- package/src/private_kernel/private_kernel_oracle.ts +116 -36
- package/src/pxe.ts +257 -180
- package/src/storage/address_store/address_store.ts +15 -15
- package/src/storage/anchor_block_store/anchor_block_store.ts +8 -0
- package/src/storage/capsule_store/capsule_store.ts +159 -23
- package/src/storage/contract_store/contract_store.ts +26 -15
- package/src/storage/metadata.ts +1 -1
- package/src/storage/note_store/note_store.ts +326 -320
- package/src/storage/note_store/stored_note.ts +48 -0
- package/src/storage/private_event_store/private_event_store.ts +301 -79
- package/src/storage/private_event_store/stored_private_event.ts +73 -0
- package/src/storage/tagging_store/recipient_tagging_store.ts +106 -20
- package/src/storage/tagging_store/sender_address_book_store.ts +20 -14
- package/src/storage/tagging_store/sender_tagging_store.ts +294 -109
- package/src/tagging/constants.ts +10 -0
- package/src/tagging/get_all_logs_by_tags.ts +92 -0
- package/src/tagging/index.ts +2 -11
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +25 -11
- package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +2 -2
- package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +7 -1
- package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +10 -7
- package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +5 -13
- package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +16 -4
- package/dest/contract_function_simulator/proxied_node.d.ts +0 -9
- package/dest/contract_function_simulator/proxied_node.d.ts.map +0 -1
- package/dest/contract_function_simulator/proxied_node.js +0 -27
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts +0 -28
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts.map +0 -1
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +0 -4
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts.map +0 -1
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts +0 -46
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +0 -1
- package/dest/private_kernel/private_kernel_oracle_impl.js +0 -86
- package/dest/public_storage/public_storage_service.d.ts +0 -24
- package/dest/public_storage/public_storage_service.d.ts.map +0 -1
- package/dest/public_storage/public_storage_service.js +0 -26
- package/dest/tree_membership/tree_membership_service.d.ts +0 -52
- package/dest/tree_membership/tree_membership_service.d.ts.map +0 -1
- package/dest/tree_membership/tree_membership_service.js +0 -84
- package/src/contract_function_simulator/proxied_node.ts +0 -33
- package/src/private_kernel/private_kernel_oracle_impl.ts +0 -133
- package/src/public_storage/public_storage_service.ts +0 -33
- package/src/tree_membership/tree_membership_service.ts +0 -112
|
@@ -2,34 +2,49 @@ import { Fr } from '@aztec/foundation/curves/bn254';
|
|
|
2
2
|
import { type Logger } from '@aztec/foundation/log';
|
|
3
3
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
4
4
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
-
|
|
5
|
+
import type { StagedStore } from '../../job_coordinator/job_coordinator.js';
|
|
6
|
+
export declare class CapsuleStore implements StagedStore {
|
|
6
7
|
#private;
|
|
8
|
+
readonly storeName = "capsule";
|
|
7
9
|
logger: Logger;
|
|
8
10
|
constructor(store: AztecAsyncKVStore);
|
|
11
|
+
/**
|
|
12
|
+
* Commits staged data to main storage.
|
|
13
|
+
* Called by JobCoordinator when a job completes successfully.
|
|
14
|
+
* Note: JobCoordinator wraps all commits in a single transaction, so we don't
|
|
15
|
+
* need our own transactionAsync here (and using one would deadlock on IndexedDB).
|
|
16
|
+
* @param jobId - The jobId identifying which staged data to commit
|
|
17
|
+
*/
|
|
18
|
+
commit(jobId: string): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Discards staged data without committing.
|
|
21
|
+
*/
|
|
22
|
+
discardStaged(jobId: string): Promise<void>;
|
|
9
23
|
/**
|
|
10
24
|
* Stores arbitrary information in a per-contract non-volatile database, which can later be retrieved with `loadCapsule`.
|
|
11
25
|
* * If data was already stored at this slot, it is overwritten.
|
|
12
26
|
* @param contractAddress - The contract address to scope the data under.
|
|
13
27
|
* @param slot - The slot in the database in which to store the value. Slots need not be contiguous.
|
|
14
28
|
* @param capsule - An array of field elements representing the capsule.
|
|
29
|
+
* @param jobId - The context in which this store will be visible until PXE decides to persist it to underlying KV store
|
|
15
30
|
* @remarks A capsule is a "blob" of data that is passed to the contract through an oracle. It works similarly
|
|
16
31
|
* to public contract storage in that it's indexed by the contract address and storage slot but instead of the global
|
|
17
32
|
* network state it's backed by local PXE db.
|
|
18
33
|
*/
|
|
19
|
-
storeCapsule(contractAddress: AztecAddress, slot: Fr, capsule: Fr[]):
|
|
34
|
+
storeCapsule(contractAddress: AztecAddress, slot: Fr, capsule: Fr[], jobId: string): void;
|
|
20
35
|
/**
|
|
21
36
|
* Returns data previously stored via `storeCapsule` in the per-contract non-volatile database.
|
|
22
37
|
* @param contractAddress - The contract address under which the data is scoped.
|
|
23
38
|
* @param slot - The slot in the database to read.
|
|
24
39
|
* @returns The stored data or `null` if no data is stored under the slot.
|
|
25
40
|
*/
|
|
26
|
-
loadCapsule(contractAddress: AztecAddress, slot: Fr): Promise<Fr[] | null>;
|
|
41
|
+
loadCapsule(contractAddress: AztecAddress, slot: Fr, jobId: string): Promise<Fr[] | null>;
|
|
27
42
|
/**
|
|
28
43
|
* Deletes data in the per-contract non-volatile database. Does nothing if no data was present.
|
|
29
44
|
* @param contractAddress - The contract address under which the data is scoped.
|
|
30
45
|
* @param slot - The slot in the database to delete.
|
|
31
46
|
*/
|
|
32
|
-
deleteCapsule(contractAddress: AztecAddress, slot: Fr):
|
|
47
|
+
deleteCapsule(contractAddress: AztecAddress, slot: Fr, jobId: string): void;
|
|
33
48
|
/**
|
|
34
49
|
* Copies a number of contiguous entries in the per-contract non-volatile database. This allows for efficient data
|
|
35
50
|
* structures by avoiding repeated calls to `loadCapsule` and `storeCapsule`.
|
|
@@ -41,7 +56,7 @@ export declare class CapsuleStore {
|
|
|
41
56
|
* @param dstSlot - The first slot to copy to.
|
|
42
57
|
* @param numEntries - The number of entries to copy.
|
|
43
58
|
*/
|
|
44
|
-
copyCapsule(contractAddress: AztecAddress, srcSlot: Fr, dstSlot: Fr, numEntries: number): Promise<void>;
|
|
59
|
+
copyCapsule(contractAddress: AztecAddress, srcSlot: Fr, dstSlot: Fr, numEntries: number, jobId: string): Promise<void>;
|
|
45
60
|
/**
|
|
46
61
|
* Appends multiple capsules to a capsule array stored at the base slot.
|
|
47
62
|
* The array length is stored at the base slot, and elements are stored in consecutive slots after it.
|
|
@@ -50,8 +65,8 @@ export declare class CapsuleStore {
|
|
|
50
65
|
* @param baseSlot - The slot where the array length is stored
|
|
51
66
|
* @param content - Array of capsule data to append
|
|
52
67
|
*/
|
|
53
|
-
appendToCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr, content: Fr[][]): Promise<void>;
|
|
54
|
-
readCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr): Promise<Fr[][]>;
|
|
55
|
-
setCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr, content: Fr[][]): Promise<void>;
|
|
68
|
+
appendToCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr, content: Fr[][], jobId: string): Promise<void>;
|
|
69
|
+
readCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr, jobId: string): Promise<Fr[][]>;
|
|
70
|
+
setCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr, content: Fr[][], jobId: string): Promise<void>;
|
|
56
71
|
}
|
|
57
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
72
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2Fwc3VsZV9zdG9yZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3N0b3JhZ2UvY2Fwc3VsZV9zdG9yZS9jYXBzdWxlX3N0b3JlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxFQUFFLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUNwRCxPQUFPLEVBQUUsS0FBSyxNQUFNLEVBQWdCLE1BQU0sdUJBQXVCLENBQUM7QUFDbEUsT0FBTyxLQUFLLEVBQUUsaUJBQWlCLEVBQWlCLE1BQU0saUJBQWlCLENBQUM7QUFDeEUsT0FBTyxLQUFLLEVBQUUsWUFBWSxFQUFFLE1BQU0sNkJBQTZCLENBQUM7QUFFaEUsT0FBTyxLQUFLLEVBQUUsV0FBVyxFQUFFLE1BQU0sMENBQTBDLENBQUM7QUFFNUUscUJBQWEsWUFBYSxZQUFXLFdBQVc7O0lBQzlDLFFBQVEsQ0FBQyxTQUFTLGFBQWE7SUFZL0IsTUFBTSxFQU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xFQUFFLEVBQUUsRUFBRSxLQUFLLEVBQUUsTUFBTSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FxQi9HO0lBRUQsZ0JBQWdCLENBQUMsZUFBZSxFQUFFLFlBQVksRUFBRSxRQUFRLEVBQUUsRUFBRSxFQUFFLEtBQUssRUFBRSxNQUFNLEdBQUcsT0FBTyxDQUFDLEVBQUUsRUFBRSxFQUFFLENBQUMsQ0EyQjVGO0lBRUQsZUFBZSxDQUFDLGVBQWUsRUFBRSxZQUFZLEVBQUUsUUFBUSxFQUFFLEVBQUUsRUFBRSxPQUFPLEVBQUUsRUFBRSxFQUFFLEVBQUUsRUFBRSxLQUFLLEVBQUUsTUFBTSxpQkEyQjFGO0NBQ0YifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capsule_store.d.ts","sourceRoot":"","sources":["../../../src/storage/capsule_store/capsule_store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAClE,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE,qBAAa,
|
|
1
|
+
{"version":3,"file":"capsule_store.d.ts","sourceRoot":"","sources":["../../../src/storage/capsule_store/capsule_store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAClE,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAC;AAE5E,qBAAa,YAAa,YAAW,W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AAQ,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,iBA2B1F;CACF"}
|
|
@@ -1,34 +1,118 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
3
|
export class CapsuleStore {
|
|
4
|
+
storeName = 'capsule';
|
|
4
5
|
#store;
|
|
5
6
|
// Arbitrary data stored by contracts. Key is computed as `${contractAddress}:${key}`
|
|
6
7
|
#capsules;
|
|
8
|
+
// jobId => `${contractAddress}:${key}` => capsule data
|
|
9
|
+
// when `#stagedCapsules.get('some-job-id').get('${some-contract-address:some-key') === null`,
|
|
10
|
+
// it signals that the capsule was deleted during the job, so it needs to be deleted on commit
|
|
11
|
+
#stagedCapsules;
|
|
7
12
|
logger;
|
|
8
13
|
constructor(store){
|
|
9
14
|
this.#store = store;
|
|
10
15
|
this.#capsules = this.#store.openMap('capsules');
|
|
16
|
+
this.#stagedCapsules = new Map();
|
|
11
17
|
this.logger = createLogger('pxe:capsule-data-provider');
|
|
12
18
|
}
|
|
13
19
|
/**
|
|
20
|
+
* Given a job denoted by `jobId`, it returns the
|
|
21
|
+
* capsules that said job has interacted with.
|
|
22
|
+
*
|
|
23
|
+
* Capsules that haven't been committed to persistence KV storage
|
|
24
|
+
* are kept in-memory in `#stagedCapsules`, this method provides a convenient
|
|
25
|
+
* way to access that in-memory collection of data.
|
|
26
|
+
*
|
|
27
|
+
* @param jobId
|
|
28
|
+
* @returns
|
|
29
|
+
*/ #getJobStagedCapsules(jobId) {
|
|
30
|
+
let jobStagedCapsules = this.#stagedCapsules.get(jobId);
|
|
31
|
+
if (!jobStagedCapsules) {
|
|
32
|
+
jobStagedCapsules = new Map();
|
|
33
|
+
this.#stagedCapsules.set(jobId, jobStagedCapsules);
|
|
34
|
+
}
|
|
35
|
+
return jobStagedCapsules;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Reads a capsule's slot from the staged version of the data associated to the given jobId.
|
|
39
|
+
*
|
|
40
|
+
* If it is not there, it reads it from the KV store.
|
|
41
|
+
*/ async #getFromStage(jobId, dbSlotKey) {
|
|
42
|
+
const jobStagedCapsules = this.#getJobStagedCapsules(jobId);
|
|
43
|
+
const staged = jobStagedCapsules.get(dbSlotKey);
|
|
44
|
+
// Always issue DB read to keep IndexedDB transaction alive, even if the value is in the job staged data. This
|
|
45
|
+
// keeps IndexedDB transactions alive (they auto-commit when a new micro-task starts and there are no pending read
|
|
46
|
+
// requests). The staged value still takes precedence if it exists (including null for deletions).
|
|
47
|
+
const dbValue = await this.#loadCapsuleFromDb(dbSlotKey);
|
|
48
|
+
return staged !== undefined ? staged : dbValue;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Writes a capsule to the stage of a job.
|
|
52
|
+
*/ #setOnStage(jobId, dbSlotKey, capsuleData) {
|
|
53
|
+
this.#getJobStagedCapsules(jobId).set(dbSlotKey, capsuleData);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Deletes a capsule on the stage of a job. Note the capsule will still
|
|
57
|
+
* exist in storage until the job is committed.
|
|
58
|
+
*/ #deleteOnStage(jobId, dbSlotKey) {
|
|
59
|
+
this.#getJobStagedCapsules(jobId).set(dbSlotKey, null);
|
|
60
|
+
}
|
|
61
|
+
async #loadCapsuleFromDb(dbSlotKey) {
|
|
62
|
+
const dataBuffer = await this.#capsules.getAsync(dbSlotKey);
|
|
63
|
+
if (!dataBuffer) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
return dataBuffer;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Commits staged data to main storage.
|
|
70
|
+
* Called by JobCoordinator when a job completes successfully.
|
|
71
|
+
* Note: JobCoordinator wraps all commits in a single transaction, so we don't
|
|
72
|
+
* need our own transactionAsync here (and using one would deadlock on IndexedDB).
|
|
73
|
+
* @param jobId - The jobId identifying which staged data to commit
|
|
74
|
+
*/ async commit(jobId) {
|
|
75
|
+
const jobStagedCapsules = this.#getJobStagedCapsules(jobId);
|
|
76
|
+
for (const [key, value] of jobStagedCapsules){
|
|
77
|
+
// In the write stage, we represent deleted capsules with null
|
|
78
|
+
// (as opposed to undefined, which denotes there was never a capsule there to begin with).
|
|
79
|
+
// So we delete from actual KV store here.
|
|
80
|
+
if (value === null) {
|
|
81
|
+
await this.#capsules.delete(key);
|
|
82
|
+
} else {
|
|
83
|
+
await this.#capsules.set(key, value);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
this.#stagedCapsules.delete(jobId);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Discards staged data without committing.
|
|
90
|
+
*/ discardStaged(jobId) {
|
|
91
|
+
this.#stagedCapsules.delete(jobId);
|
|
92
|
+
return Promise.resolve();
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
14
95
|
* Stores arbitrary information in a per-contract non-volatile database, which can later be retrieved with `loadCapsule`.
|
|
15
96
|
* * If data was already stored at this slot, it is overwritten.
|
|
16
97
|
* @param contractAddress - The contract address to scope the data under.
|
|
17
98
|
* @param slot - The slot in the database in which to store the value. Slots need not be contiguous.
|
|
18
99
|
* @param capsule - An array of field elements representing the capsule.
|
|
100
|
+
* @param jobId - The context in which this store will be visible until PXE decides to persist it to underlying KV store
|
|
19
101
|
* @remarks A capsule is a "blob" of data that is passed to the contract through an oracle. It works similarly
|
|
20
102
|
* to public contract storage in that it's indexed by the contract address and storage slot but instead of the global
|
|
21
103
|
* network state it's backed by local PXE db.
|
|
22
|
-
*/
|
|
23
|
-
|
|
104
|
+
*/ storeCapsule(contractAddress, slot, capsule, jobId) {
|
|
105
|
+
const dbSlotKey = dbSlotToKey(contractAddress, slot);
|
|
106
|
+
// A store overrides any pre-existing data on the slot
|
|
107
|
+
this.#setOnStage(jobId, dbSlotKey, Buffer.concat(capsule.map((value)=>value.toBuffer())));
|
|
24
108
|
}
|
|
25
109
|
/**
|
|
26
110
|
* Returns data previously stored via `storeCapsule` in the per-contract non-volatile database.
|
|
27
111
|
* @param contractAddress - The contract address under which the data is scoped.
|
|
28
112
|
* @param slot - The slot in the database to read.
|
|
29
113
|
* @returns The stored data or `null` if no data is stored under the slot.
|
|
30
|
-
*/ async loadCapsule(contractAddress, slot) {
|
|
31
|
-
const dataBuffer = await this.#
|
|
114
|
+
*/ async loadCapsule(contractAddress, slot, jobId) {
|
|
115
|
+
const dataBuffer = await this.#getFromStage(jobId, dbSlotToKey(contractAddress, slot));
|
|
32
116
|
if (!dataBuffer) {
|
|
33
117
|
this.logger.trace(`Data not found for contract ${contractAddress.toString()} and slot ${slot.toString()}`);
|
|
34
118
|
return null;
|
|
@@ -43,8 +127,9 @@ export class CapsuleStore {
|
|
|
43
127
|
* Deletes data in the per-contract non-volatile database. Does nothing if no data was present.
|
|
44
128
|
* @param contractAddress - The contract address under which the data is scoped.
|
|
45
129
|
* @param slot - The slot in the database to delete.
|
|
46
|
-
*/
|
|
47
|
-
|
|
130
|
+
*/ deleteCapsule(contractAddress, slot, jobId) {
|
|
131
|
+
// When we commit this, we will interpret null as a deletion, so we'll propagate the delete to the KV store
|
|
132
|
+
this.#deleteOnStage(jobId, dbSlotToKey(contractAddress, slot));
|
|
48
133
|
}
|
|
49
134
|
/**
|
|
50
135
|
* Copies a number of contiguous entries in the per-contract non-volatile database. This allows for efficient data
|
|
@@ -56,7 +141,11 @@ export class CapsuleStore {
|
|
|
56
141
|
* @param srcSlot - The first slot to copy from.
|
|
57
142
|
* @param dstSlot - The first slot to copy to.
|
|
58
143
|
* @param numEntries - The number of entries to copy.
|
|
59
|
-
*/ copyCapsule(contractAddress, srcSlot, dstSlot, numEntries) {
|
|
144
|
+
*/ copyCapsule(contractAddress, srcSlot, dstSlot, numEntries, jobId) {
|
|
145
|
+
// This transactional context gives us "copy atomicity":
|
|
146
|
+
// there shouldn't be concurrent writes to what's being copied here.
|
|
147
|
+
// Equally important: this in practice is expected to perform thousands of DB operations
|
|
148
|
+
// and not using a transaction here would heavily impact performance.
|
|
60
149
|
return this.#store.transactionAsync(async ()=>{
|
|
61
150
|
// In order to support overlapping source and destination regions, we need to check the relative positions of source
|
|
62
151
|
// and destination. If destination is ahead of source, then by the time we overwrite source elements using forward
|
|
@@ -69,11 +158,11 @@ export class CapsuleStore {
|
|
|
69
158
|
for (const i of indexes){
|
|
70
159
|
const currentSrcSlot = dbSlotToKey(contractAddress, srcSlot.add(new Fr(i)));
|
|
71
160
|
const currentDstSlot = dbSlotToKey(contractAddress, dstSlot.add(new Fr(i)));
|
|
72
|
-
const toCopy = await this.#
|
|
161
|
+
const toCopy = await this.#getFromStage(jobId, currentSrcSlot);
|
|
73
162
|
if (!toCopy) {
|
|
74
163
|
throw new Error(`Attempted to copy empty slot ${currentSrcSlot} for contract ${contractAddress.toString()}`);
|
|
75
164
|
}
|
|
76
|
-
|
|
165
|
+
this.#setOnStage(jobId, currentDstSlot, toCopy);
|
|
77
166
|
}
|
|
78
167
|
});
|
|
79
168
|
}
|
|
@@ -84,32 +173,42 @@ export class CapsuleStore {
|
|
|
84
173
|
* @param contractAddress - The contract address that owns the capsule array
|
|
85
174
|
* @param baseSlot - The slot where the array length is stored
|
|
86
175
|
* @param content - Array of capsule data to append
|
|
87
|
-
*/ appendToCapsuleArray(contractAddress, baseSlot, content) {
|
|
176
|
+
*/ appendToCapsuleArray(contractAddress, baseSlot, content, jobId) {
|
|
177
|
+
// We wrap this in a transaction to serialize concurrent calls from Promise.all.
|
|
178
|
+
// Without this, concurrent appends to the same array could race: both read length=0,
|
|
179
|
+
// both write at the same slots, one overwrites the other.
|
|
180
|
+
// Equally important: this in practice is expected to perform thousands of DB operations
|
|
181
|
+
// and not using a transaction here would heavily impact performance.
|
|
88
182
|
return this.#store.transactionAsync(async ()=>{
|
|
89
183
|
// Load current length, defaulting to 0 if not found
|
|
90
|
-
const lengthData = await this.loadCapsule(contractAddress, baseSlot);
|
|
184
|
+
const lengthData = await this.loadCapsule(contractAddress, baseSlot, jobId);
|
|
91
185
|
const currentLength = lengthData ? lengthData[0].toNumber() : 0;
|
|
92
186
|
// Store each capsule at consecutive slots after baseSlot + 1 + currentLength
|
|
93
187
|
for(let i = 0; i < content.length; i++){
|
|
94
188
|
const nextSlot = arraySlot(baseSlot, currentLength + i);
|
|
95
|
-
|
|
189
|
+
this.storeCapsule(contractAddress, nextSlot, content[i], jobId);
|
|
96
190
|
}
|
|
97
191
|
// Update length to include all new capsules
|
|
98
192
|
const newLength = currentLength + content.length;
|
|
99
|
-
|
|
193
|
+
this.storeCapsule(contractAddress, baseSlot, [
|
|
100
194
|
new Fr(newLength)
|
|
101
|
-
]);
|
|
195
|
+
], jobId);
|
|
102
196
|
});
|
|
103
197
|
}
|
|
104
|
-
readCapsuleArray(contractAddress, baseSlot) {
|
|
198
|
+
readCapsuleArray(contractAddress, baseSlot, jobId) {
|
|
199
|
+
// I'm leaving this transactional context here though because I'm assuming this
|
|
200
|
+
// gives us "read array atomicity": there shouldn't be concurrent writes to what's being copied
|
|
201
|
+
// here.
|
|
202
|
+
// This is one point we should revisit in the future if we want to relax the concurrency
|
|
203
|
+
// of jobs: different calls running concurrently on the same contract may cause trouble.
|
|
105
204
|
return this.#store.transactionAsync(async ()=>{
|
|
106
205
|
// Load length, defaulting to 0 if not found
|
|
107
|
-
const maybeLength = await this.loadCapsule(contractAddress, baseSlot);
|
|
206
|
+
const maybeLength = await this.loadCapsule(contractAddress, baseSlot, jobId);
|
|
108
207
|
const length = maybeLength ? maybeLength[0].toBigInt() : 0n;
|
|
109
208
|
const values = [];
|
|
110
209
|
// Read each capsule at consecutive slots after baseSlot
|
|
111
210
|
for(let i = 0; i < length; i++){
|
|
112
|
-
const currentValue = await this.loadCapsule(contractAddress, arraySlot(baseSlot, i));
|
|
211
|
+
const currentValue = await this.loadCapsule(contractAddress, arraySlot(baseSlot, i), jobId);
|
|
113
212
|
if (currentValue == undefined) {
|
|
114
213
|
throw new Error(`Expected non-empty value at capsule array in base slot ${baseSlot} at index ${i} for contract ${contractAddress}`);
|
|
115
214
|
}
|
|
@@ -118,22 +217,30 @@ export class CapsuleStore {
|
|
|
118
217
|
return values;
|
|
119
218
|
});
|
|
120
219
|
}
|
|
121
|
-
setCapsuleArray(contractAddress, baseSlot, content) {
|
|
220
|
+
setCapsuleArray(contractAddress, baseSlot, content, jobId) {
|
|
221
|
+
// This transactional context in theory isn't so critical now because we aren't
|
|
222
|
+
// writing to DB so if there's exceptions midway and it blows up, no visible impact
|
|
223
|
+
// to persistent storage will happen.
|
|
224
|
+
// I'm leaving this transactional context here though because I'm assuming this
|
|
225
|
+
// gives us "write array atomicity": there shouldn't be concurrent writes to what's being copied
|
|
226
|
+
// here.
|
|
227
|
+
// This is one point we should revisit in the future if we want to relax the concurrency
|
|
228
|
+
// of jobs: different calls running concurrently on the same contract may cause trouble.
|
|
122
229
|
return this.#store.transactionAsync(async ()=>{
|
|
123
230
|
// Load current length, defaulting to 0 if not found
|
|
124
|
-
const maybeLength = await this.loadCapsule(contractAddress, baseSlot);
|
|
231
|
+
const maybeLength = await this.loadCapsule(contractAddress, baseSlot, jobId);
|
|
125
232
|
const originalLength = maybeLength ? maybeLength[0].toNumber() : 0;
|
|
126
233
|
// Set the new length
|
|
127
|
-
|
|
234
|
+
this.storeCapsule(contractAddress, baseSlot, [
|
|
128
235
|
new Fr(content.length)
|
|
129
|
-
]);
|
|
236
|
+
], jobId);
|
|
130
237
|
// Store the new content, possibly overwriting existing values
|
|
131
238
|
for(let i = 0; i < content.length; i++){
|
|
132
|
-
|
|
239
|
+
this.storeCapsule(contractAddress, arraySlot(baseSlot, i), content[i], jobId);
|
|
133
240
|
}
|
|
134
241
|
// Clear any stragglers
|
|
135
242
|
for(let i = content.length; i < originalLength; i++){
|
|
136
|
-
|
|
243
|
+
this.deleteCapsule(contractAddress, arraySlot(baseSlot, i), jobId);
|
|
137
244
|
}
|
|
138
245
|
});
|
|
139
246
|
}
|
|
@@ -63,4 +63,4 @@ export declare class ContractStore {
|
|
|
63
63
|
getDebugFunctionName(contractAddress: AztecAddress, selector: FunctionSelector): Promise<string>;
|
|
64
64
|
getFunctionCall(functionName: string, args: any[], to: AztecAddress): Promise<FunctionCall>;
|
|
65
65
|
}
|
|
66
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
66
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29udHJhY3Rfc3RvcmUuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9zdG9yYWdlL2NvbnRyYWN0X3N0b3JlL2NvbnRyYWN0X3N0b3JlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLG9CQUFvQixFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFDN0QsT0FBTyxLQUFLLEVBQUUsRUFBRSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFFekQsT0FBTyxLQUFLLEVBQUUsaUJBQWlCLEVBQUUsTUFBTSx5QkFBeUIsQ0FBQztBQUNqRSxPQUFPLEtBQUssRUFBRSxpQkFBaUIsRUFBaUIsTUFBTSxpQkFBaUIsQ0FBQztBQUN4RSxPQUFPLEVBQ0wsS0FBSyxnQkFBZ0IsRUFDckIsS0FBSyxXQUFXLEVBRWhCLEtBQUssZ0NBQWdDLEVBQ3JDLFlBQVksRUFDWixLQUFLLHFCQUFxQixFQUMxQixnQkFBZ0IsRUFNakIsTUFBTSxtQkFBbUIsQ0FBQztBQUMzQixPQUFPLEVBQUUsWUFBWSxFQUFFLE1BQU0sNkJBQTZCLENBQUM7QUFDM0QsT0FBTyxFQUNMLEtBQUssYUFBYSxFQUNsQixLQUFLLDJCQUEyQixFQUdqQyxNQUFNLHdCQUF3QixDQUFDO0FBSWhDOzs7Ozs7R0FNRztBQUNILHFCQUFhLGFBQWE7O0lBWXhCLFlBQVksS0FBSyxFQUFFLGlCQUFpQixFQUlu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S,CAAC,CAI5C;IAEY,8BAA8B,CACzC,eAAe,EAAE,YAAY,GAC5B,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAI5C;IAED;;;;;;;;OAQG;IACU,4BAA4B,CACvC,eAAe,EAAE,EAAE,EACnB,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,iBAAiB,CAAC,OAAO,oBAAoB,CAAC,GAAG,SAAS,CAAC,CAGrE;IAEY,oBAAoB,CAAC,eAAe,EAAE,YAAY,+BAG9D;IAEY,oBAAoB,CAAC,eAAe,EAAE,YAAY,EAAE,QAAQ,EAAE,gBAAgB,mBAI1F;IA8BY,eAAe,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,CAuBvG;CACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { toArray } from '@aztec/foundation/iterable';
|
|
2
|
-
import { FunctionSelector, FunctionType, contractArtifactFromBuffer, contractArtifactToBuffer, encodeArguments, getFunctionDebugMetadata } from '@aztec/stdlib/abi';
|
|
2
|
+
import { FunctionCall, FunctionSelector, FunctionType, contractArtifactFromBuffer, contractArtifactToBuffer, encodeArguments, getFunctionDebugMetadata } from '@aztec/stdlib/abi';
|
|
3
3
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
4
|
import { SerializableContractInstance, getContractClassFromArtifact } from '@aztec/stdlib/contract';
|
|
5
5
|
import { PrivateFunctionsTree } from './private_functions_tree.js';
|
|
@@ -13,20 +13,23 @@ import { PrivateFunctionsTree } from './private_functions_tree.js';
|
|
|
13
13
|
/** Map from contract class id to private function tree. */ // TODO: Update it to be LRU cache so that it doesn't keep all the data all the time.
|
|
14
14
|
#privateFunctionTrees = new Map();
|
|
15
15
|
/** Map from contract address to contract class id */ #contractClassIdMap = new Map();
|
|
16
|
+
#store;
|
|
16
17
|
#contractArtifacts;
|
|
17
18
|
#contractInstances;
|
|
18
19
|
constructor(store){
|
|
20
|
+
this.#store = store;
|
|
19
21
|
this.#contractArtifacts = store.openMap('contract_artifacts');
|
|
20
22
|
this.#contractInstances = store.openMap('contracts_instances');
|
|
21
23
|
}
|
|
22
24
|
// Setters
|
|
23
25
|
async addContractArtifact(id, contract) {
|
|
26
|
+
// Validation outside transactionAsync - these are not DB operations
|
|
24
27
|
const privateFunctions = contract.functions.filter((functionArtifact)=>functionArtifact.functionType === FunctionType.PRIVATE);
|
|
25
28
|
const privateSelectors = await Promise.all(privateFunctions.map(async (privateFunctionArtifact)=>(await FunctionSelector.fromNameAndParameters(privateFunctionArtifact.name, privateFunctionArtifact.parameters)).toString()));
|
|
26
29
|
if (privateSelectors.length !== new Set(privateSelectors).size) {
|
|
27
30
|
throw new Error('Repeated function selectors of private functions');
|
|
28
31
|
}
|
|
29
|
-
await this.#contractArtifacts.set(id.toString(), contractArtifactToBuffer(contract));
|
|
32
|
+
await this.#store.transactionAsync(()=>this.#contractArtifacts.set(id.toString(), contractArtifactToBuffer(contract)));
|
|
30
33
|
}
|
|
31
34
|
async addContractInstance(contract) {
|
|
32
35
|
this.#contractClassIdMap.set(contract.address.toString(), contract.currentContractClassId);
|
|
@@ -68,18 +71,24 @@ import { PrivateFunctionsTree } from './private_functions_tree.js';
|
|
|
68
71
|
return contractClassId && this.getContractArtifact(contractClassId);
|
|
69
72
|
}
|
|
70
73
|
// Public getters
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
74
|
+
getContractsAddresses() {
|
|
75
|
+
return this.#store.transactionAsync(async ()=>{
|
|
76
|
+
const keys = await toArray(this.#contractInstances.keysAsync());
|
|
77
|
+
return keys.map(AztecAddress.fromString);
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
/** Returns a contract instance for a given address. Throws if not found. */ getContractInstance(contractAddress) {
|
|
81
|
+
return this.#store.transactionAsync(async ()=>{
|
|
82
|
+
const contract = await this.#contractInstances.getAsync(contractAddress.toString());
|
|
83
|
+
return contract && SerializableContractInstance.fromBuffer(contract).withAddress(contractAddress);
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
getContractArtifact(contractClassId) {
|
|
87
|
+
return this.#store.transactionAsync(async ()=>{
|
|
88
|
+
const contract = await this.#contractArtifacts.getAsync(contractClassId.toString());
|
|
89
|
+
// TODO(@spalladino): AztecAsyncMap lies and returns Uint8Arrays instead of Buffers, hence the extra Buffer.from.
|
|
90
|
+
return contract && contractArtifactFromBuffer(Buffer.from(contract));
|
|
91
|
+
});
|
|
83
92
|
}
|
|
84
93
|
/** Returns a contract class for a given class id. Throws if not found. */ async getContractClass(contractClassId) {
|
|
85
94
|
const artifact = await this.getContractArtifact(contractClassId);
|
|
@@ -210,15 +219,15 @@ import { PrivateFunctionsTree } from './private_functions_tree.js';
|
|
|
210
219
|
if (!functionDao) {
|
|
211
220
|
throw new Error(`Unknown function ${functionName} in contract ${contract.name}.`);
|
|
212
221
|
}
|
|
213
|
-
return {
|
|
222
|
+
return FunctionCall.from({
|
|
214
223
|
name: functionDao.name,
|
|
215
|
-
|
|
224
|
+
to,
|
|
216
225
|
selector: await FunctionSelector.fromNameAndParameters(functionDao.name, functionDao.parameters),
|
|
217
226
|
type: functionDao.functionType,
|
|
218
|
-
to,
|
|
219
227
|
hideMsgSender: false,
|
|
220
228
|
isStatic: functionDao.isStatic,
|
|
229
|
+
args: encodeArguments(functionDao, args),
|
|
221
230
|
returnTypes: functionDao.returnTypes
|
|
222
|
-
};
|
|
231
|
+
});
|
|
223
232
|
}
|
|
224
233
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const PXE_DATA_SCHEMA_VERSION =
|
|
1
|
+
export declare const PXE_DATA_SCHEMA_VERSION = 3;
|
|
2
2
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWV0YWRhdGEuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9zdG9yYWdlL21ldGFkYXRhLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLGVBQU8sTUFBTSx1QkFBdUIsSUFBSSxDQUFDIn0=
|
package/dest/storage/metadata.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const PXE_DATA_SCHEMA_VERSION =
|
|
1
|
+
export const PXE_DATA_SCHEMA_VERSION = 3;
|
|
@@ -1,84 +1,83 @@
|
|
|
1
|
-
import type { Fr } from '@aztec/foundation/
|
|
1
|
+
import type { Fr } from '@aztec/foundation/schemas';
|
|
2
2
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
3
|
-
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
4
|
import type { DataInBlock } from '@aztec/stdlib/block';
|
|
5
|
-
import { type NotesFilter } from '@aztec/stdlib/note';
|
|
6
5
|
import { NoteDao } from '@aztec/stdlib/note';
|
|
6
|
+
import type { StagedStore } from '../../job_coordinator/job_coordinator.js';
|
|
7
|
+
import type { NotesFilter } from '../../notes_filter.js';
|
|
7
8
|
/**
|
|
8
9
|
* NoteStore manages the storage and retrieval of notes.
|
|
9
10
|
*
|
|
10
|
-
* Notes can be active or nullified. This class processes new notes, nullifications,
|
|
11
|
-
*
|
|
11
|
+
* Notes can be active or nullified. This class processes new notes, nullifications, and performs rollback handling in
|
|
12
|
+
* the case of a reorg.
|
|
12
13
|
**/
|
|
13
|
-
export declare class NoteStore {
|
|
14
|
+
export declare class NoteStore implements StagedStore {
|
|
14
15
|
#private;
|
|
15
|
-
|
|
16
|
+
readonly storeName: string;
|
|
17
|
+
constructor(store: AztecAsyncKVStore);
|
|
16
18
|
/**
|
|
17
|
-
*
|
|
19
|
+
* Adds multiple notes to the notes store under the specified scope.
|
|
18
20
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
+
* Notes are stored using their siloedNullifier as the key, which provides uniqueness. Each note is indexed by
|
|
22
|
+
* multiple criteria for efficient retrieval.
|
|
21
23
|
*
|
|
22
|
-
* @param
|
|
23
|
-
* @
|
|
24
|
+
* @param notes - Notes to store
|
|
25
|
+
* @param scope - The scope (user/account) under which to store the notes
|
|
26
|
+
* @param jobId - The job context for staged writes
|
|
24
27
|
*/
|
|
25
|
-
|
|
28
|
+
addNotes(notes: NoteDao[], scope: AztecAddress, jobId: string): Promise<void[]>;
|
|
26
29
|
/**
|
|
27
|
-
*
|
|
30
|
+
* Retrieves notes based on the provided filter criteria.
|
|
28
31
|
*
|
|
29
|
-
*
|
|
30
|
-
* Each scope gets its own set of indexes for efficient note retrieval by various criteria.
|
|
32
|
+
* This method queries both active and optionally nullified notes based on the filter parameters.
|
|
31
33
|
*
|
|
32
|
-
* @param
|
|
33
|
-
*
|
|
34
|
+
* @param filter - Filter criteria including contractAddress (required), and optional owner,
|
|
35
|
+
* storageSlot, status, scopes, and siloedNullifier.
|
|
36
|
+
* @params jobId - the job context to read from.
|
|
37
|
+
* @returns Filtered and deduplicated notes (a note might be present in multiple scopes - we ensure it is only
|
|
38
|
+
* returned once if this is the case)
|
|
34
39
|
*/
|
|
35
|
-
|
|
40
|
+
getNotes(filter: NotesFilter, jobId: string): Promise<NoteDao[]>;
|
|
36
41
|
/**
|
|
37
|
-
*
|
|
42
|
+
* Transitions notes from "active" to "nullified" state.
|
|
38
43
|
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* for efficient retrieval.
|
|
44
|
+
* This operation processes a batch of nullifiers to mark the corresponding notes as spent/nullified.
|
|
45
|
+
* The operation is atomic - if any nullifier is not found, the entire operation fails and no notes are modified.
|
|
42
46
|
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
47
|
+
* applyNullifiers is idempotent: the same nullifier can be applied multiple times without error.
|
|
48
|
+
* This relaxes constraints on usage of NoteService#validateAndStoreNote, which can then be run concurrently in a Promise.all
|
|
49
|
+
* context without risking unnecessarily defensive checks failing.
|
|
50
|
+
*
|
|
51
|
+
* @param nullifiers - Array of nullifiers with their block numbers to process
|
|
52
|
+
* @param jobId - The job context for staged writes
|
|
53
|
+
* @returns Array of NoteDao objects that were nullified
|
|
54
|
+
* @throws Error if any nullifier is not found in this notes store
|
|
45
55
|
*/
|
|
46
|
-
|
|
56
|
+
applyNullifiers(nullifiers: DataInBlock<Fr>[], jobId: string): Promise<NoteDao[]>;
|
|
47
57
|
/**
|
|
48
58
|
* Synchronizes notes and nullifiers to a specific block number.
|
|
49
59
|
*
|
|
50
|
-
* This method ensures that the state of notes and nullifiers is consistent with the
|
|
51
|
-
*
|
|
52
|
-
*
|
|
60
|
+
* This method ensures that the state of notes and nullifiers is consistent with the specified block number.
|
|
61
|
+
* It restores any notes that were nullified after the given block and deletes any active notes created after that
|
|
62
|
+
* block.
|
|
63
|
+
*
|
|
64
|
+
* IMPORTANT: This method must be called within a transaction to ensure atomicity.
|
|
53
65
|
*
|
|
54
66
|
* @param blockNumber - The new chain tip after a reorg
|
|
55
67
|
* @param synchedBlockNumber - The block number up to which PXE managed to sync before the reorg happened.
|
|
56
68
|
*/
|
|
57
|
-
|
|
69
|
+
rollback(blockNumber: number, synchedBlockNumber: number): Promise<void>;
|
|
58
70
|
/**
|
|
59
|
-
*
|
|
71
|
+
* Commits in memory job data to persistent storage.
|
|
60
72
|
*
|
|
61
|
-
*
|
|
62
|
-
* parameters.
|
|
73
|
+
* Called by JobCoordinator when a job completes successfully.
|
|
63
74
|
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
* @returns Filtered and deduplicated notes (a note might be present in multiple scopes - we ensure it is only
|
|
67
|
-
* returned once if this is the case)
|
|
68
|
-
* @throws If filtering by an empty scopes array. Scopes have to be set to undefined or to a non-empty array.
|
|
69
|
-
*/
|
|
70
|
-
getNotes(filter: NotesFilter): Promise<NoteDao[]>;
|
|
71
|
-
/**
|
|
72
|
-
* Transitions notes from "active" to "nullified" state.
|
|
75
|
+
* Note: JobCoordinator wraps all commits in a single transaction, so we don't need our own transactionAsync here
|
|
76
|
+
* (and using one would throw on IndexedDB as it does not support nested txs).
|
|
73
77
|
*
|
|
74
|
-
*
|
|
75
|
-
* as spent/nullified. The operation is atomic - if any nullifier is not found,
|
|
76
|
-
* the entire operation fails and no notes are modified.
|
|
77
|
-
*
|
|
78
|
-
* @param nullifiers - Array of nullifiers with their block numbers to process
|
|
79
|
-
* @returns Promise resolving to array of nullified NoteDao objects
|
|
80
|
-
* @throws Error if any nullifier is not found in the active notes
|
|
78
|
+
* @param jobId - The jobId identifying which staged data to commit
|
|
81
79
|
*/
|
|
82
|
-
|
|
80
|
+
commit(jobId: string): Promise<void>;
|
|
81
|
+
discardStaged(jobId: string): Promise<void>;
|
|
83
82
|
}
|
|
84
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
83
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibm90ZV9zdG9yZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3N0b3JhZ2Uvbm90ZV9zdG9yZS9ub3RlX3N0b3JlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sS0FBSyxFQUFFLEVBQUUsRUFBRSxNQUFNLDJCQUEyQixDQUFDO0FBQ3BELE9BQU8sS0FBSyxFQUFFLGlCQUFpQixFQUFxQyxNQUFNLGlCQUFpQixDQUFDO0FBQzVGLE9BQU8sS0FBSyxFQUFFLFlBQVksRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBQ2hFLE9BQU8sS0FBSyxFQUFFLFdBQVcsRUFBRSxNQUFNLHFCQUFxQixDQUFDO0FBQ3ZELE9BQU8sRUFBRSxPQUFPLEVBQWMsTUFBTSxvQkFBb0IsQ0FBQztB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