@aztec/pxe 0.67.1 → 0.68.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/database/kv_pxe_database.d.ts +3 -3
- package/dest/database/kv_pxe_database.d.ts.map +1 -1
- package/dest/database/kv_pxe_database.js +5 -5
- package/dest/database/pxe_database.d.ts +6 -6
- package/dest/database/pxe_database.d.ts.map +1 -1
- package/dest/kernel_oracle/index.js +2 -2
- package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.js +2 -2
- package/dest/kernel_prover/kernel_prover.d.ts.map +1 -1
- package/dest/kernel_prover/kernel_prover.js +5 -2
- package/dest/kernel_prover/test/test_circuit_prover.d.ts +1 -2
- package/dest/kernel_prover/test/test_circuit_prover.d.ts.map +1 -1
- package/dest/kernel_prover/test/test_circuit_prover.js +4 -10
- package/dest/pxe_service/error_enriching.d.ts.map +1 -1
- package/dest/pxe_service/error_enriching.js +6 -3
- package/dest/pxe_service/pxe_service.d.ts +6 -5
- package/dest/pxe_service/pxe_service.d.ts.map +1 -1
- package/dest/pxe_service/pxe_service.js +33 -24
- package/dest/simulator_oracle/index.d.ts +8 -6
- package/dest/simulator_oracle/index.d.ts.map +1 -1
- package/dest/simulator_oracle/index.js +170 -158
- package/dest/simulator_oracle/tagging_utils.d.ts +16 -0
- package/dest/simulator_oracle/tagging_utils.d.ts.map +1 -0
- package/dest/simulator_oracle/tagging_utils.js +25 -0
- package/dest/utils/create_pxe_service.d.ts.map +1 -1
- package/dest/utils/create_pxe_service.js +8 -5
- package/package.json +17 -17
- package/src/database/kv_pxe_database.ts +6 -4
- package/src/database/pxe_database.ts +6 -6
- package/src/kernel_oracle/index.ts +1 -1
- package/src/kernel_prover/hints/build_private_kernel_reset_private_inputs.ts +1 -1
- package/src/kernel_prover/kernel_prover.ts +11 -1
- package/src/kernel_prover/test/test_circuit_prover.ts +6 -22
- package/src/pxe_service/error_enriching.ts +5 -2
- package/src/pxe_service/pxe_service.ts +44 -35
- package/src/simulator_oracle/index.ts +203 -188
- package/src/simulator_oracle/tagging_utils.ts +31 -0
- package/src/utils/create_pxe_service.ts +7 -4
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BBNativePrivateKernelProver } from '@aztec/bb-prover';
|
|
2
|
+
import { BBWasmPrivateKernelProver } from '@aztec/bb-prover/wasm';
|
|
2
3
|
import { randomBytes } from '@aztec/foundation/crypto';
|
|
3
4
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
5
|
import { KeyStore } from '@aztec/key-store';
|
|
@@ -40,10 +41,12 @@ function createProver(config, logSuffix) {
|
|
|
40
41
|
}
|
|
41
42
|
// (@PhilWindle) Temporary validation until WASM is implemented
|
|
42
43
|
if (!config.bbBinaryPath || !config.bbWorkingDirectory) {
|
|
43
|
-
|
|
44
|
+
return new BBWasmPrivateKernelProver(16);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
const bbConfig = config;
|
|
48
|
+
const log = createLogger('pxe:bb-native-prover' + (logSuffix ? `:${logSuffix}` : ''));
|
|
49
|
+
return BBNativePrivateKernelProver.new({ bbSkipCleanup: false, ...bbConfig }, log);
|
|
44
50
|
}
|
|
45
|
-
const bbConfig = config;
|
|
46
|
-
const log = createLogger('pxe:bb-native-prover' + (logSuffix ? `:${logSuffix}` : ''));
|
|
47
|
-
return BBNativePrivateKernelProver.new({ bbSkipCleanup: false, ...bbConfig }, log);
|
|
48
51
|
}
|
|
49
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
52
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY3JlYXRlX3B4ZV9zZXJ2aWNlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3V0aWxzL2NyZWF0ZV9weGVfc2VydmljZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsMkJBQTJCLEVBQUUsTUF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yxNQUFNLENBQUMsa0JBQWtCLEVBQUUsQ0FBQztRQUN2RCxPQUFPLElBQUkseUJBQXlCLENBQUMsRUFBRSxDQUFDLENBQUM7SUFDM0MsQ0FBQztTQUFNLENBQUM7UUFDTixNQUFNLFFBQVEsR0FBRyxNQUNDLENBQUM7UUFDbkIsTUFBTSxHQUFHLEdBQUcsWUFBWSxDQUFDLHNCQUFzQixHQUFHLENBQUMsU0FBUyxDQUFDLENBQUMsQ0FBQyxJQUFJLFNBQVMsRUFBRSxDQUFDLENBQUMsQ0FBQyxFQUFFLENBQUMsQ0FBQyxDQUFDO1FBQ3RGLE9BQU8sMkJBQTJCLENBQUMsR0FBRyxDQUFDLEVBQUUsYUFBYSxFQUFFLEtBQUssRUFBRSxHQUFHLFFBQVEsRUFBRSxFQUFFLEdBQUcsQ0FBQyxDQUFDO0lBQ3JGLENBQUM7QUFDSCxDQUFDIn0=
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/pxe",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.68.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"clean": "rm -rf ./dest .tsbuildinfo ./src/config/package_info.ts",
|
|
24
24
|
"formatting": "run -T prettier --check ./src && run -T eslint ./src",
|
|
25
25
|
"formatting:fix": "run -T eslint --fix ./src && run -T prettier -w ./src",
|
|
26
|
-
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests",
|
|
26
|
+
"test": "HARDWARE_CONCURRENCY=16 RAYON_NUM_THREADS=4 NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=8",
|
|
27
27
|
"start": "LOG_LEVEL=${LOG_LEVEL:-debug} && node ./dest/bin/index.js",
|
|
28
28
|
"generate": "node ./scripts/generate_package_info.js"
|
|
29
29
|
},
|
|
@@ -59,9 +59,9 @@
|
|
|
59
59
|
],
|
|
60
60
|
"reporters": [
|
|
61
61
|
[
|
|
62
|
-
"
|
|
62
|
+
"jest-silent-reporter",
|
|
63
63
|
{
|
|
64
|
-
"
|
|
64
|
+
"useDots": true
|
|
65
65
|
}
|
|
66
66
|
]
|
|
67
67
|
],
|
|
@@ -71,19 +71,19 @@
|
|
|
71
71
|
]
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
|
-
"@aztec/bb-prover": "0.
|
|
75
|
-
"@aztec/bb.js": "0.
|
|
76
|
-
"@aztec/builder": "0.
|
|
77
|
-
"@aztec/circuit-types": "0.
|
|
78
|
-
"@aztec/circuits.js": "0.
|
|
79
|
-
"@aztec/ethereum": "0.
|
|
80
|
-
"@aztec/foundation": "0.
|
|
81
|
-
"@aztec/key-store": "0.
|
|
82
|
-
"@aztec/kv-store": "0.
|
|
83
|
-
"@aztec/noir-protocol-circuits-types": "0.
|
|
84
|
-
"@aztec/protocol-contracts": "0.
|
|
85
|
-
"@aztec/simulator": "0.
|
|
86
|
-
"@aztec/types": "0.
|
|
74
|
+
"@aztec/bb-prover": "0.68.0",
|
|
75
|
+
"@aztec/bb.js": "0.68.0",
|
|
76
|
+
"@aztec/builder": "0.68.0",
|
|
77
|
+
"@aztec/circuit-types": "0.68.0",
|
|
78
|
+
"@aztec/circuits.js": "0.68.0",
|
|
79
|
+
"@aztec/ethereum": "0.68.0",
|
|
80
|
+
"@aztec/foundation": "0.68.0",
|
|
81
|
+
"@aztec/key-store": "0.68.0",
|
|
82
|
+
"@aztec/kv-store": "0.68.0",
|
|
83
|
+
"@aztec/noir-protocol-circuits-types": "0.68.0",
|
|
84
|
+
"@aztec/protocol-contracts": "0.68.0",
|
|
85
|
+
"@aztec/simulator": "0.68.0",
|
|
86
|
+
"@aztec/types": "0.68.0",
|
|
87
87
|
"@msgpack/msgpack": "^3.0.0-beta2",
|
|
88
88
|
"@noir-lang/noirc_abi": "portal:../../noir/packages/noirc_abi",
|
|
89
89
|
"@noir-lang/types": "workspace:*",
|
|
@@ -538,7 +538,7 @@ export class KVPxeDatabase implements PxeDatabase {
|
|
|
538
538
|
return (await toArray(this.#completeAddresses.valuesAsync())).map(v => CompleteAddress.fromBuffer(v));
|
|
539
539
|
}
|
|
540
540
|
|
|
541
|
-
async
|
|
541
|
+
async addSenderAddress(address: AztecAddress): Promise<boolean> {
|
|
542
542
|
if (await this.#addressBook.hasAsync(address.toString())) {
|
|
543
543
|
return false;
|
|
544
544
|
}
|
|
@@ -548,11 +548,11 @@ export class KVPxeDatabase implements PxeDatabase {
|
|
|
548
548
|
return true;
|
|
549
549
|
}
|
|
550
550
|
|
|
551
|
-
async
|
|
551
|
+
async getSenderAddresses(): Promise<AztecAddress[]> {
|
|
552
552
|
return (await toArray(this.#addressBook.entriesAsync())).map(AztecAddress.fromString);
|
|
553
553
|
}
|
|
554
554
|
|
|
555
|
-
async
|
|
555
|
+
async removeSenderAddress(address: AztecAddress): Promise<boolean> {
|
|
556
556
|
if (!this.#addressBook.hasAsync(address.toString())) {
|
|
557
557
|
return false;
|
|
558
558
|
}
|
|
@@ -585,7 +585,9 @@ export class KVPxeDatabase implements PxeDatabase {
|
|
|
585
585
|
|
|
586
586
|
async #setTaggingSecretsIndexes(indexedSecrets: IndexedTaggingSecret[], storageMap: AztecAsyncMap<string, number>) {
|
|
587
587
|
await Promise.all(
|
|
588
|
-
indexedSecrets.map(indexedSecret =>
|
|
588
|
+
indexedSecrets.map(indexedSecret =>
|
|
589
|
+
storageMap.set(indexedSecret.appTaggingSecret.toString(), indexedSecret.index),
|
|
590
|
+
),
|
|
589
591
|
);
|
|
590
592
|
}
|
|
591
593
|
|
|
@@ -119,24 +119,24 @@ export interface PxeDatabase extends ContractArtifactDatabase, ContractInstanceD
|
|
|
119
119
|
setHeader(header: BlockHeader): Promise<void>;
|
|
120
120
|
|
|
121
121
|
/**
|
|
122
|
-
* Adds
|
|
122
|
+
* Adds sender address to the database.
|
|
123
123
|
* @param address - The address to add to the address book.
|
|
124
124
|
* @returns A promise resolving to true if the address was added, false if it already exists.
|
|
125
125
|
*/
|
|
126
|
-
|
|
126
|
+
addSenderAddress(address: AztecAddress): Promise<boolean>;
|
|
127
127
|
|
|
128
128
|
/**
|
|
129
|
-
* Retrieves the list of
|
|
129
|
+
* Retrieves the list of sender addresses in the address book.
|
|
130
130
|
* @returns An array of Aztec addresses.
|
|
131
131
|
*/
|
|
132
|
-
|
|
132
|
+
getSenderAddresses(): Promise<AztecAddress[]>;
|
|
133
133
|
|
|
134
134
|
/**
|
|
135
|
-
* Removes a
|
|
135
|
+
* Removes a sender address from the database.
|
|
136
136
|
* @param address - The address to remove from the address book.
|
|
137
137
|
* @returns A promise resolving to true if the address was removed, false if it does not exist.
|
|
138
138
|
*/
|
|
139
|
-
|
|
139
|
+
removeSenderAddress(address: AztecAddress): Promise<boolean>;
|
|
140
140
|
|
|
141
141
|
/**
|
|
142
142
|
* Adds complete address to the database.
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
import { createLogger } from '@aztec/foundation/log';
|
|
16
16
|
import { type Tuple } from '@aztec/foundation/serialize';
|
|
17
17
|
import { type KeyStore } from '@aztec/key-store';
|
|
18
|
-
import { getVKIndex, getVKSiblingPath } from '@aztec/noir-protocol-circuits-types';
|
|
18
|
+
import { getVKIndex, getVKSiblingPath } from '@aztec/noir-protocol-circuits-types/client';
|
|
19
19
|
|
|
20
20
|
import { type ContractDataOracle } from '../contract_data_oracle/index.js';
|
|
21
21
|
import { type ProvingDataOracle } from './../kernel_prover/proving_data_oracle.js';
|
|
@@ -37,7 +37,7 @@ import {
|
|
|
37
37
|
import { makeTuple } from '@aztec/foundation/array';
|
|
38
38
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
39
39
|
import { type Tuple, assertLength } from '@aztec/foundation/serialize';
|
|
40
|
-
import { privateKernelResetDimensionsConfig } from '@aztec/noir-protocol-circuits-types';
|
|
40
|
+
import { privateKernelResetDimensionsConfig } from '@aztec/noir-protocol-circuits-types/client';
|
|
41
41
|
|
|
42
42
|
import { type ProvingDataOracle } from '../proving_data_oracle.js';
|
|
43
43
|
|
|
@@ -31,7 +31,8 @@ import { vkAsFieldsMegaHonk } from '@aztec/foundation/crypto';
|
|
|
31
31
|
import { createLogger } from '@aztec/foundation/log';
|
|
32
32
|
import { assertLength } from '@aztec/foundation/serialize';
|
|
33
33
|
import { pushTestData } from '@aztec/foundation/testing';
|
|
34
|
-
import {
|
|
34
|
+
import { Timer } from '@aztec/foundation/timer';
|
|
35
|
+
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/client';
|
|
35
36
|
import {
|
|
36
37
|
getProtocolContractSiblingPath,
|
|
37
38
|
isProtocolContract,
|
|
@@ -118,6 +119,8 @@ export class KernelProver {
|
|
|
118
119
|
profile: boolean = false,
|
|
119
120
|
dryRun: boolean = false,
|
|
120
121
|
): Promise<PrivateKernelSimulateOutput<PrivateKernelTailCircuitPublicInputs>> {
|
|
122
|
+
const timer = new Timer();
|
|
123
|
+
|
|
121
124
|
const isPrivateOnlyTx = this.isPrivateOnly(executionResult);
|
|
122
125
|
|
|
123
126
|
const executionStack = [executionResult];
|
|
@@ -197,7 +200,9 @@ export class KernelProver {
|
|
|
197
200
|
privateCallData,
|
|
198
201
|
isPrivateOnlyTx,
|
|
199
202
|
);
|
|
203
|
+
|
|
200
204
|
pushTestData('private-kernel-inputs-init', proofInput);
|
|
205
|
+
|
|
201
206
|
output = await this.proofCreator.simulateProofInit(proofInput);
|
|
202
207
|
|
|
203
208
|
acirs.push(output.bytecode);
|
|
@@ -214,7 +219,9 @@ export class KernelProver {
|
|
|
214
219
|
assertLength<Fr, typeof VK_TREE_HEIGHT>(previousVkMembershipWitness.siblingPath, VK_TREE_HEIGHT),
|
|
215
220
|
);
|
|
216
221
|
const proofInput = new PrivateKernelInnerCircuitPrivateInputs(previousKernelData, privateCallData);
|
|
222
|
+
|
|
217
223
|
pushTestData('private-kernel-inputs-inner', proofInput);
|
|
224
|
+
|
|
218
225
|
output = await this.proofCreator.simulateProofInner(proofInput);
|
|
219
226
|
|
|
220
227
|
acirs.push(output.bytecode);
|
|
@@ -267,6 +274,7 @@ export class KernelProver {
|
|
|
267
274
|
const privateInputs = new PrivateKernelTailCircuitPrivateInputs(previousKernelData);
|
|
268
275
|
|
|
269
276
|
pushTestData('private-kernel-inputs-ordering', privateInputs);
|
|
277
|
+
|
|
270
278
|
const tailOutput = await this.proofCreator.simulateProofTail(privateInputs);
|
|
271
279
|
if (tailOutput.publicInputs.forPublic) {
|
|
272
280
|
const privateLogs = privateInputs.previousKernel.publicInputs.end.privateLogs;
|
|
@@ -282,6 +290,8 @@ export class KernelProver {
|
|
|
282
290
|
tailOutput.profileResult = { gateCounts };
|
|
283
291
|
}
|
|
284
292
|
|
|
293
|
+
this.log.info(`Witness generation took ${timer.ms()}ms`);
|
|
294
|
+
|
|
285
295
|
// TODO(#7368) how do we 'bincode' encode these inputs?
|
|
286
296
|
if (!dryRun) {
|
|
287
297
|
const ivcProof = await this.proofCreator.createClientIvcProof(acirs, witnessStack);
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type AppCircuitSimulateOutput,
|
|
3
|
-
type PrivateKernelProver,
|
|
4
|
-
type PrivateKernelSimulateOutput,
|
|
5
|
-
} from '@aztec/circuit-types';
|
|
1
|
+
import { type PrivateKernelProver, type PrivateKernelSimulateOutput } from '@aztec/circuit-types';
|
|
6
2
|
import type { CircuitSimulationStats } from '@aztec/circuit-types/stats';
|
|
7
3
|
import {
|
|
8
|
-
CLIENT_IVC_VERIFICATION_KEY_LENGTH_IN_FIELDS,
|
|
9
4
|
ClientIvcProof,
|
|
10
5
|
type PrivateKernelCircuitPublicInputs,
|
|
11
6
|
type PrivateKernelInitCircuitPrivateInputs,
|
|
@@ -13,13 +8,12 @@ import {
|
|
|
13
8
|
type PrivateKernelResetCircuitPrivateInputs,
|
|
14
9
|
type PrivateKernelTailCircuitPrivateInputs,
|
|
15
10
|
type PrivateKernelTailCircuitPublicInputs,
|
|
16
|
-
VerificationKeyAsFields,
|
|
17
11
|
} from '@aztec/circuits.js';
|
|
18
12
|
import { createLogger } from '@aztec/foundation/log';
|
|
19
13
|
import { elapsed } from '@aztec/foundation/timer';
|
|
20
14
|
import {
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
ClientCircuitVks,
|
|
16
|
+
type ClientProtocolArtifact,
|
|
23
17
|
executeInit,
|
|
24
18
|
executeInner,
|
|
25
19
|
executeReset,
|
|
@@ -27,7 +21,7 @@ import {
|
|
|
27
21
|
executeTailForPublic,
|
|
28
22
|
getPrivateKernelResetArtifactName,
|
|
29
23
|
maxPrivateKernelResetDimensions,
|
|
30
|
-
} from '@aztec/noir-protocol-circuits-types';
|
|
24
|
+
} from '@aztec/noir-protocol-circuits-types/client';
|
|
31
25
|
|
|
32
26
|
import { type WitnessMap } from '@noir-lang/types';
|
|
33
27
|
|
|
@@ -114,22 +108,12 @@ export class TestPrivateKernelProver implements PrivateKernelProver {
|
|
|
114
108
|
return Promise.resolve(0);
|
|
115
109
|
}
|
|
116
110
|
|
|
117
|
-
computeAppCircuitVerificationKey(
|
|
118
|
-
_bytecode: Buffer,
|
|
119
|
-
_appCircuitName?: string | undefined,
|
|
120
|
-
): Promise<AppCircuitSimulateOutput> {
|
|
121
|
-
const appCircuitProofOutput: AppCircuitSimulateOutput = {
|
|
122
|
-
verificationKey: VerificationKeyAsFields.makeEmpty(CLIENT_IVC_VERIFICATION_KEY_LENGTH_IN_FIELDS),
|
|
123
|
-
};
|
|
124
|
-
return Promise.resolve(appCircuitProofOutput);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
111
|
private makeEmptyKernelSimulateOutput<
|
|
128
112
|
PublicInputsType extends PrivateKernelTailCircuitPublicInputs | PrivateKernelCircuitPublicInputs,
|
|
129
|
-
>(publicInputs: PublicInputsType, circuitType:
|
|
113
|
+
>(publicInputs: PublicInputsType, circuitType: ClientProtocolArtifact) {
|
|
130
114
|
const kernelProofOutput: PrivateKernelSimulateOutput<PublicInputsType> = {
|
|
131
115
|
publicInputs,
|
|
132
|
-
verificationKey:
|
|
116
|
+
verificationKey: ClientCircuitVks[circuitType].keyAsFields,
|
|
133
117
|
outputWitness: new Map(),
|
|
134
118
|
bytecode: Buffer.from([]),
|
|
135
119
|
};
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { type SimulationError, isNoirCallStackUnresolved } from '@aztec/circuit-types';
|
|
2
|
-
import {
|
|
2
|
+
import { PUBLIC_DISPATCH_SELECTOR } from '@aztec/circuits.js/constants';
|
|
3
|
+
import { FunctionSelector } from '@aztec/foundation/abi';
|
|
4
|
+
import { AztecAddress } from '@aztec/foundation/aztec-address';
|
|
5
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
3
6
|
import { type Logger } from '@aztec/foundation/log';
|
|
4
7
|
import { resolveAssertionMessageFromRevertData, resolveOpcodeLocations } from '@aztec/simulator/errors';
|
|
5
8
|
|
|
@@ -39,7 +42,7 @@ export async function enrichSimulationError(err: SimulationError, db: PxeDatabas
|
|
|
39
42
|
);
|
|
40
43
|
} else {
|
|
41
44
|
logger.warn(
|
|
42
|
-
`Could not function artifact in contract ${contract.name} for function '${fnName}' when enriching error callstack`,
|
|
45
|
+
`Could not find function artifact in contract ${contract.name} for function '${fnName}' when enriching error callstack`,
|
|
43
46
|
);
|
|
44
47
|
}
|
|
45
48
|
});
|
|
@@ -31,38 +31,39 @@ import {
|
|
|
31
31
|
UniqueNote,
|
|
32
32
|
getNonNullifiedL1ToL2MessageWitness,
|
|
33
33
|
} from '@aztec/circuit-types';
|
|
34
|
+
import type {
|
|
35
|
+
CompleteAddress,
|
|
36
|
+
ContractClassWithId,
|
|
37
|
+
ContractInstanceWithAddress,
|
|
38
|
+
GasFees,
|
|
39
|
+
L1_TO_L2_MSG_TREE_HEIGHT,
|
|
40
|
+
NodeInfo,
|
|
41
|
+
PartialAddress,
|
|
42
|
+
PrivateKernelTailCircuitPublicInputs,
|
|
43
|
+
} from '@aztec/circuits.js';
|
|
34
44
|
import {
|
|
35
|
-
type AztecAddress,
|
|
36
|
-
type CompleteAddress,
|
|
37
|
-
type ContractClassWithId,
|
|
38
|
-
type ContractInstanceWithAddress,
|
|
39
|
-
type GasFees,
|
|
40
|
-
type L1_TO_L2_MSG_TREE_HEIGHT,
|
|
41
|
-
type NodeInfo,
|
|
42
|
-
type PartialAddress,
|
|
43
|
-
type PrivateKernelTailCircuitPublicInputs,
|
|
44
|
-
computeAddressSecret,
|
|
45
45
|
computeContractAddressFromInstance,
|
|
46
46
|
computeContractClassId,
|
|
47
47
|
getContractClassFromArtifact,
|
|
48
|
-
} from '@aztec/circuits.js';
|
|
48
|
+
} from '@aztec/circuits.js/contract';
|
|
49
49
|
import { computeNoteHashNonce, siloNullifier } from '@aztec/circuits.js/hash';
|
|
50
|
+
import { computeAddressSecret } from '@aztec/circuits.js/keys';
|
|
50
51
|
import {
|
|
51
52
|
type AbiDecoded,
|
|
52
53
|
type ContractArtifact,
|
|
53
54
|
EventSelector,
|
|
54
55
|
FunctionSelector,
|
|
56
|
+
FunctionType,
|
|
55
57
|
encodeArguments,
|
|
56
58
|
} from '@aztec/foundation/abi';
|
|
59
|
+
import { type AztecAddress } from '@aztec/foundation/aztec-address';
|
|
57
60
|
import { Fr, type Point } from '@aztec/foundation/fields';
|
|
58
61
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
62
|
+
import { Timer } from '@aztec/foundation/timer';
|
|
59
63
|
import { type KeyStore } from '@aztec/key-store';
|
|
60
64
|
import { type L2TipsStore } from '@aztec/kv-store/stores';
|
|
61
|
-
import {
|
|
62
|
-
|
|
63
|
-
getCanonicalProtocolContract,
|
|
64
|
-
protocolContractNames,
|
|
65
|
-
} from '@aztec/protocol-contracts';
|
|
65
|
+
import { ProtocolContractAddress, protocolContractNames } from '@aztec/protocol-contracts';
|
|
66
|
+
import { getCanonicalProtocolContract } from '@aztec/protocol-contracts/bundle';
|
|
66
67
|
import { type AcirSimulator } from '@aztec/simulator/client';
|
|
67
68
|
|
|
68
69
|
import { inspect } from 'util';
|
|
@@ -165,37 +166,37 @@ export class PXEService implements PXE {
|
|
|
165
166
|
return accountCompleteAddress;
|
|
166
167
|
}
|
|
167
168
|
|
|
168
|
-
public async
|
|
169
|
+
public async registerSender(address: AztecAddress): Promise<AztecAddress> {
|
|
169
170
|
const accounts = await this.keyStore.getAccounts();
|
|
170
171
|
if (accounts.includes(address)) {
|
|
171
|
-
this.log.info(`
|
|
172
|
+
this.log.info(`Sender:\n "${address.toString()}"\n already registered.`);
|
|
172
173
|
return address;
|
|
173
174
|
}
|
|
174
175
|
|
|
175
|
-
const wasAdded = await this.db.
|
|
176
|
+
const wasAdded = await this.db.addSenderAddress(address);
|
|
176
177
|
|
|
177
178
|
if (wasAdded) {
|
|
178
|
-
this.log.info(`Added
|
|
179
|
+
this.log.info(`Added sender:\n ${address.toString()}`);
|
|
179
180
|
} else {
|
|
180
|
-
this.log.info(`
|
|
181
|
+
this.log.info(`Sender:\n "${address.toString()}"\n already registered.`);
|
|
181
182
|
}
|
|
182
183
|
|
|
183
184
|
return address;
|
|
184
185
|
}
|
|
185
186
|
|
|
186
|
-
public
|
|
187
|
-
const
|
|
187
|
+
public getSenders(): Promise<AztecAddress[]> {
|
|
188
|
+
const senders = this.db.getSenderAddresses();
|
|
188
189
|
|
|
189
|
-
return Promise.resolve(
|
|
190
|
+
return Promise.resolve(senders);
|
|
190
191
|
}
|
|
191
192
|
|
|
192
|
-
public async
|
|
193
|
-
const wasRemoved = await this.db.
|
|
193
|
+
public async removeSender(address: AztecAddress): Promise<void> {
|
|
194
|
+
const wasRemoved = await this.db.removeSenderAddress(address);
|
|
194
195
|
|
|
195
196
|
if (wasRemoved) {
|
|
196
|
-
this.log.info(`Removed
|
|
197
|
+
this.log.info(`Removed sender:\n ${address.toString()}`);
|
|
197
198
|
} else {
|
|
198
|
-
this.log.info(`
|
|
199
|
+
this.log.info(`Sender:\n "${address.toString()}"\n not in address book.`);
|
|
199
200
|
}
|
|
200
201
|
|
|
201
202
|
return Promise.resolve();
|
|
@@ -242,8 +243,14 @@ export class PXEService implements PXE {
|
|
|
242
243
|
|
|
243
244
|
await this.db.addContractArtifact(contractClassId, artifact);
|
|
244
245
|
|
|
245
|
-
|
|
246
|
-
|
|
246
|
+
const functionNames: Record<string, string> = {};
|
|
247
|
+
for (const fn of artifact.functions) {
|
|
248
|
+
if (fn.functionType === FunctionType.PUBLIC) {
|
|
249
|
+
functionNames[FunctionSelector.fromNameAndParameters(fn.name, fn.parameters).toString()] = fn.name;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
await this.node.registerContractFunctionNames(instance.address, functionNames);
|
|
247
254
|
|
|
248
255
|
// TODO(#10007): Node should get public contract class from the registration event, not from PXE registration
|
|
249
256
|
await this.node.addContractClass({ ...contractClass, privateFunctions: [], unconstrainedFunctions: [] });
|
|
@@ -481,6 +488,7 @@ export class PXEService implements PXE {
|
|
|
481
488
|
simulatePublic: boolean,
|
|
482
489
|
msgSender: AztecAddress | undefined = undefined,
|
|
483
490
|
skipTxValidation: boolean = false,
|
|
491
|
+
enforceFeePayment: boolean = true,
|
|
484
492
|
profile: boolean = false,
|
|
485
493
|
scopes?: AztecAddress[],
|
|
486
494
|
): Promise<TxSimulationResult> {
|
|
@@ -494,10 +502,11 @@ export class PXEService implements PXE {
|
|
|
494
502
|
version: txRequest.txContext.version,
|
|
495
503
|
authWitnesses: txRequest.authWitnesses.map(w => w.requestHash),
|
|
496
504
|
};
|
|
497
|
-
this.log.
|
|
505
|
+
this.log.info(
|
|
498
506
|
`Simulating transaction execution request to ${txRequest.functionSelector} at ${txRequest.origin}`,
|
|
499
507
|
txInfo,
|
|
500
508
|
);
|
|
509
|
+
const timer = new Timer();
|
|
501
510
|
await this.synchronizer.sync();
|
|
502
511
|
const privateExecutionResult = await this.#executePrivate(txRequest, msgSender, scopes);
|
|
503
512
|
|
|
@@ -517,7 +526,7 @@ export class PXEService implements PXE {
|
|
|
517
526
|
const simulatedTx = privateSimulationResult.toSimulatedTx();
|
|
518
527
|
let publicOutput: PublicSimulationOutput | undefined;
|
|
519
528
|
if (simulatePublic) {
|
|
520
|
-
publicOutput = await this.#simulatePublicCalls(simulatedTx);
|
|
529
|
+
publicOutput = await this.#simulatePublicCalls(simulatedTx, enforceFeePayment);
|
|
521
530
|
}
|
|
522
531
|
|
|
523
532
|
if (!skipTxValidation) {
|
|
@@ -526,7 +535,7 @@ export class PXEService implements PXE {
|
|
|
526
535
|
}
|
|
527
536
|
}
|
|
528
537
|
|
|
529
|
-
this.log.info(`Simulation completed for ${simulatedTx.tryGetTxHash()}`, {
|
|
538
|
+
this.log.info(`Simulation completed for ${simulatedTx.tryGetTxHash()} in ${timer.ms()}ms`, {
|
|
530
539
|
txHash: simulatedTx.tryGetTxHash(),
|
|
531
540
|
...txInfo,
|
|
532
541
|
...(profileResult ? { gateCounts: profileResult.gateCounts } : {}),
|
|
@@ -774,11 +783,11 @@ export class PXEService implements PXE {
|
|
|
774
783
|
* It can also be used for estimating gas in the future.
|
|
775
784
|
* @param tx - The transaction to be simulated.
|
|
776
785
|
*/
|
|
777
|
-
async #simulatePublicCalls(tx: Tx) {
|
|
786
|
+
async #simulatePublicCalls(tx: Tx, enforceFeePayment: boolean) {
|
|
778
787
|
// Simulating public calls can throw if the TX fails in a phase that doesn't allow reverts (setup)
|
|
779
788
|
// Or return as reverted if it fails in a phase that allows reverts (app logic, teardown)
|
|
780
789
|
try {
|
|
781
|
-
const result = await this.node.simulatePublicCalls(tx);
|
|
790
|
+
const result = await this.node.simulatePublicCalls(tx, enforceFeePayment);
|
|
782
791
|
if (result.revertReason) {
|
|
783
792
|
throw result.revertReason;
|
|
784
793
|
}
|