@aztec/pxe 2.1.0-rc.9 → 3.0.0-devnet.2
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.js +18 -8
- package/dest/config/index.d.ts +8 -8
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +3 -3
- package/dest/config/package_info.js +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +82 -26
- package/dest/contract_function_simulator/execution_data_provider.d.ts +27 -38
- package/dest/contract_function_simulator/execution_data_provider.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_note_cache.d.ts +2 -2
- package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
- package/dest/contract_function_simulator/execution_note_cache.js +7 -4
- 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/index.d.ts +3 -1
- 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/log_retrieval_response.d.ts.map +1 -1
- package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +7 -3
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +1 -0
- 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 +1 -1
- 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 +1 -1
- 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 +97 -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/oracle.d.ts +12 -11
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +79 -76
- package/dest/contract_function_simulator/oracle/private_execution.d.ts +2 -2
- package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution.js +6 -15
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +26 -10
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +69 -18
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +10 -22
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +33 -38
- package/dest/contract_function_simulator/pxe_oracle_interface.d.ts +19 -55
- package/dest/contract_function_simulator/pxe_oracle_interface.d.ts.map +1 -1
- package/dest/contract_function_simulator/pxe_oracle_interface.js +174 -187
- package/dest/entrypoints/client/bundle/index.d.ts +3 -1
- package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/index.js +2 -1
- package/dest/entrypoints/client/bundle/utils.d.ts +8 -8
- package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/bundle/utils.js +8 -8
- package/dest/entrypoints/client/lazy/index.d.ts +3 -1
- package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/index.js +2 -1
- package/dest/entrypoints/client/lazy/utils.d.ts +7 -7
- package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
- package/dest/entrypoints/client/lazy/utils.js +7 -7
- package/dest/entrypoints/server/index.d.ts +3 -1
- 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 +4 -23
- package/dest/entrypoints/server/utils.d.ts.map +1 -1
- package/dest/entrypoints/server/utils.js +4 -25
- package/dest/{pxe_service/error_enriching.d.ts → error_enriching.d.ts} +1 -1
- package/dest/error_enriching.d.ts.map +1 -0
- package/dest/{pxe_service/error_enriching.js → error_enriching.js} +3 -0
- package/dest/oracle_version.d.ts +2 -2
- package/dest/oracle_version.js +2 -2
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.js +6 -6
- package/dest/private_kernel/private_kernel_execution_prover.d.ts +7 -0
- package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_execution_prover.js +23 -18
- package/dest/private_kernel/private_kernel_oracle_impl.d.ts +2 -2
- package/dest/pxe.d.ts +233 -0
- package/dest/pxe.d.ts.map +1 -0
- package/dest/{pxe_service/pxe_service.js → pxe.js} +215 -217
- package/dest/storage/address_data_provider/address_data_provider.d.ts +1 -3
- 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/capsule_data_provider/capsule_data_provider.d.ts +1 -3
- package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts.map +1 -1
- package/dest/storage/capsule_data_provider/capsule_data_provider.js +0 -4
- package/dest/storage/contract_data_provider/contract_data_provider.d.ts +3 -4
- 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 -3
- package/dest/storage/index.d.ts +0 -1
- package/dest/storage/index.d.ts.map +1 -1
- package/dest/storage/index.js +0 -1
- package/dest/storage/note_data_provider/note_dao.d.ts +1 -1
- package/dest/storage/note_data_provider/note_dao.d.ts.map +1 -1
- package/dest/storage/note_data_provider/note_data_provider.d.ts +70 -7
- package/dest/storage/note_data_provider/note_data_provider.d.ts.map +1 -1
- package/dest/storage/note_data_provider/note_data_provider.js +120 -72
- package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts +1 -3
- 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 +0 -3
- package/dest/storage/sync_data_provider/sync_data_provider.d.ts +1 -3
- 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/tagging_data_provider.d.ts +28 -6
- 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/synchronizer.d.ts.map +1 -1
- package/dest/synchronizer/synchronizer.js +2 -3
- 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 +18 -21
- package/src/bin/check_oracle_version.ts +23 -9
- package/src/config/index.ts +11 -10
- package/src/config/package_info.ts +1 -1
- package/src/contract_function_simulator/contract_function_simulator.ts +128 -44
- package/src/contract_function_simulator/execution_data_provider.ts +29 -47
- package/src/contract_function_simulator/execution_note_cache.ts +11 -6
- package/src/contract_function_simulator/execution_tagging_index_cache.ts +32 -0
- package/src/contract_function_simulator/index.ts +3 -1
- package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +8 -3
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +1 -1
- 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 +160 -0
- package/src/contract_function_simulator/oracle/oracle.ts +102 -77
- package/src/contract_function_simulator/oracle/private_execution.ts +7 -15
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +106 -45
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +51 -76
- package/src/contract_function_simulator/pxe_oracle_interface.ts +199 -218
- package/src/entrypoints/client/bundle/index.ts +3 -1
- package/src/entrypoints/client/bundle/utils.ts +11 -19
- package/src/entrypoints/client/lazy/index.ts +3 -1
- package/src/entrypoints/client/lazy/utils.ts +10 -18
- package/src/entrypoints/server/index.ts +3 -1
- package/src/entrypoints/server/utils.ts +9 -39
- package/src/{pxe_service/error_enriching.ts → error_enriching.ts} +5 -1
- package/src/oracle_version.ts +2 -2
- package/src/private_kernel/hints/compute_tx_include_by_timestamp.ts +6 -6
- package/src/private_kernel/private_kernel_execution_prover.ts +35 -23
- package/src/{pxe_service/pxe_service.ts → pxe.ts} +230 -261
- package/src/storage/address_data_provider/address_data_provider.ts +1 -7
- package/src/storage/capsule_data_provider/capsule_data_provider.ts +1 -11
- package/src/storage/contract_data_provider/contract_data_provider.ts +3 -9
- package/src/storage/index.ts +0 -1
- package/src/storage/note_data_provider/note_dao.ts +1 -1
- package/src/storage/note_data_provider/note_data_provider.ts +142 -99
- package/src/storage/private_event_data_provider/private_event_data_provider.ts +1 -7
- package/src/storage/sync_data_provider/sync_data_provider.ts +1 -7
- package/src/storage/tagging_data_provider/tagging_data_provider.ts +52 -55
- package/src/synchronizer/synchronizer.ts +2 -3
- 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.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 -101
- 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/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/test/pxe_test_suite.ts +0 -113
|
@@ -1,21 +1,15 @@
|
|
|
1
|
-
import { L1_TO_L2_MSG_TREE_HEIGHT } from '@aztec/constants';
|
|
2
1
|
import { Fr } from '@aztec/foundation/fields';
|
|
3
2
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
4
3
|
import { SerialQueue } from '@aztec/foundation/queue';
|
|
5
4
|
import { Timer } from '@aztec/foundation/timer';
|
|
6
|
-
import type { SiblingPath } from '@aztec/foundation/trees';
|
|
7
5
|
import { KeyStore } from '@aztec/key-store';
|
|
8
6
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
9
7
|
import { L2TipsKVStore } from '@aztec/kv-store/stores';
|
|
10
|
-
import {
|
|
11
|
-
ProtocolContractAddress,
|
|
12
|
-
type ProtocolContractsProvider,
|
|
13
|
-
protocolContractNames,
|
|
14
|
-
} from '@aztec/protocol-contracts';
|
|
8
|
+
import { type ProtocolContractsProvider, protocolContractNames } from '@aztec/protocol-contracts';
|
|
15
9
|
import type { CircuitSimulator } from '@aztec/simulator/client';
|
|
16
10
|
import {
|
|
17
11
|
type ContractArtifact,
|
|
18
|
-
|
|
12
|
+
type EventMetadataDefinition,
|
|
19
13
|
FunctionCall,
|
|
20
14
|
FunctionSelector,
|
|
21
15
|
FunctionType,
|
|
@@ -25,40 +19,25 @@ import {
|
|
|
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 type { GasFees } from '@aztec/stdlib/gas';
|
|
40
31
|
import { siloNullifier } from '@aztec/stdlib/hash';
|
|
41
|
-
import type {
|
|
42
|
-
AztecNode,
|
|
43
|
-
EventMetadataDefinition,
|
|
44
|
-
GetContractClassLogsResponse,
|
|
45
|
-
GetPublicLogsResponse,
|
|
46
|
-
PXE,
|
|
47
|
-
PXEInfo,
|
|
48
|
-
PrivateKernelProver,
|
|
49
|
-
} from '@aztec/stdlib/interfaces/client';
|
|
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 { LogFilter } from '@aztec/stdlib/logs';
|
|
56
|
-
import { computeL2ToL1MembershipWitness, getNonNullifiedL1ToL2MessageWitness } from '@aztec/stdlib/messaging';
|
|
57
38
|
import { type NotesFilter, UniqueNote } from '@aztec/stdlib/note';
|
|
58
|
-
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
59
39
|
import {
|
|
60
40
|
type ContractOverrides,
|
|
61
|
-
type IndexedTxEffect,
|
|
62
41
|
PrivateExecutionResult,
|
|
63
42
|
PrivateSimulationResult,
|
|
64
43
|
type ProvingTimings,
|
|
@@ -67,47 +46,43 @@ import {
|
|
|
67
46
|
type SimulationTimings,
|
|
68
47
|
Tx,
|
|
69
48
|
TxExecutionRequest,
|
|
70
|
-
type TxHash,
|
|
71
49
|
TxProfileResult,
|
|
72
50
|
TxProvingResult,
|
|
73
|
-
type TxReceipt,
|
|
74
51
|
TxSimulationResult,
|
|
75
52
|
UtilitySimulationResult,
|
|
76
53
|
} from '@aztec/stdlib/tx';
|
|
77
54
|
|
|
78
55
|
import { inspect } from 'util';
|
|
79
56
|
|
|
80
|
-
import type {
|
|
81
|
-
import { getPackageInfo } from '../config/package_info.js';
|
|
57
|
+
import type { PXEConfig } from './config/index.js';
|
|
82
58
|
import {
|
|
83
59
|
ContractFunctionSimulator,
|
|
84
60
|
generateSimulatedProvingResult,
|
|
85
|
-
} from '
|
|
86
|
-
import { readCurrentClassId } from '
|
|
87
|
-
import { ProxiedContractDataProviderFactory } from '
|
|
88
|
-
import { ProxiedNodeFactory } from '
|
|
89
|
-
import { PXEOracleInterface } from '
|
|
61
|
+
} from './contract_function_simulator/contract_function_simulator.js';
|
|
62
|
+
import { readCurrentClassId } from './contract_function_simulator/oracle/private_execution.js';
|
|
63
|
+
import { ProxiedContractDataProviderFactory } from './contract_function_simulator/proxied_contract_data_source.js';
|
|
64
|
+
import { ProxiedNodeFactory } from './contract_function_simulator/proxied_node.js';
|
|
65
|
+
import { PXEOracleInterface } from './contract_function_simulator/pxe_oracle_interface.js';
|
|
66
|
+
import { enrichPublicSimulationError, enrichSimulationError } from './error_enriching.js';
|
|
90
67
|
import {
|
|
91
68
|
PrivateKernelExecutionProver,
|
|
92
69
|
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
|
-
import { enrichPublicSimulationError, enrichSimulationError } from './error_enriching.js';
|
|
70
|
+
} from './private_kernel/private_kernel_execution_prover.js';
|
|
71
|
+
import { PrivateKernelOracleImpl } from './private_kernel/private_kernel_oracle_impl.js';
|
|
72
|
+
import { AddressDataProvider } from './storage/address_data_provider/address_data_provider.js';
|
|
73
|
+
import { CapsuleDataProvider } from './storage/capsule_data_provider/capsule_data_provider.js';
|
|
74
|
+
import { ContractDataProvider } from './storage/contract_data_provider/contract_data_provider.js';
|
|
75
|
+
import { NoteDataProvider } from './storage/note_data_provider/note_data_provider.js';
|
|
76
|
+
import { PrivateEventDataProvider } from './storage/private_event_data_provider/private_event_data_provider.js';
|
|
77
|
+
import { SyncDataProvider } from './storage/sync_data_provider/sync_data_provider.js';
|
|
78
|
+
import { TaggingDataProvider } from './storage/tagging_data_provider/tagging_data_provider.js';
|
|
79
|
+
import { Synchronizer } from './synchronizer/index.js';
|
|
104
80
|
|
|
105
81
|
/**
|
|
106
|
-
*
|
|
82
|
+
* Private eXecution Environment (PXE) is a library used by wallets to simulate private phase of transactions and to
|
|
83
|
+
* manage private state of users.
|
|
107
84
|
*/
|
|
108
|
-
export class
|
|
109
|
-
#nodeInfo?: NodeInfo;
|
|
110
|
-
|
|
85
|
+
export class PXE {
|
|
111
86
|
private constructor(
|
|
112
87
|
private node: AztecNode,
|
|
113
88
|
private synchronizer: Synchronizer,
|
|
@@ -120,7 +95,6 @@ export class PXEService implements PXE {
|
|
|
120
95
|
private addressDataProvider: AddressDataProvider,
|
|
121
96
|
private privateEventDataProvider: PrivateEventDataProvider,
|
|
122
97
|
private simulator: CircuitSimulator,
|
|
123
|
-
private packageVersion: string,
|
|
124
98
|
private proverEnabled: boolean,
|
|
125
99
|
private proofCreator: PrivateKernelProver,
|
|
126
100
|
private protocolContractsProvider: ProtocolContractsProvider,
|
|
@@ -129,11 +103,11 @@ export class PXEService implements PXE {
|
|
|
129
103
|
) {}
|
|
130
104
|
|
|
131
105
|
/**
|
|
132
|
-
* Creates an instance of a PXE
|
|
106
|
+
* Creates an instance of a PXE by instantiating all the necessary data providers and services.
|
|
133
107
|
* Also triggers the registration of the protocol contracts and makes sure the provided node
|
|
134
108
|
* can be contacted.
|
|
135
109
|
*
|
|
136
|
-
* @returns A promise that resolves PXE
|
|
110
|
+
* @returns A promise that resolves PXE is ready to be used.
|
|
137
111
|
*/
|
|
138
112
|
public static async create(
|
|
139
113
|
node: AztecNode,
|
|
@@ -141,7 +115,7 @@ export class PXEService implements PXE {
|
|
|
141
115
|
proofCreator: PrivateKernelProver,
|
|
142
116
|
simulator: CircuitSimulator,
|
|
143
117
|
protocolContractsProvider: ProtocolContractsProvider,
|
|
144
|
-
config:
|
|
118
|
+
config: PXEConfig,
|
|
145
119
|
loggerOrSuffix?: string | Logger,
|
|
146
120
|
) {
|
|
147
121
|
const log =
|
|
@@ -149,7 +123,6 @@ export class PXEService implements PXE {
|
|
|
149
123
|
? createLogger(loggerOrSuffix ? `pxe:service:${loggerOrSuffix}` : `pxe:service`)
|
|
150
124
|
: loggerOrSuffix;
|
|
151
125
|
|
|
152
|
-
const packageVersion = getPackageInfo().version;
|
|
153
126
|
const proverEnabled = !!config.proverEnabled;
|
|
154
127
|
const addressDataProvider = new AddressDataProvider(store);
|
|
155
128
|
const privateEventDataProvider = new PrivateEventDataProvider(store);
|
|
@@ -172,7 +145,7 @@ export class PXEService implements PXE {
|
|
|
172
145
|
|
|
173
146
|
const jobQueue = new SerialQueue();
|
|
174
147
|
|
|
175
|
-
const
|
|
148
|
+
const pxe = new PXE(
|
|
176
149
|
node,
|
|
177
150
|
synchronizer,
|
|
178
151
|
keyStore,
|
|
@@ -184,7 +157,6 @@ export class PXEService implements PXE {
|
|
|
184
157
|
addressDataProvider,
|
|
185
158
|
privateEventDataProvider,
|
|
186
159
|
simulator,
|
|
187
|
-
packageVersion,
|
|
188
160
|
proverEnabled,
|
|
189
161
|
proofCreator,
|
|
190
162
|
protocolContractsProvider,
|
|
@@ -192,69 +164,12 @@ export class PXEService implements PXE {
|
|
|
192
164
|
jobQueue,
|
|
193
165
|
);
|
|
194
166
|
|
|
195
|
-
|
|
167
|
+
pxe.jobQueue.start();
|
|
196
168
|
|
|
197
|
-
await
|
|
198
|
-
const info = await
|
|
169
|
+
await pxe.#registerProtocolContracts();
|
|
170
|
+
const info = await node.getNodeInfo();
|
|
199
171
|
log.info(`Started PXE connected to chain ${info.l1ChainId} version ${info.rollupVersion}`);
|
|
200
|
-
return
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
public getL1ToL2MessageBlock(l1ToL2Message: Fr): Promise<number | undefined> {
|
|
204
|
-
return this.node.getL1ToL2MessageBlock(l1ToL2Message);
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
// Aztec node proxy methods
|
|
208
|
-
|
|
209
|
-
public isL1ToL2MessageSynced(l1ToL2Message: Fr): Promise<boolean> {
|
|
210
|
-
return this.node.isL1ToL2MessageSynced(l1ToL2Message);
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
public async getL2ToL1MembershipWitness(
|
|
214
|
-
blockNumber: number,
|
|
215
|
-
l2Tol1Message: Fr,
|
|
216
|
-
): Promise<[bigint, SiblingPath<number>]> {
|
|
217
|
-
const result = await computeL2ToL1MembershipWitness(this.node, blockNumber, l2Tol1Message);
|
|
218
|
-
if (!result) {
|
|
219
|
-
throw new Error(`L2 to L1 message not found in block ${blockNumber}`);
|
|
220
|
-
}
|
|
221
|
-
return [result.leafIndex, result.siblingPath];
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
public getTxReceipt(txHash: TxHash): Promise<TxReceipt> {
|
|
225
|
-
return this.node.getTxReceipt(txHash);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
public getTxEffect(txHash: TxHash): Promise<IndexedTxEffect | undefined> {
|
|
229
|
-
return this.node.getTxEffect(txHash);
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
public getBlockNumber(): Promise<number> {
|
|
233
|
-
return this.node.getBlockNumber();
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
public getProvenBlockNumber(): Promise<number> {
|
|
237
|
-
return this.node.getProvenBlockNumber();
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
public getPublicLogs(filter: LogFilter): Promise<GetPublicLogsResponse> {
|
|
241
|
-
return this.node.getPublicLogs(filter);
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
public getContractClassLogs(filter: LogFilter): Promise<GetContractClassLogsResponse> {
|
|
245
|
-
return this.node.getContractClassLogs(filter);
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
public getPublicStorageAt(contract: AztecAddress, slot: Fr) {
|
|
249
|
-
return this.node.getPublicStorageAt('latest', contract, slot);
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
public async getL1ToL2MembershipWitness(
|
|
253
|
-
contractAddress: AztecAddress,
|
|
254
|
-
messageHash: Fr,
|
|
255
|
-
secret: Fr,
|
|
256
|
-
): Promise<[bigint, SiblingPath<typeof L1_TO_L2_MSG_TREE_HEIGHT>]> {
|
|
257
|
-
return await getNonNullifiedL1ToL2MessageWitness(this.node, contractAddress, messageHash, secret);
|
|
172
|
+
return pxe;
|
|
258
173
|
}
|
|
259
174
|
|
|
260
175
|
// Internal methods
|
|
@@ -335,7 +250,7 @@ export class PXEService implements PXE {
|
|
|
335
250
|
const contract = await this.contractDataProvider.getContract(to);
|
|
336
251
|
if (!contract) {
|
|
337
252
|
throw new Error(
|
|
338
|
-
`Unknown contract ${to}: add it to PXE
|
|
253
|
+
`Unknown contract ${to}: add it to PXE by calling server.addContracts(...).\nSee docs for context: https://docs.aztec.network/developers/reference/debugging/aztecnr-errors#unknown-contract-0x0-add-it-to-pxe-by-calling-serveraddcontracts`,
|
|
339
254
|
);
|
|
340
255
|
}
|
|
341
256
|
|
|
@@ -350,6 +265,7 @@ export class PXEService implements PXE {
|
|
|
350
265
|
selector: await FunctionSelector.fromNameAndParameters(functionDao.name, functionDao.parameters),
|
|
351
266
|
type: functionDao.functionType,
|
|
352
267
|
to,
|
|
268
|
+
hideMsgSender: false,
|
|
353
269
|
isStatic: functionDao.isStatic,
|
|
354
270
|
returnTypes: functionDao.returnTypes,
|
|
355
271
|
};
|
|
@@ -454,8 +370,13 @@ export class PXEService implements PXE {
|
|
|
454
370
|
privateExecutionResult: PrivateExecutionResult,
|
|
455
371
|
config: PrivateKernelExecutionProverConfig,
|
|
456
372
|
): Promise<PrivateKernelExecutionProofOutput<PrivateKernelTailCircuitPublicInputs>> {
|
|
457
|
-
const
|
|
458
|
-
const kernelOracle = new PrivateKernelOracleImpl(
|
|
373
|
+
const simulationAnchorBlock = privateExecutionResult.getSimulationAnchorBlockNumber();
|
|
374
|
+
const kernelOracle = new PrivateKernelOracleImpl(
|
|
375
|
+
this.contractDataProvider,
|
|
376
|
+
this.keyStore,
|
|
377
|
+
this.node,
|
|
378
|
+
simulationAnchorBlock,
|
|
379
|
+
);
|
|
459
380
|
const kernelTraceProver = new PrivateKernelExecutionProver(kernelOracle, proofCreator, !this.proverEnabled);
|
|
460
381
|
this.log.debug(`Executing kernel trace prover (${JSON.stringify(config)})...`);
|
|
461
382
|
return await kernelTraceProver.proveWithKernels(txExecutionRequest.toTxRequest(), privateExecutionResult, config);
|
|
@@ -463,24 +384,24 @@ export class PXEService implements PXE {
|
|
|
463
384
|
|
|
464
385
|
// Public API
|
|
465
386
|
|
|
466
|
-
/** Returns an estimate of the db size in bytes. */
|
|
467
|
-
public async estimateDbSize() {
|
|
468
|
-
const treeRootsSize = Object.keys(MerkleTreeId).length * Fr.SIZE_IN_BYTES;
|
|
469
|
-
const dbSizes = await Promise.all([
|
|
470
|
-
this.addressDataProvider.getSize(),
|
|
471
|
-
this.capsuleDataProvider.getSize(),
|
|
472
|
-
this.contractDataProvider.getSize(),
|
|
473
|
-
this.noteDataProvider.getSize(),
|
|
474
|
-
this.syncDataProvider.getSize(),
|
|
475
|
-
this.taggingDataProvider.getSize(),
|
|
476
|
-
]);
|
|
477
|
-
return [...dbSizes, treeRootsSize].reduce((sum, size) => sum + size, 0);
|
|
478
|
-
}
|
|
479
|
-
|
|
480
387
|
public getContractInstance(address: AztecAddress): Promise<ContractInstanceWithAddress | undefined> {
|
|
481
388
|
return this.contractDataProvider.getContractInstance(address);
|
|
482
389
|
}
|
|
483
390
|
|
|
391
|
+
/**
|
|
392
|
+
* Returns the contract class metadata given a contract class id.
|
|
393
|
+
* The metadata consists of its contract class, whether it has been publicly registered, and its artifact.
|
|
394
|
+
* @remark - it queries the node to check whether the contract class with the given id has been publicly registered.
|
|
395
|
+
* @param id - Identifier of the class.
|
|
396
|
+
* @param includeArtifact - Identifier of the class.
|
|
397
|
+
* @returns - It returns the contract class metadata, with the artifact field being optional, and will only be returned if true is passed in
|
|
398
|
+
* for `includeArtifact`
|
|
399
|
+
* TODO(@spalladino): The PXE actually holds artifacts and not classes, what should we return? Also,
|
|
400
|
+
* should the pxe query the node for contract public info, and merge it with its own definitions?
|
|
401
|
+
* TODO(@spalladino): This method is strictly needed to decide whether to publicly register a class or not
|
|
402
|
+
* during a public deployment. We probably want a nicer and more general API for this, but it'll have to
|
|
403
|
+
* do for the time being.
|
|
404
|
+
*/
|
|
484
405
|
public async getContractClassMetadata(
|
|
485
406
|
id: Fr,
|
|
486
407
|
includeArtifact: boolean = false,
|
|
@@ -501,6 +422,17 @@ export class PXEService implements PXE {
|
|
|
501
422
|
};
|
|
502
423
|
}
|
|
503
424
|
|
|
425
|
+
/**
|
|
426
|
+
* Returns the contract metadata given an address.
|
|
427
|
+
* The metadata consists of its contract instance, which includes the contract class identifier,
|
|
428
|
+
* initialization hash, deployment salt, and public keys hash; whether the contract instance has been initialized;
|
|
429
|
+
* and whether the contract instance with the given address has been publicly deployed.
|
|
430
|
+
* @remark - it queries the node to check whether the contract instance has been initialized / publicly deployed through a node.
|
|
431
|
+
* This query is not dependent on the PXE.
|
|
432
|
+
* @param address - The address that the contract instance resides at.
|
|
433
|
+
* @returns - It returns the contract metadata
|
|
434
|
+
* TODO(@spalladino): Should we return the public keys in plain as well here?
|
|
435
|
+
*/
|
|
504
436
|
public async getContractMetadata(address: AztecAddress): Promise<{
|
|
505
437
|
contractInstance: ContractInstanceWithAddress | undefined;
|
|
506
438
|
isContractInitialized: boolean;
|
|
@@ -519,6 +451,16 @@ export class PXEService implements PXE {
|
|
|
519
451
|
};
|
|
520
452
|
}
|
|
521
453
|
|
|
454
|
+
/**
|
|
455
|
+
* Registers a user account in PXE given its master encryption private key.
|
|
456
|
+
* Once a new account is registered, the PXE will trial-decrypt all published notes on
|
|
457
|
+
* the chain and store those that correspond to the registered account. Will do nothing if the
|
|
458
|
+
* account is already registered.
|
|
459
|
+
*
|
|
460
|
+
* @param secretKey - Secret key of the corresponding user master public key.
|
|
461
|
+
* @param partialAddress - The partial address of the account contract corresponding to the account being registered.
|
|
462
|
+
* @returns The complete address of the account.
|
|
463
|
+
*/
|
|
522
464
|
public async registerAccount(secretKey: Fr, partialAddress: PartialAddress): Promise<CompleteAddress> {
|
|
523
465
|
const accounts = await this.keyStore.getAccounts();
|
|
524
466
|
const accountCompleteAddress = await this.keyStore.addAccount(secretKey, partialAddress);
|
|
@@ -535,6 +477,15 @@ export class PXEService implements PXE {
|
|
|
535
477
|
return accountCompleteAddress;
|
|
536
478
|
}
|
|
537
479
|
|
|
480
|
+
/**
|
|
481
|
+
* Registers a user contact in PXE.
|
|
482
|
+
*
|
|
483
|
+
* Once a new contact is registered, the PXE will be able to receive notes tagged from this contact.
|
|
484
|
+
* Will do nothing if the account is already registered.
|
|
485
|
+
*
|
|
486
|
+
* @param address - Address of the user to add to the address book
|
|
487
|
+
* @returns The address address of the account.
|
|
488
|
+
*/
|
|
538
489
|
public async registerSender(address: AztecAddress): Promise<AztecAddress> {
|
|
539
490
|
const accounts = await this.keyStore.getAccounts();
|
|
540
491
|
if (accounts.includes(address)) {
|
|
@@ -553,10 +504,17 @@ export class PXEService implements PXE {
|
|
|
553
504
|
return address;
|
|
554
505
|
}
|
|
555
506
|
|
|
507
|
+
/**
|
|
508
|
+
* Retrieves the addresses stored as senders on this PXE.
|
|
509
|
+
* @returns An array of the senders on this PXE.
|
|
510
|
+
*/
|
|
556
511
|
public getSenders(): Promise<AztecAddress[]> {
|
|
557
512
|
return this.taggingDataProvider.getSenderAddresses();
|
|
558
513
|
}
|
|
559
514
|
|
|
515
|
+
/**
|
|
516
|
+
* Removes a sender in the address book.
|
|
517
|
+
*/
|
|
560
518
|
public async removeSender(address: AztecAddress): Promise<void> {
|
|
561
519
|
const wasRemoved = await this.taggingDataProvider.removeSenderAddress(address);
|
|
562
520
|
|
|
@@ -567,6 +525,10 @@ export class PXEService implements PXE {
|
|
|
567
525
|
}
|
|
568
526
|
}
|
|
569
527
|
|
|
528
|
+
/**
|
|
529
|
+
* Retrieves the user accounts registered on this PXE.
|
|
530
|
+
* @returns An array of the accounts registered on this PXE.
|
|
531
|
+
*/
|
|
570
532
|
public async getRegisteredAccounts(): Promise<CompleteAddress[]> {
|
|
571
533
|
// Get complete addresses of both the recipients and the accounts
|
|
572
534
|
const completeAddresses = await this.addressDataProvider.getCompleteAddresses();
|
|
@@ -577,12 +539,25 @@ export class PXEService implements PXE {
|
|
|
577
539
|
);
|
|
578
540
|
}
|
|
579
541
|
|
|
542
|
+
/**
|
|
543
|
+
* Registers a contract class in the PXE without registering any associated contract instance with it.
|
|
544
|
+
*
|
|
545
|
+
* @param artifact - The build artifact for the contract class.
|
|
546
|
+
*/
|
|
580
547
|
public async registerContractClass(artifact: ContractArtifact): Promise<void> {
|
|
581
548
|
const { id: contractClassId } = await getContractClassFromArtifact(artifact);
|
|
582
549
|
await this.contractDataProvider.addContractArtifact(contractClassId, artifact);
|
|
583
550
|
this.log.info(`Added contract class ${artifact.name} with id ${contractClassId}`);
|
|
584
551
|
}
|
|
585
552
|
|
|
553
|
+
/**
|
|
554
|
+
* Adds deployed contracts to the PXE. Deployed contract information is used to access the
|
|
555
|
+
* contract code when simulating local transactions. This is automatically called by aztec.js when
|
|
556
|
+
* deploying a contract. Dapps that wish to interact with contracts already deployed should register
|
|
557
|
+
* these contracts in their users' PXE through this method.
|
|
558
|
+
*
|
|
559
|
+
* @param contract - A contract instance to register, with an optional artifact which can be omitted if the contract class has already been registered.
|
|
560
|
+
*/
|
|
586
561
|
public async registerContract(contract: { instance: ContractInstanceWithAddress; artifact?: ContractArtifact }) {
|
|
587
562
|
const { instance } = contract;
|
|
588
563
|
let { artifact } = contract;
|
|
@@ -622,6 +597,15 @@ export class PXEService implements PXE {
|
|
|
622
597
|
);
|
|
623
598
|
}
|
|
624
599
|
|
|
600
|
+
/**
|
|
601
|
+
* Updates a deployed contract in the PXE. This is used to update the contract artifact when
|
|
602
|
+
* an update has happened, so the new code can be used in the simulation of local transactions.
|
|
603
|
+
* This is called by aztec.js when instantiating a contract in a given address with a mismatching artifact.
|
|
604
|
+
* @param contractAddress - The address of the contract to update.
|
|
605
|
+
* @param artifact - The updated artifact for the contract.
|
|
606
|
+
* @throws If the artifact's contract class is not found in the PXE or if the contract class is different from
|
|
607
|
+
* the current one (current one from the point of view of the node to which the PXE is connected).
|
|
608
|
+
*/
|
|
625
609
|
public updateContract(contractAddress: AztecAddress, artifact: ContractArtifact): Promise<void> {
|
|
626
610
|
// We disable concurrently updating contracts to avoid concurrently syncing with the node, or changing a contract's
|
|
627
611
|
// class while we're simulating it.
|
|
@@ -659,64 +643,68 @@ export class PXEService implements PXE {
|
|
|
659
643
|
});
|
|
660
644
|
}
|
|
661
645
|
|
|
646
|
+
/**
|
|
647
|
+
* Retrieves the addresses of contracts added to this PXE.
|
|
648
|
+
* @returns An array of contracts addresses registered on this PXE.
|
|
649
|
+
*/
|
|
662
650
|
public getContracts(): Promise<AztecAddress[]> {
|
|
663
651
|
return this.contractDataProvider.getContractsAddresses();
|
|
664
652
|
}
|
|
665
653
|
|
|
654
|
+
/**
|
|
655
|
+
* A debugging utility to get notes based on the provided filter.
|
|
656
|
+
*
|
|
657
|
+
* Note that this should not be used in production code because the structure of notes is considered to be
|
|
658
|
+
* an implementation detail of contracts. This is only meant to be used for debugging purposes. If you need to obtain
|
|
659
|
+
* note-related information in production code, please implement a custom utility function on your contract and call
|
|
660
|
+
* that function instead (e.g. `get_balance(owner: AztecAddress) -> u128` utility function on a Token contract).
|
|
661
|
+
*
|
|
662
|
+
* @param filter - The filter to apply to the notes.
|
|
663
|
+
* @returns The requested notes.
|
|
664
|
+
*/
|
|
666
665
|
public async getNotes(filter: NotesFilter): Promise<UniqueNote[]> {
|
|
667
|
-
// We need to manually trigger private state sync to have a guarantee that all the
|
|
666
|
+
// We need to manually trigger private state sync to have a guarantee that all the notes are available.
|
|
668
667
|
await this.simulateUtility('sync_private_state', [], filter.contractAddress);
|
|
669
668
|
|
|
670
669
|
const noteDaos = await this.noteDataProvider.getNotes(filter);
|
|
671
670
|
|
|
672
|
-
const
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
if (completeAddress === undefined) {
|
|
681
|
-
throw new Error(`Cannot find complete address for recipient ${dao.recipient.toString()}`);
|
|
682
|
-
}
|
|
683
|
-
recipient = completeAddress.address;
|
|
671
|
+
const uniqueNotes = noteDaos.map(async dao => {
|
|
672
|
+
const completeAddresses = await this.addressDataProvider.getCompleteAddresses();
|
|
673
|
+
const completeAddressIndex = completeAddresses.findIndex(completeAddress =>
|
|
674
|
+
completeAddress.address.equals(dao.recipient),
|
|
675
|
+
);
|
|
676
|
+
const completeAddress = completeAddresses[completeAddressIndex];
|
|
677
|
+
if (completeAddress === undefined) {
|
|
678
|
+
throw new Error(`Cannot find complete address for recipient ${dao.recipient.toString()}`);
|
|
684
679
|
}
|
|
680
|
+
const recipient = completeAddress.address;
|
|
685
681
|
return new UniqueNote(dao.note, recipient, dao.contractAddress, dao.storageSlot, dao.txHash, dao.noteNonce);
|
|
686
682
|
});
|
|
687
|
-
return Promise.all(
|
|
688
|
-
}
|
|
689
|
-
|
|
690
|
-
public async getBlock(blockNumber: number): Promise<L2Block | undefined> {
|
|
691
|
-
// If a negative block number is provided the current block number is fetched.
|
|
692
|
-
if (blockNumber < 0) {
|
|
693
|
-
blockNumber = await this.node.getBlockNumber();
|
|
694
|
-
}
|
|
695
|
-
return await this.node.getBlock(blockNumber);
|
|
696
|
-
}
|
|
697
|
-
|
|
698
|
-
public async getCurrentBaseFees(): Promise<GasFees> {
|
|
699
|
-
return await this.node.getCurrentBaseFees();
|
|
683
|
+
return Promise.all(uniqueNotes);
|
|
700
684
|
}
|
|
701
685
|
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
686
|
+
/**
|
|
687
|
+
* Proves the private portion of a simulated transaction, ready to send to the network
|
|
688
|
+
* (where validators prove the public portion).
|
|
689
|
+
*
|
|
690
|
+
* @param txRequest - An authenticated tx request ready for proving
|
|
691
|
+
* @returns A result containing the proof and public inputs of the tail circuit.
|
|
692
|
+
* @throws If contract code not found, or public simulation reverts.
|
|
693
|
+
* Also throws if simulatePublic is true and public simulation reverts.
|
|
694
|
+
*/
|
|
695
|
+
public proveTx(txRequest: TxExecutionRequest): Promise<TxProvingResult> {
|
|
696
|
+
let privateExecutionResult: PrivateExecutionResult;
|
|
706
697
|
// We disable proving concurrently mostly out of caution, since it accesses some of our stores. Proving is so
|
|
707
698
|
// computationally demanding that it'd be rare for someone to try to do it concurrently regardless.
|
|
708
699
|
return this.#putInJobQueue(async () => {
|
|
709
700
|
const totalTimer = new Timer();
|
|
710
701
|
try {
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
contractFunctionSimulator = this.#getSimulatorForTx();
|
|
718
|
-
privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest);
|
|
719
|
-
}
|
|
702
|
+
const syncTimer = new Timer();
|
|
703
|
+
await this.synchronizer.sync();
|
|
704
|
+
const syncTime = syncTimer.ms();
|
|
705
|
+
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
706
|
+
privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest);
|
|
707
|
+
|
|
720
708
|
const {
|
|
721
709
|
publicInputs,
|
|
722
710
|
clientIvcProof,
|
|
@@ -746,16 +734,38 @@ export class PXEService implements PXE {
|
|
|
746
734
|
};
|
|
747
735
|
|
|
748
736
|
this.log.debug(`Proving completed in ${totalTime}ms`, { timings });
|
|
749
|
-
|
|
737
|
+
|
|
738
|
+
const txProvingResult = new TxProvingResult(privateExecutionResult, publicInputs, clientIvcProof!, {
|
|
750
739
|
timings,
|
|
751
740
|
nodeRPCCalls: contractFunctionSimulator?.getStats().nodeRPCCalls,
|
|
752
741
|
});
|
|
742
|
+
|
|
743
|
+
const preTagsUsedInTheTx = privateExecutionResult.entrypoint.preTags;
|
|
744
|
+
if (preTagsUsedInTheTx.length > 0) {
|
|
745
|
+
await this.taggingDataProvider.setLastUsedIndexesAsSender(preTagsUsedInTheTx);
|
|
746
|
+
this.log.debug(`Stored used pre tags as sender for the tx`, {
|
|
747
|
+
preTagsUsedInTheTx,
|
|
748
|
+
});
|
|
749
|
+
} else {
|
|
750
|
+
this.log.debug(`No pre tags used in the tx`);
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
return txProvingResult;
|
|
753
754
|
} catch (err: any) {
|
|
754
755
|
throw this.#contextualizeError(err, inspect(txRequest), inspect(privateExecutionResult));
|
|
755
756
|
}
|
|
756
757
|
});
|
|
757
758
|
}
|
|
758
759
|
|
|
760
|
+
/**
|
|
761
|
+
* Profiles a transaction, reporting gate counts (unless disabled) and returns an execution trace.
|
|
762
|
+
*
|
|
763
|
+
* @param txRequest - An authenticated tx request ready for simulation
|
|
764
|
+
* @param msgSender - (Optional) The message sender to use for the simulation.
|
|
765
|
+
* @param skipTxValidation - (Optional) If false, this function throws if the transaction is unable to be included in a block at the current state.
|
|
766
|
+
* @returns A trace of the program execution with gate counts.
|
|
767
|
+
* @throws If the code for the functions executed in this transaction have not been made available via `addContracts`.
|
|
768
|
+
*/
|
|
759
769
|
public profileTx(
|
|
760
770
|
txRequest: TxExecutionRequest,
|
|
761
771
|
profileMode: 'full' | 'execution-steps' | 'gates',
|
|
@@ -828,7 +838,29 @@ export class PXEService implements PXE {
|
|
|
828
838
|
});
|
|
829
839
|
}
|
|
830
840
|
|
|
831
|
-
|
|
841
|
+
/**
|
|
842
|
+
* Simulates a transaction based on the provided preauthenticated execution request.
|
|
843
|
+
* This will run a local simulation of private execution (and optionally of public as well), run the
|
|
844
|
+
* kernel circuits to ensure adherence to protocol rules (without generating a proof), and return the
|
|
845
|
+
* simulation results .
|
|
846
|
+
*
|
|
847
|
+
*
|
|
848
|
+
* Note that this is used with `ContractFunctionInteraction::simulateTx` to bypass certain checks.
|
|
849
|
+
* In that case, the transaction returned is only potentially ready to be sent to the network for execution.
|
|
850
|
+
*
|
|
851
|
+
*
|
|
852
|
+
* @param txRequest - An authenticated tx request ready for simulation
|
|
853
|
+
* @param simulatePublic - Whether to simulate the public part of the transaction.
|
|
854
|
+
* @param skipTxValidation - (Optional) If false, this function throws if the transaction is unable to be included in a block at the current state.
|
|
855
|
+
* @param skipFeeEnforcement - (Optional) If false, fees are enforced.
|
|
856
|
+
* @param overrides - (Optional) State overrides for the simulation, such as msgSender, contract instances and artifacts.
|
|
857
|
+
* @param scopes - (Optional) The accounts whose notes we can access in this call. Currently optional and will default to all.
|
|
858
|
+
* @returns A simulated transaction result object that includes public and private return values.
|
|
859
|
+
* @throws If the code for the functions executed in this transaction have not been made available via `addContracts`.
|
|
860
|
+
* Also throws if simulatePublic is true and public simulation reverts.
|
|
861
|
+
*
|
|
862
|
+
* TODO(#7456) Prevent msgSender being defined here for the first call
|
|
863
|
+
*/
|
|
832
864
|
public simulateTx(
|
|
833
865
|
txRequest: TxExecutionRequest,
|
|
834
866
|
simulatePublic: boolean,
|
|
@@ -965,19 +997,18 @@ export class PXEService implements PXE {
|
|
|
965
997
|
});
|
|
966
998
|
}
|
|
967
999
|
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
1000
|
+
/**
|
|
1001
|
+
* Simulate the execution of a contract utility function.
|
|
1002
|
+
*
|
|
1003
|
+
* @param functionName - The name of the utility contract function to be called.
|
|
1004
|
+
* @param args - The arguments to be provided to the function.
|
|
1005
|
+
* @param to - The address of the contract to be called.
|
|
1006
|
+
* @param authwits - (Optional) The authentication witnesses required for the function call.
|
|
1007
|
+
* @param from - (Optional) The msg sender to set for the call.
|
|
1008
|
+
* @param scopes - (Optional) The accounts whose notes we can access in this call. Currently optional and will
|
|
1009
|
+
* default to all.
|
|
1010
|
+
* @returns The result of the utility function call, structured based on the function ABI.
|
|
1011
|
+
*/
|
|
981
1012
|
public simulateUtility(
|
|
982
1013
|
functionName: string,
|
|
983
1014
|
args: any[],
|
|
@@ -995,7 +1026,6 @@ export class PXEService implements PXE {
|
|
|
995
1026
|
const syncTimer = new Timer();
|
|
996
1027
|
await this.synchronizer.sync();
|
|
997
1028
|
const syncTime = syncTimer.ms();
|
|
998
|
-
// TODO - Should check if `from` has the permission to call the view function.
|
|
999
1029
|
const functionCall = await this.#getFunctionCall(functionName, args, to);
|
|
1000
1030
|
const functionTimer = new Timer();
|
|
1001
1031
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
@@ -1031,46 +1061,15 @@ export class PXEService implements PXE {
|
|
|
1031
1061
|
});
|
|
1032
1062
|
}
|
|
1033
1063
|
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
this.node.getChainId(),
|
|
1044
|
-
this.node.getEncodedEnr(),
|
|
1045
|
-
this.node.getL1ContractAddresses(),
|
|
1046
|
-
this.node.getProtocolContractAddresses(),
|
|
1047
|
-
]);
|
|
1048
|
-
|
|
1049
|
-
this.#nodeInfo = {
|
|
1050
|
-
nodeVersion,
|
|
1051
|
-
l1ChainId: chainId,
|
|
1052
|
-
rollupVersion,
|
|
1053
|
-
enr,
|
|
1054
|
-
l1ContractAddresses: contractAddresses,
|
|
1055
|
-
protocolContractAddresses: protocolContractAddresses,
|
|
1056
|
-
};
|
|
1057
|
-
}
|
|
1058
|
-
|
|
1059
|
-
return this.#nodeInfo;
|
|
1060
|
-
}
|
|
1061
|
-
|
|
1062
|
-
public getPXEInfo(): Promise<PXEInfo> {
|
|
1063
|
-
return Promise.resolve({
|
|
1064
|
-
pxeVersion: this.packageVersion,
|
|
1065
|
-
protocolContractAddresses: {
|
|
1066
|
-
classRegistry: ProtocolContractAddress.ContractClassRegistry,
|
|
1067
|
-
feeJuice: ProtocolContractAddress.FeeJuice,
|
|
1068
|
-
instanceRegistry: ProtocolContractAddress.ContractInstanceRegistry,
|
|
1069
|
-
multiCallEntrypoint: ProtocolContractAddress.MultiCallEntrypoint,
|
|
1070
|
-
},
|
|
1071
|
-
});
|
|
1072
|
-
}
|
|
1073
|
-
|
|
1064
|
+
/**
|
|
1065
|
+
* Returns the private events given search parameters.
|
|
1066
|
+
* @param contractAddress - The address of the contract to get events from.
|
|
1067
|
+
* @param eventMetadata - Metadata of the event. This should be the class generated from the contract. e.g. Contract.events.Event
|
|
1068
|
+
* @param from - The block number to search from.
|
|
1069
|
+
* @param numBlocks - The amount of blocks to search.
|
|
1070
|
+
* @param recipients - The addresses that decrypted the logs.
|
|
1071
|
+
* @returns - The deserialized events.
|
|
1072
|
+
*/
|
|
1074
1073
|
public async getPrivateEvents<T>(
|
|
1075
1074
|
contractAddress: AztecAddress,
|
|
1076
1075
|
eventMetadataDef: EventMetadataDefinition,
|
|
@@ -1100,39 +1099,9 @@ export class PXEService implements PXE {
|
|
|
1100
1099
|
return decodedEvents;
|
|
1101
1100
|
}
|
|
1102
1101
|
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
toBlock: from + limit,
|
|
1107
|
-
});
|
|
1108
|
-
|
|
1109
|
-
const decodedEvents = logs
|
|
1110
|
-
.map(log => {
|
|
1111
|
-
// +1 for the event selector
|
|
1112
|
-
const expectedLength = eventMetadataDef.fieldNames.length + 1;
|
|
1113
|
-
if (log.log.emittedLength !== expectedLength) {
|
|
1114
|
-
throw new Error(
|
|
1115
|
-
`Something is weird here, we have matching EventSelectors, but the actual payload has mismatched length. Expected ${expectedLength}. Got ${log.log.emittedLength}.`,
|
|
1116
|
-
);
|
|
1117
|
-
}
|
|
1118
|
-
|
|
1119
|
-
const logFields = log.log.getEmittedFields();
|
|
1120
|
-
// 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.
|
|
1121
|
-
if (!EventSelector.fromField(logFields[logFields.length - 1]).equals(eventMetadataDef.eventSelector)) {
|
|
1122
|
-
return undefined;
|
|
1123
|
-
}
|
|
1124
|
-
|
|
1125
|
-
return decodeFromAbi([eventMetadataDef.abiType], log.log.fields) as T;
|
|
1126
|
-
})
|
|
1127
|
-
.filter(log => log !== undefined) as T[];
|
|
1128
|
-
|
|
1129
|
-
return decodedEvents;
|
|
1130
|
-
}
|
|
1131
|
-
|
|
1132
|
-
async resetNoteSyncData() {
|
|
1133
|
-
return await this.taggingDataProvider.resetNoteSyncData();
|
|
1134
|
-
}
|
|
1135
|
-
|
|
1102
|
+
/**
|
|
1103
|
+
* Stops the PXE's job queue.
|
|
1104
|
+
*/
|
|
1136
1105
|
public stop(): Promise<void> {
|
|
1137
1106
|
return this.jobQueue.end();
|
|
1138
1107
|
}
|