@aztec/stdlib 0.81.0 → 0.82.1-alpha-testnet.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/abi/abi.d.ts +5 -1
- package/dest/abi/abi.d.ts.map +1 -1
- package/dest/abi/abi.js +2 -1
- package/dest/auth_witness/auth_witness.d.ts +21 -0
- package/dest/auth_witness/auth_witness.d.ts.map +1 -1
- package/dest/auth_witness/auth_witness.js +29 -0
- package/dest/avm/avm.d.ts +24 -48
- package/dest/avm/avm.d.ts.map +1 -1
- package/dest/avm/avm_circuit_public_inputs.d.ts +18 -36
- package/dest/avm/avm_circuit_public_inputs.d.ts.map +1 -1
- package/dest/avm/avm_proving_request.d.ts +27 -54
- package/dest/avm/avm_proving_request.d.ts.map +1 -1
- package/dest/block/index.d.ts +0 -1
- package/dest/block/index.d.ts.map +1 -1
- package/dest/block/index.js +0 -1
- package/dest/block/l2_block_downloader/l2_block_stream.d.ts.map +1 -1
- package/dest/block/l2_block_downloader/l2_block_stream.js +0 -2
- package/dest/block/l2_block_source.d.ts +6 -0
- package/dest/block/l2_block_source.d.ts.map +1 -1
- package/dest/contract/contract_class.d.ts.map +1 -1
- package/dest/contract/contract_class.js +3 -21
- package/dest/contract/interfaces/contract_class.d.ts +1 -143
- package/dest/contract/interfaces/contract_class.d.ts.map +1 -1
- package/dest/contract/interfaces/contract_class.js +0 -5
- package/dest/contract/interfaces/contract_data_source.d.ts +3 -8
- package/dest/contract/interfaces/contract_data_source.d.ts.map +1 -1
- package/dest/database-version/version_manager.d.ts +5 -0
- package/dest/database-version/version_manager.d.ts.map +1 -1
- package/dest/database-version/version_manager.js +7 -0
- package/dest/hash/hash.d.ts +8 -1
- package/dest/hash/hash.d.ts.map +1 -1
- package/dest/hash/hash.js +12 -1
- package/dest/interfaces/archiver.d.ts +1 -2
- package/dest/interfaces/archiver.d.ts.map +1 -1
- package/dest/interfaces/archiver.js +2 -4
- package/dest/interfaces/aztec-node-admin.d.ts +20 -0
- package/dest/interfaces/aztec-node-admin.d.ts.map +1 -0
- package/dest/interfaces/aztec-node-admin.js +16 -0
- package/dest/interfaces/aztec-node.d.ts +8 -38
- package/dest/interfaces/aztec-node.d.ts.map +1 -1
- package/dest/interfaces/aztec-node.js +4 -12
- package/dest/interfaces/client.d.ts +1 -0
- package/dest/interfaces/client.d.ts.map +1 -1
- package/dest/interfaces/client.js +1 -0
- package/dest/interfaces/private_kernel_prover.d.ts +2 -3
- package/dest/interfaces/private_kernel_prover.d.ts.map +1 -1
- package/dest/interfaces/prover-client.js +1 -1
- package/dest/interfaces/prover-node.d.ts +1 -2
- package/dest/interfaces/prover-node.d.ts.map +1 -1
- package/dest/interfaces/prover-node.js +5 -4
- package/dest/interfaces/proving-job.d.ts +27 -54
- package/dest/interfaces/proving-job.d.ts.map +1 -1
- package/dest/interfaces/pxe.d.ts +21 -39
- package/dest/interfaces/pxe.d.ts.map +1 -1
- package/dest/interfaces/pxe.js +10 -9
- package/dest/kernel/index.d.ts +1 -1
- package/dest/kernel/index.d.ts.map +1 -1
- package/dest/kernel/index.js +1 -1
- package/dest/kernel/private_kernel_prover_output.d.ts +49 -0
- package/dest/kernel/private_kernel_prover_output.d.ts.map +1 -0
- package/dest/kernel/private_kernel_prover_output.js +8 -0
- package/dest/kernel/private_kernel_simulated_output.d.ts +3 -7
- package/dest/kernel/private_kernel_simulated_output.d.ts.map +1 -1
- package/dest/kernel/public_call_request.d.ts +14 -19
- package/dest/kernel/public_call_request.d.ts.map +1 -1
- package/dest/kernel/public_call_request.js +19 -20
- package/dest/logs/log_with_tx_data.js +2 -2
- package/dest/noir/index.d.ts +5 -1
- package/dest/noir/index.d.ts.map +1 -1
- package/dest/proofs/client_ivc_proof.d.ts +1 -2
- package/dest/proofs/client_ivc_proof.d.ts.map +1 -1
- package/dest/proofs/client_ivc_proof.js +6 -9
- package/dest/rollup/tube_inputs.d.ts +7 -2
- package/dest/rollup/tube_inputs.d.ts.map +1 -1
- package/dest/rollup/tube_inputs.js +10 -4
- package/dest/stats/stats.d.ts +1 -1
- package/dest/stats/stats.d.ts.map +1 -1
- package/dest/tests/factories.d.ts +2 -2
- package/dest/tests/factories.d.ts.map +1 -1
- package/dest/tests/factories.js +3 -13
- package/dest/tests/mocks.d.ts +3 -4
- package/dest/tests/mocks.d.ts.map +1 -1
- package/dest/tests/mocks.js +13 -48
- package/dest/trees/nullifier_membership_witness.d.ts +4 -0
- package/dest/trees/nullifier_membership_witness.d.ts.map +1 -1
- package/dest/trees/nullifier_membership_witness.js +10 -0
- package/dest/trees/public_data_witness.d.ts +5 -5
- package/dest/trees/public_data_witness.d.ts.map +1 -1
- package/dest/trees/public_data_witness.js +13 -0
- package/dest/tx/call_context.d.ts +1 -1
- package/dest/tx/hashed_values.d.ts +16 -4
- package/dest/tx/hashed_values.d.ts.map +1 -1
- package/dest/tx/hashed_values.js +26 -9
- package/dest/tx/index.d.ts +3 -1
- package/dest/tx/index.d.ts.map +1 -1
- package/dest/tx/index.js +3 -1
- package/dest/tx/private_execution_result.d.ts +10 -26
- package/dest/tx/private_execution_result.d.ts.map +1 -1
- package/dest/tx/private_execution_result.js +18 -70
- package/dest/tx/profiled_tx.d.ts +9 -0
- package/dest/tx/profiled_tx.d.ts.map +1 -0
- package/dest/tx/profiled_tx.js +27 -0
- package/dest/tx/proven_tx.d.ts +33 -0
- package/dest/tx/proven_tx.d.ts.map +1 -0
- package/dest/tx/proven_tx.js +33 -0
- package/dest/tx/public_call_request_with_calldata.d.ts +41 -0
- package/dest/tx/public_call_request_with_calldata.d.ts.map +1 -0
- package/dest/tx/public_call_request_with_calldata.js +57 -0
- package/dest/tx/simulated_tx.d.ts +8 -44
- package/dest/tx/simulated_tx.d.ts.map +1 -1
- package/dest/tx/simulated_tx.js +19 -44
- package/dest/tx/tx.d.ts +16 -20
- package/dest/tx/tx.d.ts.map +1 -1
- package/dest/tx/tx.js +56 -42
- package/dest/tx/tx_execution_request.js +1 -1
- package/dest/tx/tx_receipt.d.ts +1 -30
- package/dest/tx/tx_receipt.d.ts.map +1 -1
- package/dest/tx/tx_receipt.js +3 -13
- package/package.json +6 -7
- package/src/abi/abi.ts +7 -2
- package/src/auth_witness/auth_witness.ts +29 -0
- package/src/block/index.ts +0 -1
- package/src/block/l2_block_downloader/l2_block_stream.ts +0 -2
- package/src/block/l2_block_source.ts +7 -0
- package/src/contract/contract_class.ts +7 -26
- package/src/contract/interfaces/contract_class.ts +2 -18
- package/src/contract/interfaces/contract_data_source.ts +3 -9
- package/src/database-version/version_manager.ts +10 -0
- package/src/hash/hash.ts +15 -1
- package/src/interfaces/archiver.ts +3 -12
- package/src/interfaces/aztec-node-admin.ts +39 -0
- package/src/interfaces/aztec-node.ts +9 -71
- package/src/interfaces/client.ts +1 -0
- package/src/interfaces/private_kernel_prover.ts +2 -3
- package/src/interfaces/prover-client.ts +1 -1
- package/src/interfaces/prover-node.ts +2 -4
- package/src/interfaces/pxe.ts +34 -56
- package/src/kernel/index.ts +1 -1
- package/src/kernel/private_kernel_prover_output.ts +44 -0
- package/src/kernel/private_kernel_simulated_output.ts +4 -13
- package/src/kernel/public_call_request.ts +22 -27
- package/src/logs/log_with_tx_data.ts +2 -2
- package/src/noir/index.ts +6 -1
- package/src/proofs/client_ivc_proof.ts +5 -15
- package/src/rollup/tube_inputs.ts +8 -4
- package/src/stats/stats.ts +1 -1
- package/src/tests/factories.ts +3 -24
- package/src/tests/mocks.ts +28 -80
- package/src/trees/nullifier_membership_witness.ts +12 -0
- package/src/trees/public_data_witness.ts +15 -0
- package/src/tx/hashed_values.ts +29 -9
- package/src/tx/index.ts +3 -1
- package/src/tx/private_execution_result.ts +16 -81
- package/src/tx/profiled_tx.ts +27 -0
- package/src/tx/proven_tx.ts +50 -0
- package/src/tx/public_call_request_with_calldata.ts +72 -0
- package/src/tx/simulated_tx.ts +12 -69
- package/src/tx/tx.ts +57 -70
- package/src/tx/tx_execution_request.ts +1 -1
- package/src/tx/tx_receipt.ts +0 -36
- package/dest/block/nullifier_with_block_source.d.ts +0 -6
- package/dest/block/nullifier_with_block_source.d.ts.map +0 -1
- package/dest/block/nullifier_with_block_source.js +0 -1
- package/dest/kernel/private_kernel_prover_profile_result.d.ts +0 -25
- package/dest/kernel/private_kernel_prover_profile_result.d.ts.map +0 -1
- package/dest/kernel/private_kernel_prover_profile_result.js +0 -7
- package/dest/tx/public_execution_request.d.ts +0 -45
- package/dest/tx/public_execution_request.d.ts.map +0 -1
- package/dest/tx/public_execution_request.js +0 -72
- package/src/block/nullifier_with_block_source.ts +0 -7
- package/src/kernel/private_kernel_prover_profile_result.ts +0 -7
- package/src/tx/public_execution_request.ts +0 -97
|
@@ -12,7 +12,7 @@ import { sortByCounter } from '../kernel/utils/order_and_comparison.js';
|
|
|
12
12
|
import { ContractClassLog } from '../logs/contract_class_log.js';
|
|
13
13
|
import { Note } from '../note/note.js';
|
|
14
14
|
import { type ZodFor, mapSchema, schemas } from '../schemas/index.js';
|
|
15
|
-
import {
|
|
15
|
+
import { HashedValues } from './hashed_values.js';
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* The contents of a new note.
|
|
@@ -67,36 +67,13 @@ export class CountedContractClassLog implements IsEmpty {
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
export class CountedPublicExecutionRequest {
|
|
71
|
-
constructor(public request: PublicExecutionRequest, public counter: number) {}
|
|
72
|
-
|
|
73
|
-
static get schema(): ZodFor<CountedPublicExecutionRequest> {
|
|
74
|
-
return z
|
|
75
|
-
.object({
|
|
76
|
-
request: PublicExecutionRequest.schema,
|
|
77
|
-
counter: schemas.Integer,
|
|
78
|
-
})
|
|
79
|
-
.transform(CountedPublicExecutionRequest.from);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
static from(fields: FieldsOf<CountedPublicExecutionRequest>) {
|
|
83
|
-
return new CountedPublicExecutionRequest(fields.request, fields.counter);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
isEmpty(): boolean {
|
|
87
|
-
return this.request.isEmpty() && !this.counter;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
static async random() {
|
|
91
|
-
return new CountedPublicExecutionRequest(await PublicExecutionRequest.random(), 0);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
70
|
export class PrivateExecutionResult {
|
|
96
71
|
constructor(
|
|
97
72
|
public entrypoint: PrivateCallExecutionResult,
|
|
98
73
|
/** The first non revertible nullifier, or zero if there was none. */
|
|
99
74
|
public firstNullifier: Fr,
|
|
75
|
+
/** An array of calldata for the enqueued public function calls and the teardown function call. */
|
|
76
|
+
public publicFunctionCalldata: HashedValues[],
|
|
100
77
|
) {}
|
|
101
78
|
|
|
102
79
|
static get schema(): ZodFor<PrivateExecutionResult> {
|
|
@@ -104,16 +81,27 @@ export class PrivateExecutionResult {
|
|
|
104
81
|
.object({
|
|
105
82
|
entrypoint: PrivateCallExecutionResult.schema,
|
|
106
83
|
firstNullifier: schemas.Fr,
|
|
84
|
+
publicFunctionCalldata: z.array(HashedValues.schema),
|
|
107
85
|
})
|
|
108
86
|
.transform(PrivateExecutionResult.from);
|
|
109
87
|
}
|
|
110
88
|
|
|
111
89
|
static from(fields: FieldsOf<PrivateExecutionResult>) {
|
|
112
|
-
return new PrivateExecutionResult(fields.entrypoint, fields.firstNullifier);
|
|
90
|
+
return new PrivateExecutionResult(fields.entrypoint, fields.firstNullifier, fields.publicFunctionCalldata);
|
|
113
91
|
}
|
|
114
92
|
|
|
115
93
|
static async random(nested = 1): Promise<PrivateExecutionResult> {
|
|
116
|
-
return new PrivateExecutionResult(await PrivateCallExecutionResult.random(nested), Fr.random()
|
|
94
|
+
return new PrivateExecutionResult(await PrivateCallExecutionResult.random(nested), Fr.random(), [
|
|
95
|
+
HashedValues.random(),
|
|
96
|
+
HashedValues.random(),
|
|
97
|
+
]);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* The block number that this execution was simulated with.
|
|
102
|
+
*/
|
|
103
|
+
getSimulationBlockNumber(): number {
|
|
104
|
+
return this.entrypoint.publicInputs.historicalHeader.globalVariables.blockNumber.toNumber();
|
|
117
105
|
}
|
|
118
106
|
}
|
|
119
107
|
|
|
@@ -142,10 +130,6 @@ export class PrivateCallExecutionResult {
|
|
|
142
130
|
public returnValues: Fr[],
|
|
143
131
|
/** The nested executions. */
|
|
144
132
|
public nestedExecutions: PrivateCallExecutionResult[],
|
|
145
|
-
/** Enqueued public function execution requests to be picked up by the sequencer. */
|
|
146
|
-
public enqueuedPublicFunctionCalls: CountedPublicExecutionRequest[],
|
|
147
|
-
/** Public function execution requested for teardown */
|
|
148
|
-
public publicTeardownFunctionCall: PublicExecutionRequest,
|
|
149
133
|
/**
|
|
150
134
|
* Contract class logs emitted during execution of this function call.
|
|
151
135
|
* Note: These are preimages to `contractClassLogsHashes`.
|
|
@@ -165,8 +149,6 @@ export class PrivateCallExecutionResult {
|
|
|
165
149
|
noteHashNullifierCounterMap: mapSchema(z.coerce.number(), z.number()),
|
|
166
150
|
returnValues: z.array(schemas.Fr),
|
|
167
151
|
nestedExecutions: z.array(z.lazy(() => PrivateCallExecutionResult.schema)),
|
|
168
|
-
enqueuedPublicFunctionCalls: z.array(CountedPublicExecutionRequest.schema),
|
|
169
|
-
publicTeardownFunctionCall: PublicExecutionRequest.schema,
|
|
170
152
|
contractClassLogs: z.array(CountedContractClassLog.schema),
|
|
171
153
|
})
|
|
172
154
|
.transform(PrivateCallExecutionResult.from);
|
|
@@ -183,8 +165,6 @@ export class PrivateCallExecutionResult {
|
|
|
183
165
|
fields.noteHashNullifierCounterMap,
|
|
184
166
|
fields.returnValues,
|
|
185
167
|
fields.nestedExecutions,
|
|
186
|
-
fields.enqueuedPublicFunctionCalls,
|
|
187
|
-
fields.publicTeardownFunctionCall,
|
|
188
168
|
fields.contractClassLogs,
|
|
189
169
|
);
|
|
190
170
|
}
|
|
@@ -200,8 +180,6 @@ export class PrivateCallExecutionResult {
|
|
|
200
180
|
new Map([[0, 0]]),
|
|
201
181
|
[Fr.random()],
|
|
202
182
|
await timesParallel(nested, () => PrivateCallExecutionResult.random(0)),
|
|
203
|
-
[await CountedPublicExecutionRequest.random()],
|
|
204
|
-
await PublicExecutionRequest.random(),
|
|
205
183
|
[new CountedContractClassLog(await ContractClassLog.random(), randomInt(10))],
|
|
206
184
|
);
|
|
207
185
|
}
|
|
@@ -250,49 +228,6 @@ export function collectSortedContractClassLogs(execResult: PrivateExecutionResul
|
|
|
250
228
|
return sortedLogs.map(l => l.log);
|
|
251
229
|
}
|
|
252
230
|
|
|
253
|
-
function collectEnqueuedCountedPublicExecutionRequests(
|
|
254
|
-
execResult: PrivateCallExecutionResult,
|
|
255
|
-
): CountedPublicExecutionRequest[] {
|
|
256
|
-
return [
|
|
257
|
-
...execResult.enqueuedPublicFunctionCalls,
|
|
258
|
-
...execResult.nestedExecutions.flatMap(collectEnqueuedCountedPublicExecutionRequests),
|
|
259
|
-
];
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
/**
|
|
263
|
-
* Collect all enqueued public function calls across all nested executions.
|
|
264
|
-
* @param execResult - The topmost execution result.
|
|
265
|
-
* @returns All enqueued public function calls.
|
|
266
|
-
*/
|
|
267
|
-
export function collectEnqueuedPublicFunctionCalls(execResult: PrivateExecutionResult): PublicExecutionRequest[] {
|
|
268
|
-
const countedRequests = collectEnqueuedCountedPublicExecutionRequests(execResult.entrypoint);
|
|
269
|
-
// without the reverse sort, the logs will be in a queue like fashion which is wrong
|
|
270
|
-
// as the kernel processes it like a stack, popping items off and pushing them to output
|
|
271
|
-
return sortByCounter(countedRequests, false).map(r => r.request);
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
export function collectPublicTeardownFunctionCall(execResult: PrivateExecutionResult): PublicExecutionRequest {
|
|
275
|
-
const collectPublicTeardownFunctionCallRecursive = (
|
|
276
|
-
callResult: PrivateCallExecutionResult,
|
|
277
|
-
): PublicExecutionRequest[] => {
|
|
278
|
-
return [
|
|
279
|
-
callResult.publicTeardownFunctionCall,
|
|
280
|
-
...callResult.nestedExecutions.flatMap(collectPublicTeardownFunctionCallRecursive),
|
|
281
|
-
].filter(call => !call.isEmpty());
|
|
282
|
-
};
|
|
283
|
-
const teardownCalls = collectPublicTeardownFunctionCallRecursive(execResult.entrypoint);
|
|
284
|
-
|
|
285
|
-
if (teardownCalls.length === 1) {
|
|
286
|
-
return teardownCalls[0];
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
if (teardownCalls.length > 1) {
|
|
290
|
-
throw new Error('Multiple public teardown calls detected');
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
return PublicExecutionRequest.empty();
|
|
294
|
-
}
|
|
295
|
-
|
|
296
231
|
export function getFinalMinRevertibleSideEffectCounter(execResult: PrivateExecutionResult): number {
|
|
297
232
|
const collectFinalMinRevertibleSideEffectCounterRecursive = (callResult: PrivateCallExecutionResult): number => {
|
|
298
233
|
return callResult.nestedExecutions.reduce((counter, exec) => {
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ZodFor } from '@aztec/foundation/schemas';
|
|
2
|
+
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
import { type PrivateExecutionStep, PrivateExecutionStepSchema } from '../kernel/private_kernel_prover_output.js';
|
|
6
|
+
|
|
7
|
+
export class TxProfileResult {
|
|
8
|
+
constructor(public executionSteps: PrivateExecutionStep[]) {}
|
|
9
|
+
|
|
10
|
+
static get schema(): ZodFor<TxProfileResult> {
|
|
11
|
+
return z
|
|
12
|
+
.object({
|
|
13
|
+
executionSteps: z.array(PrivateExecutionStepSchema),
|
|
14
|
+
})
|
|
15
|
+
.transform(({ executionSteps }) => new TxProfileResult(executionSteps));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
static random(): TxProfileResult {
|
|
19
|
+
return new TxProfileResult([
|
|
20
|
+
{
|
|
21
|
+
functionName: 'random',
|
|
22
|
+
bytecode: Buffer.from('random'),
|
|
23
|
+
witness: new Map([[1, 'random']]),
|
|
24
|
+
},
|
|
25
|
+
]);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { FieldsOf } from '@aztec/foundation/types';
|
|
2
|
+
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
import { PrivateKernelTailCircuitPublicInputs } from '../kernel/private_kernel_tail_circuit_public_inputs.js';
|
|
6
|
+
import { ClientIvcProof } from '../proofs/client_ivc_proof.js';
|
|
7
|
+
import { PrivateExecutionResult, collectSortedContractClassLogs } from './private_execution_result.js';
|
|
8
|
+
import { Tx } from './tx.js';
|
|
9
|
+
|
|
10
|
+
export class TxProvingResult {
|
|
11
|
+
constructor(
|
|
12
|
+
public privateExecutionResult: PrivateExecutionResult,
|
|
13
|
+
public publicInputs: PrivateKernelTailCircuitPublicInputs,
|
|
14
|
+
public clientIvcProof: ClientIvcProof,
|
|
15
|
+
) {}
|
|
16
|
+
|
|
17
|
+
toTx(): Tx {
|
|
18
|
+
const contractClassLogs = collectSortedContractClassLogs(this.privateExecutionResult);
|
|
19
|
+
|
|
20
|
+
const tx = new Tx(
|
|
21
|
+
this.publicInputs,
|
|
22
|
+
this.clientIvcProof,
|
|
23
|
+
contractClassLogs,
|
|
24
|
+
this.privateExecutionResult.publicFunctionCalldata,
|
|
25
|
+
);
|
|
26
|
+
return tx;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
static get schema() {
|
|
30
|
+
return z
|
|
31
|
+
.object({
|
|
32
|
+
privateExecutionResult: PrivateExecutionResult.schema,
|
|
33
|
+
publicInputs: PrivateKernelTailCircuitPublicInputs.schema,
|
|
34
|
+
clientIvcProof: ClientIvcProof.schema,
|
|
35
|
+
})
|
|
36
|
+
.transform(TxProvingResult.from);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
static from(fields: FieldsOf<TxProvingResult>) {
|
|
40
|
+
return new TxProvingResult(fields.privateExecutionResult, fields.publicInputs, fields.clientIvcProof);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
static async random() {
|
|
44
|
+
return new TxProvingResult(
|
|
45
|
+
await PrivateExecutionResult.random(),
|
|
46
|
+
PrivateKernelTailCircuitPublicInputs.empty(),
|
|
47
|
+
ClientIvcProof.empty(),
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
3
|
+
|
|
4
|
+
import { inspect } from 'util';
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
|
|
7
|
+
import { FunctionSelector } from '../abi/function_selector.js';
|
|
8
|
+
import { PublicCallRequest } from '../kernel/public_call_request.js';
|
|
9
|
+
import { type ZodFor, schemas } from '../schemas/index.js';
|
|
10
|
+
import { Vector } from '../types/index.js';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The call request of a public function, including the calldata.
|
|
14
|
+
*/
|
|
15
|
+
export class PublicCallRequestWithCalldata {
|
|
16
|
+
constructor(
|
|
17
|
+
/**
|
|
18
|
+
* Request of the public call.
|
|
19
|
+
*/
|
|
20
|
+
public request: PublicCallRequest,
|
|
21
|
+
/**
|
|
22
|
+
* Function selector and arguments of the public call.
|
|
23
|
+
*/
|
|
24
|
+
public calldata: Fr[],
|
|
25
|
+
) {}
|
|
26
|
+
|
|
27
|
+
// Public functions get routed through the dispatch function, whose first argument is the target function selector.
|
|
28
|
+
get functionSelector(): FunctionSelector {
|
|
29
|
+
return FunctionSelector.fromField(this.calldata[0]);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
get args(): Fr[] {
|
|
33
|
+
return this.calldata.slice(1);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
static get schema(): ZodFor<PublicCallRequestWithCalldata> {
|
|
37
|
+
return z
|
|
38
|
+
.object({
|
|
39
|
+
request: PublicCallRequest.schema,
|
|
40
|
+
calldata: z.array(schemas.Fr),
|
|
41
|
+
})
|
|
42
|
+
.transform(PublicCallRequestWithCalldata.from);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
static from(fields: Pick<PublicCallRequestWithCalldata, 'request' | 'calldata'>): PublicCallRequestWithCalldata {
|
|
46
|
+
return new PublicCallRequestWithCalldata(fields.request, fields.calldata);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
toBuffer() {
|
|
50
|
+
return serializeToBuffer(this.request, new Vector(this.calldata));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
static fromBuffer(buffer: Buffer | BufferReader) {
|
|
54
|
+
const reader = BufferReader.asReader(buffer);
|
|
55
|
+
return new PublicCallRequestWithCalldata(PublicCallRequest.fromBuffer(reader), reader.readVector(Fr));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
static empty() {
|
|
59
|
+
return new PublicCallRequestWithCalldata(PublicCallRequest.empty(), []);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
isEmpty(): boolean {
|
|
63
|
+
return this.request.isEmpty() && this.calldata.length === 0;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
[inspect.custom]() {
|
|
67
|
+
return `PublicCallRequestWithCalldata {
|
|
68
|
+
request: ${inspect(this.request)}
|
|
69
|
+
calldata: ${this.calldata}
|
|
70
|
+
}`;
|
|
71
|
+
}
|
|
72
|
+
}
|
package/src/tx/simulated_tx.ts
CHANGED
|
@@ -5,17 +5,11 @@ import { z } from 'zod';
|
|
|
5
5
|
|
|
6
6
|
import { Gas } from '../gas/gas.js';
|
|
7
7
|
import type { GasUsed } from '../gas/gas_used.js';
|
|
8
|
-
import {
|
|
9
|
-
type PrivateKernelProverProfileResult,
|
|
10
|
-
PrivateKernelProverProfileResultSchema,
|
|
11
|
-
} from '../kernel/private_kernel_prover_profile_result.js';
|
|
12
8
|
import { PrivateKernelTailCircuitPublicInputs } from '../kernel/private_kernel_tail_circuit_public_inputs.js';
|
|
13
9
|
import { ClientIvcProof } from '../proofs/client_ivc_proof.js';
|
|
14
10
|
import {
|
|
15
11
|
PrivateCallExecutionResult,
|
|
16
12
|
PrivateExecutionResult,
|
|
17
|
-
collectEnqueuedPublicFunctionCalls,
|
|
18
|
-
collectPublicTeardownFunctionCall,
|
|
19
13
|
collectSortedContractClassLogs,
|
|
20
14
|
} from './private_execution_result.js';
|
|
21
15
|
import { NestedProcessReturnValues, PublicSimulationOutput } from './public_simulation_output.js';
|
|
@@ -33,29 +27,23 @@ export class PrivateSimulationResult {
|
|
|
33
27
|
|
|
34
28
|
toSimulatedTx(): Tx {
|
|
35
29
|
const contractClassLogs = collectSortedContractClassLogs(this.privateExecutionResult);
|
|
36
|
-
const enqueuedPublicFunctions = collectEnqueuedPublicFunctionCalls(this.privateExecutionResult);
|
|
37
|
-
const teardownPublicFunction = collectPublicTeardownFunctionCall(this.privateExecutionResult);
|
|
38
30
|
|
|
39
31
|
const tx = new Tx(
|
|
40
32
|
this.publicInputs,
|
|
41
33
|
ClientIvcProof.empty(),
|
|
42
34
|
contractClassLogs,
|
|
43
|
-
|
|
44
|
-
teardownPublicFunction,
|
|
35
|
+
this.privateExecutionResult.publicFunctionCalldata,
|
|
45
36
|
);
|
|
46
37
|
return tx;
|
|
47
38
|
}
|
|
48
39
|
}
|
|
49
40
|
|
|
50
|
-
export class TxSimulationResult
|
|
41
|
+
export class TxSimulationResult {
|
|
51
42
|
constructor(
|
|
52
|
-
privateExecutionResult: PrivateExecutionResult,
|
|
53
|
-
publicInputs: PrivateKernelTailCircuitPublicInputs,
|
|
43
|
+
public privateExecutionResult: PrivateExecutionResult,
|
|
44
|
+
public publicInputs: PrivateKernelTailCircuitPublicInputs,
|
|
54
45
|
public publicOutput?: PublicSimulationOutput,
|
|
55
|
-
|
|
56
|
-
) {
|
|
57
|
-
super(privateExecutionResult, publicInputs);
|
|
58
|
-
}
|
|
46
|
+
) {}
|
|
59
47
|
|
|
60
48
|
get gasUsed(): GasUsed {
|
|
61
49
|
return (
|
|
@@ -74,34 +62,22 @@ export class TxSimulationResult extends PrivateSimulationResult {
|
|
|
74
62
|
privateExecutionResult: PrivateExecutionResult.schema,
|
|
75
63
|
publicInputs: PrivateKernelTailCircuitPublicInputs.schema,
|
|
76
64
|
publicOutput: PublicSimulationOutput.schema.optional(),
|
|
77
|
-
profileResult: PrivateKernelProverProfileResultSchema.optional(),
|
|
78
65
|
})
|
|
79
66
|
.transform(TxSimulationResult.from);
|
|
80
67
|
}
|
|
81
68
|
|
|
82
69
|
static from(fields: Omit<FieldsOf<TxSimulationResult>, 'gasUsed'>) {
|
|
83
|
-
return new TxSimulationResult(
|
|
84
|
-
fields.privateExecutionResult,
|
|
85
|
-
fields.publicInputs,
|
|
86
|
-
fields.publicOutput,
|
|
87
|
-
fields.profileResult,
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
getPublicReturnValues() {
|
|
92
|
-
return this.publicOutput ? this.publicOutput.publicReturnValues : [];
|
|
70
|
+
return new TxSimulationResult(fields.privateExecutionResult, fields.publicInputs, fields.publicOutput);
|
|
93
71
|
}
|
|
94
72
|
|
|
95
73
|
static fromPrivateSimulationResultAndPublicOutput(
|
|
96
74
|
privateSimulationResult: PrivateSimulationResult,
|
|
97
75
|
publicOutput?: PublicSimulationOutput,
|
|
98
|
-
profileResult?: PrivateKernelProverProfileResult,
|
|
99
76
|
) {
|
|
100
77
|
return new TxSimulationResult(
|
|
101
78
|
privateSimulationResult.privateExecutionResult,
|
|
102
79
|
privateSimulationResult.publicInputs,
|
|
103
80
|
publicOutput,
|
|
104
|
-
profileResult,
|
|
105
81
|
);
|
|
106
82
|
}
|
|
107
83
|
|
|
@@ -112,50 +88,17 @@ export class TxSimulationResult extends PrivateSimulationResult {
|
|
|
112
88
|
await PublicSimulationOutput.random(),
|
|
113
89
|
);
|
|
114
90
|
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
export class TxProvingResult {
|
|
118
|
-
constructor(
|
|
119
|
-
public privateExecutionResult: PrivateExecutionResult,
|
|
120
|
-
public publicInputs: PrivateKernelTailCircuitPublicInputs,
|
|
121
|
-
public clientIvcProof: ClientIvcProof,
|
|
122
|
-
) {}
|
|
123
91
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
const enqueuedPublicFunctions = collectEnqueuedPublicFunctionCalls(this.privateExecutionResult);
|
|
127
|
-
const teardownPublicFunction = collectPublicTeardownFunctionCall(this.privateExecutionResult);
|
|
128
|
-
|
|
129
|
-
const tx = new Tx(
|
|
130
|
-
this.publicInputs,
|
|
131
|
-
this.clientIvcProof,
|
|
132
|
-
contractClassLogs,
|
|
133
|
-
enqueuedPublicFunctions,
|
|
134
|
-
teardownPublicFunction,
|
|
135
|
-
);
|
|
136
|
-
return tx;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
static get schema() {
|
|
140
|
-
return z
|
|
141
|
-
.object({
|
|
142
|
-
privateExecutionResult: PrivateExecutionResult.schema,
|
|
143
|
-
publicInputs: PrivateKernelTailCircuitPublicInputs.schema,
|
|
144
|
-
clientIvcProof: ClientIvcProof.schema,
|
|
145
|
-
})
|
|
146
|
-
.transform(TxProvingResult.from);
|
|
92
|
+
getPrivateReturnValues() {
|
|
93
|
+
return new PrivateSimulationResult(this.privateExecutionResult, this.publicInputs).getPrivateReturnValues();
|
|
147
94
|
}
|
|
148
95
|
|
|
149
|
-
|
|
150
|
-
return new
|
|
96
|
+
toSimulatedTx(): Tx {
|
|
97
|
+
return new PrivateSimulationResult(this.privateExecutionResult, this.publicInputs).toSimulatedTx();
|
|
151
98
|
}
|
|
152
99
|
|
|
153
|
-
|
|
154
|
-
return
|
|
155
|
-
await PrivateExecutionResult.random(),
|
|
156
|
-
PrivateKernelTailCircuitPublicInputs.empty(),
|
|
157
|
-
ClientIvcProof.empty(),
|
|
158
|
-
);
|
|
100
|
+
getPublicReturnValues() {
|
|
101
|
+
return this.publicOutput ? this.publicOutput.publicReturnValues : [];
|
|
159
102
|
}
|
|
160
103
|
}
|
|
161
104
|
|