@aztec/pxe 3.0.0-canary.a9708bd → 3.0.0-devnet.20251212
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 +12 -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 +11 -11
- package/dest/entrypoints/pxe_creation_options.d.ts +3 -1
- 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 +9 -41
- 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 +15 -23
- package/src/entrypoints/client/lazy/index.ts +3 -1
- package/src/entrypoints/client/lazy/utils.ts +14 -22
- package/src/entrypoints/pxe_creation_options.ts +2 -0
- package/src/entrypoints/server/index.ts +3 -1
- package/src/entrypoints/server/utils.ts +12 -56
- 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,17 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Fr } from '@aztec/foundation/
|
|
1
|
+
import type { PrivateEventFilter } from '@aztec/aztec.js/wallet';
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import { SerialQueue } from '@aztec/foundation/queue';
|
|
5
5
|
import { Timer } from '@aztec/foundation/timer';
|
|
6
|
-
import type { SiblingPath } from '@aztec/foundation/trees';
|
|
7
6
|
import { KeyStore } from '@aztec/key-store';
|
|
8
7
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
9
8
|
import { L2TipsKVStore } from '@aztec/kv-store/stores';
|
|
10
|
-
import {
|
|
11
|
-
ProtocolContractAddress,
|
|
12
|
-
type ProtocolContractsProvider,
|
|
13
|
-
protocolContractNames,
|
|
14
|
-
} from '@aztec/protocol-contracts';
|
|
9
|
+
import { type ProtocolContractsProvider, protocolContractNames } from '@aztec/protocol-contracts';
|
|
15
10
|
import type { CircuitSimulator } from '@aztec/simulator/client';
|
|
16
11
|
import {
|
|
17
12
|
type ContractArtifact,
|
|
@@ -19,46 +14,32 @@ import {
|
|
|
19
14
|
FunctionCall,
|
|
20
15
|
FunctionSelector,
|
|
21
16
|
FunctionType,
|
|
22
|
-
decodeFromAbi,
|
|
23
17
|
decodeFunctionSignature,
|
|
24
18
|
encodeArguments,
|
|
25
19
|
} from '@aztec/stdlib/abi';
|
|
26
20
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
27
21
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
28
|
-
import type { L2Block } from '@aztec/stdlib/block';
|
|
29
22
|
import {
|
|
30
23
|
CompleteAddress,
|
|
31
24
|
type ContractClassWithId,
|
|
32
25
|
type ContractInstanceWithAddress,
|
|
33
|
-
type NodeInfo,
|
|
34
26
|
type PartialAddress,
|
|
35
27
|
computeContractAddressFromInstance,
|
|
36
28
|
getContractClassFromArtifact,
|
|
37
29
|
} from '@aztec/stdlib/contract';
|
|
38
30
|
import { SimulationError } from '@aztec/stdlib/errors';
|
|
39
|
-
import
|
|
40
|
-
import {
|
|
41
|
-
import type {
|
|
42
|
-
AztecNode,
|
|
43
|
-
EventMetadataDefinition,
|
|
44
|
-
GetContractClassLogsResponse,
|
|
45
|
-
GetPublicLogsResponse,
|
|
46
|
-
PXE,
|
|
47
|
-
PXEInfo,
|
|
48
|
-
PrivateKernelProver,
|
|
49
|
-
} from '@aztec/stdlib/interfaces/client';
|
|
31
|
+
import { computeProtocolNullifier, siloNullifier } from '@aztec/stdlib/hash';
|
|
32
|
+
import type { AztecNode, PrivateKernelProver } from '@aztec/stdlib/interfaces/client';
|
|
50
33
|
import type {
|
|
51
34
|
PrivateExecutionStep,
|
|
52
35
|
PrivateKernelExecutionProofOutput,
|
|
53
36
|
PrivateKernelTailCircuitPublicInputs,
|
|
54
37
|
} from '@aztec/stdlib/kernel';
|
|
55
|
-
import type {
|
|
56
|
-
import {
|
|
57
|
-
import { type NotesFilter, UniqueNote } from '@aztec/stdlib/note';
|
|
58
|
-
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
38
|
+
import type { NotesFilter } from '@aztec/stdlib/note';
|
|
39
|
+
import { NoteDao } from '@aztec/stdlib/note';
|
|
59
40
|
import {
|
|
60
41
|
type ContractOverrides,
|
|
61
|
-
type
|
|
42
|
+
type InTx,
|
|
62
43
|
PrivateExecutionResult,
|
|
63
44
|
PrivateSimulationResult,
|
|
64
45
|
type ProvingTimings,
|
|
@@ -67,47 +48,49 @@ import {
|
|
|
67
48
|
type SimulationTimings,
|
|
68
49
|
Tx,
|
|
69
50
|
TxExecutionRequest,
|
|
70
|
-
type TxHash,
|
|
71
51
|
TxProfileResult,
|
|
72
52
|
TxProvingResult,
|
|
73
|
-
type TxReceipt,
|
|
74
53
|
TxSimulationResult,
|
|
75
54
|
UtilitySimulationResult,
|
|
76
55
|
} from '@aztec/stdlib/tx';
|
|
77
56
|
|
|
78
57
|
import { inspect } from 'util';
|
|
79
58
|
|
|
80
|
-
import type {
|
|
81
|
-
import { getPackageInfo } from '../config/package_info.js';
|
|
59
|
+
import type { PXEConfig } from './config/index.js';
|
|
82
60
|
import {
|
|
83
61
|
ContractFunctionSimulator,
|
|
84
62
|
generateSimulatedProvingResult,
|
|
85
|
-
} from '
|
|
86
|
-
import { readCurrentClassId } from '
|
|
87
|
-
import { ProxiedContractDataProviderFactory } from '
|
|
88
|
-
import { ProxiedNodeFactory } from '
|
|
89
|
-
import { PXEOracleInterface } from '
|
|
63
|
+
} from './contract_function_simulator/contract_function_simulator.js';
|
|
64
|
+
import { readCurrentClassId } from './contract_function_simulator/oracle/private_execution.js';
|
|
65
|
+
import { ProxiedContractDataProviderFactory } from './contract_function_simulator/proxied_contract_data_source.js';
|
|
66
|
+
import { ProxiedNodeFactory } from './contract_function_simulator/proxied_node.js';
|
|
67
|
+
import { PXEOracleInterface } from './contract_function_simulator/pxe_oracle_interface.js';
|
|
68
|
+
import { enrichPublicSimulationError, enrichSimulationError } from './error_enriching.js';
|
|
69
|
+
import { PrivateEventFilterValidator } from './events/private_event_filter_validator.js';
|
|
90
70
|
import {
|
|
91
71
|
PrivateKernelExecutionProver,
|
|
92
72
|
type PrivateKernelExecutionProverConfig,
|
|
93
|
-
} from '
|
|
94
|
-
import { PrivateKernelOracleImpl } from '
|
|
95
|
-
import { AddressDataProvider } from '
|
|
96
|
-
import { CapsuleDataProvider } from '
|
|
97
|
-
import { ContractDataProvider } from '
|
|
98
|
-
import { NoteDataProvider } from '
|
|
99
|
-
import { PrivateEventDataProvider } from '
|
|
100
|
-
import { SyncDataProvider } from '
|
|
101
|
-
import { TaggingDataProvider } from '
|
|
102
|
-
import { Synchronizer } from '
|
|
103
|
-
|
|
73
|
+
} from './private_kernel/private_kernel_execution_prover.js';
|
|
74
|
+
import { PrivateKernelOracleImpl } from './private_kernel/private_kernel_oracle_impl.js';
|
|
75
|
+
import { AddressDataProvider } from './storage/address_data_provider/address_data_provider.js';
|
|
76
|
+
import { CapsuleDataProvider } from './storage/capsule_data_provider/capsule_data_provider.js';
|
|
77
|
+
import { ContractDataProvider } from './storage/contract_data_provider/contract_data_provider.js';
|
|
78
|
+
import { NoteDataProvider } from './storage/note_data_provider/note_data_provider.js';
|
|
79
|
+
import { PrivateEventDataProvider } from './storage/private_event_data_provider/private_event_data_provider.js';
|
|
80
|
+
import { SyncDataProvider } from './storage/sync_data_provider/sync_data_provider.js';
|
|
81
|
+
import { TaggingDataProvider } from './storage/tagging_data_provider/tagging_data_provider.js';
|
|
82
|
+
import { Synchronizer } from './synchronizer/index.js';
|
|
83
|
+
|
|
84
|
+
export type PackedPrivateEvent = InTx & {
|
|
85
|
+
packedEvent: Fr[];
|
|
86
|
+
eventSelector: EventSelector;
|
|
87
|
+
};
|
|
104
88
|
|
|
105
89
|
/**
|
|
106
|
-
*
|
|
90
|
+
* Private eXecution Environment (PXE) is a library used by wallets to simulate private phase of transactions and to
|
|
91
|
+
* manage private state of users.
|
|
107
92
|
*/
|
|
108
|
-
export class
|
|
109
|
-
#nodeInfo?: NodeInfo;
|
|
110
|
-
|
|
93
|
+
export class PXE {
|
|
111
94
|
private constructor(
|
|
112
95
|
private node: AztecNode,
|
|
113
96
|
private synchronizer: Synchronizer,
|
|
@@ -120,7 +103,6 @@ export class PXEService implements PXE {
|
|
|
120
103
|
private addressDataProvider: AddressDataProvider,
|
|
121
104
|
private privateEventDataProvider: PrivateEventDataProvider,
|
|
122
105
|
private simulator: CircuitSimulator,
|
|
123
|
-
private packageVersion: string,
|
|
124
106
|
private proverEnabled: boolean,
|
|
125
107
|
private proofCreator: PrivateKernelProver,
|
|
126
108
|
private protocolContractsProvider: ProtocolContractsProvider,
|
|
@@ -129,11 +111,11 @@ export class PXEService implements PXE {
|
|
|
129
111
|
) {}
|
|
130
112
|
|
|
131
113
|
/**
|
|
132
|
-
* Creates an instance of a PXE
|
|
114
|
+
* Creates an instance of a PXE by instantiating all the necessary data providers and services.
|
|
133
115
|
* Also triggers the registration of the protocol contracts and makes sure the provided node
|
|
134
116
|
* can be contacted.
|
|
135
117
|
*
|
|
136
|
-
* @returns A promise that resolves PXE
|
|
118
|
+
* @returns A promise that resolves PXE is ready to be used.
|
|
137
119
|
*/
|
|
138
120
|
public static async create(
|
|
139
121
|
node: AztecNode,
|
|
@@ -141,7 +123,7 @@ export class PXEService implements PXE {
|
|
|
141
123
|
proofCreator: PrivateKernelProver,
|
|
142
124
|
simulator: CircuitSimulator,
|
|
143
125
|
protocolContractsProvider: ProtocolContractsProvider,
|
|
144
|
-
config:
|
|
126
|
+
config: PXEConfig,
|
|
145
127
|
loggerOrSuffix?: string | Logger,
|
|
146
128
|
) {
|
|
147
129
|
const log =
|
|
@@ -149,7 +131,6 @@ export class PXEService implements PXE {
|
|
|
149
131
|
? createLogger(loggerOrSuffix ? `pxe:service:${loggerOrSuffix}` : `pxe:service`)
|
|
150
132
|
: loggerOrSuffix;
|
|
151
133
|
|
|
152
|
-
const packageVersion = getPackageInfo().version;
|
|
153
134
|
const proverEnabled = !!config.proverEnabled;
|
|
154
135
|
const addressDataProvider = new AddressDataProvider(store);
|
|
155
136
|
const privateEventDataProvider = new PrivateEventDataProvider(store);
|
|
@@ -172,7 +153,7 @@ export class PXEService implements PXE {
|
|
|
172
153
|
|
|
173
154
|
const jobQueue = new SerialQueue();
|
|
174
155
|
|
|
175
|
-
const
|
|
156
|
+
const pxe = new PXE(
|
|
176
157
|
node,
|
|
177
158
|
synchronizer,
|
|
178
159
|
keyStore,
|
|
@@ -184,7 +165,6 @@ export class PXEService implements PXE {
|
|
|
184
165
|
addressDataProvider,
|
|
185
166
|
privateEventDataProvider,
|
|
186
167
|
simulator,
|
|
187
|
-
packageVersion,
|
|
188
168
|
proverEnabled,
|
|
189
169
|
proofCreator,
|
|
190
170
|
protocolContractsProvider,
|
|
@@ -192,65 +172,12 @@ export class PXEService implements PXE {
|
|
|
192
172
|
jobQueue,
|
|
193
173
|
);
|
|
194
174
|
|
|
195
|
-
|
|
175
|
+
pxe.jobQueue.start();
|
|
196
176
|
|
|
197
|
-
await
|
|
198
|
-
const info = await
|
|
177
|
+
await pxe.#registerProtocolContracts();
|
|
178
|
+
const info = await node.getNodeInfo();
|
|
199
179
|
log.info(`Started PXE connected to chain ${info.l1ChainId} version ${info.rollupVersion}`);
|
|
200
|
-
return
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
// Aztec node proxy methods
|
|
204
|
-
|
|
205
|
-
public isL1ToL2MessageSynced(l1ToL2Message: Fr): Promise<boolean> {
|
|
206
|
-
return this.node.isL1ToL2MessageSynced(l1ToL2Message);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
public async getL2ToL1MembershipWitness(
|
|
210
|
-
blockNumber: number,
|
|
211
|
-
l2Tol1Message: Fr,
|
|
212
|
-
): Promise<[bigint, SiblingPath<number>]> {
|
|
213
|
-
const result = await computeL2ToL1MembershipWitness(this.node, blockNumber, l2Tol1Message);
|
|
214
|
-
if (!result) {
|
|
215
|
-
throw new Error(`L2 to L1 message not found in block ${blockNumber}`);
|
|
216
|
-
}
|
|
217
|
-
return [result.leafIndex, result.siblingPath];
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
public getTxReceipt(txHash: TxHash): Promise<TxReceipt> {
|
|
221
|
-
return this.node.getTxReceipt(txHash);
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
public getTxEffect(txHash: TxHash): Promise<IndexedTxEffect | undefined> {
|
|
225
|
-
return this.node.getTxEffect(txHash);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
public getBlockNumber(): Promise<number> {
|
|
229
|
-
return this.node.getBlockNumber();
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
public getProvenBlockNumber(): Promise<number> {
|
|
233
|
-
return this.node.getProvenBlockNumber();
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
public getPublicLogs(filter: LogFilter): Promise<GetPublicLogsResponse> {
|
|
237
|
-
return this.node.getPublicLogs(filter);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
public getContractClassLogs(filter: LogFilter): Promise<GetContractClassLogsResponse> {
|
|
241
|
-
return this.node.getContractClassLogs(filter);
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
public getPublicStorageAt(contract: AztecAddress, slot: Fr) {
|
|
245
|
-
return this.node.getPublicStorageAt('latest', contract, slot);
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
public async getL1ToL2MembershipWitness(
|
|
249
|
-
contractAddress: AztecAddress,
|
|
250
|
-
messageHash: Fr,
|
|
251
|
-
secret: Fr,
|
|
252
|
-
): Promise<[bigint, SiblingPath<typeof L1_TO_L2_MSG_TREE_HEIGHT>]> {
|
|
253
|
-
return await getNonNullifiedL1ToL2MessageWitness(this.node, contractAddress, messageHash, secret);
|
|
180
|
+
return pxe;
|
|
254
181
|
}
|
|
255
182
|
|
|
256
183
|
// Internal methods
|
|
@@ -331,7 +258,7 @@ export class PXEService implements PXE {
|
|
|
331
258
|
const contract = await this.contractDataProvider.getContract(to);
|
|
332
259
|
if (!contract) {
|
|
333
260
|
throw new Error(
|
|
334
|
-
`Unknown contract ${to}: add it to PXE
|
|
261
|
+
`Unknown contract ${to}: add it to PXE by calling server.addContracts(...).\nSee docs for context: https://docs.aztec.network/developers/resources/debugging/aztecnr-errors#unknown-contract-0x0-add-it-to-pxe-by-calling-serveraddcontracts`,
|
|
335
262
|
);
|
|
336
263
|
}
|
|
337
264
|
|
|
@@ -346,6 +273,7 @@ export class PXEService implements PXE {
|
|
|
346
273
|
selector: await FunctionSelector.fromNameAndParameters(functionDao.name, functionDao.parameters),
|
|
347
274
|
type: functionDao.functionType,
|
|
348
275
|
to,
|
|
276
|
+
hideMsgSender: false,
|
|
349
277
|
isStatic: functionDao.isStatic,
|
|
350
278
|
returnTypes: functionDao.returnTypes,
|
|
351
279
|
};
|
|
@@ -442,7 +370,7 @@ export class PXEService implements PXE {
|
|
|
442
370
|
* @param proofCreator - The proof creator to use for proving the execution.
|
|
443
371
|
* @param privateExecutionResult - The result of the private execution
|
|
444
372
|
* @param config - The configuration for the kernel execution prover.
|
|
445
|
-
* @returns An object that contains the output of the kernel execution, including the
|
|
373
|
+
* @returns An object that contains the output of the kernel execution, including the ChonkProof if proving is enabled.
|
|
446
374
|
*/
|
|
447
375
|
async #prove(
|
|
448
376
|
txExecutionRequest: TxExecutionRequest,
|
|
@@ -450,8 +378,13 @@ export class PXEService implements PXE {
|
|
|
450
378
|
privateExecutionResult: PrivateExecutionResult,
|
|
451
379
|
config: PrivateKernelExecutionProverConfig,
|
|
452
380
|
): Promise<PrivateKernelExecutionProofOutput<PrivateKernelTailCircuitPublicInputs>> {
|
|
453
|
-
const
|
|
454
|
-
const kernelOracle = new PrivateKernelOracleImpl(
|
|
381
|
+
const simulationAnchorBlock = privateExecutionResult.getSimulationAnchorBlockNumber();
|
|
382
|
+
const kernelOracle = new PrivateKernelOracleImpl(
|
|
383
|
+
this.contractDataProvider,
|
|
384
|
+
this.keyStore,
|
|
385
|
+
this.node,
|
|
386
|
+
simulationAnchorBlock,
|
|
387
|
+
);
|
|
455
388
|
const kernelTraceProver = new PrivateKernelExecutionProver(kernelOracle, proofCreator, !this.proverEnabled);
|
|
456
389
|
this.log.debug(`Executing kernel trace prover (${JSON.stringify(config)})...`);
|
|
457
390
|
return await kernelTraceProver.proveWithKernels(txExecutionRequest.toTxRequest(), privateExecutionResult, config);
|
|
@@ -459,24 +392,24 @@ export class PXEService implements PXE {
|
|
|
459
392
|
|
|
460
393
|
// Public API
|
|
461
394
|
|
|
462
|
-
/** Returns an estimate of the db size in bytes. */
|
|
463
|
-
public async estimateDbSize() {
|
|
464
|
-
const treeRootsSize = Object.keys(MerkleTreeId).length * Fr.SIZE_IN_BYTES;
|
|
465
|
-
const dbSizes = await Promise.all([
|
|
466
|
-
this.addressDataProvider.getSize(),
|
|
467
|
-
this.capsuleDataProvider.getSize(),
|
|
468
|
-
this.contractDataProvider.getSize(),
|
|
469
|
-
this.noteDataProvider.getSize(),
|
|
470
|
-
this.syncDataProvider.getSize(),
|
|
471
|
-
this.taggingDataProvider.getSize(),
|
|
472
|
-
]);
|
|
473
|
-
return [...dbSizes, treeRootsSize].reduce((sum, size) => sum + size, 0);
|
|
474
|
-
}
|
|
475
|
-
|
|
476
395
|
public getContractInstance(address: AztecAddress): Promise<ContractInstanceWithAddress | undefined> {
|
|
477
396
|
return this.contractDataProvider.getContractInstance(address);
|
|
478
397
|
}
|
|
479
398
|
|
|
399
|
+
/**
|
|
400
|
+
* Returns the contract class metadata given a contract class id.
|
|
401
|
+
* The metadata consists of its contract class, whether it has been publicly registered, and its artifact.
|
|
402
|
+
* @remark - it queries the node to check whether the contract class with the given id has been publicly registered.
|
|
403
|
+
* @param id - Identifier of the class.
|
|
404
|
+
* @param includeArtifact - Identifier of the class.
|
|
405
|
+
* @returns - It returns the contract class metadata, with the artifact field being optional, and will only be returned if true is passed in
|
|
406
|
+
* for `includeArtifact`
|
|
407
|
+
* TODO(@spalladino): The PXE actually holds artifacts and not classes, what should we return? Also,
|
|
408
|
+
* should the pxe query the node for contract public info, and merge it with its own definitions?
|
|
409
|
+
* TODO(@spalladino): This method is strictly needed to decide whether to publicly register a class or not
|
|
410
|
+
* during a public deployment. We probably want a nicer and more general API for this, but it'll have to
|
|
411
|
+
* do for the time being.
|
|
412
|
+
*/
|
|
480
413
|
public async getContractClassMetadata(
|
|
481
414
|
id: Fr,
|
|
482
415
|
includeArtifact: boolean = false,
|
|
@@ -497,6 +430,17 @@ export class PXEService implements PXE {
|
|
|
497
430
|
};
|
|
498
431
|
}
|
|
499
432
|
|
|
433
|
+
/**
|
|
434
|
+
* Returns the contract metadata given an address.
|
|
435
|
+
* The metadata consists of its contract instance, which includes the contract class identifier,
|
|
436
|
+
* initialization hash, deployment salt, and public keys hash; whether the contract instance has been initialized;
|
|
437
|
+
* and whether the contract instance with the given address has been publicly deployed.
|
|
438
|
+
* @remark - it queries the node to check whether the contract instance has been initialized / publicly deployed through a node.
|
|
439
|
+
* This query is not dependent on the PXE.
|
|
440
|
+
* @param address - The address that the contract instance resides at.
|
|
441
|
+
* @returns - It returns the contract metadata
|
|
442
|
+
* TODO(@spalladino): Should we return the public keys in plain as well here?
|
|
443
|
+
*/
|
|
500
444
|
public async getContractMetadata(address: AztecAddress): Promise<{
|
|
501
445
|
contractInstance: ContractInstanceWithAddress | undefined;
|
|
502
446
|
isContractInitialized: boolean;
|
|
@@ -515,6 +459,16 @@ export class PXEService implements PXE {
|
|
|
515
459
|
};
|
|
516
460
|
}
|
|
517
461
|
|
|
462
|
+
/**
|
|
463
|
+
* Registers a user account in PXE given its master encryption private key.
|
|
464
|
+
* Once a new account is registered, the PXE will trial-decrypt all published notes on
|
|
465
|
+
* the chain and store those that correspond to the registered account. Will do nothing if the
|
|
466
|
+
* account is already registered.
|
|
467
|
+
*
|
|
468
|
+
* @param secretKey - Secret key of the corresponding user master public key.
|
|
469
|
+
* @param partialAddress - The partial address of the account contract corresponding to the account being registered.
|
|
470
|
+
* @returns The complete address of the account.
|
|
471
|
+
*/
|
|
518
472
|
public async registerAccount(secretKey: Fr, partialAddress: PartialAddress): Promise<CompleteAddress> {
|
|
519
473
|
const accounts = await this.keyStore.getAccounts();
|
|
520
474
|
const accountCompleteAddress = await this.keyStore.addAccount(secretKey, partialAddress);
|
|
@@ -531,6 +485,15 @@ export class PXEService implements PXE {
|
|
|
531
485
|
return accountCompleteAddress;
|
|
532
486
|
}
|
|
533
487
|
|
|
488
|
+
/**
|
|
489
|
+
* Registers a user contact in PXE.
|
|
490
|
+
*
|
|
491
|
+
* Once a new contact is registered, the PXE will be able to receive notes tagged from this contact.
|
|
492
|
+
* Will do nothing if the account is already registered.
|
|
493
|
+
*
|
|
494
|
+
* @param address - Address of the user to add to the address book
|
|
495
|
+
* @returns The address address of the account.
|
|
496
|
+
*/
|
|
534
497
|
public async registerSender(address: AztecAddress): Promise<AztecAddress> {
|
|
535
498
|
const accounts = await this.keyStore.getAccounts();
|
|
536
499
|
if (accounts.includes(address)) {
|
|
@@ -549,10 +512,17 @@ export class PXEService implements PXE {
|
|
|
549
512
|
return address;
|
|
550
513
|
}
|
|
551
514
|
|
|
515
|
+
/**
|
|
516
|
+
* Retrieves the addresses stored as senders on this PXE.
|
|
517
|
+
* @returns An array of the senders on this PXE.
|
|
518
|
+
*/
|
|
552
519
|
public getSenders(): Promise<AztecAddress[]> {
|
|
553
520
|
return this.taggingDataProvider.getSenderAddresses();
|
|
554
521
|
}
|
|
555
522
|
|
|
523
|
+
/**
|
|
524
|
+
* Removes a sender in the address book.
|
|
525
|
+
*/
|
|
556
526
|
public async removeSender(address: AztecAddress): Promise<void> {
|
|
557
527
|
const wasRemoved = await this.taggingDataProvider.removeSenderAddress(address);
|
|
558
528
|
|
|
@@ -563,6 +533,10 @@ export class PXEService implements PXE {
|
|
|
563
533
|
}
|
|
564
534
|
}
|
|
565
535
|
|
|
536
|
+
/**
|
|
537
|
+
* Retrieves the user accounts registered on this PXE.
|
|
538
|
+
* @returns An array of the accounts registered on this PXE.
|
|
539
|
+
*/
|
|
566
540
|
public async getRegisteredAccounts(): Promise<CompleteAddress[]> {
|
|
567
541
|
// Get complete addresses of both the recipients and the accounts
|
|
568
542
|
const completeAddresses = await this.addressDataProvider.getCompleteAddresses();
|
|
@@ -573,12 +547,25 @@ export class PXEService implements PXE {
|
|
|
573
547
|
);
|
|
574
548
|
}
|
|
575
549
|
|
|
550
|
+
/**
|
|
551
|
+
* Registers a contract class in the PXE without registering any associated contract instance with it.
|
|
552
|
+
*
|
|
553
|
+
* @param artifact - The build artifact for the contract class.
|
|
554
|
+
*/
|
|
576
555
|
public async registerContractClass(artifact: ContractArtifact): Promise<void> {
|
|
577
556
|
const { id: contractClassId } = await getContractClassFromArtifact(artifact);
|
|
578
557
|
await this.contractDataProvider.addContractArtifact(contractClassId, artifact);
|
|
579
558
|
this.log.info(`Added contract class ${artifact.name} with id ${contractClassId}`);
|
|
580
559
|
}
|
|
581
560
|
|
|
561
|
+
/**
|
|
562
|
+
* Adds deployed contracts to the PXE. Deployed contract information is used to access the
|
|
563
|
+
* contract code when simulating local transactions. This is automatically called by aztec.js when
|
|
564
|
+
* deploying a contract. Dapps that wish to interact with contracts already deployed should register
|
|
565
|
+
* these contracts in their users' PXE through this method.
|
|
566
|
+
*
|
|
567
|
+
* @param contract - A contract instance to register, with an optional artifact which can be omitted if the contract class has already been registered.
|
|
568
|
+
*/
|
|
582
569
|
public async registerContract(contract: { instance: ContractInstanceWithAddress; artifact?: ContractArtifact }) {
|
|
583
570
|
const { instance } = contract;
|
|
584
571
|
let { artifact } = contract;
|
|
@@ -618,6 +605,15 @@ export class PXEService implements PXE {
|
|
|
618
605
|
);
|
|
619
606
|
}
|
|
620
607
|
|
|
608
|
+
/**
|
|
609
|
+
* Updates a deployed contract in the PXE. This is used to update the contract artifact when
|
|
610
|
+
* an update has happened, so the new code can be used in the simulation of local transactions.
|
|
611
|
+
* This is called by aztec.js when instantiating a contract in a given address with a mismatching artifact.
|
|
612
|
+
* @param contractAddress - The address of the contract to update.
|
|
613
|
+
* @param artifact - The updated artifact for the contract.
|
|
614
|
+
* @throws If the artifact's contract class is not found in the PXE or if the contract class is different from
|
|
615
|
+
* the current one (current one from the point of view of the node to which the PXE is connected).
|
|
616
|
+
*/
|
|
621
617
|
public updateContract(contractAddress: AztecAddress, artifact: ContractArtifact): Promise<void> {
|
|
622
618
|
// We disable concurrently updating contracts to avoid concurrently syncing with the node, or changing a contract's
|
|
623
619
|
// class while we're simulating it.
|
|
@@ -655,67 +651,58 @@ export class PXEService implements PXE {
|
|
|
655
651
|
});
|
|
656
652
|
}
|
|
657
653
|
|
|
654
|
+
/**
|
|
655
|
+
* Retrieves the addresses of contracts added to this PXE.
|
|
656
|
+
* @returns An array of contracts addresses registered on this PXE.
|
|
657
|
+
*/
|
|
658
658
|
public getContracts(): Promise<AztecAddress[]> {
|
|
659
659
|
return this.contractDataProvider.getContractsAddresses();
|
|
660
660
|
}
|
|
661
661
|
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
throw new Error(`Cannot find complete address for recipient ${dao.recipient.toString()}`);
|
|
678
|
-
}
|
|
679
|
-
recipient = completeAddress.address;
|
|
680
|
-
}
|
|
681
|
-
return new UniqueNote(dao.note, recipient, dao.contractAddress, dao.storageSlot, dao.txHash, dao.noteNonce);
|
|
682
|
-
});
|
|
683
|
-
return Promise.all(extendedNotes);
|
|
684
|
-
}
|
|
685
|
-
|
|
686
|
-
public async getBlock(blockNumber: number): Promise<L2Block | undefined> {
|
|
687
|
-
// If a negative block number is provided the current block number is fetched.
|
|
688
|
-
if (blockNumber < 0) {
|
|
689
|
-
blockNumber = await this.node.getBlockNumber();
|
|
690
|
-
}
|
|
691
|
-
return await this.node.getBlock(blockNumber);
|
|
692
|
-
}
|
|
662
|
+
/**
|
|
663
|
+
* A debugging utility to get notes based on the provided filter.
|
|
664
|
+
*
|
|
665
|
+
* Note that this should not be used in production code because the structure of notes is considered to be
|
|
666
|
+
* an implementation detail of contracts. This is only meant to be used for debugging purposes. If you need to obtain
|
|
667
|
+
* note-related information in production code, please implement a custom utility function on your contract and call
|
|
668
|
+
* that function instead (e.g. `get_balance(owner: AztecAddress) -> u128` utility function on a Token contract).
|
|
669
|
+
*
|
|
670
|
+
* @param filter - The filter to apply to the notes.
|
|
671
|
+
* @returns The requested notes.
|
|
672
|
+
*/
|
|
673
|
+
public async getNotes(filter: NotesFilter): Promise<NoteDao[]> {
|
|
674
|
+
// We need to manually trigger private state sync to have a guarantee that all the notes are available.
|
|
675
|
+
const call = await this.#getFunctionCall('sync_private_state', [], filter.contractAddress);
|
|
676
|
+
await this.simulateUtility(call);
|
|
693
677
|
|
|
694
|
-
|
|
695
|
-
return await this.node.getCurrentBaseFees();
|
|
678
|
+
return this.noteDataProvider.getNotes(filter);
|
|
696
679
|
}
|
|
697
680
|
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
681
|
+
/**
|
|
682
|
+
* Proves the private portion of a simulated transaction, ready to send to the network
|
|
683
|
+
* (where validators prove the public portion).
|
|
684
|
+
*
|
|
685
|
+
* @param txRequest - An authenticated tx request ready for proving
|
|
686
|
+
* @returns A result containing the proof and public inputs of the tail circuit.
|
|
687
|
+
* @throws If contract code not found, or public simulation reverts.
|
|
688
|
+
* Also throws if simulatePublic is true and public simulation reverts.
|
|
689
|
+
*/
|
|
690
|
+
public proveTx(txRequest: TxExecutionRequest): Promise<TxProvingResult> {
|
|
691
|
+
let privateExecutionResult: PrivateExecutionResult;
|
|
702
692
|
// We disable proving concurrently mostly out of caution, since it accesses some of our stores. Proving is so
|
|
703
693
|
// computationally demanding that it'd be rare for someone to try to do it concurrently regardless.
|
|
704
694
|
return this.#putInJobQueue(async () => {
|
|
705
695
|
const totalTimer = new Timer();
|
|
706
696
|
try {
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
contractFunctionSimulator = this.#getSimulatorForTx();
|
|
714
|
-
privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest);
|
|
715
|
-
}
|
|
697
|
+
const syncTimer = new Timer();
|
|
698
|
+
await this.synchronizer.sync();
|
|
699
|
+
const syncTime = syncTimer.ms();
|
|
700
|
+
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
701
|
+
privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest);
|
|
702
|
+
|
|
716
703
|
const {
|
|
717
704
|
publicInputs,
|
|
718
|
-
|
|
705
|
+
chonkProof,
|
|
719
706
|
executionSteps,
|
|
720
707
|
timings: { proving } = {},
|
|
721
708
|
} = await this.#prove(txRequest, this.proofCreator, privateExecutionResult, {
|
|
@@ -742,16 +729,38 @@ export class PXEService implements PXE {
|
|
|
742
729
|
};
|
|
743
730
|
|
|
744
731
|
this.log.debug(`Proving completed in ${totalTime}ms`, { timings });
|
|
745
|
-
|
|
732
|
+
|
|
733
|
+
const txProvingResult = new TxProvingResult(privateExecutionResult, publicInputs, chonkProof!, {
|
|
746
734
|
timings,
|
|
747
735
|
nodeRPCCalls: contractFunctionSimulator?.getStats().nodeRPCCalls,
|
|
748
736
|
});
|
|
737
|
+
|
|
738
|
+
const preTagsUsedInTheTx = privateExecutionResult.entrypoint.preTags;
|
|
739
|
+
if (preTagsUsedInTheTx.length > 0) {
|
|
740
|
+
await this.taggingDataProvider.setLastUsedIndexesAsSender(preTagsUsedInTheTx);
|
|
741
|
+
this.log.debug(`Stored used pre tags as sender for the tx`, {
|
|
742
|
+
preTagsUsedInTheTx,
|
|
743
|
+
});
|
|
744
|
+
} else {
|
|
745
|
+
this.log.debug(`No pre tags used in the tx`);
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
return txProvingResult;
|
|
749
749
|
} catch (err: any) {
|
|
750
750
|
throw this.#contextualizeError(err, inspect(txRequest), inspect(privateExecutionResult));
|
|
751
751
|
}
|
|
752
752
|
});
|
|
753
753
|
}
|
|
754
754
|
|
|
755
|
+
/**
|
|
756
|
+
* Profiles a transaction, reporting gate counts (unless disabled) and returns an execution trace.
|
|
757
|
+
*
|
|
758
|
+
* @param txRequest - An authenticated tx request ready for simulation
|
|
759
|
+
* @param msgSender - (Optional) The message sender to use for the simulation.
|
|
760
|
+
* @param skipTxValidation - (Optional) If false, this function throws if the transaction is unable to be included in a block at the current state.
|
|
761
|
+
* @returns A trace of the program execution with gate counts.
|
|
762
|
+
* @throws If the code for the functions executed in this transaction have not been made available via `addContracts`.
|
|
763
|
+
*/
|
|
755
764
|
public profileTx(
|
|
756
765
|
txRequest: TxExecutionRequest,
|
|
757
766
|
profileMode: 'full' | 'execution-steps' | 'gates',
|
|
@@ -824,7 +833,29 @@ export class PXEService implements PXE {
|
|
|
824
833
|
});
|
|
825
834
|
}
|
|
826
835
|
|
|
827
|
-
|
|
836
|
+
/**
|
|
837
|
+
* Simulates a transaction based on the provided preauthenticated execution request.
|
|
838
|
+
* This will run a local simulation of private execution (and optionally of public as well), run the
|
|
839
|
+
* kernel circuits to ensure adherence to protocol rules (without generating a proof), and return the
|
|
840
|
+
* simulation results .
|
|
841
|
+
*
|
|
842
|
+
*
|
|
843
|
+
* Note that this is used with `ContractFunctionInteraction::simulateTx` to bypass certain checks.
|
|
844
|
+
* In that case, the transaction returned is only potentially ready to be sent to the network for execution.
|
|
845
|
+
*
|
|
846
|
+
*
|
|
847
|
+
* @param txRequest - An authenticated tx request ready for simulation
|
|
848
|
+
* @param simulatePublic - Whether to simulate the public part of the transaction.
|
|
849
|
+
* @param skipTxValidation - (Optional) If false, this function throws if the transaction is unable to be included in a block at the current state.
|
|
850
|
+
* @param skipFeeEnforcement - (Optional) If false, fees are enforced.
|
|
851
|
+
* @param overrides - (Optional) State overrides for the simulation, such as msgSender, contract instances and artifacts.
|
|
852
|
+
* @param scopes - (Optional) The accounts whose notes we can access in this call. Currently optional and will default to all.
|
|
853
|
+
* @returns A simulated transaction result object that includes public and private return values.
|
|
854
|
+
* @throws If the code for the functions executed in this transaction have not been made available via `addContracts`.
|
|
855
|
+
* Also throws if simulatePublic is true and public simulation reverts.
|
|
856
|
+
*
|
|
857
|
+
* TODO(#7456) Prevent msgSender being defined here for the first call
|
|
858
|
+
*/
|
|
828
859
|
public simulateTx(
|
|
829
860
|
txRequest: TxExecutionRequest,
|
|
830
861
|
simulatePublic: boolean,
|
|
@@ -869,10 +900,9 @@ export class PXEService implements PXE {
|
|
|
869
900
|
|
|
870
901
|
if (skipKernels) {
|
|
871
902
|
// According to the protocol rules, the nonce generator for the note hashes
|
|
872
|
-
// can either be the first nullifier in the tx or the
|
|
873
|
-
// if there are none.
|
|
903
|
+
// can either be the first nullifier in the tx or the protocol nullifier if there are none.
|
|
874
904
|
const nonceGenerator = privateExecutionResult.firstNullifier.equals(Fr.ZERO)
|
|
875
|
-
? await txRequest.toTxRequest().hash()
|
|
905
|
+
? await computeProtocolNullifier(await txRequest.toTxRequest().hash())
|
|
876
906
|
: privateExecutionResult.firstNullifier;
|
|
877
907
|
({ publicInputs, executionSteps } = await generateSimulatedProvingResult(
|
|
878
908
|
privateExecutionResult,
|
|
@@ -961,25 +991,18 @@ export class PXEService implements PXE {
|
|
|
961
991
|
});
|
|
962
992
|
}
|
|
963
993
|
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
this.log.info(`Sent transaction ${txHash}`);
|
|
974
|
-
return txHash;
|
|
975
|
-
}
|
|
976
|
-
|
|
994
|
+
/**
|
|
995
|
+
* Simulate the execution of a contract utility function.
|
|
996
|
+
*
|
|
997
|
+
* @param call - The function call containing the function details, arguments, and target contract address.
|
|
998
|
+
* @param authwits - (Optional) The authentication witnesses required for the function call.
|
|
999
|
+
* @param scopes - (Optional) The accounts whose notes we can access in this call. Currently optional and will
|
|
1000
|
+
* default to all.
|
|
1001
|
+
* @returns The result of the utility function call, structured based on the function ABI.
|
|
1002
|
+
*/
|
|
977
1003
|
public simulateUtility(
|
|
978
|
-
|
|
979
|
-
args: any[],
|
|
980
|
-
to: AztecAddress,
|
|
1004
|
+
call: FunctionCall,
|
|
981
1005
|
authwits?: AuthWitness[],
|
|
982
|
-
_from?: AztecAddress,
|
|
983
1006
|
scopes?: AztecAddress[],
|
|
984
1007
|
): Promise<UtilitySimulationResult> {
|
|
985
1008
|
// We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
|
|
@@ -991,21 +1014,14 @@ export class PXEService implements PXE {
|
|
|
991
1014
|
const syncTimer = new Timer();
|
|
992
1015
|
await this.synchronizer.sync();
|
|
993
1016
|
const syncTime = syncTimer.ms();
|
|
994
|
-
// TODO - Should check if `from` has the permission to call the view function.
|
|
995
|
-
const functionCall = await this.#getFunctionCall(functionName, args, to);
|
|
996
1017
|
const functionTimer = new Timer();
|
|
997
1018
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
998
|
-
const executionResult = await this.#simulateUtility(
|
|
999
|
-
contractFunctionSimulator,
|
|
1000
|
-
functionCall,
|
|
1001
|
-
authwits ?? [],
|
|
1002
|
-
scopes,
|
|
1003
|
-
);
|
|
1019
|
+
const executionResult = await this.#simulateUtility(contractFunctionSimulator, call, authwits ?? [], scopes);
|
|
1004
1020
|
const functionTime = functionTimer.ms();
|
|
1005
1021
|
|
|
1006
1022
|
const totalTime = totalTimer.ms();
|
|
1007
1023
|
|
|
1008
|
-
const perFunction = [{ functionName, time: functionTime }];
|
|
1024
|
+
const perFunction = [{ functionName: call.name, time: functionTime }];
|
|
1009
1025
|
|
|
1010
1026
|
const timings: SimulationTimings = {
|
|
1011
1027
|
total: totalTime,
|
|
@@ -1017,118 +1033,50 @@ export class PXEService implements PXE {
|
|
|
1017
1033
|
const simulationStats = contractFunctionSimulator.getStats();
|
|
1018
1034
|
return { result: executionResult, stats: { timings, nodeRPCCalls: simulationStats.nodeRPCCalls } };
|
|
1019
1035
|
} catch (err: any) {
|
|
1036
|
+
const { to, name, args } = call;
|
|
1020
1037
|
const stringifiedArgs = args.map(arg => arg.toString()).join(', ');
|
|
1021
1038
|
throw this.#contextualizeError(
|
|
1022
1039
|
err,
|
|
1023
|
-
`simulateUtility ${to}:${
|
|
1040
|
+
`simulateUtility ${to}:${name}(${stringifiedArgs})`,
|
|
1024
1041
|
`scopes=${scopes?.map(s => s.toString()).join(', ') ?? 'undefined'}`,
|
|
1025
1042
|
);
|
|
1026
1043
|
}
|
|
1027
1044
|
});
|
|
1028
1045
|
}
|
|
1029
1046
|
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
l1ChainId: chainId,
|
|
1048
|
-
rollupVersion,
|
|
1049
|
-
enr,
|
|
1050
|
-
l1ContractAddresses: contractAddresses,
|
|
1051
|
-
protocolContractAddresses: protocolContractAddresses,
|
|
1052
|
-
};
|
|
1053
|
-
}
|
|
1054
|
-
|
|
1055
|
-
return this.#nodeInfo;
|
|
1056
|
-
}
|
|
1057
|
-
|
|
1058
|
-
public getPXEInfo(): Promise<PXEInfo> {
|
|
1059
|
-
return Promise.resolve({
|
|
1060
|
-
pxeVersion: this.packageVersion,
|
|
1061
|
-
protocolContractAddresses: {
|
|
1062
|
-
classRegistry: ProtocolContractAddress.ContractClassRegistry,
|
|
1063
|
-
feeJuice: ProtocolContractAddress.FeeJuice,
|
|
1064
|
-
instanceRegistry: ProtocolContractAddress.ContractInstanceRegistry,
|
|
1065
|
-
multiCallEntrypoint: ProtocolContractAddress.MultiCallEntrypoint,
|
|
1066
|
-
},
|
|
1067
|
-
});
|
|
1068
|
-
}
|
|
1069
|
-
|
|
1070
|
-
public async getPrivateEvents<T>(
|
|
1071
|
-
contractAddress: AztecAddress,
|
|
1072
|
-
eventMetadataDef: EventMetadataDefinition,
|
|
1073
|
-
from: number,
|
|
1074
|
-
numBlocks: number,
|
|
1075
|
-
recipients: AztecAddress[],
|
|
1076
|
-
): Promise<T[]> {
|
|
1077
|
-
if (recipients.length === 0) {
|
|
1078
|
-
throw new Error('Recipients are required to get private events');
|
|
1079
|
-
}
|
|
1080
|
-
|
|
1081
|
-
this.log.verbose(`Getting private events for ${contractAddress.toString()} from ${from} to ${from + numBlocks}`);
|
|
1082
|
-
|
|
1047
|
+
/**
|
|
1048
|
+
* Returns the private events given search parameters.
|
|
1049
|
+
* @param eventSelector - Event selector to search for.
|
|
1050
|
+
* @param filter
|
|
1051
|
+
* contractAddress - The address of the contract to get events from. Required.
|
|
1052
|
+
* scopes - One or more event scope addresses to filter by. Required.
|
|
1053
|
+
* fromBlock - The block number to search from (inclusive). Optional. If provided, it must be >= 0.
|
|
1054
|
+
* Defaults to 0.
|
|
1055
|
+
* If toBlock is defined but fromBlock is not, fromBlock defaults to toBlock - 1.
|
|
1056
|
+
* toBlock - The block number to search up to (exclusive). Optional. If provided, it must be > 0.
|
|
1057
|
+
* Defaults to the latest known block to PXE + 1.
|
|
1058
|
+
* @returns - The packed events with block and tx metadata.
|
|
1059
|
+
*/
|
|
1060
|
+
public async getPrivateEvents(
|
|
1061
|
+
eventSelector: EventSelector,
|
|
1062
|
+
filter: PrivateEventFilter,
|
|
1063
|
+
): Promise<PackedPrivateEvent[]> {
|
|
1083
1064
|
// We need to manually trigger private state sync to have a guarantee that all the events are available.
|
|
1084
|
-
await this
|
|
1085
|
-
|
|
1086
|
-
const events = await this.privateEventDataProvider.getPrivateEvents(
|
|
1087
|
-
contractAddress,
|
|
1088
|
-
from,
|
|
1089
|
-
numBlocks,
|
|
1090
|
-
recipients,
|
|
1091
|
-
eventMetadataDef.eventSelector,
|
|
1092
|
-
);
|
|
1093
|
-
|
|
1094
|
-
const decodedEvents = events.map((event: Fr[]): T => decodeFromAbi([eventMetadataDef.abiType], event) as T);
|
|
1095
|
-
|
|
1096
|
-
return decodedEvents;
|
|
1097
|
-
}
|
|
1098
|
-
|
|
1099
|
-
async getPublicEvents<T>(eventMetadataDef: EventMetadataDefinition, from: number, limit: number): Promise<T[]> {
|
|
1100
|
-
const { logs } = await this.node.getPublicLogs({
|
|
1101
|
-
fromBlock: from,
|
|
1102
|
-
toBlock: from + limit,
|
|
1103
|
-
});
|
|
1065
|
+
const call = await this.#getFunctionCall('sync_private_state', [], filter.contractAddress);
|
|
1066
|
+
await this.simulateUtility(call);
|
|
1104
1067
|
|
|
1105
|
-
const
|
|
1106
|
-
.map(log => {
|
|
1107
|
-
// +1 for the event selector
|
|
1108
|
-
const expectedLength = eventMetadataDef.fieldNames.length + 1;
|
|
1109
|
-
if (log.log.emittedLength !== expectedLength) {
|
|
1110
|
-
throw new Error(
|
|
1111
|
-
`Something is weird here, we have matching EventSelectors, but the actual payload has mismatched length. Expected ${expectedLength}. Got ${log.log.emittedLength}.`,
|
|
1112
|
-
);
|
|
1113
|
-
}
|
|
1114
|
-
|
|
1115
|
-
const logFields = log.log.getEmittedFields();
|
|
1116
|
-
// We are assuming here that event logs are the last 4 bytes of the event. This is not enshrined but is a function of aztec.nr raw log emission.
|
|
1117
|
-
if (!EventSelector.fromField(logFields[logFields.length - 1]).equals(eventMetadataDef.eventSelector)) {
|
|
1118
|
-
return undefined;
|
|
1119
|
-
}
|
|
1120
|
-
|
|
1121
|
-
return decodeFromAbi([eventMetadataDef.abiType], log.log.fields) as T;
|
|
1122
|
-
})
|
|
1123
|
-
.filter(log => log !== undefined) as T[];
|
|
1068
|
+
const sanitizedFilter = await new PrivateEventFilterValidator(this.syncDataProvider).validate(filter);
|
|
1124
1069
|
|
|
1125
|
-
|
|
1126
|
-
|
|
1070
|
+
this.log.error(
|
|
1071
|
+
`Getting private events for ${sanitizedFilter.contractAddress.toString()} from ${sanitizedFilter.fromBlock} to ${sanitizedFilter.toBlock}`,
|
|
1072
|
+
);
|
|
1127
1073
|
|
|
1128
|
-
|
|
1129
|
-
return await this.taggingDataProvider.resetNoteSyncData();
|
|
1074
|
+
return this.privateEventDataProvider.getPrivateEvents(eventSelector, sanitizedFilter);
|
|
1130
1075
|
}
|
|
1131
1076
|
|
|
1077
|
+
/**
|
|
1078
|
+
* Stops the PXE's job queue.
|
|
1079
|
+
*/
|
|
1132
1080
|
public stop(): Promise<void> {
|
|
1133
1081
|
return this.jobQueue.end();
|
|
1134
1082
|
}
|