@aztec/pxe 3.0.0-canary.a9708bd → 3.0.0-devnet.2-patch.1
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/README.md +5 -5
- package/dest/bin/check_oracle_version.d.ts +1 -1
- package/dest/bin/check_oracle_version.js +110 -10
- package/dest/config/index.d.ts +9 -17
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +10 -16
- package/dest/config/package_info.d.ts +1 -1
- package/dest/config/package_info.js +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +6 -6
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +97 -42
- package/dest/contract_function_simulator/execution_data_provider.d.ts +40 -57
- package/dest/contract_function_simulator/execution_data_provider.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_note_cache.d.ts +11 -9
- package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_note_cache.js +28 -17
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +16 -0
- package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -0
- package/dest/contract_function_simulator/execution_tagging_index_cache.js +26 -0
- package/dest/contract_function_simulator/hashed_values_cache.d.ts +2 -2
- package/dest/contract_function_simulator/hashed_values_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.d.ts +4 -2
- package/dest/contract_function_simulator/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/index.js +2 -1
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +2 -2
- package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +2 -2
- package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +3 -3
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +8 -4
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +6 -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 +12 -3
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +22 -0
- package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -0
- package/dest/contract_function_simulator/noir-structs/utility_context.js +33 -0
- package/dest/contract_function_simulator/oracle/index.d.ts +2 -2
- package/dest/contract_function_simulator/oracle/index.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/index.js +1 -1
- package/dest/contract_function_simulator/oracle/interfaces.d.ts +104 -0
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -0
- package/dest/contract_function_simulator/oracle/interfaces.js +4 -0
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +2 -4
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.js +1 -1
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +10 -4
- package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/note_packing_utils.js +10 -5
- package/dest/contract_function_simulator/oracle/oracle.d.ts +17 -15
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +101 -81
- package/dest/contract_function_simulator/oracle/private_execution.d.ts +6 -5
- package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution.js +7 -16
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +34 -22
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +89 -25
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +23 -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 +38 -42
- package/dest/contract_function_simulator/pick_notes.d.ts +2 -2
- package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -1
- package/dest/contract_function_simulator/pick_notes.js +1 -1
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +1 -1
- package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -1
- package/dest/contract_function_simulator/proxied_node.d.ts +1 -1
- package/dest/contract_function_simulator/proxied_node.d.ts.map +1 -1
- package/dest/contract_function_simulator/pxe_oracle_interface.d.ts +34 -68
- package/dest/contract_function_simulator/pxe_oracle_interface.d.ts.map +1 -1
- package/dest/contract_function_simulator/pxe_oracle_interface.js +220 -208
- package/dest/entrypoints/client/bundle/index.d.ts +4 -2
- package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.js +2 -1
- package/dest/entrypoints/client/bundle/utils.d.ts +9 -9
- package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/utils.js +21 -12
- package/dest/entrypoints/client/lazy/index.d.ts +4 -2
- package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/index.js +2 -1
- package/dest/entrypoints/client/lazy/utils.d.ts +8 -8
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +20 -11
- package/dest/entrypoints/pxe_creation_options.d.ts +5 -2
- package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
- package/dest/entrypoints/server/index.d.ts +4 -2
- package/dest/entrypoints/server/index.d.ts.map +1 -1
- package/dest/entrypoints/server/index.js +2 -1
- package/dest/entrypoints/server/utils.d.ts +5 -24
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +17 -45
- package/dest/error_enriching.d.ts +11 -0
- package/dest/error_enriching.d.ts.map +1 -0
- package/dest/{pxe_service/error_enriching.js → error_enriching.js} +3 -0
- package/dest/events/index.d.ts +2 -0
- package/dest/events/index.d.ts.map +1 -0
- package/dest/events/index.js +1 -0
- package/dest/events/private_event_filter_validator.d.ts +8 -0
- package/dest/events/private_event_filter_validator.d.ts.map +1 -0
- package/dest/events/private_event_filter_validator.js +39 -0
- package/dest/oracle_version.d.ts +3 -3
- package/dest/oracle_version.js +2 -2
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts +3 -3
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts.map +1 -1
- package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.js +7 -7
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +1 -1
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.js +6 -6
- package/dest/private_kernel/hints/index.d.ts +1 -1
- package/dest/private_kernel/index.d.ts +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.d.ts +9 -2
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.js +38 -32
- package/dest/private_kernel/private_kernel_oracle.d.ts +3 -2
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts +8 -7
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +1 -1
- package/dest/pxe.d.ts +240 -0
- package/dest/pxe.d.ts.map +1 -0
- package/dest/{pxe_service/pxe_service.js → pxe.js} +227 -241
- package/dest/storage/address_data_provider/address_data_provider.d.ts +2 -4
- package/dest/storage/address_data_provider/address_data_provider.d.ts.map +1 -1
- package/dest/storage/address_data_provider/address_data_provider.js +0 -3
- package/dest/storage/address_data_provider/index.d.ts +1 -1
- package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts +3 -5
- package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts.map +1 -1
- package/dest/storage/capsule_data_provider/capsule_data_provider.js +1 -5
- package/dest/storage/capsule_data_provider/index.d.ts +1 -1
- package/dest/storage/contract_data_provider/contract_data_provider.d.ts +6 -17
- package/dest/storage/contract_data_provider/contract_data_provider.d.ts.map +1 -1
- package/dest/storage/contract_data_provider/contract_data_provider.js +0 -15
- package/dest/storage/contract_data_provider/index.d.ts +1 -1
- package/dest/storage/contract_data_provider/private_functions_tree.d.ts +1 -1
- package/dest/storage/contract_data_provider/private_functions_tree.d.ts.map +1 -1
- package/dest/storage/contract_data_provider/private_functions_tree.js +1 -1
- package/dest/storage/index.d.ts +1 -2
- package/dest/storage/index.d.ts.map +1 -1
- package/dest/storage/index.js +0 -1
- package/dest/storage/metadata.d.ts +1 -1
- package/dest/storage/note_data_provider/index.d.ts +2 -2
- package/dest/storage/note_data_provider/index.d.ts.map +1 -1
- package/dest/storage/note_data_provider/index.js +1 -1
- package/dest/storage/note_data_provider/note_data_provider.d.ts +75 -11
- package/dest/storage/note_data_provider/note_data_provider.d.ts.map +1 -1
- package/dest/storage/note_data_provider/note_data_provider.js +143 -81
- package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts +31 -17
- package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts.map +1 -1
- package/dest/storage/private_event_data_provider/private_event_data_provider.js +47 -28
- package/dest/storage/sync_data_provider/index.d.ts +1 -1
- package/dest/storage/sync_data_provider/sync_data_provider.d.ts +4 -5
- package/dest/storage/sync_data_provider/sync_data_provider.d.ts.map +1 -1
- package/dest/storage/sync_data_provider/sync_data_provider.js +0 -3
- package/dest/storage/tagging_data_provider/index.d.ts +1 -1
- package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts +29 -7
- package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts.map +1 -1
- package/dest/storage/tagging_data_provider/tagging_data_provider.js +46 -39
- package/dest/synchronizer/index.d.ts +1 -1
- package/dest/synchronizer/synchronizer.d.ts +3 -2
- package/dest/synchronizer/synchronizer.d.ts.map +1 -1
- package/dest/synchronizer/synchronizer.js +4 -4
- package/dest/tagging/constants.d.ts +2 -0
- package/dest/tagging/constants.d.ts.map +1 -0
- package/dest/tagging/constants.js +2 -0
- package/dest/tagging/index.d.ts +7 -0
- package/dest/tagging/index.d.ts.map +1 -0
- package/dest/tagging/index.js +5 -0
- package/dest/tagging/siloed_tag.d.ts +14 -0
- package/dest/tagging/siloed_tag.d.ts.map +1 -0
- package/dest/tagging/siloed_tag.js +20 -0
- package/dest/tagging/tag.d.ts +12 -0
- package/dest/tagging/tag.d.ts.map +1 -0
- package/dest/tagging/tag.js +17 -0
- package/dest/tagging/utils.d.ts +18 -0
- package/dest/tagging/utils.d.ts.map +1 -0
- package/dest/tagging/utils.js +24 -0
- package/package.json +22 -24
- package/src/bin/check_oracle_version.ts +134 -10
- package/src/config/index.ts +18 -32
- package/src/config/package_info.ts +1 -1
- package/src/contract_function_simulator/contract_function_simulator.ts +151 -62
- package/src/contract_function_simulator/execution_data_provider.ts +47 -65
- package/src/contract_function_simulator/execution_note_cache.ts +33 -17
- package/src/contract_function_simulator/execution_tagging_index_cache.ts +32 -0
- package/src/contract_function_simulator/hashed_values_cache.ts +1 -1
- package/src/contract_function_simulator/index.ts +3 -1
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +1 -1
- package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +1 -1
- package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +10 -5
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +14 -2
- package/src/contract_function_simulator/noir-structs/utility_context.ts +42 -0
- package/src/contract_function_simulator/oracle/index.ts +1 -1
- package/src/contract_function_simulator/oracle/interfaces.ts +176 -0
- package/src/contract_function_simulator/oracle/message_load_oracle_inputs.ts +1 -1
- package/src/contract_function_simulator/oracle/note_packing_utils.ts +21 -5
- package/src/contract_function_simulator/oracle/oracle.ts +135 -80
- package/src/contract_function_simulator/oracle/private_execution.ts +10 -17
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +123 -49
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +68 -80
- package/src/contract_function_simulator/pick_notes.ts +1 -1
- package/src/contract_function_simulator/pxe_oracle_interface.ts +291 -271
- package/src/entrypoints/client/bundle/index.ts +3 -1
- package/src/entrypoints/client/bundle/utils.ts +21 -23
- package/src/entrypoints/client/lazy/index.ts +3 -1
- package/src/entrypoints/client/lazy/utils.ts +20 -23
- package/src/entrypoints/pxe_creation_options.ts +4 -1
- package/src/entrypoints/server/index.ts +3 -1
- package/src/entrypoints/server/utils.ts +20 -68
- package/src/{pxe_service/error_enriching.ts → error_enriching.ts} +5 -1
- package/src/events/index.ts +1 -0
- package/src/events/private_event_filter_validator.ts +47 -0
- package/src/oracle_version.ts +2 -2
- package/src/private_kernel/hints/build_private_kernel_reset_private_inputs.ts +5 -9
- package/src/private_kernel/hints/compute_tx_include_by_timestamp.ts +6 -6
- package/src/private_kernel/private_kernel_execution_prover.ts +51 -43
- package/src/private_kernel/private_kernel_oracle.ts +2 -1
- package/src/private_kernel/private_kernel_oracle_impl.ts +4 -3
- package/src/{pxe_service/pxe_service.ts → pxe.ts} +256 -308
- package/src/storage/address_data_provider/address_data_provider.ts +1 -7
- package/src/storage/capsule_data_provider/capsule_data_provider.ts +2 -12
- package/src/storage/contract_data_provider/contract_data_provider.ts +4 -27
- package/src/storage/contract_data_provider/private_functions_tree.ts +1 -1
- package/src/storage/index.ts +0 -1
- package/src/storage/note_data_provider/index.ts +1 -1
- package/src/storage/note_data_provider/note_data_provider.ts +171 -109
- package/src/storage/private_event_data_provider/private_event_data_provider.ts +69 -41
- package/src/storage/sync_data_provider/sync_data_provider.ts +3 -8
- package/src/storage/tagging_data_provider/tagging_data_provider.ts +52 -55
- package/src/synchronizer/synchronizer.ts +4 -4
- package/src/tagging/constants.ts +2 -0
- package/src/tagging/index.ts +6 -0
- package/src/tagging/siloed_tag.ts +22 -0
- package/src/tagging/tag.ts +16 -0
- package/src/tagging/utils.ts +31 -0
- package/dest/bin/index.d.ts +0 -3
- package/dest/bin/index.d.ts.map +0 -1
- package/dest/bin/index.js +0 -48
- package/dest/contract_function_simulator/oracle/typed_oracle.d.ts +0 -87
- package/dest/contract_function_simulator/oracle/typed_oracle.d.ts.map +0 -1
- package/dest/contract_function_simulator/oracle/typed_oracle.js +0 -146
- package/dest/contract_function_simulator/tagging_utils.d.ts +0 -17
- package/dest/contract_function_simulator/tagging_utils.d.ts.map +0 -1
- package/dest/contract_function_simulator/tagging_utils.js +0 -23
- package/dest/pxe_service/error_enriching.d.ts +0 -11
- package/dest/pxe_service/error_enriching.d.ts.map +0 -1
- package/dest/pxe_service/index.d.ts +0 -3
- package/dest/pxe_service/index.d.ts.map +0 -1
- package/dest/pxe_service/index.js +0 -2
- package/dest/pxe_service/pxe_service.d.ts +0 -100
- package/dest/pxe_service/pxe_service.d.ts.map +0 -1
- package/dest/storage/data_provider.d.ts +0 -4
- package/dest/storage/data_provider.d.ts.map +0 -1
- package/dest/storage/data_provider.js +0 -1
- package/dest/storage/note_data_provider/note_dao.d.ts +0 -100
- package/dest/storage/note_data_provider/note_dao.d.ts.map +0 -1
- package/dest/storage/note_data_provider/note_dao.js +0 -102
- package/dest/test/pxe_test_suite.d.ts +0 -3
- package/dest/test/pxe_test_suite.d.ts.map +0 -1
- package/dest/test/pxe_test_suite.js +0 -97
- package/src/bin/index.ts +0 -62
- package/src/contract_function_simulator/oracle/typed_oracle.ts +0 -289
- package/src/contract_function_simulator/tagging_utils.ts +0 -32
- package/src/pxe_service/index.ts +0 -2
- package/src/storage/data_provider.ts +0 -3
- package/src/storage/note_data_provider/note_dao.ts +0 -154
- package/src/test/pxe_test_suite.ts +0 -113
|
@@ -1,27 +1,44 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
4
|
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
4
5
|
import type { AztecAsyncArray, AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
|
|
5
6
|
import type { EventSelector } from '@aztec/stdlib/abi';
|
|
6
7
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
7
|
-
import
|
|
8
|
+
import { L2BlockHash } from '@aztec/stdlib/block';
|
|
9
|
+
import { type InTx, TxHash } from '@aztec/stdlib/tx';
|
|
8
10
|
|
|
9
|
-
import type {
|
|
11
|
+
import type { PackedPrivateEvent } from '../../pxe.js';
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
export type PrivateEventDataProviderFilter = {
|
|
14
|
+
contractAddress: AztecAddress;
|
|
15
|
+
fromBlock: number;
|
|
16
|
+
toBlock: number;
|
|
17
|
+
scopes: AztecAddress[];
|
|
18
|
+
txHash?: TxHash;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
type PrivateEventEntry = {
|
|
12
22
|
msgContent: Buffer;
|
|
13
|
-
blockNumber: number;
|
|
14
23
|
eventCommitmentIndex: number;
|
|
15
|
-
|
|
24
|
+
l2BlockNumber: number;
|
|
25
|
+
l2BlockHash: Buffer;
|
|
26
|
+
txHash: Buffer;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
type PrivateEventMetadata = InTx & {
|
|
30
|
+
contractAddress: AztecAddress;
|
|
31
|
+
scope: AztecAddress;
|
|
32
|
+
};
|
|
16
33
|
|
|
17
34
|
/**
|
|
18
35
|
* Stores decrypted private event logs.
|
|
19
36
|
*/
|
|
20
|
-
export class PrivateEventDataProvider
|
|
37
|
+
export class PrivateEventDataProvider {
|
|
21
38
|
#store: AztecAsyncKVStore;
|
|
22
39
|
/** Array storing the actual private event log entries containing the log content and block number */
|
|
23
40
|
#eventLogs: AztecAsyncArray<PrivateEventEntry>;
|
|
24
|
-
/** Map from
|
|
41
|
+
/** Map from contract_address_scope_eventSelector to array of indices into #eventLogs for efficient lookup */
|
|
25
42
|
#eventLogIndex: AztecAsyncMap<string, number[]>;
|
|
26
43
|
/** Map from eventCommitmentIndex to boolean indicating if log has been seen. */
|
|
27
44
|
#seenLogs: AztecAsyncMap<number, boolean>;
|
|
@@ -35,27 +52,31 @@ export class PrivateEventDataProvider implements DataProvider {
|
|
|
35
52
|
this.#seenLogs = this.#store.openMap('seen_logs');
|
|
36
53
|
}
|
|
37
54
|
|
|
55
|
+
#keyFor(contractAddress: AztecAddress, scope: AztecAddress, eventSelector: EventSelector): string {
|
|
56
|
+
return `${contractAddress.toString()}_${scope.toString()}_${eventSelector.toString()}`;
|
|
57
|
+
}
|
|
58
|
+
|
|
38
59
|
/**
|
|
39
60
|
* Store a private event log.
|
|
40
|
-
* @param contractAddress - The address of the contract that emitted the event.
|
|
41
|
-
* @param recipient - The recipient of the event.
|
|
42
61
|
* @param eventSelector - The event selector of the event.
|
|
43
62
|
* @param msgContent - The content of the event.
|
|
44
|
-
* @param txHash - The transaction hash of the event log.
|
|
45
63
|
* @param eventCommitmentIndex - The index of the event commitment in the nullifier tree.
|
|
46
|
-
* @param
|
|
64
|
+
* @param metadata
|
|
65
|
+
* contractAddress - The address of the contract that emitted the event.
|
|
66
|
+
* scope - The address to which the event is scoped.
|
|
67
|
+
* txHash - The transaction hash of the event log.
|
|
68
|
+
* blockNumber - The block number in which the event was emitted.
|
|
47
69
|
*/
|
|
48
70
|
storePrivateEventLog(
|
|
49
|
-
contractAddress: AztecAddress,
|
|
50
|
-
recipient: AztecAddress,
|
|
51
71
|
eventSelector: EventSelector,
|
|
52
72
|
msgContent: Fr[],
|
|
53
|
-
txHash: TxHash,
|
|
54
73
|
eventCommitmentIndex: number,
|
|
55
|
-
|
|
74
|
+
metadata: PrivateEventMetadata,
|
|
56
75
|
): Promise<void> {
|
|
76
|
+
const { contractAddress, scope, txHash, l2BlockNumber, l2BlockHash } = metadata;
|
|
77
|
+
|
|
57
78
|
return this.#store.transactionAsync(async () => {
|
|
58
|
-
const key =
|
|
79
|
+
const key = this.#keyFor(contractAddress, scope, eventSelector);
|
|
59
80
|
|
|
60
81
|
// Check if this exact log has already been stored using eventCommitmentIndex as unique identifier
|
|
61
82
|
const hasBeenSeen = await this.#seenLogs.getAsync(eventCommitmentIndex);
|
|
@@ -64,13 +85,15 @@ export class PrivateEventDataProvider implements DataProvider {
|
|
|
64
85
|
return;
|
|
65
86
|
}
|
|
66
87
|
|
|
67
|
-
this.logger.verbose('storing private event log', { contractAddress,
|
|
88
|
+
this.logger.verbose('storing private event log', { contractAddress, scope, msgContent, l2BlockNumber });
|
|
68
89
|
|
|
69
90
|
const index = await this.#eventLogs.lengthAsync();
|
|
70
91
|
await this.#eventLogs.push({
|
|
71
92
|
msgContent: serializeToBuffer(msgContent),
|
|
72
|
-
|
|
93
|
+
l2BlockNumber,
|
|
94
|
+
l2BlockHash: l2BlockHash.toBuffer(),
|
|
73
95
|
eventCommitmentIndex,
|
|
96
|
+
txHash: txHash.toBuffer(),
|
|
74
97
|
});
|
|
75
98
|
|
|
76
99
|
const existingIndices = (await this.#eventLogIndex.getAsync(key)) || [];
|
|
@@ -83,29 +106,28 @@ export class PrivateEventDataProvider implements DataProvider {
|
|
|
83
106
|
|
|
84
107
|
/**
|
|
85
108
|
* Returns the private events given search parameters.
|
|
86
|
-
* @param contractAddress - The address of the contract to get events from.
|
|
87
|
-
* @param from - The block number to search from.
|
|
88
|
-
* @param numBlocks - The amount of blocks to search.
|
|
89
|
-
* @param recipients - The addresses that decrypted the logs.
|
|
90
109
|
* @param eventSelector - The event selector to filter by.
|
|
91
|
-
* @
|
|
110
|
+
* @param filter - Filtering criteria:
|
|
111
|
+
* contractAddress: The address of the contract to get events from.
|
|
112
|
+
* fromBlock: The block number to search from (inclusive).
|
|
113
|
+
* toBlock: The block number to search upto (exclusive).
|
|
114
|
+
* scope: - The addresses that decrypted the logs.
|
|
115
|
+
* @returns - The event log contents, augmented with metadata about
|
|
116
|
+
* the transaction and block it the event was included in .
|
|
92
117
|
*/
|
|
93
118
|
public async getPrivateEvents(
|
|
94
|
-
contractAddress: AztecAddress,
|
|
95
|
-
from: number,
|
|
96
|
-
numBlocks: number,
|
|
97
|
-
recipients: AztecAddress[],
|
|
98
119
|
eventSelector: EventSelector,
|
|
99
|
-
|
|
100
|
-
|
|
120
|
+
filter: PrivateEventDataProviderFilter,
|
|
121
|
+
): Promise<PackedPrivateEvent[]> {
|
|
122
|
+
const events: Array<{ eventCommitmentIndex: number; event: PackedPrivateEvent }> = [];
|
|
101
123
|
|
|
102
|
-
for (const
|
|
103
|
-
const key =
|
|
124
|
+
for (const scope of filter.scopes) {
|
|
125
|
+
const key = this.#keyFor(filter.contractAddress, scope, eventSelector);
|
|
104
126
|
const indices = (await this.#eventLogIndex.getAsync(key)) || [];
|
|
105
127
|
|
|
106
128
|
for (const index of indices) {
|
|
107
129
|
const entry = await this.#eventLogs.atAsync(index);
|
|
108
|
-
if (!entry || entry.
|
|
130
|
+
if (!entry || entry.l2BlockNumber < filter.fromBlock || entry.l2BlockNumber >= filter.toBlock) {
|
|
109
131
|
continue;
|
|
110
132
|
}
|
|
111
133
|
|
|
@@ -113,22 +135,28 @@ export class PrivateEventDataProvider implements DataProvider {
|
|
|
113
135
|
const reader = BufferReader.asReader(entry.msgContent);
|
|
114
136
|
const numFields = entry.msgContent.length / Fr.SIZE_IN_BYTES;
|
|
115
137
|
const msgContent = reader.readArray(numFields, Fr);
|
|
138
|
+
const txHash = TxHash.fromBuffer(entry.txHash);
|
|
139
|
+
const l2BlockHash = L2BlockHash.fromBuffer(entry.l2BlockHash);
|
|
140
|
+
|
|
141
|
+
if (filter.txHash && !txHash.equals(filter.txHash)) {
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
116
144
|
|
|
117
145
|
events.push({
|
|
118
|
-
msgContent,
|
|
119
|
-
blockNumber: entry.blockNumber,
|
|
120
146
|
eventCommitmentIndex: entry.eventCommitmentIndex,
|
|
147
|
+
event: {
|
|
148
|
+
packedEvent: msgContent,
|
|
149
|
+
l2BlockNumber: BlockNumber(entry.l2BlockNumber),
|
|
150
|
+
txHash,
|
|
151
|
+
l2BlockHash,
|
|
152
|
+
eventSelector,
|
|
153
|
+
},
|
|
121
154
|
});
|
|
122
155
|
}
|
|
123
156
|
}
|
|
124
157
|
|
|
125
158
|
// Sort by eventCommitmentIndex only
|
|
126
159
|
events.sort((a, b) => a.eventCommitmentIndex - b.eventCommitmentIndex);
|
|
127
|
-
|
|
128
|
-
return events.map(e => e.msgContent);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
getSize(): Promise<number> {
|
|
132
|
-
return this.#eventLogs.lengthAsync();
|
|
160
|
+
return events.map(ev => ev.event);
|
|
133
161
|
}
|
|
134
162
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
+
import type { BlockNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import type { AztecAsyncKVStore, AztecAsyncSingleton } from '@aztec/kv-store';
|
|
2
3
|
import { BlockHeader } from '@aztec/stdlib/tx';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export class SyncDataProvider implements DataProvider {
|
|
5
|
+
export class SyncDataProvider {
|
|
7
6
|
#store: AztecAsyncKVStore;
|
|
8
7
|
#synchronizedHeader: AztecAsyncSingleton<Buffer>;
|
|
9
8
|
|
|
@@ -16,7 +15,7 @@ export class SyncDataProvider implements DataProvider {
|
|
|
16
15
|
await this.#synchronizedHeader.set(header.toBuffer());
|
|
17
16
|
}
|
|
18
17
|
|
|
19
|
-
async getBlockNumber(): Promise<
|
|
18
|
+
async getBlockNumber(): Promise<BlockNumber> {
|
|
20
19
|
const headerBuffer = await this.#synchronizedHeader.getAsync();
|
|
21
20
|
if (!headerBuffer) {
|
|
22
21
|
throw new Error(`Trying to get block number with a not-yet-synchronized PXE - this should never happen`);
|
|
@@ -33,8 +32,4 @@ export class SyncDataProvider implements DataProvider {
|
|
|
33
32
|
|
|
34
33
|
return BlockHeader.fromBuffer(headerBuffer);
|
|
35
34
|
}
|
|
36
|
-
|
|
37
|
-
async getSize(): Promise<number> {
|
|
38
|
-
return (await this.#synchronizedHeader.getAsync())?.length ?? 0;
|
|
39
|
-
}
|
|
40
35
|
}
|
|
@@ -1,93 +1,90 @@
|
|
|
1
|
-
import type { Fr } from '@aztec/foundation/fields';
|
|
2
1
|
import { toArray } from '@aztec/foundation/iterable';
|
|
3
2
|
import type { AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
|
|
4
3
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
-
import type {
|
|
4
|
+
import type { DirectionalAppTaggingSecret, PreTag } from '@aztec/stdlib/logs';
|
|
6
5
|
|
|
7
6
|
export class TaggingDataProvider {
|
|
8
7
|
#store: AztecAsyncKVStore;
|
|
9
8
|
#addressBook: AztecAsyncMap<string, true>;
|
|
10
9
|
|
|
11
|
-
// Stores the last index
|
|
12
|
-
//
|
|
13
|
-
|
|
14
|
-
#
|
|
15
|
-
#taggingSecretIndexesForRecipients: AztecAsyncMap<string, number>;
|
|
10
|
+
// Stores the last used index for each directional app tagging secret. Taking into account whether we are
|
|
11
|
+
// requesting the index as a sender or as a recipient because the sender and recipient can be in the same PXE.
|
|
12
|
+
#lastUsedIndexesAsSenders: AztecAsyncMap<string, number>;
|
|
13
|
+
#lastUsedIndexesAsRecipients: AztecAsyncMap<string, number>;
|
|
16
14
|
|
|
17
15
|
constructor(store: AztecAsyncKVStore) {
|
|
18
16
|
this.#store = store;
|
|
19
17
|
|
|
20
18
|
this.#addressBook = this.#store.openMap('address_book');
|
|
21
19
|
|
|
22
|
-
this.#
|
|
23
|
-
this.#
|
|
20
|
+
this.#lastUsedIndexesAsSenders = this.#store.openMap('last_used_indexes_as_senders');
|
|
21
|
+
this.#lastUsedIndexesAsRecipients = this.#store.openMap('last_used_indexes_as_recipients');
|
|
24
22
|
}
|
|
25
23
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Sets the last used indexes when sending a log.
|
|
26
|
+
* @param preTags - The pre tags containing the directional app tagging secrets and the indexes that are to be
|
|
27
|
+
* updated in the db.
|
|
28
|
+
* @throws If any two pre tags contain the same directional app tagging secret
|
|
29
|
+
*/
|
|
30
|
+
setLastUsedIndexesAsSender(preTags: PreTag[]) {
|
|
31
|
+
this.#assertUniqueSecrets(preTags, 'sender');
|
|
29
32
|
|
|
30
|
-
|
|
31
|
-
|
|
33
|
+
return Promise.all(
|
|
34
|
+
preTags.map(({ secret, index }) => this.#lastUsedIndexesAsSenders.set(secret.toString(), index)),
|
|
35
|
+
);
|
|
32
36
|
}
|
|
33
37
|
|
|
34
38
|
/**
|
|
35
|
-
* Sets the
|
|
36
|
-
* @
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* @param indexedSecrets - The app tagging secrets and indexes to set.
|
|
40
|
-
* @param storageMap - The storage map to set the indexes in.
|
|
41
|
-
* @param inDirectionOf - The address that the secrets are in the direction of.
|
|
39
|
+
* Sets the last used indexes when looking for logs.
|
|
40
|
+
* @param preTags - The pre tags containing the directional app tagging secrets and the indexes that are to be
|
|
41
|
+
* updated in the db.
|
|
42
|
+
* @throws If any two pre tags contain the same directional app tagging secret
|
|
42
43
|
*/
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
inDirectionOf: AztecAddress,
|
|
47
|
-
) {
|
|
44
|
+
setLastUsedIndexesAsRecipient(preTags: PreTag[]) {
|
|
45
|
+
this.#assertUniqueSecrets(preTags, 'recipient');
|
|
46
|
+
|
|
48
47
|
return Promise.all(
|
|
49
|
-
|
|
50
|
-
storageMap.set(`${indexedSecret.appTaggingSecret.toString()}_${inDirectionOf.toString()}`, indexedSecret.index),
|
|
51
|
-
),
|
|
48
|
+
preTags.map(({ secret, index }) => this.#lastUsedIndexesAsRecipients.set(secret.toString(), index)),
|
|
52
49
|
);
|
|
53
50
|
}
|
|
54
51
|
|
|
55
|
-
|
|
56
|
-
|
|
52
|
+
// It should never happen that we would receive any two pre tags on the input containing the same directional app
|
|
53
|
+
// tagging secret as everywhere we always just apply the largest index. Hence this check is a good way to catch
|
|
54
|
+
// bugs.
|
|
55
|
+
#assertUniqueSecrets(preTags: PreTag[], role: 'sender' | 'recipient'): void {
|
|
56
|
+
const secretStrings = preTags.map(({ secret }) => secret.toString());
|
|
57
|
+
const uniqueSecrets = new Set(secretStrings);
|
|
58
|
+
if (uniqueSecrets.size !== secretStrings.length) {
|
|
59
|
+
throw new Error(`Duplicate secrets found when setting last used indexes as ${role}`);
|
|
60
|
+
}
|
|
57
61
|
}
|
|
58
62
|
|
|
59
|
-
|
|
60
|
-
|
|
63
|
+
/**
|
|
64
|
+
* Returns the last used index when sending a log with a given secret.
|
|
65
|
+
* @param secret - The directional app tagging secret.
|
|
66
|
+
* @returns The last used index for the given directional app tagging secret, or undefined if not found.
|
|
67
|
+
*/
|
|
68
|
+
async getLastUsedIndexesAsSender(secret: DirectionalAppTaggingSecret): Promise<number | undefined> {
|
|
69
|
+
return await this.#lastUsedIndexesAsSenders.getAsync(secret.toString());
|
|
61
70
|
}
|
|
62
71
|
|
|
63
72
|
/**
|
|
64
|
-
* Returns the
|
|
65
|
-
* @
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
* @param appTaggingSecrets - The app tagging secrets to get the indexes for.
|
|
69
|
-
* @param storageMap - The storage map to get the indexes from.
|
|
70
|
-
* @param inDirectionOf - The address that the secrets are in the direction of.
|
|
71
|
-
* @returns The indexes of the tagging secrets.
|
|
73
|
+
* Returns the last used indexes when looking for logs as a recipient.
|
|
74
|
+
* @param secrets - The directional app tagging secrets to obtain the indexes for.
|
|
75
|
+
* @returns The last used indexes for the given directional app tagging secrets, or undefined if have never yet found
|
|
76
|
+
* a log for a given secret.
|
|
72
77
|
*/
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
storageMap: AztecAsyncMap<string, number>,
|
|
76
|
-
inDirectionOf: AztecAddress,
|
|
77
|
-
): Promise<number[]> {
|
|
78
|
-
return Promise.all(
|
|
79
|
-
appTaggingSecrets.map(
|
|
80
|
-
async secret => (await storageMap.getAsync(`${secret.toString()}_${inDirectionOf.toString()}`)) ?? 0,
|
|
81
|
-
),
|
|
82
|
-
);
|
|
78
|
+
getLastUsedIndexesAsRecipient(secrets: DirectionalAppTaggingSecret[]): Promise<(number | undefined)[]> {
|
|
79
|
+
return Promise.all(secrets.map(secret => this.#lastUsedIndexesAsRecipients.getAsync(secret.toString())));
|
|
83
80
|
}
|
|
84
81
|
|
|
85
82
|
resetNoteSyncData(): Promise<void> {
|
|
86
83
|
return this.#store.transactionAsync(async () => {
|
|
87
|
-
const
|
|
88
|
-
await Promise.all(
|
|
89
|
-
const
|
|
90
|
-
await Promise.all(
|
|
84
|
+
const keysForSenders = await toArray(this.#lastUsedIndexesAsSenders.keysAsync());
|
|
85
|
+
await Promise.all(keysForSenders.map(secret => this.#lastUsedIndexesAsSenders.delete(secret)));
|
|
86
|
+
const keysForRecipients = await toArray(this.#lastUsedIndexesAsRecipients.keysAsync());
|
|
87
|
+
await Promise.all(keysForRecipients.map(secret => this.#lastUsedIndexesAsRecipients.delete(secret)));
|
|
91
88
|
});
|
|
92
89
|
}
|
|
93
90
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
2
3
|
import type { L2TipsKVStore } from '@aztec/kv-store/stores';
|
|
3
4
|
import { L2BlockStream, type L2BlockStreamEvent, type L2BlockStreamEventHandler } from '@aztec/stdlib/block';
|
|
@@ -55,15 +56,14 @@ export class Synchronizer implements L2BlockStreamEventHandler {
|
|
|
55
56
|
archive: lastBlock.archive.root.toString(),
|
|
56
57
|
header: lastBlock.header.toInspect(),
|
|
57
58
|
});
|
|
58
|
-
await this.syncDataProvider.setHeader(lastBlock.
|
|
59
|
+
await this.syncDataProvider.setHeader(lastBlock.getBlockHeader());
|
|
59
60
|
break;
|
|
60
61
|
}
|
|
61
62
|
case 'chain-pruned': {
|
|
62
63
|
this.log.warn(`Pruning data after block ${event.block.number} due to reorg`);
|
|
63
64
|
// We first unnullify and then remove so that unnullified notes that were created after the block number end up deleted.
|
|
64
65
|
const lastSynchedBlockNumber = await this.syncDataProvider.getBlockNumber();
|
|
65
|
-
await this.noteDataProvider.
|
|
66
|
-
await this.noteDataProvider.removeNotesAfter(event.block.number);
|
|
66
|
+
await this.noteDataProvider.rollbackNotesAndNullifiers(event.block.number, lastSynchedBlockNumber);
|
|
67
67
|
// Remove all note tagging indexes to force a full resync. This is suboptimal, but unless we track the
|
|
68
68
|
// block number in which each index is used it's all we can do.
|
|
69
69
|
await this.taggingDataProvider.resetNoteSyncData();
|
|
@@ -110,7 +110,7 @@ export class Synchronizer implements L2BlockStreamEventHandler {
|
|
|
110
110
|
}
|
|
111
111
|
if (!currentHeader) {
|
|
112
112
|
// REFACTOR: We should know the header of the genesis block without having to request it from the node.
|
|
113
|
-
await this.syncDataProvider.setHeader((await this.node.getBlockHeader(
|
|
113
|
+
await this.syncDataProvider.setHeader((await this.node.getBlockHeader(BlockNumber.ZERO))!);
|
|
114
114
|
}
|
|
115
115
|
await this.blockStream.sync();
|
|
116
116
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { poseidon2Hash } from '@aztec/foundation/crypto/poseidon';
|
|
2
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
+
|
|
5
|
+
import type { Tag } from './tag.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Represents a tag used in private log as it "appears on the chain" - that is the tag is siloed with a contract
|
|
9
|
+
* address that emitted the log.
|
|
10
|
+
*/
|
|
11
|
+
export class SiloedTag {
|
|
12
|
+
private constructor(public readonly value: Fr) {}
|
|
13
|
+
|
|
14
|
+
static async compute(tag: Tag, app: AztecAddress): Promise<SiloedTag> {
|
|
15
|
+
const siloedTag = await poseidon2Hash([app, tag.value]);
|
|
16
|
+
return new SiloedTag(siloedTag);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
toString(): string {
|
|
20
|
+
return this.value.toString();
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { poseidon2Hash } from '@aztec/foundation/crypto/poseidon';
|
|
2
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
+
import type { PreTag } from '@aztec/stdlib/logs';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Represents a tag of a private log. This is not the tag that "appears" on the chain as this tag is first siloed
|
|
7
|
+
* with a contract address by kernels before being included in the final log.
|
|
8
|
+
*/
|
|
9
|
+
export class Tag {
|
|
10
|
+
private constructor(public readonly value: Fr) {}
|
|
11
|
+
|
|
12
|
+
static async compute(preTag: PreTag): Promise<Tag> {
|
|
13
|
+
const tag = await poseidon2Hash([preTag.secret.value, preTag.index]);
|
|
14
|
+
return new Tag(tag);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { DirectionalAppTaggingSecret, PreTag } from '@aztec/stdlib/logs';
|
|
2
|
+
|
|
3
|
+
// TODO(benesjan): Make this return tags instead - this will moves some complexity from syncTaggedLogs
|
|
4
|
+
export function getPreTagsForTheWindow(
|
|
5
|
+
secretsAndWindows: { secret: DirectionalAppTaggingSecret; leftMostIndex: number; rightMostIndex: number }[],
|
|
6
|
+
): PreTag[] {
|
|
7
|
+
const secrets = [];
|
|
8
|
+
for (const secretAndWindow of secretsAndWindows) {
|
|
9
|
+
for (let i = secretAndWindow.leftMostIndex; i <= secretAndWindow.rightMostIndex; i++) {
|
|
10
|
+
secrets.push({ secret: secretAndWindow.secret, index: i });
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return secrets;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Creates a map from directional app tagging secret to initial index.
|
|
18
|
+
* @param preTags - The pre tags to get the initial indexes map from.
|
|
19
|
+
* @returns The map from directional app tagging secret to initial index.
|
|
20
|
+
*/
|
|
21
|
+
export function getInitialIndexesMap(preTags: { secret: DirectionalAppTaggingSecret; index: number | undefined }[]): {
|
|
22
|
+
[k: string]: number;
|
|
23
|
+
} {
|
|
24
|
+
const initialIndexes: { [k: string]: number } = {};
|
|
25
|
+
|
|
26
|
+
for (const preTag of preTags) {
|
|
27
|
+
initialIndexes[preTag.secret.toString()] = preTag.index ?? 0;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return initialIndexes;
|
|
31
|
+
}
|
package/dest/bin/index.d.ts
DELETED
package/dest/bin/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bin/index.ts"],"names":[],"mappings":""}
|
package/dest/bin/index.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env -S node --no-warnings
|
|
2
|
-
import { createNamespacedSafeJsonRpcServer } from '@aztec/foundation/json-rpc/server';
|
|
3
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
4
|
-
import { PXESchema, createAztecNodeClient } from '@aztec/stdlib/interfaces/client';
|
|
5
|
-
import http from 'http';
|
|
6
|
-
import { getPXEServiceConfig } from '../config/index.js';
|
|
7
|
-
import { createPXEService } from '../entrypoints/server/utils.js';
|
|
8
|
-
const { PXE_PORT = 8080, AZTEC_NODE_URL = 'http://localhost:8079' } = process.env;
|
|
9
|
-
const logger = createLogger('pxe:service');
|
|
10
|
-
/**
|
|
11
|
-
* Creates an http server that forwards calls to the PXE and starts it on the given port.
|
|
12
|
-
* @param pxeService - PXE that answers queries to the created HTTP server.
|
|
13
|
-
* @param port - Port to listen in.
|
|
14
|
-
* @param maxBatchSize - Maximum allowed batch size for JSON RPC batch requests.
|
|
15
|
-
* @returns A running http server.
|
|
16
|
-
*/ function startPXEHttpServer(pxeService, port, opts = {}) {
|
|
17
|
-
const rpcServer = createNamespacedSafeJsonRpcServer({
|
|
18
|
-
pxe: [
|
|
19
|
-
pxeService,
|
|
20
|
-
PXESchema
|
|
21
|
-
]
|
|
22
|
-
}, opts);
|
|
23
|
-
const app = rpcServer.getApp();
|
|
24
|
-
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
25
|
-
const httpServer = http.createServer(app.callback());
|
|
26
|
-
httpServer.listen(port);
|
|
27
|
-
return httpServer;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Create and start a new PXE HTTP Server
|
|
31
|
-
*/ async function main() {
|
|
32
|
-
logger.info(`Setting up PXE...`);
|
|
33
|
-
const pxeConfig = getPXEServiceConfig();
|
|
34
|
-
const nodeRpcClient = createAztecNodeClient(AZTEC_NODE_URL, {});
|
|
35
|
-
const pxeService = await createPXEService(nodeRpcClient, pxeConfig);
|
|
36
|
-
const shutdown = ()=>{
|
|
37
|
-
logger.info('Shutting down...');
|
|
38
|
-
process.exit(0);
|
|
39
|
-
};
|
|
40
|
-
process.once('SIGINT', shutdown);
|
|
41
|
-
process.once('SIGTERM', shutdown);
|
|
42
|
-
startPXEHttpServer(pxeService, PXE_PORT);
|
|
43
|
-
logger.info(`PXE listening on port ${PXE_PORT}`);
|
|
44
|
-
}
|
|
45
|
-
main().catch((err)=>{
|
|
46
|
-
logger.error(err);
|
|
47
|
-
process.exit(1);
|
|
48
|
-
});
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import type { L1_TO_L2_MSG_TREE_HEIGHT } from '@aztec/constants';
|
|
2
|
-
import { Fr, Point } from '@aztec/foundation/fields';
|
|
3
|
-
import type { FunctionSelector, NoteSelector } from '@aztec/stdlib/abi';
|
|
4
|
-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
-
import type { CompleteAddress, ContractInstance } from '@aztec/stdlib/contract';
|
|
6
|
-
import type { KeyValidationRequest } from '@aztec/stdlib/kernel';
|
|
7
|
-
import type { ContractClassLog, IndexedTaggingSecret } from '@aztec/stdlib/logs';
|
|
8
|
-
import type { Note, NoteStatus } from '@aztec/stdlib/note';
|
|
9
|
-
import { type MerkleTreeId, type NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
|
|
10
|
-
import type { BlockHeader } from '@aztec/stdlib/tx';
|
|
11
|
-
import type { UInt64 } from '@aztec/stdlib/types';
|
|
12
|
-
import type { MessageLoadOracleInputs } from './message_load_oracle_inputs.js';
|
|
13
|
-
/**
|
|
14
|
-
* Information about a note needed during execution.
|
|
15
|
-
*/
|
|
16
|
-
export interface NoteData {
|
|
17
|
-
/** The actual note content (the fields of the Noir #[note] struct). */
|
|
18
|
-
note: Note;
|
|
19
|
-
/** The address of the contract that owns the note. */
|
|
20
|
-
contractAddress: AztecAddress;
|
|
21
|
-
/** The storage slot of the note. */
|
|
22
|
-
storageSlot: Fr;
|
|
23
|
-
/** The nonce injected into the note hash preimage by kernels. */
|
|
24
|
-
noteNonce: Fr;
|
|
25
|
-
/** A hash of the note as it gets stored in the note hash tree. */
|
|
26
|
-
noteHash: Fr;
|
|
27
|
-
/** The corresponding nullifier of the note. Undefined for pending notes. */
|
|
28
|
-
siloedNullifier?: Fr;
|
|
29
|
-
/** The note's leaf index in the note hash tree. Undefined for pending notes. */
|
|
30
|
-
index?: bigint;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Oracle with typed parameters and typed return values.
|
|
34
|
-
* Methods that require read and/or write will have to be implemented based on the context (public, private, or view)
|
|
35
|
-
* and are unavailable by default.
|
|
36
|
-
*/
|
|
37
|
-
export declare abstract class TypedOracle {
|
|
38
|
-
utilityAssertCompatibleOracleVersion(_version: number): void;
|
|
39
|
-
utilityGetRandomField(): Fr;
|
|
40
|
-
privateStoreInExecutionCache(_values: Fr[], _hash: Fr): void;
|
|
41
|
-
privateLoadFromExecutionCache(_hash: Fr): Promise<Fr[]>;
|
|
42
|
-
utilityGetBlockNumber(): Promise<number>;
|
|
43
|
-
utilityGetTimestamp(): Promise<UInt64>;
|
|
44
|
-
utilityGetContractAddress(): Promise<AztecAddress>;
|
|
45
|
-
utilityGetChainId(): Promise<Fr>;
|
|
46
|
-
utilityGetVersion(): Promise<Fr>;
|
|
47
|
-
utilityGetKeyValidationRequest(_pkMHash: Fr): Promise<KeyValidationRequest>;
|
|
48
|
-
utilityGetContractInstance(_address: AztecAddress): Promise<ContractInstance>;
|
|
49
|
-
utilityGetMembershipWitness(_blockNumber: number, _treeId: MerkleTreeId, _leafValue: Fr): Promise<Fr[] | undefined>;
|
|
50
|
-
utilityGetNullifierMembershipWitness(_blockNumber: number, _nullifier: Fr): Promise<NullifierMembershipWitness | undefined>;
|
|
51
|
-
utilityGetPublicDataWitness(_blockNumber: number, _leafSlot: Fr): Promise<PublicDataWitness | undefined>;
|
|
52
|
-
utilityGetLowNullifierMembershipWitness(_blockNumber: number, _nullifier: Fr): Promise<NullifierMembershipWitness | undefined>;
|
|
53
|
-
utilityGetBlockHeader(_blockNumber: number): Promise<BlockHeader | undefined>;
|
|
54
|
-
utilityGetCompleteAddress(_account: AztecAddress): Promise<CompleteAddress>;
|
|
55
|
-
utilityGetAuthWitness(_messageHash: Fr): Promise<Fr[] | undefined>;
|
|
56
|
-
utilityGetNotes(_storageSlot: Fr, _numSelects: number, _selectByIndexes: number[], _selectByOffsets: number[], _selectByLengths: number[], _selectValues: Fr[], _selectComparators: number[], _sortByIndexes: number[], _sortByOffsets: number[], _sortByLengths: number[], _sortOrder: number[], _limit: number, _offset: number, _status: NoteStatus): Promise<NoteData[]>;
|
|
57
|
-
privateNotifyCreatedNote(_storageSlot: Fr, _noteTypeId: NoteSelector, _note: Fr[], _noteHash: Fr, _counter: number): void;
|
|
58
|
-
privateNotifyNullifiedNote(_innerNullifier: Fr, _noteHash: Fr, _counter: number): Promise<void>;
|
|
59
|
-
privateNotifyCreatedNullifier(_innerNullifier: Fr): Promise<void>;
|
|
60
|
-
utilityCheckNullifierExists(_innerNullifier: Fr): Promise<boolean>;
|
|
61
|
-
utilityGetL1ToL2MembershipWitness(_contractAddress: AztecAddress, _messageHash: Fr, _secret: Fr): Promise<MessageLoadOracleInputs<typeof L1_TO_L2_MSG_TREE_HEIGHT>>;
|
|
62
|
-
utilityStorageRead(_contractAddress: AztecAddress, _startStorageSlot: Fr, _blockNumber: number, _numberOfElements: number): Promise<Fr[]>;
|
|
63
|
-
privateNotifyCreatedContractClassLog(_log: ContractClassLog, _counter: number): void;
|
|
64
|
-
privateCallPrivateFunction(_targetContractAddress: AztecAddress, _functionSelector: FunctionSelector, _argsHash: Fr, _sideEffectCounter: number, _isStaticCall: boolean): Promise<{
|
|
65
|
-
endSideEffectCounter: Fr;
|
|
66
|
-
returnsHash: Fr;
|
|
67
|
-
}>;
|
|
68
|
-
privateNotifyEnqueuedPublicFunctionCall(_targetContractAddress: AztecAddress, _calldataHash: Fr, _sideEffectCounter: number, _isStaticCall: boolean): Promise<void>;
|
|
69
|
-
privateNotifySetPublicTeardownFunctionCall(_targetContractAddress: AztecAddress, _calldataHash: Fr, _sideEffectCounter: number, _isStaticCall: boolean): Promise<void>;
|
|
70
|
-
privateNotifySetMinRevertibleSideEffectCounter(_minRevertibleSideEffectCounter: number): Promise<void>;
|
|
71
|
-
utilityDebugLog(_message: string, _fields: Fr[]): void;
|
|
72
|
-
utilityGetIndexedTaggingSecretAsSender(_sender: AztecAddress, _recipient: AztecAddress): Promise<IndexedTaggingSecret>;
|
|
73
|
-
privateIncrementAppTaggingSecretIndexAsSender(_sender: AztecAddress, _recipient: AztecAddress): Promise<void>;
|
|
74
|
-
utilityFetchTaggedLogs(_pendingTaggedLogArrayBaseSlot: Fr): Promise<void>;
|
|
75
|
-
utilityValidateEnqueuedNotesAndEvents(_contractAddress: AztecAddress, _noteValidationRequestsArrayBaseSlot: Fr, _eventValidationRequestsArrayBaseSlot: Fr): Promise<void>;
|
|
76
|
-
utilityBulkRetrieveLogs(_contractAddress: AztecAddress, _logRetrievalRequestsArrayBaseSlot: Fr, _logRetrievalResponsesArrayBaseSlot: Fr): Promise<void>;
|
|
77
|
-
utilityStoreCapsule(_contractAddress: AztecAddress, _key: Fr, _capsule: Fr[]): Promise<void>;
|
|
78
|
-
utilityLoadCapsule(_contractAddress: AztecAddress, _key: Fr): Promise<Fr[] | null>;
|
|
79
|
-
utilityDeleteCapsule(_contractAddress: AztecAddress, _key: Fr): Promise<void>;
|
|
80
|
-
utilityCopyCapsule(_contractAddress: AztecAddress, _srcKey: Fr, _dstKey: Fr, _numEntries: number): Promise<void>;
|
|
81
|
-
utilityAes128Decrypt(_ciphertext: Buffer, _iv: Buffer, _symKey: Buffer): Promise<Buffer>;
|
|
82
|
-
utilityGetSharedSecret(_address: AztecAddress, _ephPk: Point): Promise<Point>;
|
|
83
|
-
utilityEmitOffchainEffect(_data: Fr[]): Promise<void>;
|
|
84
|
-
privateGetSenderForTags(): Promise<AztecAddress | undefined>;
|
|
85
|
-
privateSetSenderForTags(_senderForTags: AztecAddress): Promise<void>;
|
|
86
|
-
}
|
|
87
|
-
//# sourceMappingURL=typed_oracle.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"typed_oracle.d.ts","sourceRoot":"","sources":["../../../src/contract_function_simulator/oracle/typed_oracle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,KAAK,EAAE,gBAAg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