@aztec/pxe 3.0.0-canary.a9708bd → 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 -214
- 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 +19 -22
- 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 -257
- 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 -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/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
|
@@ -4,36 +4,34 @@ import { SerialQueue } from '@aztec/foundation/queue';
|
|
|
4
4
|
import { Timer } from '@aztec/foundation/timer';
|
|
5
5
|
import { KeyStore } from '@aztec/key-store';
|
|
6
6
|
import { L2TipsKVStore } from '@aztec/kv-store/stores';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { protocolContractNames } from '@aztec/protocol-contracts';
|
|
8
|
+
import { FunctionSelector, FunctionType, decodeFromAbi, decodeFunctionSignature, encodeArguments } from '@aztec/stdlib/abi';
|
|
9
9
|
import { computeContractAddressFromInstance, getContractClassFromArtifact } from '@aztec/stdlib/contract';
|
|
10
10
|
import { SimulationError } from '@aztec/stdlib/errors';
|
|
11
11
|
import { siloNullifier } from '@aztec/stdlib/hash';
|
|
12
|
-
import { computeL2ToL1MembershipWitness, getNonNullifiedL1ToL2MessageWitness } from '@aztec/stdlib/messaging';
|
|
13
12
|
import { UniqueNote } from '@aztec/stdlib/note';
|
|
14
|
-
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
15
13
|
import { PrivateSimulationResult, TxProfileResult, TxProvingResult, TxSimulationResult } from '@aztec/stdlib/tx';
|
|
16
14
|
import { inspect } from 'util';
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import { PXEOracleInterface } from '../contract_function_simulator/pxe_oracle_interface.js';
|
|
23
|
-
import { PrivateKernelExecutionProver } from '../private_kernel/private_kernel_execution_prover.js';
|
|
24
|
-
import { PrivateKernelOracleImpl } from '../private_kernel/private_kernel_oracle_impl.js';
|
|
25
|
-
import { AddressDataProvider } from '../storage/address_data_provider/address_data_provider.js';
|
|
26
|
-
import { CapsuleDataProvider } from '../storage/capsule_data_provider/capsule_data_provider.js';
|
|
27
|
-
import { ContractDataProvider } from '../storage/contract_data_provider/contract_data_provider.js';
|
|
28
|
-
import { NoteDataProvider } from '../storage/note_data_provider/note_data_provider.js';
|
|
29
|
-
import { PrivateEventDataProvider } from '../storage/private_event_data_provider/private_event_data_provider.js';
|
|
30
|
-
import { SyncDataProvider } from '../storage/sync_data_provider/sync_data_provider.js';
|
|
31
|
-
import { TaggingDataProvider } from '../storage/tagging_data_provider/tagging_data_provider.js';
|
|
32
|
-
import { Synchronizer } from '../synchronizer/index.js';
|
|
15
|
+
import { ContractFunctionSimulator, generateSimulatedProvingResult } from './contract_function_simulator/contract_function_simulator.js';
|
|
16
|
+
import { readCurrentClassId } from './contract_function_simulator/oracle/private_execution.js';
|
|
17
|
+
import { ProxiedContractDataProviderFactory } from './contract_function_simulator/proxied_contract_data_source.js';
|
|
18
|
+
import { ProxiedNodeFactory } from './contract_function_simulator/proxied_node.js';
|
|
19
|
+
import { PXEOracleInterface } from './contract_function_simulator/pxe_oracle_interface.js';
|
|
33
20
|
import { enrichPublicSimulationError, enrichSimulationError } from './error_enriching.js';
|
|
21
|
+
import { PrivateKernelExecutionProver } from './private_kernel/private_kernel_execution_prover.js';
|
|
22
|
+
import { PrivateKernelOracleImpl } from './private_kernel/private_kernel_oracle_impl.js';
|
|
23
|
+
import { AddressDataProvider } from './storage/address_data_provider/address_data_provider.js';
|
|
24
|
+
import { CapsuleDataProvider } from './storage/capsule_data_provider/capsule_data_provider.js';
|
|
25
|
+
import { ContractDataProvider } from './storage/contract_data_provider/contract_data_provider.js';
|
|
26
|
+
import { NoteDataProvider } from './storage/note_data_provider/note_data_provider.js';
|
|
27
|
+
import { PrivateEventDataProvider } from './storage/private_event_data_provider/private_event_data_provider.js';
|
|
28
|
+
import { SyncDataProvider } from './storage/sync_data_provider/sync_data_provider.js';
|
|
29
|
+
import { TaggingDataProvider } from './storage/tagging_data_provider/tagging_data_provider.js';
|
|
30
|
+
import { Synchronizer } from './synchronizer/index.js';
|
|
34
31
|
/**
|
|
35
|
-
*
|
|
36
|
-
|
|
32
|
+
* Private eXecution Environment (PXE) is a library used by wallets to simulate private phase of transactions and to
|
|
33
|
+
* manage private state of users.
|
|
34
|
+
*/ export class PXE {
|
|
37
35
|
node;
|
|
38
36
|
synchronizer;
|
|
39
37
|
keyStore;
|
|
@@ -45,14 +43,12 @@ import { enrichPublicSimulationError, enrichSimulationError } from './error_enri
|
|
|
45
43
|
addressDataProvider;
|
|
46
44
|
privateEventDataProvider;
|
|
47
45
|
simulator;
|
|
48
|
-
packageVersion;
|
|
49
46
|
proverEnabled;
|
|
50
47
|
proofCreator;
|
|
51
48
|
protocolContractsProvider;
|
|
52
49
|
log;
|
|
53
50
|
jobQueue;
|
|
54
|
-
|
|
55
|
-
constructor(node, synchronizer, keyStore, contractDataProvider, noteDataProvider, capsuleDataProvider, syncDataProvider, taggingDataProvider, addressDataProvider, privateEventDataProvider, simulator, packageVersion, proverEnabled, proofCreator, protocolContractsProvider, log, jobQueue){
|
|
51
|
+
constructor(node, synchronizer, keyStore, contractDataProvider, noteDataProvider, capsuleDataProvider, syncDataProvider, taggingDataProvider, addressDataProvider, privateEventDataProvider, simulator, proverEnabled, proofCreator, protocolContractsProvider, log, jobQueue){
|
|
56
52
|
this.node = node;
|
|
57
53
|
this.synchronizer = synchronizer;
|
|
58
54
|
this.keyStore = keyStore;
|
|
@@ -64,7 +60,6 @@ import { enrichPublicSimulationError, enrichSimulationError } from './error_enri
|
|
|
64
60
|
this.addressDataProvider = addressDataProvider;
|
|
65
61
|
this.privateEventDataProvider = privateEventDataProvider;
|
|
66
62
|
this.simulator = simulator;
|
|
67
|
-
this.packageVersion = packageVersion;
|
|
68
63
|
this.proverEnabled = proverEnabled;
|
|
69
64
|
this.proofCreator = proofCreator;
|
|
70
65
|
this.protocolContractsProvider = protocolContractsProvider;
|
|
@@ -72,14 +67,13 @@ import { enrichPublicSimulationError, enrichSimulationError } from './error_enri
|
|
|
72
67
|
this.jobQueue = jobQueue;
|
|
73
68
|
}
|
|
74
69
|
/**
|
|
75
|
-
* Creates an instance of a PXE
|
|
70
|
+
* Creates an instance of a PXE by instantiating all the necessary data providers and services.
|
|
76
71
|
* Also triggers the registration of the protocol contracts and makes sure the provided node
|
|
77
72
|
* can be contacted.
|
|
78
73
|
*
|
|
79
|
-
* @returns A promise that resolves PXE
|
|
74
|
+
* @returns A promise that resolves PXE is ready to be used.
|
|
80
75
|
*/ static async create(node, store, proofCreator, simulator, protocolContractsProvider, config, loggerOrSuffix) {
|
|
81
76
|
const log = !loggerOrSuffix || typeof loggerOrSuffix === 'string' ? createLogger(loggerOrSuffix ? `pxe:service:${loggerOrSuffix}` : `pxe:service`) : loggerOrSuffix;
|
|
82
|
-
const packageVersion = getPackageInfo().version;
|
|
83
77
|
const proverEnabled = !!config.proverEnabled;
|
|
84
78
|
const addressDataProvider = new AddressDataProvider(store);
|
|
85
79
|
const privateEventDataProvider = new PrivateEventDataProvider(store);
|
|
@@ -92,50 +86,12 @@ import { enrichPublicSimulationError, enrichSimulationError } from './error_enri
|
|
|
92
86
|
const tipsStore = new L2TipsKVStore(store, 'pxe');
|
|
93
87
|
const synchronizer = new Synchronizer(node, syncDataProvider, noteDataProvider, taggingDataProvider, tipsStore, config, loggerOrSuffix);
|
|
94
88
|
const jobQueue = new SerialQueue();
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
await
|
|
98
|
-
const info = await
|
|
89
|
+
const pxe = new PXE(node, synchronizer, keyStore, contractDataProvider, noteDataProvider, capsuleDataProvider, syncDataProvider, taggingDataProvider, addressDataProvider, privateEventDataProvider, simulator, proverEnabled, proofCreator, protocolContractsProvider, log, jobQueue);
|
|
90
|
+
pxe.jobQueue.start();
|
|
91
|
+
await pxe.#registerProtocolContracts();
|
|
92
|
+
const info = await node.getNodeInfo();
|
|
99
93
|
log.info(`Started PXE connected to chain ${info.l1ChainId} version ${info.rollupVersion}`);
|
|
100
|
-
return
|
|
101
|
-
}
|
|
102
|
-
// Aztec node proxy methods
|
|
103
|
-
isL1ToL2MessageSynced(l1ToL2Message) {
|
|
104
|
-
return this.node.isL1ToL2MessageSynced(l1ToL2Message);
|
|
105
|
-
}
|
|
106
|
-
async getL2ToL1MembershipWitness(blockNumber, l2Tol1Message) {
|
|
107
|
-
const result = await computeL2ToL1MembershipWitness(this.node, blockNumber, l2Tol1Message);
|
|
108
|
-
if (!result) {
|
|
109
|
-
throw new Error(`L2 to L1 message not found in block ${blockNumber}`);
|
|
110
|
-
}
|
|
111
|
-
return [
|
|
112
|
-
result.leafIndex,
|
|
113
|
-
result.siblingPath
|
|
114
|
-
];
|
|
115
|
-
}
|
|
116
|
-
getTxReceipt(txHash) {
|
|
117
|
-
return this.node.getTxReceipt(txHash);
|
|
118
|
-
}
|
|
119
|
-
getTxEffect(txHash) {
|
|
120
|
-
return this.node.getTxEffect(txHash);
|
|
121
|
-
}
|
|
122
|
-
getBlockNumber() {
|
|
123
|
-
return this.node.getBlockNumber();
|
|
124
|
-
}
|
|
125
|
-
getProvenBlockNumber() {
|
|
126
|
-
return this.node.getProvenBlockNumber();
|
|
127
|
-
}
|
|
128
|
-
getPublicLogs(filter) {
|
|
129
|
-
return this.node.getPublicLogs(filter);
|
|
130
|
-
}
|
|
131
|
-
getContractClassLogs(filter) {
|
|
132
|
-
return this.node.getContractClassLogs(filter);
|
|
133
|
-
}
|
|
134
|
-
getPublicStorageAt(contract, slot) {
|
|
135
|
-
return this.node.getPublicStorageAt('latest', contract, slot);
|
|
136
|
-
}
|
|
137
|
-
async getL1ToL2MembershipWitness(contractAddress, messageHash, secret) {
|
|
138
|
-
return await getNonNullifiedL1ToL2MessageWitness(this.node, contractAddress, messageHash, secret);
|
|
94
|
+
return pxe;
|
|
139
95
|
}
|
|
140
96
|
// Internal methods
|
|
141
97
|
#getSimulatorForTx(overrides) {
|
|
@@ -190,7 +146,7 @@ import { enrichPublicSimulationError, enrichSimulationError } from './error_enri
|
|
|
190
146
|
async #getFunctionCall(functionName, args, to) {
|
|
191
147
|
const contract = await this.contractDataProvider.getContract(to);
|
|
192
148
|
if (!contract) {
|
|
193
|
-
throw new Error(`Unknown contract ${to}: add it to PXE
|
|
149
|
+
throw new Error(`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`);
|
|
194
150
|
}
|
|
195
151
|
const functionDao = contract.functions.find((f)=>f.name === functionName);
|
|
196
152
|
if (!functionDao) {
|
|
@@ -202,6 +158,7 @@ import { enrichPublicSimulationError, enrichSimulationError } from './error_enri
|
|
|
202
158
|
selector: await FunctionSelector.fromNameAndParameters(functionDao.name, functionDao.parameters),
|
|
203
159
|
type: functionDao.functionType,
|
|
204
160
|
to,
|
|
161
|
+
hideMsgSender: false,
|
|
205
162
|
isStatic: functionDao.isStatic,
|
|
206
163
|
returnTypes: functionDao.returnTypes
|
|
207
164
|
};
|
|
@@ -277,32 +234,30 @@ import { enrichPublicSimulationError, enrichSimulationError } from './error_enri
|
|
|
277
234
|
* @param config - The configuration for the kernel execution prover.
|
|
278
235
|
* @returns An object that contains the output of the kernel execution, including the ClientIvcProof if proving is enabled.
|
|
279
236
|
*/ async #prove(txExecutionRequest, proofCreator, privateExecutionResult, config) {
|
|
280
|
-
const
|
|
281
|
-
const kernelOracle = new PrivateKernelOracleImpl(this.contractDataProvider, this.keyStore, this.node,
|
|
237
|
+
const simulationAnchorBlock = privateExecutionResult.getSimulationAnchorBlockNumber();
|
|
238
|
+
const kernelOracle = new PrivateKernelOracleImpl(this.contractDataProvider, this.keyStore, this.node, simulationAnchorBlock);
|
|
282
239
|
const kernelTraceProver = new PrivateKernelExecutionProver(kernelOracle, proofCreator, !this.proverEnabled);
|
|
283
240
|
this.log.debug(`Executing kernel trace prover (${JSON.stringify(config)})...`);
|
|
284
241
|
return await kernelTraceProver.proveWithKernels(txExecutionRequest.toTxRequest(), privateExecutionResult, config);
|
|
285
242
|
}
|
|
286
243
|
// Public API
|
|
287
|
-
/** Returns an estimate of the db size in bytes. */ async estimateDbSize() {
|
|
288
|
-
const treeRootsSize = Object.keys(MerkleTreeId).length * Fr.SIZE_IN_BYTES;
|
|
289
|
-
const dbSizes = await Promise.all([
|
|
290
|
-
this.addressDataProvider.getSize(),
|
|
291
|
-
this.capsuleDataProvider.getSize(),
|
|
292
|
-
this.contractDataProvider.getSize(),
|
|
293
|
-
this.noteDataProvider.getSize(),
|
|
294
|
-
this.syncDataProvider.getSize(),
|
|
295
|
-
this.taggingDataProvider.getSize()
|
|
296
|
-
]);
|
|
297
|
-
return [
|
|
298
|
-
...dbSizes,
|
|
299
|
-
treeRootsSize
|
|
300
|
-
].reduce((sum, size)=>sum + size, 0);
|
|
301
|
-
}
|
|
302
244
|
getContractInstance(address) {
|
|
303
245
|
return this.contractDataProvider.getContractInstance(address);
|
|
304
246
|
}
|
|
305
|
-
|
|
247
|
+
/**
|
|
248
|
+
* Returns the contract class metadata given a contract class id.
|
|
249
|
+
* The metadata consists of its contract class, whether it has been publicly registered, and its artifact.
|
|
250
|
+
* @remark - it queries the node to check whether the contract class with the given id has been publicly registered.
|
|
251
|
+
* @param id - Identifier of the class.
|
|
252
|
+
* @param includeArtifact - Identifier of the class.
|
|
253
|
+
* @returns - It returns the contract class metadata, with the artifact field being optional, and will only be returned if true is passed in
|
|
254
|
+
* for `includeArtifact`
|
|
255
|
+
* TODO(@spalladino): The PXE actually holds artifacts and not classes, what should we return? Also,
|
|
256
|
+
* should the pxe query the node for contract public info, and merge it with its own definitions?
|
|
257
|
+
* TODO(@spalladino): This method is strictly needed to decide whether to publicly register a class or not
|
|
258
|
+
* during a public deployment. We probably want a nicer and more general API for this, but it'll have to
|
|
259
|
+
* do for the time being.
|
|
260
|
+
*/ async getContractClassMetadata(id, includeArtifact = false) {
|
|
306
261
|
const artifact = await this.contractDataProvider.getContractArtifact(id);
|
|
307
262
|
if (!artifact) {
|
|
308
263
|
this.log.warn(`No artifact found for contract class ${id.toString()} when looking for its metadata`);
|
|
@@ -313,7 +268,17 @@ import { enrichPublicSimulationError, enrichSimulationError } from './error_enri
|
|
|
313
268
|
artifact: includeArtifact ? artifact : undefined
|
|
314
269
|
};
|
|
315
270
|
}
|
|
316
|
-
|
|
271
|
+
/**
|
|
272
|
+
* Returns the contract metadata given an address.
|
|
273
|
+
* The metadata consists of its contract instance, which includes the contract class identifier,
|
|
274
|
+
* initialization hash, deployment salt, and public keys hash; whether the contract instance has been initialized;
|
|
275
|
+
* and whether the contract instance with the given address has been publicly deployed.
|
|
276
|
+
* @remark - it queries the node to check whether the contract instance has been initialized / publicly deployed through a node.
|
|
277
|
+
* This query is not dependent on the PXE.
|
|
278
|
+
* @param address - The address that the contract instance resides at.
|
|
279
|
+
* @returns - It returns the contract metadata
|
|
280
|
+
* TODO(@spalladino): Should we return the public keys in plain as well here?
|
|
281
|
+
*/ async getContractMetadata(address) {
|
|
317
282
|
let instance;
|
|
318
283
|
try {
|
|
319
284
|
instance = await this.contractDataProvider.getContractInstance(address);
|
|
@@ -326,7 +291,16 @@ import { enrichPublicSimulationError, enrichSimulationError } from './error_enri
|
|
|
326
291
|
isContractPublished: await this.#isContractPublished(address)
|
|
327
292
|
};
|
|
328
293
|
}
|
|
329
|
-
|
|
294
|
+
/**
|
|
295
|
+
* Registers a user account in PXE given its master encryption private key.
|
|
296
|
+
* Once a new account is registered, the PXE will trial-decrypt all published notes on
|
|
297
|
+
* the chain and store those that correspond to the registered account. Will do nothing if the
|
|
298
|
+
* account is already registered.
|
|
299
|
+
*
|
|
300
|
+
* @param secretKey - Secret key of the corresponding user master public key.
|
|
301
|
+
* @param partialAddress - The partial address of the account contract corresponding to the account being registered.
|
|
302
|
+
* @returns The complete address of the account.
|
|
303
|
+
*/ async registerAccount(secretKey, partialAddress) {
|
|
330
304
|
const accounts = await this.keyStore.getAccounts();
|
|
331
305
|
const accountCompleteAddress = await this.keyStore.addAccount(secretKey, partialAddress);
|
|
332
306
|
if (accounts.includes(accountCompleteAddress.address)) {
|
|
@@ -340,7 +314,15 @@ import { enrichPublicSimulationError, enrichSimulationError } from './error_enri
|
|
|
340
314
|
await this.noteDataProvider.addScope(accountCompleteAddress.address);
|
|
341
315
|
return accountCompleteAddress;
|
|
342
316
|
}
|
|
343
|
-
|
|
317
|
+
/**
|
|
318
|
+
* Registers a user contact in PXE.
|
|
319
|
+
*
|
|
320
|
+
* Once a new contact is registered, the PXE will be able to receive notes tagged from this contact.
|
|
321
|
+
* Will do nothing if the account is already registered.
|
|
322
|
+
*
|
|
323
|
+
* @param address - Address of the user to add to the address book
|
|
324
|
+
* @returns The address address of the account.
|
|
325
|
+
*/ async registerSender(address) {
|
|
344
326
|
const accounts = await this.keyStore.getAccounts();
|
|
345
327
|
if (accounts.includes(address)) {
|
|
346
328
|
this.log.info(`Sender:\n "${address.toString()}"\n already registered.`);
|
|
@@ -354,10 +336,15 @@ import { enrichPublicSimulationError, enrichSimulationError } from './error_enri
|
|
|
354
336
|
}
|
|
355
337
|
return address;
|
|
356
338
|
}
|
|
357
|
-
|
|
339
|
+
/**
|
|
340
|
+
* Retrieves the addresses stored as senders on this PXE.
|
|
341
|
+
* @returns An array of the senders on this PXE.
|
|
342
|
+
*/ getSenders() {
|
|
358
343
|
return this.taggingDataProvider.getSenderAddresses();
|
|
359
344
|
}
|
|
360
|
-
|
|
345
|
+
/**
|
|
346
|
+
* Removes a sender in the address book.
|
|
347
|
+
*/ async removeSender(address) {
|
|
361
348
|
const wasRemoved = await this.taggingDataProvider.removeSenderAddress(address);
|
|
362
349
|
if (wasRemoved) {
|
|
363
350
|
this.log.info(`Removed sender:\n ${address.toString()}`);
|
|
@@ -365,19 +352,33 @@ import { enrichPublicSimulationError, enrichSimulationError } from './error_enri
|
|
|
365
352
|
this.log.info(`Sender:\n "${address.toString()}"\n not in address book.`);
|
|
366
353
|
}
|
|
367
354
|
}
|
|
368
|
-
|
|
355
|
+
/**
|
|
356
|
+
* Retrieves the user accounts registered on this PXE.
|
|
357
|
+
* @returns An array of the accounts registered on this PXE.
|
|
358
|
+
*/ async getRegisteredAccounts() {
|
|
369
359
|
// Get complete addresses of both the recipients and the accounts
|
|
370
360
|
const completeAddresses = await this.addressDataProvider.getCompleteAddresses();
|
|
371
361
|
// Filter out the addresses not corresponding to accounts
|
|
372
362
|
const accounts = await this.keyStore.getAccounts();
|
|
373
363
|
return completeAddresses.filter((completeAddress)=>accounts.find((address)=>address.equals(completeAddress.address)));
|
|
374
364
|
}
|
|
375
|
-
|
|
365
|
+
/**
|
|
366
|
+
* Registers a contract class in the PXE without registering any associated contract instance with it.
|
|
367
|
+
*
|
|
368
|
+
* @param artifact - The build artifact for the contract class.
|
|
369
|
+
*/ async registerContractClass(artifact) {
|
|
376
370
|
const { id: contractClassId } = await getContractClassFromArtifact(artifact);
|
|
377
371
|
await this.contractDataProvider.addContractArtifact(contractClassId, artifact);
|
|
378
372
|
this.log.info(`Added contract class ${artifact.name} with id ${contractClassId}`);
|
|
379
373
|
}
|
|
380
|
-
|
|
374
|
+
/**
|
|
375
|
+
* Adds deployed contracts to the PXE. Deployed contract information is used to access the
|
|
376
|
+
* contract code when simulating local transactions. This is automatically called by aztec.js when
|
|
377
|
+
* deploying a contract. Dapps that wish to interact with contracts already deployed should register
|
|
378
|
+
* these contracts in their users' PXE through this method.
|
|
379
|
+
*
|
|
380
|
+
* @param contract - A contract instance to register, with an optional artifact which can be omitted if the contract class has already been registered.
|
|
381
|
+
*/ async registerContract(contract) {
|
|
381
382
|
const { instance } = contract;
|
|
382
383
|
let { artifact } = contract;
|
|
383
384
|
if (artifact) {
|
|
@@ -404,7 +405,15 @@ import { enrichPublicSimulationError, enrichSimulationError } from './error_enri
|
|
|
404
405
|
await this.contractDataProvider.addContractInstance(instance);
|
|
405
406
|
this.log.info(`Added contract ${artifact.name} at ${instance.address.toString()} with class ${instance.currentContractClassId}`);
|
|
406
407
|
}
|
|
407
|
-
|
|
408
|
+
/**
|
|
409
|
+
* Updates a deployed contract in the PXE. This is used to update the contract artifact when
|
|
410
|
+
* an update has happened, so the new code can be used in the simulation of local transactions.
|
|
411
|
+
* This is called by aztec.js when instantiating a contract in a given address with a mismatching artifact.
|
|
412
|
+
* @param contractAddress - The address of the contract to update.
|
|
413
|
+
* @param artifact - The updated artifact for the contract.
|
|
414
|
+
* @throws If the artifact's contract class is not found in the PXE or if the contract class is different from
|
|
415
|
+
* the current one (current one from the point of view of the node to which the PXE is connected).
|
|
416
|
+
*/ updateContract(contractAddress, artifact) {
|
|
408
417
|
// We disable concurrently updating contracts to avoid concurrently syncing with the node, or changing a contract's
|
|
409
418
|
// class while we're simulating it.
|
|
410
419
|
return this.#putInJobQueue(async ()=>{
|
|
@@ -427,53 +436,58 @@ import { enrichPublicSimulationError, enrichSimulationError } from './error_enri
|
|
|
427
436
|
this.log.info(`Updated contract ${artifact.name} at ${contractAddress.toString()} to class ${contractClass.id}`);
|
|
428
437
|
});
|
|
429
438
|
}
|
|
430
|
-
|
|
439
|
+
/**
|
|
440
|
+
* Retrieves the addresses of contracts added to this PXE.
|
|
441
|
+
* @returns An array of contracts addresses registered on this PXE.
|
|
442
|
+
*/ getContracts() {
|
|
431
443
|
return this.contractDataProvider.getContractsAddresses();
|
|
432
444
|
}
|
|
433
|
-
|
|
434
|
-
|
|
445
|
+
/**
|
|
446
|
+
* A debugging utility to get notes based on the provided filter.
|
|
447
|
+
*
|
|
448
|
+
* Note that this should not be used in production code because the structure of notes is considered to be
|
|
449
|
+
* an implementation detail of contracts. This is only meant to be used for debugging purposes. If you need to obtain
|
|
450
|
+
* note-related information in production code, please implement a custom utility function on your contract and call
|
|
451
|
+
* that function instead (e.g. `get_balance(owner: AztecAddress) -> u128` utility function on a Token contract).
|
|
452
|
+
*
|
|
453
|
+
* @param filter - The filter to apply to the notes.
|
|
454
|
+
* @returns The requested notes.
|
|
455
|
+
*/ async getNotes(filter) {
|
|
456
|
+
// We need to manually trigger private state sync to have a guarantee that all the notes are available.
|
|
435
457
|
await this.simulateUtility('sync_private_state', [], filter.contractAddress);
|
|
436
458
|
const noteDaos = await this.noteDataProvider.getNotes(filter);
|
|
437
|
-
const
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
if (completeAddress === undefined) {
|
|
444
|
-
throw new Error(`Cannot find complete address for recipient ${dao.recipient.toString()}`);
|
|
445
|
-
}
|
|
446
|
-
recipient = completeAddress.address;
|
|
459
|
+
const uniqueNotes = noteDaos.map(async (dao)=>{
|
|
460
|
+
const completeAddresses = await this.addressDataProvider.getCompleteAddresses();
|
|
461
|
+
const completeAddressIndex = completeAddresses.findIndex((completeAddress)=>completeAddress.address.equals(dao.recipient));
|
|
462
|
+
const completeAddress = completeAddresses[completeAddressIndex];
|
|
463
|
+
if (completeAddress === undefined) {
|
|
464
|
+
throw new Error(`Cannot find complete address for recipient ${dao.recipient.toString()}`);
|
|
447
465
|
}
|
|
466
|
+
const recipient = completeAddress.address;
|
|
448
467
|
return new UniqueNote(dao.note, recipient, dao.contractAddress, dao.storageSlot, dao.txHash, dao.noteNonce);
|
|
449
468
|
});
|
|
450
|
-
return Promise.all(
|
|
451
|
-
}
|
|
452
|
-
async getBlock(blockNumber) {
|
|
453
|
-
// If a negative block number is provided the current block number is fetched.
|
|
454
|
-
if (blockNumber < 0) {
|
|
455
|
-
blockNumber = await this.node.getBlockNumber();
|
|
456
|
-
}
|
|
457
|
-
return await this.node.getBlock(blockNumber);
|
|
458
|
-
}
|
|
459
|
-
async getCurrentBaseFees() {
|
|
460
|
-
return await this.node.getCurrentBaseFees();
|
|
469
|
+
return Promise.all(uniqueNotes);
|
|
461
470
|
}
|
|
462
|
-
|
|
471
|
+
/**
|
|
472
|
+
* Proves the private portion of a simulated transaction, ready to send to the network
|
|
473
|
+
* (where validators prove the public portion).
|
|
474
|
+
*
|
|
475
|
+
* @param txRequest - An authenticated tx request ready for proving
|
|
476
|
+
* @returns A result containing the proof and public inputs of the tail circuit.
|
|
477
|
+
* @throws If contract code not found, or public simulation reverts.
|
|
478
|
+
* Also throws if simulatePublic is true and public simulation reverts.
|
|
479
|
+
*/ proveTx(txRequest) {
|
|
480
|
+
let privateExecutionResult;
|
|
463
481
|
// We disable proving concurrently mostly out of caution, since it accesses some of our stores. Proving is so
|
|
464
482
|
// computationally demanding that it'd be rare for someone to try to do it concurrently regardless.
|
|
465
483
|
return this.#putInJobQueue(async ()=>{
|
|
466
484
|
const totalTimer = new Timer();
|
|
467
485
|
try {
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
syncTime = syncTimer.ms();
|
|
474
|
-
contractFunctionSimulator = this.#getSimulatorForTx();
|
|
475
|
-
privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest);
|
|
476
|
-
}
|
|
486
|
+
const syncTimer = new Timer();
|
|
487
|
+
await this.synchronizer.sync();
|
|
488
|
+
const syncTime = syncTimer.ms();
|
|
489
|
+
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
490
|
+
privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest);
|
|
477
491
|
const { publicInputs, clientIvcProof, executionSteps, timings: { proving } = {} } = await this.#prove(txRequest, this.proofCreator, privateExecutionResult, {
|
|
478
492
|
simulate: false,
|
|
479
493
|
skipFeeEnforcement: false,
|
|
@@ -495,16 +509,34 @@ import { enrichPublicSimulationError, enrichSimulationError } from './error_enri
|
|
|
495
509
|
this.log.debug(`Proving completed in ${totalTime}ms`, {
|
|
496
510
|
timings
|
|
497
511
|
});
|
|
498
|
-
|
|
512
|
+
const txProvingResult = new TxProvingResult(privateExecutionResult, publicInputs, clientIvcProof, {
|
|
499
513
|
timings,
|
|
500
514
|
nodeRPCCalls: contractFunctionSimulator?.getStats().nodeRPCCalls
|
|
501
515
|
});
|
|
516
|
+
const preTagsUsedInTheTx = privateExecutionResult.entrypoint.preTags;
|
|
517
|
+
if (preTagsUsedInTheTx.length > 0) {
|
|
518
|
+
await this.taggingDataProvider.setLastUsedIndexesAsSender(preTagsUsedInTheTx);
|
|
519
|
+
this.log.debug(`Stored used pre tags as sender for the tx`, {
|
|
520
|
+
preTagsUsedInTheTx
|
|
521
|
+
});
|
|
522
|
+
} else {
|
|
523
|
+
this.log.debug(`No pre tags used in the tx`);
|
|
524
|
+
}
|
|
525
|
+
return txProvingResult;
|
|
502
526
|
} catch (err) {
|
|
503
527
|
throw this.#contextualizeError(err, inspect(txRequest), inspect(privateExecutionResult));
|
|
504
528
|
}
|
|
505
529
|
});
|
|
506
530
|
}
|
|
507
|
-
|
|
531
|
+
/**
|
|
532
|
+
* Profiles a transaction, reporting gate counts (unless disabled) and returns an execution trace.
|
|
533
|
+
*
|
|
534
|
+
* @param txRequest - An authenticated tx request ready for simulation
|
|
535
|
+
* @param msgSender - (Optional) The message sender to use for the simulation.
|
|
536
|
+
* @param skipTxValidation - (Optional) If false, this function throws if the transaction is unable to be included in a block at the current state.
|
|
537
|
+
* @returns A trace of the program execution with gate counts.
|
|
538
|
+
* @throws If the code for the functions executed in this transaction have not been made available via `addContracts`.
|
|
539
|
+
*/ profileTx(txRequest, profileMode, skipProofGeneration = true) {
|
|
508
540
|
// We disable concurrent profiles for consistency with simulateTx.
|
|
509
541
|
return this.#putInJobQueue(async ()=>{
|
|
510
542
|
const totalTimer = new Timer();
|
|
@@ -556,8 +588,29 @@ import { enrichPublicSimulationError, enrichSimulationError } from './error_enri
|
|
|
556
588
|
}
|
|
557
589
|
});
|
|
558
590
|
}
|
|
559
|
-
|
|
560
|
-
|
|
591
|
+
/**
|
|
592
|
+
* Simulates a transaction based on the provided preauthenticated execution request.
|
|
593
|
+
* This will run a local simulation of private execution (and optionally of public as well), run the
|
|
594
|
+
* kernel circuits to ensure adherence to protocol rules (without generating a proof), and return the
|
|
595
|
+
* simulation results .
|
|
596
|
+
*
|
|
597
|
+
*
|
|
598
|
+
* Note that this is used with `ContractFunctionInteraction::simulateTx` to bypass certain checks.
|
|
599
|
+
* In that case, the transaction returned is only potentially ready to be sent to the network for execution.
|
|
600
|
+
*
|
|
601
|
+
*
|
|
602
|
+
* @param txRequest - An authenticated tx request ready for simulation
|
|
603
|
+
* @param simulatePublic - Whether to simulate the public part of the transaction.
|
|
604
|
+
* @param skipTxValidation - (Optional) If false, this function throws if the transaction is unable to be included in a block at the current state.
|
|
605
|
+
* @param skipFeeEnforcement - (Optional) If false, fees are enforced.
|
|
606
|
+
* @param overrides - (Optional) State overrides for the simulation, such as msgSender, contract instances and artifacts.
|
|
607
|
+
* @param scopes - (Optional) The accounts whose notes we can access in this call. Currently optional and will default to all.
|
|
608
|
+
* @returns A simulated transaction result object that includes public and private return values.
|
|
609
|
+
* @throws If the code for the functions executed in this transaction have not been made available via `addContracts`.
|
|
610
|
+
* Also throws if simulatePublic is true and public simulation reverts.
|
|
611
|
+
*
|
|
612
|
+
* TODO(#7456) Prevent msgSender being defined here for the first call
|
|
613
|
+
*/ simulateTx(txRequest, simulatePublic, skipTxValidation = false, skipFeeEnforcement = false, overrides, scopes) {
|
|
561
614
|
// We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
|
|
562
615
|
// to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
|
|
563
616
|
// delete the same read value, or reading values that another simulation is currently modifying).
|
|
@@ -654,19 +707,18 @@ import { enrichPublicSimulationError, enrichSimulationError } from './error_enri
|
|
|
654
707
|
}
|
|
655
708
|
});
|
|
656
709
|
}
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
simulateUtility(functionName, args, to, authwits, _from, scopes) {
|
|
710
|
+
/**
|
|
711
|
+
* Simulate the execution of a contract utility function.
|
|
712
|
+
*
|
|
713
|
+
* @param functionName - The name of the utility contract function to be called.
|
|
714
|
+
* @param args - The arguments to be provided to the function.
|
|
715
|
+
* @param to - The address of the contract to be called.
|
|
716
|
+
* @param authwits - (Optional) The authentication witnesses required for the function call.
|
|
717
|
+
* @param from - (Optional) The msg sender to set for the call.
|
|
718
|
+
* @param scopes - (Optional) The accounts whose notes we can access in this call. Currently optional and will
|
|
719
|
+
* default to all.
|
|
720
|
+
* @returns The result of the utility function call, structured based on the function ABI.
|
|
721
|
+
*/ simulateUtility(functionName, args, to, authwits, _from, scopes) {
|
|
670
722
|
// We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
|
|
671
723
|
// to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
|
|
672
724
|
// delete the same read value, or reading values that another simulation is currently modifying).
|
|
@@ -676,7 +728,6 @@ import { enrichPublicSimulationError, enrichSimulationError } from './error_enri
|
|
|
676
728
|
const syncTimer = new Timer();
|
|
677
729
|
await this.synchronizer.sync();
|
|
678
730
|
const syncTime = syncTimer.ms();
|
|
679
|
-
// TODO - Should check if `from` has the permission to call the view function.
|
|
680
731
|
const functionCall = await this.#getFunctionCall(functionName, args, to);
|
|
681
732
|
const functionTimer = new Timer();
|
|
682
733
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
@@ -709,42 +760,15 @@ import { enrichPublicSimulationError, enrichSimulationError } from './error_enri
|
|
|
709
760
|
}
|
|
710
761
|
});
|
|
711
762
|
}
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
this.node.getEncodedEnr(),
|
|
722
|
-
this.node.getL1ContractAddresses(),
|
|
723
|
-
this.node.getProtocolContractAddresses()
|
|
724
|
-
]);
|
|
725
|
-
this.#nodeInfo = {
|
|
726
|
-
nodeVersion,
|
|
727
|
-
l1ChainId: chainId,
|
|
728
|
-
rollupVersion,
|
|
729
|
-
enr,
|
|
730
|
-
l1ContractAddresses: contractAddresses,
|
|
731
|
-
protocolContractAddresses: protocolContractAddresses
|
|
732
|
-
};
|
|
733
|
-
}
|
|
734
|
-
return this.#nodeInfo;
|
|
735
|
-
}
|
|
736
|
-
getPXEInfo() {
|
|
737
|
-
return Promise.resolve({
|
|
738
|
-
pxeVersion: this.packageVersion,
|
|
739
|
-
protocolContractAddresses: {
|
|
740
|
-
classRegistry: ProtocolContractAddress.ContractClassRegistry,
|
|
741
|
-
feeJuice: ProtocolContractAddress.FeeJuice,
|
|
742
|
-
instanceRegistry: ProtocolContractAddress.ContractInstanceRegistry,
|
|
743
|
-
multiCallEntrypoint: ProtocolContractAddress.MultiCallEntrypoint
|
|
744
|
-
}
|
|
745
|
-
});
|
|
746
|
-
}
|
|
747
|
-
async getPrivateEvents(contractAddress, eventMetadataDef, from, numBlocks, recipients) {
|
|
763
|
+
/**
|
|
764
|
+
* Returns the private events given search parameters.
|
|
765
|
+
* @param contractAddress - The address of the contract to get events from.
|
|
766
|
+
* @param eventMetadata - Metadata of the event. This should be the class generated from the contract. e.g. Contract.events.Event
|
|
767
|
+
* @param from - The block number to search from.
|
|
768
|
+
* @param numBlocks - The amount of blocks to search.
|
|
769
|
+
* @param recipients - The addresses that decrypted the logs.
|
|
770
|
+
* @returns - The deserialized events.
|
|
771
|
+
*/ async getPrivateEvents(contractAddress, eventMetadataDef, from, numBlocks, recipients) {
|
|
748
772
|
if (recipients.length === 0) {
|
|
749
773
|
throw new Error('Recipients are required to get private events');
|
|
750
774
|
}
|
|
@@ -757,32 +781,9 @@ import { enrichPublicSimulationError, enrichSimulationError } from './error_enri
|
|
|
757
781
|
], event));
|
|
758
782
|
return decodedEvents;
|
|
759
783
|
}
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
toBlock: from + limit
|
|
764
|
-
});
|
|
765
|
-
const decodedEvents = logs.map((log)=>{
|
|
766
|
-
// +1 for the event selector
|
|
767
|
-
const expectedLength = eventMetadataDef.fieldNames.length + 1;
|
|
768
|
-
if (log.log.emittedLength !== expectedLength) {
|
|
769
|
-
throw new Error(`Something is weird here, we have matching EventSelectors, but the actual payload has mismatched length. Expected ${expectedLength}. Got ${log.log.emittedLength}.`);
|
|
770
|
-
}
|
|
771
|
-
const logFields = log.log.getEmittedFields();
|
|
772
|
-
// 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.
|
|
773
|
-
if (!EventSelector.fromField(logFields[logFields.length - 1]).equals(eventMetadataDef.eventSelector)) {
|
|
774
|
-
return undefined;
|
|
775
|
-
}
|
|
776
|
-
return decodeFromAbi([
|
|
777
|
-
eventMetadataDef.abiType
|
|
778
|
-
], log.log.fields);
|
|
779
|
-
}).filter((log)=>log !== undefined);
|
|
780
|
-
return decodedEvents;
|
|
781
|
-
}
|
|
782
|
-
async resetNoteSyncData() {
|
|
783
|
-
return await this.taggingDataProvider.resetNoteSyncData();
|
|
784
|
-
}
|
|
785
|
-
stop() {
|
|
784
|
+
/**
|
|
785
|
+
* Stops the PXE's job queue.
|
|
786
|
+
*/ stop() {
|
|
786
787
|
return this.jobQueue.end();
|
|
787
788
|
}
|
|
788
789
|
}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
2
2
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
3
|
import { CompleteAddress } from '@aztec/stdlib/contract';
|
|
4
|
-
|
|
5
|
-
export declare class AddressDataProvider implements DataProvider {
|
|
4
|
+
export declare class AddressDataProvider {
|
|
6
5
|
#private;
|
|
7
6
|
constructor(store: AztecAsyncKVStore);
|
|
8
7
|
addCompleteAddress(completeAddress: CompleteAddress): Promise<boolean>;
|
|
9
8
|
getCompleteAddress(account: AztecAddress): Promise<CompleteAddress | undefined>;
|
|
10
9
|
getCompleteAddresses(): Promise<CompleteAddress[]>;
|
|
11
|
-
getSize(): Promise<number>;
|
|
12
10
|
}
|
|
13
11
|
//# sourceMappingURL=address_data_provider.d.ts.map
|