@aztec/pxe 4.0.0-devnet.1-patch.1 → 4.0.0-devnet.2-patch.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/access_scopes.d.ts +9 -0
- package/dest/access_scopes.d.ts.map +1 -0
- package/dest/access_scopes.js +6 -0
- package/dest/contract_function_simulator/contract_function_simulator.d.ts +5 -4
- package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
- package/dest/contract_function_simulator/contract_function_simulator.js +7 -11
- package/dest/contract_function_simulator/noir-structs/event_validation_request.js +1 -1
- package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +2 -2
- 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/oracle/interfaces.d.ts +2 -2
- package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.d.ts +2 -2
- package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/oracle.js +2 -2
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +3 -2
- package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/private_execution_oracle.js +10 -2
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +5 -4
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
- package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +12 -7
- package/dest/contract_sync/contract_sync_service.d.ts +4 -2
- package/dest/contract_sync/contract_sync_service.d.ts.map +1 -1
- package/dest/contract_sync/contract_sync_service.js +34 -19
- package/dest/contract_sync/helpers.d.ts +3 -2
- package/dest/contract_sync/helpers.d.ts.map +1 -1
- package/dest/contract_sync/helpers.js +3 -3
- package/dest/debug/pxe_debug_utils.d.ts +5 -4
- package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
- package/dest/debug/pxe_debug_utils.js +1 -1
- 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 -0
- 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 -0
- 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 -0
- package/dest/logs/log_service.d.ts +3 -2
- package/dest/logs/log_service.d.ts.map +1 -1
- package/dest/logs/log_service.js +5 -10
- package/dest/notes/note_service.d.ts +4 -3
- package/dest/notes/note_service.d.ts.map +1 -1
- package/dest/notes/note_service.js +3 -2
- package/dest/notes_filter.d.ts +25 -0
- package/dest/notes_filter.d.ts.map +1 -0
- package/dest/notes_filter.js +4 -0
- package/dest/oracle_version.d.ts +2 -2
- package/dest/oracle_version.js +2 -2
- package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts +4 -0
- package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts.map +1 -0
- package/dest/private_kernel/hints/{compute_tx_include_by_timestamp.js → compute_tx_expiration_timestamp.js} +12 -12
- package/dest/private_kernel/hints/index.d.ts +1 -1
- package/dest/private_kernel/hints/index.js +1 -1
- package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.js +4 -4
- package/dest/private_kernel/private_kernel_execution_prover.js +6 -6
- package/dest/private_kernel/private_kernel_oracle.d.ts +6 -2
- package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
- package/dest/private_kernel/private_kernel_oracle.js +7 -3
- package/dest/pxe.d.ts +11 -7
- package/dest/pxe.d.ts.map +1 -1
- package/dest/pxe.js +23 -20
- package/dest/storage/contract_store/contract_store.d.ts +42 -15
- package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
- package/dest/storage/contract_store/contract_store.js +140 -64
- package/dest/storage/note_store/note_store.d.ts +3 -3
- package/dest/storage/note_store/note_store.d.ts.map +1 -1
- package/dest/storage/note_store/note_store.js +3 -4
- package/dest/tagging/get_all_logs_by_tags.d.ts +1 -1
- package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -1
- package/dest/tagging/get_all_logs_by_tags.js +17 -3
- package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +4 -4
- package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +2 -2
- package/package.json +16 -16
- package/src/access_scopes.ts +9 -0
- package/src/contract_function_simulator/contract_function_simulator.ts +11 -15
- package/src/contract_function_simulator/noir-structs/event_validation_request.ts +1 -1
- package/src/contract_function_simulator/noir-structs/note_validation_request.ts +1 -1
- package/src/contract_function_simulator/oracle/interfaces.ts +1 -1
- package/src/contract_function_simulator/oracle/oracle.ts +2 -2
- package/src/contract_function_simulator/oracle/private_execution_oracle.ts +14 -3
- package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +15 -9
- package/src/contract_sync/contract_sync_service.ts +49 -26
- package/src/contract_sync/helpers.ts +7 -2
- package/src/debug/pxe_debug_utils.ts +8 -6
- package/src/entrypoints/client/bundle/index.ts +2 -0
- package/src/entrypoints/client/lazy/index.ts +2 -0
- package/src/entrypoints/server/index.ts +2 -0
- package/src/logs/log_service.ts +7 -19
- package/src/notes/note_service.ts +4 -3
- package/src/notes_filter.ts +26 -0
- package/src/oracle_version.ts +2 -2
- package/src/private_kernel/hints/{compute_tx_include_by_timestamp.ts → compute_tx_expiration_timestamp.ts} +13 -13
- package/src/private_kernel/hints/index.ts +1 -1
- package/src/private_kernel/hints/private_kernel_reset_private_inputs_builder.ts +7 -7
- package/src/private_kernel/private_kernel_execution_prover.ts +6 -6
- package/src/private_kernel/private_kernel_oracle.ts +7 -7
- package/src/pxe.ts +37 -34
- package/src/storage/contract_store/contract_store.ts +170 -71
- package/src/storage/note_store/note_store.ts +8 -5
- package/src/tagging/get_all_logs_by_tags.ts +28 -4
- package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +4 -4
- package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +2 -2
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +0 -4
- package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MAX_TX_LIFETIME } from '@aztec/constants';
|
|
2
2
|
import type { PrivateKernelCircuitPublicInputs } from '@aztec/stdlib/kernel';
|
|
3
3
|
import type { UInt64 } from '@aztec/stdlib/types';
|
|
4
4
|
|
|
@@ -8,12 +8,12 @@ const ROUNDED_DURATIONS = [
|
|
|
8
8
|
1, // 1 second
|
|
9
9
|
];
|
|
10
10
|
|
|
11
|
-
function roundTimestamp(blockTimestamp: bigint,
|
|
11
|
+
function roundTimestamp(blockTimestamp: bigint, expirationTimestamp: bigint): UInt64 {
|
|
12
12
|
return ROUNDED_DURATIONS.reduce((timestamp, duration) => {
|
|
13
13
|
if (timestamp <= blockTimestamp) {
|
|
14
14
|
// The timestamp must be greater than the block timestamp.
|
|
15
15
|
// If it is too small, round it down again using a smaller duration.
|
|
16
|
-
const totalDuration =
|
|
16
|
+
const totalDuration = expirationTimestamp - blockTimestamp;
|
|
17
17
|
const roundedDuration = totalDuration - (totalDuration % BigInt(duration));
|
|
18
18
|
return blockTimestamp + roundedDuration;
|
|
19
19
|
}
|
|
@@ -21,36 +21,36 @@ function roundTimestamp(blockTimestamp: bigint, includeByTimestamp: bigint): UIn
|
|
|
21
21
|
}, 0n);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
export function
|
|
24
|
+
export function computeTxExpirationTimestamp(
|
|
25
25
|
previousKernel: PrivateKernelCircuitPublicInputs,
|
|
26
|
-
|
|
26
|
+
txLifetime = MAX_TX_LIFETIME,
|
|
27
27
|
): UInt64 {
|
|
28
|
-
if (
|
|
28
|
+
if (txLifetime > MAX_TX_LIFETIME) {
|
|
29
29
|
throw new Error(
|
|
30
|
-
`Custom
|
|
30
|
+
`Custom tx lifetime cannot be greater than the max allowed. Max allowed: ${MAX_TX_LIFETIME}. Custom value: ${txLifetime}.`,
|
|
31
31
|
);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
const anchorBlockTimestamp = previousKernel.constants.anchorBlockHeader.globalVariables.timestamp;
|
|
35
|
-
const maxTimestamp = anchorBlockTimestamp + BigInt(
|
|
36
|
-
const
|
|
35
|
+
const maxTimestamp = anchorBlockTimestamp + BigInt(txLifetime);
|
|
36
|
+
const expirationTimestamp = previousKernel.expirationTimestamp;
|
|
37
37
|
|
|
38
|
-
// If the
|
|
38
|
+
// If the expirationTimestamp set during the tx execution is greater than or equal to the max allowed duration,
|
|
39
39
|
// use the maximum allowed timestamp.
|
|
40
40
|
// Note: It shouldn't be larger than the max allowed duration, but we check for it anyway.
|
|
41
|
-
if (
|
|
41
|
+
if (expirationTimestamp >= maxTimestamp) {
|
|
42
42
|
return maxTimestamp;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
// Round it down to the nearest hour/min/second to reduce precision and avoid revealing the exact value.
|
|
46
46
|
// This makes it harder for others to infer what function calls may have been used to produce a specific timestamp.
|
|
47
|
-
const roundedTimestamp = roundTimestamp(anchorBlockTimestamp,
|
|
47
|
+
const roundedTimestamp = roundTimestamp(anchorBlockTimestamp, expirationTimestamp);
|
|
48
48
|
|
|
49
49
|
// The tx can't be published if the timestamp is the same or less than the anchor block's timestamp.
|
|
50
50
|
// Future blocks will have a greater timestamp, so the tx would never be included.
|
|
51
51
|
if (roundedTimestamp <= anchorBlockTimestamp) {
|
|
52
52
|
throw new Error(
|
|
53
|
-
`Include-by timestamp must be greater than the anchor block timestamp. Anchor block timestamp: ${anchorBlockTimestamp}. Include-by timestamp: ${
|
|
53
|
+
`Include-by timestamp must be greater than the anchor block timestamp. Anchor block timestamp: ${anchorBlockTimestamp}. Include-by timestamp: ${expirationTimestamp}.`,
|
|
54
54
|
);
|
|
55
55
|
}
|
|
56
56
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from './private_kernel_reset_private_inputs_builder.js';
|
|
2
|
-
export * from './
|
|
2
|
+
export * from './compute_tx_expiration_timestamp.js';
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
type PrivateKernelSimulateOutput,
|
|
27
27
|
ReadRequestActionEnum,
|
|
28
28
|
ReadRequestResetActions,
|
|
29
|
-
type
|
|
29
|
+
type ScopedKeyValidationRequestAndSeparator,
|
|
30
30
|
ScopedNoteHash,
|
|
31
31
|
ScopedNullifier,
|
|
32
32
|
ScopedReadRequest,
|
|
@@ -68,9 +68,9 @@ function getNullifierMembershipWitnessResolver(oracle: PrivateKernelOracle) {
|
|
|
68
68
|
};
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
async function
|
|
71
|
+
async function getMasterSecretKeysAndKeyTypeDomainSeparators(
|
|
72
72
|
keyValidationRequests: ClaimedLengthArray<
|
|
73
|
-
|
|
73
|
+
ScopedKeyValidationRequestAndSeparator,
|
|
74
74
|
typeof MAX_KEY_VALIDATION_REQUESTS_PER_TX
|
|
75
75
|
>,
|
|
76
76
|
numRequestsToVerify: number,
|
|
@@ -189,8 +189,8 @@ export class PrivateKernelResetPrivateInputsBuilder {
|
|
|
189
189
|
this.previousKernel.validationRequests.nullifierReadRequests,
|
|
190
190
|
this.nullifierResetActions,
|
|
191
191
|
),
|
|
192
|
-
|
|
193
|
-
this.previousKernel.validationRequests.
|
|
192
|
+
getMasterSecretKeysAndKeyTypeDomainSeparators(
|
|
193
|
+
this.previousKernel.validationRequests.scopedKeyValidationRequestsAndSeparators,
|
|
194
194
|
dimensions.KEY_VALIDATION,
|
|
195
195
|
oracle,
|
|
196
196
|
),
|
|
@@ -357,8 +357,8 @@ export class PrivateKernelResetPrivateInputsBuilder {
|
|
|
357
357
|
}
|
|
358
358
|
|
|
359
359
|
private needsResetNullifierKeys() {
|
|
360
|
-
const numCurr = this.previousKernel.validationRequests.
|
|
361
|
-
const numNext = this.nextIteration ? this.nextIteration.
|
|
360
|
+
const numCurr = this.previousKernel.validationRequests.scopedKeyValidationRequestsAndSeparators.claimedLength;
|
|
361
|
+
const numNext = this.nextIteration ? this.nextIteration.keyValidationRequestsAndSeparators.claimedLength : 0;
|
|
362
362
|
const maxAmountToKeep = !this.nextIteration ? 0 : MAX_KEY_VALIDATION_REQUESTS_PER_TX;
|
|
363
363
|
if (numCurr + numNext <= maxAmountToKeep) {
|
|
364
364
|
return false;
|
|
@@ -260,20 +260,20 @@ export class PrivateKernelExecutionProver {
|
|
|
260
260
|
// TODO: Enable padding once we better understand the final amounts to pad to.
|
|
261
261
|
const paddedSideEffectAmounts = PaddedSideEffectAmounts.empty();
|
|
262
262
|
|
|
263
|
-
// Use the aggregated
|
|
264
|
-
// TODO: Call `
|
|
265
|
-
const
|
|
263
|
+
// Use the aggregated expirationTimestamp set throughout the tx execution.
|
|
264
|
+
// TODO: Call `computeTxExpirationTimestamp` to round the value down and reduce precision, improving privacy.
|
|
265
|
+
const expirationTimestampUpperBound = previousKernelData.publicInputs.expirationTimestamp;
|
|
266
266
|
const anchorBlockTimestamp = previousKernelData.publicInputs.constants.anchorBlockHeader.globalVariables.timestamp;
|
|
267
|
-
if (
|
|
267
|
+
if (expirationTimestampUpperBound <= anchorBlockTimestamp) {
|
|
268
268
|
throw new Error(
|
|
269
|
-
`Include-by timestamp must be greater than the anchor block timestamp. Anchor block timestamp: ${anchorBlockTimestamp}. Include-by timestamp: ${
|
|
269
|
+
`Include-by timestamp must be greater than the anchor block timestamp. Anchor block timestamp: ${anchorBlockTimestamp}. Include-by timestamp: ${expirationTimestampUpperBound}.`,
|
|
270
270
|
);
|
|
271
271
|
}
|
|
272
272
|
|
|
273
273
|
const privateInputs = new PrivateKernelTailCircuitPrivateInputs(
|
|
274
274
|
previousKernelData,
|
|
275
275
|
paddedSideEffectAmounts,
|
|
276
|
-
|
|
276
|
+
expirationTimestampUpperBound,
|
|
277
277
|
);
|
|
278
278
|
|
|
279
279
|
const witgenTimer = new Timer();
|
|
@@ -8,11 +8,7 @@ import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
|
8
8
|
import type { FunctionSelector } from '@aztec/stdlib/abi';
|
|
9
9
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
10
10
|
import { BlockHash } from '@aztec/stdlib/block';
|
|
11
|
-
import {
|
|
12
|
-
type ContractInstanceWithAddress,
|
|
13
|
-
computeContractClassIdPreimage,
|
|
14
|
-
computeSaltedInitializationHash,
|
|
15
|
-
} from '@aztec/stdlib/contract';
|
|
11
|
+
import { type ContractInstanceWithAddress, computeSaltedInitializationHash } from '@aztec/stdlib/contract';
|
|
16
12
|
import { DelayedPublicMutableValues, DelayedPublicMutableValuesWithHash } from '@aztec/stdlib/delayed-public-mutable';
|
|
17
13
|
import { computePublicDataTreeLeafSlot } from '@aztec/stdlib/hash';
|
|
18
14
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
@@ -49,11 +45,15 @@ export class PrivateKernelOracle {
|
|
|
49
45
|
|
|
50
46
|
/** Retrieves the preimage of a contract class id from the contract classes db. */
|
|
51
47
|
public async getContractClassIdPreimage(contractClassId: Fr) {
|
|
52
|
-
const contractClass = await this.contractStore.
|
|
48
|
+
const contractClass = await this.contractStore.getContractClassWithPreimage(contractClassId);
|
|
53
49
|
if (!contractClass) {
|
|
54
50
|
throw new Error(`Contract class not found when getting class id preimage. Class id: ${contractClassId}.`);
|
|
55
51
|
}
|
|
56
|
-
return
|
|
52
|
+
return {
|
|
53
|
+
artifactHash: contractClass.artifactHash,
|
|
54
|
+
privateFunctionsRoot: contractClass.privateFunctionsRoot,
|
|
55
|
+
publicBytecodeCommitment: contractClass.publicBytecodeCommitment,
|
|
56
|
+
};
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
/** Returns a membership witness with the sibling path and leaf index in our private functions tree. */
|
package/src/pxe.ts
CHANGED
|
@@ -52,6 +52,7 @@ import {
|
|
|
52
52
|
|
|
53
53
|
import { inspect } from 'util';
|
|
54
54
|
|
|
55
|
+
import type { AccessScopes } from './access_scopes.js';
|
|
55
56
|
import { BlockSynchronizer } from './block_synchronizer/index.js';
|
|
56
57
|
import type { PXEConfig } from './config/index.js';
|
|
57
58
|
import { BenchmarkedNodeFactory } from './contract_function_simulator/benchmarked_node.js';
|
|
@@ -92,6 +93,8 @@ export type ProfileTxOpts = {
|
|
|
92
93
|
profileMode: 'full' | 'execution-steps' | 'gates';
|
|
93
94
|
/** If true, proof generation is skipped during profiling. Defaults to true. */
|
|
94
95
|
skipProofGeneration?: boolean;
|
|
96
|
+
/** Addresses whose private state and keys are accessible during private execution. */
|
|
97
|
+
scopes: AccessScopes;
|
|
95
98
|
};
|
|
96
99
|
|
|
97
100
|
/** Options for PXE.simulateTx. */
|
|
@@ -104,16 +107,16 @@ export type SimulateTxOpts = {
|
|
|
104
107
|
skipFeeEnforcement?: boolean;
|
|
105
108
|
/** State overrides for the simulation, such as contract instances and artifacts. */
|
|
106
109
|
overrides?: SimulationOverrides;
|
|
107
|
-
/**
|
|
108
|
-
scopes
|
|
110
|
+
/** Addresses whose private state and keys are accessible during private execution */
|
|
111
|
+
scopes: AccessScopes;
|
|
109
112
|
};
|
|
110
113
|
|
|
111
114
|
/** Options for PXE.simulateUtility. */
|
|
112
115
|
export type SimulateUtilityOpts = {
|
|
113
116
|
/** The authentication witnesses required for the function call. */
|
|
114
117
|
authwits?: AuthWitness[];
|
|
115
|
-
/** The accounts whose notes we can access in this call
|
|
116
|
-
scopes
|
|
118
|
+
/** The accounts whose notes we can access in this call */
|
|
119
|
+
scopes: AccessScopes;
|
|
117
120
|
};
|
|
118
121
|
|
|
119
122
|
/** Args for PXE.create. */
|
|
@@ -341,9 +344,8 @@ export class PXE {
|
|
|
341
344
|
async #registerProtocolContracts() {
|
|
342
345
|
const registered: Record<string, string> = {};
|
|
343
346
|
for (const name of protocolContractNames) {
|
|
344
|
-
const { address,
|
|
345
|
-
|
|
346
|
-
await this.contractStore.addContractArtifact(contractClass.id, artifact);
|
|
347
|
+
const { address, instance, artifact } = await this.protocolContractsProvider.getProtocolContractArtifact(name);
|
|
348
|
+
await this.contractStore.addContractArtifact(artifact);
|
|
347
349
|
await this.contractStore.addContractInstance(instance);
|
|
348
350
|
registered[name] = address.toString();
|
|
349
351
|
}
|
|
@@ -355,7 +357,7 @@ export class PXE {
|
|
|
355
357
|
async #executePrivate(
|
|
356
358
|
contractFunctionSimulator: ContractFunctionSimulator,
|
|
357
359
|
txRequest: TxExecutionRequest,
|
|
358
|
-
scopes:
|
|
360
|
+
scopes: AccessScopes,
|
|
359
361
|
jobId: string,
|
|
360
362
|
): Promise<PrivateExecutionResult> {
|
|
361
363
|
const { origin: contractAddress, functionSelector } = txRequest;
|
|
@@ -366,9 +368,11 @@ export class PXE {
|
|
|
366
368
|
await this.contractSyncService.ensureContractSynced(
|
|
367
369
|
contractAddress,
|
|
368
370
|
functionSelector,
|
|
369
|
-
|
|
371
|
+
(privateSyncCall, execScopes) =>
|
|
372
|
+
this.#simulateUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId),
|
|
370
373
|
anchorBlockHeader,
|
|
371
374
|
jobId,
|
|
375
|
+
scopes,
|
|
372
376
|
);
|
|
373
377
|
|
|
374
378
|
const result = await contractFunctionSimulator.run(txRequest, {
|
|
@@ -402,7 +406,7 @@ export class PXE {
|
|
|
402
406
|
contractFunctionSimulator: ContractFunctionSimulator,
|
|
403
407
|
call: FunctionCall,
|
|
404
408
|
authWitnesses: AuthWitness[] | undefined,
|
|
405
|
-
scopes:
|
|
409
|
+
scopes: AccessScopes,
|
|
406
410
|
jobId: string,
|
|
407
411
|
) {
|
|
408
412
|
try {
|
|
@@ -596,8 +600,7 @@ export class PXE {
|
|
|
596
600
|
* @param artifact - The build artifact for the contract class.
|
|
597
601
|
*/
|
|
598
602
|
public async registerContractClass(artifact: ContractArtifact): Promise<void> {
|
|
599
|
-
const
|
|
600
|
-
await this.contractStore.addContractArtifact(contractClassId, artifact);
|
|
603
|
+
const contractClassId = await this.contractStore.addContractArtifact(artifact);
|
|
601
604
|
this.log.info(`Added contract class ${artifact.name} with id ${contractClassId}`);
|
|
602
605
|
}
|
|
603
606
|
|
|
@@ -616,17 +619,17 @@ export class PXE {
|
|
|
616
619
|
if (artifact) {
|
|
617
620
|
// If the user provides an artifact, validate it against the expected class id and register it
|
|
618
621
|
const contractClass = await getContractClassFromArtifact(artifact);
|
|
619
|
-
|
|
620
|
-
if (!contractClassId.equals(instance.currentContractClassId)) {
|
|
622
|
+
if (!contractClass.id.equals(instance.currentContractClassId)) {
|
|
621
623
|
throw new Error(
|
|
622
|
-
`Artifact does not match expected class id (computed ${
|
|
624
|
+
`Artifact does not match expected class id (computed ${contractClass.id} but instance refers to ${instance.currentContractClassId})`,
|
|
623
625
|
);
|
|
624
626
|
}
|
|
625
627
|
const computedAddress = await computeContractAddressFromInstance(instance);
|
|
626
628
|
if (!computedAddress.equals(instance.address)) {
|
|
627
629
|
throw new Error('Added a contract in which the address does not match the contract instance.');
|
|
628
630
|
}
|
|
629
|
-
|
|
631
|
+
|
|
632
|
+
await this.contractStore.addContractArtifact(artifact, contractClass);
|
|
630
633
|
|
|
631
634
|
const publicFunctionSignatures = artifact.functions
|
|
632
635
|
.filter(fn => fn.functionType === FunctionType.PUBLIC)
|
|
@@ -675,15 +678,16 @@ export class PXE {
|
|
|
675
678
|
throw new Error('Could not update contract to a class different from the current one.');
|
|
676
679
|
}
|
|
677
680
|
|
|
678
|
-
await this.contractStore.addContractArtifact(contractClass.id, artifact);
|
|
679
|
-
|
|
680
681
|
const publicFunctionSignatures = artifact.functions
|
|
681
682
|
.filter(fn => fn.functionType === FunctionType.PUBLIC)
|
|
682
683
|
.map(fn => decodeFunctionSignature(fn.name, fn.parameters));
|
|
683
684
|
await this.node.registerContractFunctionSignatures(publicFunctionSignatures);
|
|
684
685
|
|
|
685
686
|
currentInstance.currentContractClassId = contractClass.id;
|
|
686
|
-
await
|
|
687
|
+
await Promise.all([
|
|
688
|
+
this.contractStore.addContractArtifact(artifact, contractClass),
|
|
689
|
+
this.contractStore.addContractInstance(currentInstance),
|
|
690
|
+
]);
|
|
687
691
|
this.log.info(`Updated contract ${artifact.name} at ${contractAddress.toString()} to class ${contractClass.id}`);
|
|
688
692
|
});
|
|
689
693
|
}
|
|
@@ -701,11 +705,12 @@ export class PXE {
|
|
|
701
705
|
* (where validators prove the public portion).
|
|
702
706
|
*
|
|
703
707
|
* @param txRequest - An authenticated tx request ready for proving
|
|
708
|
+
* @param scopes - Addresses whose private state and keys are accessible during private execution.
|
|
704
709
|
* @returns A result containing the proof and public inputs of the tail circuit.
|
|
705
710
|
* @throws If contract code not found, or public simulation reverts.
|
|
706
711
|
* Also throws if simulatePublic is true and public simulation reverts.
|
|
707
712
|
*/
|
|
708
|
-
public proveTx(txRequest: TxExecutionRequest): Promise<TxProvingResult> {
|
|
713
|
+
public proveTx(txRequest: TxExecutionRequest, scopes: AztecAddress[]): Promise<TxProvingResult> {
|
|
709
714
|
let privateExecutionResult: PrivateExecutionResult;
|
|
710
715
|
// We disable proving concurrently mostly out of caution, since it accesses some of our stores. Proving is so
|
|
711
716
|
// computationally demanding that it'd be rare for someone to try to do it concurrently regardless.
|
|
@@ -716,7 +721,7 @@ export class PXE {
|
|
|
716
721
|
await this.blockStateSynchronizer.sync();
|
|
717
722
|
const syncTime = syncTimer.ms();
|
|
718
723
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
719
|
-
privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest,
|
|
724
|
+
privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest, scopes, jobId);
|
|
720
725
|
|
|
721
726
|
const {
|
|
722
727
|
publicInputs,
|
|
@@ -786,7 +791,7 @@ export class PXE {
|
|
|
786
791
|
*/
|
|
787
792
|
public profileTx(
|
|
788
793
|
txRequest: TxExecutionRequest,
|
|
789
|
-
{ profileMode, skipProofGeneration = true }: ProfileTxOpts,
|
|
794
|
+
{ profileMode, skipProofGeneration = true, scopes }: ProfileTxOpts,
|
|
790
795
|
): Promise<TxProfileResult> {
|
|
791
796
|
// We disable concurrent profiles for consistency with simulateTx.
|
|
792
797
|
return this.#putInJobQueue(async jobId => {
|
|
@@ -809,12 +814,7 @@ export class PXE {
|
|
|
809
814
|
const syncTime = syncTimer.ms();
|
|
810
815
|
|
|
811
816
|
const contractFunctionSimulator = this.#getSimulatorForTx();
|
|
812
|
-
const privateExecutionResult = await this.#executePrivate(
|
|
813
|
-
contractFunctionSimulator,
|
|
814
|
-
txRequest,
|
|
815
|
-
undefined,
|
|
816
|
-
jobId,
|
|
817
|
-
);
|
|
817
|
+
const privateExecutionResult = await this.#executePrivate(contractFunctionSimulator, txRequest, scopes, jobId);
|
|
818
818
|
|
|
819
819
|
const { executionSteps, timings: { proving } = {} } = await this.#prove(
|
|
820
820
|
txRequest,
|
|
@@ -1005,7 +1005,7 @@ export class PXE {
|
|
|
1005
1005
|
inspect(txRequest),
|
|
1006
1006
|
`simulatePublic=${simulatePublic}`,
|
|
1007
1007
|
`skipTxValidation=${skipTxValidation}`,
|
|
1008
|
-
`scopes=${scopes
|
|
1008
|
+
`scopes=${scopes === 'ALL_SCOPES' ? scopes : scopes.map(s => s.toString()).join(', ')}`,
|
|
1009
1009
|
);
|
|
1010
1010
|
}
|
|
1011
1011
|
});
|
|
@@ -1017,7 +1017,7 @@ export class PXE {
|
|
|
1017
1017
|
*/
|
|
1018
1018
|
public simulateUtility(
|
|
1019
1019
|
call: FunctionCall,
|
|
1020
|
-
{ authwits, scopes }: SimulateUtilityOpts = {},
|
|
1020
|
+
{ authwits, scopes }: SimulateUtilityOpts = { scopes: 'ALL_SCOPES' },
|
|
1021
1021
|
): Promise<UtilitySimulationResult> {
|
|
1022
1022
|
// We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
|
|
1023
1023
|
// to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
|
|
@@ -1035,9 +1035,11 @@ export class PXE {
|
|
|
1035
1035
|
await this.contractSyncService.ensureContractSynced(
|
|
1036
1036
|
call.to,
|
|
1037
1037
|
call.selector,
|
|
1038
|
-
|
|
1038
|
+
(privateSyncCall, execScopes) =>
|
|
1039
|
+
this.#simulateUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId),
|
|
1039
1040
|
anchorBlockHeader,
|
|
1040
1041
|
jobId,
|
|
1042
|
+
scopes,
|
|
1041
1043
|
);
|
|
1042
1044
|
|
|
1043
1045
|
const executionResult = await this.#simulateUtility(
|
|
@@ -1068,7 +1070,7 @@ export class PXE {
|
|
|
1068
1070
|
throw this.#contextualizeError(
|
|
1069
1071
|
err,
|
|
1070
1072
|
`simulateUtility ${to}:${name}(${stringifiedArgs})`,
|
|
1071
|
-
`scopes=${scopes
|
|
1073
|
+
`scopes=${scopes === 'ALL_SCOPES' ? scopes : scopes.map(s => s.toString()).join(', ')}`,
|
|
1072
1074
|
);
|
|
1073
1075
|
}
|
|
1074
1076
|
});
|
|
@@ -1104,10 +1106,11 @@ export class PXE {
|
|
|
1104
1106
|
await this.contractSyncService.ensureContractSynced(
|
|
1105
1107
|
filter.contractAddress,
|
|
1106
1108
|
null,
|
|
1107
|
-
async privateSyncCall =>
|
|
1108
|
-
await this.#simulateUtility(contractFunctionSimulator, privateSyncCall, [],
|
|
1109
|
+
async (privateSyncCall, execScopes) =>
|
|
1110
|
+
await this.#simulateUtility(contractFunctionSimulator, privateSyncCall, [], execScopes, jobId),
|
|
1109
1111
|
anchorBlockHeader,
|
|
1110
1112
|
jobId,
|
|
1113
|
+
filter.scopes,
|
|
1111
1114
|
);
|
|
1112
1115
|
});
|
|
1113
1116
|
|