@aztec/simulator 0.47.0 → 0.47.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/acvm/acvm.d.ts +1 -1
- package/dest/acvm/acvm.d.ts.map +1 -1
- package/dest/acvm/oracle/oracle.d.ts +2 -2
- package/dest/acvm/oracle/oracle.d.ts.map +1 -1
- package/dest/acvm/oracle/oracle.js +6 -8
- package/dest/acvm/oracle/typed_oracle.d.ts +7 -4
- package/dest/acvm/oracle/typed_oracle.d.ts.map +1 -1
- package/dest/acvm/oracle/typed_oracle.js +1 -1
- package/dest/acvm/serialize.d.ts +0 -11
- package/dest/acvm/serialize.d.ts.map +1 -1
- package/dest/acvm/serialize.js +1 -26
- package/dest/avm/avm_gas.d.ts.map +1 -1
- package/dest/avm/avm_gas.js +2 -1
- package/dest/avm/opcodes/commitment.d.ts +16 -0
- package/dest/avm/opcodes/commitment.d.ts.map +1 -0
- package/dest/avm/opcodes/commitment.js +50 -0
- package/dest/avm/serialization/bytecode_serialization.d.ts.map +1 -1
- package/dest/avm/serialization/bytecode_serialization.js +3 -1
- package/dest/avm/serialization/instruction_serialization.d.ts +4 -3
- package/dest/avm/serialization/instruction_serialization.d.ts.map +1 -1
- package/dest/avm/serialization/instruction_serialization.js +5 -4
- package/dest/client/client_execution_context.d.ts +12 -9
- package/dest/client/client_execution_context.d.ts.map +1 -1
- package/dest/client/client_execution_context.js +21 -23
- package/dest/client/execution_result.d.ts +12 -6
- package/dest/client/execution_result.d.ts.map +1 -1
- package/dest/client/execution_result.js +21 -8
- package/dest/mocks/fixtures.d.ts +5 -5
- package/dest/mocks/fixtures.d.ts.map +1 -1
- package/dest/mocks/fixtures.js +6 -9
- package/dest/public/abstract_phase_manager.d.ts +4 -5
- package/dest/public/abstract_phase_manager.d.ts.map +1 -1
- package/dest/public/abstract_phase_manager.js +16 -83
- package/dest/public/execution.d.ts +8 -10
- package/dest/public/execution.d.ts.map +1 -1
- package/dest/public/execution.js +10 -1
- package/dest/public/executor.d.ts +2 -1
- package/dest/public/executor.d.ts.map +1 -1
- package/dest/public/executor.js +3 -3
- package/dest/public/index.d.ts +1 -1
- package/dest/public/index.d.ts.map +1 -1
- package/dest/public/index.js +1 -1
- package/dest/public/side_effect_trace.d.ts +1 -0
- package/dest/public/side_effect_trace.d.ts.map +1 -1
- package/dest/public/side_effect_trace.js +9 -9
- package/package.json +9 -9
- package/src/acvm/acvm.ts +1 -1
- package/src/acvm/oracle/oracle.ts +5 -7
- package/src/acvm/oracle/typed_oracle.ts +4 -10
- package/src/acvm/serialize.ts +0 -29
- package/src/avm/avm_gas.ts +1 -0
- package/src/avm/opcodes/commitment.ts +66 -0
- package/src/avm/serialization/bytecode_serialization.ts +2 -0
- package/src/avm/serialization/instruction_serialization.ts +1 -0
- package/src/client/client_execution_context.ts +29 -30
- package/src/client/execution_result.ts +25 -10
- package/src/mocks/fixtures.ts +13 -11
- package/src/public/abstract_phase_manager.ts +22 -102
- package/src/public/execution.ts +30 -14
- package/src/public/executor.ts +4 -3
- package/src/public/index.ts +1 -1
- package/src/public/side_effect_trace.ts +13 -7
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
type AvmProvingRequest,
|
|
4
4
|
MerkleTreeId,
|
|
5
5
|
type NestedProcessReturnValues,
|
|
6
|
+
type PublicExecutionRequest,
|
|
6
7
|
type PublicKernelNonTailRequest,
|
|
7
8
|
PublicKernelType,
|
|
8
9
|
type PublicProvingRequest,
|
|
@@ -13,7 +14,6 @@ import {
|
|
|
13
14
|
import {
|
|
14
15
|
type AvmExecutionHints,
|
|
15
16
|
AztecAddress,
|
|
16
|
-
CallRequest,
|
|
17
17
|
ClientIvcProof,
|
|
18
18
|
ContractStorageRead,
|
|
19
19
|
ContractStorageUpdateRequest,
|
|
@@ -40,7 +40,7 @@ import {
|
|
|
40
40
|
NoteHash,
|
|
41
41
|
Nullifier,
|
|
42
42
|
PublicCallData,
|
|
43
|
-
|
|
43
|
+
PublicCallRequest,
|
|
44
44
|
PublicCallStackItem,
|
|
45
45
|
PublicCircuitPublicInputs,
|
|
46
46
|
PublicKernelCircuitPrivateInputs,
|
|
@@ -62,7 +62,6 @@ import {
|
|
|
62
62
|
getVKSiblingPath,
|
|
63
63
|
} from '@aztec/noir-protocol-circuits-types';
|
|
64
64
|
import {
|
|
65
|
-
type PublicExecutionRequest,
|
|
66
65
|
type PublicExecutionResult,
|
|
67
66
|
type PublicExecutor,
|
|
68
67
|
accumulateReturnValues,
|
|
@@ -165,76 +164,18 @@ export abstract class AbstractPhaseManager {
|
|
|
165
164
|
previousKernelArtifact: ProtocolArtifact,
|
|
166
165
|
): Promise<PhaseResult>;
|
|
167
166
|
|
|
168
|
-
public static extractEnqueuedPublicCallsByPhase(tx: Tx): Record<PublicKernelType,
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
|
-
const publicCallsStack = tx.enqueuedPublicFunctionCalls.slice().reverse();
|
|
180
|
-
const nonRevertibleCallStack = data.endNonRevertibleData.publicCallStack.filter(i => !i.isEmpty());
|
|
181
|
-
const revertibleCallStack = data.end.publicCallStack.filter(i => !i.isEmpty());
|
|
182
|
-
|
|
183
|
-
const callRequestsStack = publicCallsStack
|
|
184
|
-
.map(call => call.toCallRequest())
|
|
185
|
-
.filter(
|
|
186
|
-
// filter out enqueued calls that are not in the public call stack
|
|
187
|
-
// TODO mitch left a question about whether this is only needed when unit testing
|
|
188
|
-
// with mock data
|
|
189
|
-
call => revertibleCallStack.find(p => p.equals(call)) || nonRevertibleCallStack.find(p => p.equals(call)),
|
|
190
|
-
);
|
|
191
|
-
|
|
192
|
-
const teardownCallStack = tx.publicTeardownFunctionCall.isEmpty() ? [] : [tx.publicTeardownFunctionCall];
|
|
193
|
-
|
|
194
|
-
if (callRequestsStack.length === 0) {
|
|
195
|
-
return {
|
|
196
|
-
[PublicKernelType.NON_PUBLIC]: [],
|
|
197
|
-
[PublicKernelType.SETUP]: [],
|
|
198
|
-
[PublicKernelType.APP_LOGIC]: [],
|
|
199
|
-
[PublicKernelType.TEARDOWN]: teardownCallStack,
|
|
200
|
-
[PublicKernelType.TAIL]: [],
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
// find the first call that is revertible
|
|
205
|
-
const firstRevertibleCallIndex = callRequestsStack.findIndex(
|
|
206
|
-
c => revertibleCallStack.findIndex(p => p.equals(c)) !== -1,
|
|
207
|
-
);
|
|
208
|
-
|
|
209
|
-
if (firstRevertibleCallIndex === 0) {
|
|
210
|
-
return {
|
|
211
|
-
[PublicKernelType.NON_PUBLIC]: [],
|
|
212
|
-
[PublicKernelType.SETUP]: [],
|
|
213
|
-
[PublicKernelType.APP_LOGIC]: publicCallsStack,
|
|
214
|
-
[PublicKernelType.TEARDOWN]: teardownCallStack,
|
|
215
|
-
[PublicKernelType.TAIL]: [],
|
|
216
|
-
};
|
|
217
|
-
} else if (firstRevertibleCallIndex === -1) {
|
|
218
|
-
// there's no app logic, split the functions between setup (many) and teardown (just one function call)
|
|
219
|
-
return {
|
|
220
|
-
[PublicKernelType.NON_PUBLIC]: [],
|
|
221
|
-
[PublicKernelType.SETUP]: publicCallsStack,
|
|
222
|
-
[PublicKernelType.APP_LOGIC]: [],
|
|
223
|
-
[PublicKernelType.TEARDOWN]: teardownCallStack,
|
|
224
|
-
[PublicKernelType.TAIL]: [],
|
|
225
|
-
};
|
|
226
|
-
} else {
|
|
227
|
-
return {
|
|
228
|
-
[PublicKernelType.NON_PUBLIC]: [],
|
|
229
|
-
[PublicKernelType.SETUP]: publicCallsStack.slice(0, firstRevertibleCallIndex),
|
|
230
|
-
[PublicKernelType.APP_LOGIC]: publicCallsStack.slice(firstRevertibleCallIndex),
|
|
231
|
-
[PublicKernelType.TEARDOWN]: teardownCallStack,
|
|
232
|
-
[PublicKernelType.TAIL]: [],
|
|
233
|
-
};
|
|
234
|
-
}
|
|
167
|
+
public static extractEnqueuedPublicCallsByPhase(tx: Tx): Record<PublicKernelType, PublicExecutionRequest[]> {
|
|
168
|
+
const teardownRequest = tx.getPublicTeardownExecutionRequest();
|
|
169
|
+
return {
|
|
170
|
+
[PublicKernelType.NON_PUBLIC]: [],
|
|
171
|
+
[PublicKernelType.SETUP]: tx.getNonRevertiblePublicExecutionRequests(),
|
|
172
|
+
[PublicKernelType.APP_LOGIC]: tx.getRevertiblePublicExecutionRequests(),
|
|
173
|
+
[PublicKernelType.TEARDOWN]: teardownRequest ? [teardownRequest] : [],
|
|
174
|
+
[PublicKernelType.TAIL]: [],
|
|
175
|
+
};
|
|
235
176
|
}
|
|
236
177
|
|
|
237
|
-
protected extractEnqueuedPublicCalls(tx: Tx):
|
|
178
|
+
protected extractEnqueuedPublicCalls(tx: Tx): PublicExecutionRequest[] {
|
|
238
179
|
const calls = AbstractPhaseManager.extractEnqueuedPublicCallsByPhase(tx)[this.phase];
|
|
239
180
|
|
|
240
181
|
return calls;
|
|
@@ -245,7 +186,7 @@ export abstract class AbstractPhaseManager {
|
|
|
245
186
|
previousPublicKernelOutput: PublicKernelCircuitPublicInputs,
|
|
246
187
|
previousKernelArtifact: ProtocolArtifact,
|
|
247
188
|
): Promise<TxPublicCallsResult> {
|
|
248
|
-
const enqueuedCalls = this.extractEnqueuedPublicCalls(tx);
|
|
189
|
+
const enqueuedCalls = [...this.extractEnqueuedPublicCalls(tx)].reverse();
|
|
249
190
|
|
|
250
191
|
if (!enqueuedCalls || !enqueuedCalls.length) {
|
|
251
192
|
return {
|
|
@@ -299,7 +240,7 @@ export abstract class AbstractPhaseManager {
|
|
|
299
240
|
|
|
300
241
|
// Sanity check for a current upstream assumption.
|
|
301
242
|
// Consumers of the result seem to expect "reverted <=> revertReason !== undefined".
|
|
302
|
-
const functionSelector = result.executionRequest.functionSelector.toString();
|
|
243
|
+
const functionSelector = result.executionRequest.callContext.functionSelector.toString();
|
|
303
244
|
if (result.reverted && !result.revertReason) {
|
|
304
245
|
throw new Error(
|
|
305
246
|
`Simulation of ${result.executionRequest.contractAddress.toString()}:${functionSelector}(${
|
|
@@ -460,13 +401,6 @@ export abstract class AbstractPhaseManager {
|
|
|
460
401
|
const publicDataTreeInfo = await this.db.getTreeInfo(MerkleTreeId.PUBLIC_DATA_TREE);
|
|
461
402
|
this.historicalHeader.state.partial.publicDataTree.root = Fr.fromBuffer(publicDataTreeInfo.root);
|
|
462
403
|
|
|
463
|
-
const callStackPreimages = await this.getPublicCallStackPreimages(result);
|
|
464
|
-
const publicCallStackHashes = padArrayEnd(
|
|
465
|
-
callStackPreimages.map(c => c.getCompressed().hash()),
|
|
466
|
-
Fr.ZERO,
|
|
467
|
-
MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL,
|
|
468
|
-
);
|
|
469
|
-
|
|
470
404
|
const publicCircuitPublicInputs = PublicCircuitPublicInputs.from({
|
|
471
405
|
callContext: result.executionRequest.callContext,
|
|
472
406
|
proverAddress: AztecAddress.ZERO,
|
|
@@ -507,7 +441,11 @@ export abstract class AbstractPhaseManager {
|
|
|
507
441
|
ContractStorageUpdateRequest.empty(),
|
|
508
442
|
MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL,
|
|
509
443
|
),
|
|
510
|
-
|
|
444
|
+
publicCallRequests: padArrayEnd(
|
|
445
|
+
result.publicCallRequests,
|
|
446
|
+
PublicCallRequest.empty(),
|
|
447
|
+
MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL,
|
|
448
|
+
),
|
|
511
449
|
unencryptedLogsHashes: padArrayEnd(result.unencryptedLogsHashes, LogHash.empty(), MAX_UNENCRYPTED_LOGS_PER_CALL),
|
|
512
450
|
historicalHeader: this.historicalHeader,
|
|
513
451
|
globalVariables: this.globalVariables,
|
|
@@ -520,23 +458,12 @@ export abstract class AbstractPhaseManager {
|
|
|
520
458
|
|
|
521
459
|
return new PublicCallStackItem(
|
|
522
460
|
result.executionRequest.contractAddress,
|
|
523
|
-
new FunctionData(result.executionRequest.functionSelector, false),
|
|
461
|
+
new FunctionData(result.executionRequest.callContext.functionSelector, false),
|
|
524
462
|
publicCircuitPublicInputs,
|
|
525
463
|
isExecutionRequest,
|
|
526
464
|
);
|
|
527
465
|
}
|
|
528
466
|
|
|
529
|
-
protected async getPublicCallStackPreimages(result: PublicExecutionResult): Promise<PublicCallStackItem[]> {
|
|
530
|
-
const nested = result.nestedExecutions;
|
|
531
|
-
if (nested.length > MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL) {
|
|
532
|
-
throw new Error(
|
|
533
|
-
`Public call stack size exceeded (max ${MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL}, got ${nested.length})`,
|
|
534
|
-
);
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
return await Promise.all(nested.map(n => this.getPublicCallStackItem(n)));
|
|
538
|
-
}
|
|
539
|
-
|
|
540
467
|
/**
|
|
541
468
|
* Looks at the side effects of a transaction and returns the highest counter
|
|
542
469
|
* @param tx - A transaction
|
|
@@ -562,10 +489,7 @@ export abstract class AbstractPhaseManager {
|
|
|
562
489
|
|
|
563
490
|
let max = 0;
|
|
564
491
|
for (const sideEffect of sideEffectCounters) {
|
|
565
|
-
if ('
|
|
566
|
-
// look at both start and end counters because for enqueued public calls start > 0 while end === 0
|
|
567
|
-
max = Math.max(max, sideEffect.startSideEffectCounter.toNumber(), sideEffect.endSideEffectCounter.toNumber());
|
|
568
|
-
} else if ('counter' in sideEffect) {
|
|
492
|
+
if ('counter' in sideEffect) {
|
|
569
493
|
max = Math.max(max, sideEffect.counter);
|
|
570
494
|
} else {
|
|
571
495
|
throw new Error('Unknown side effect type');
|
|
@@ -593,10 +517,6 @@ export abstract class AbstractPhaseManager {
|
|
|
593
517
|
protected async getPublicCallData(result: PublicExecutionResult, isExecutionRequest = false) {
|
|
594
518
|
const bytecodeHash = await this.getBytecodeHash(result);
|
|
595
519
|
const callStackItem = await this.getPublicCallStackItem(result, isExecutionRequest);
|
|
596
|
-
|
|
597
|
-
c.toCallRequest(callStackItem.publicInputs.callContext),
|
|
598
|
-
);
|
|
599
|
-
const publicCallStack = padArrayEnd(publicCallRequests, CallRequest.empty(), MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL);
|
|
600
|
-
return new PublicCallData(callStackItem, publicCallStack, makeEmptyProof(), bytecodeHash);
|
|
520
|
+
return new PublicCallData(callStackItem, makeEmptyProof(), bytecodeHash);
|
|
601
521
|
}
|
|
602
522
|
}
|
package/src/public/execution.ts
CHANGED
|
@@ -1,18 +1,26 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
type PublicExecutionRequest,
|
|
3
|
+
type SimulationError,
|
|
4
|
+
type UnencryptedFunctionL2Logs,
|
|
5
|
+
} from '@aztec/circuit-types';
|
|
2
6
|
import {
|
|
3
7
|
type AvmExecutionHints,
|
|
4
8
|
type ContractStorageRead,
|
|
5
9
|
type ContractStorageUpdateRequest,
|
|
6
10
|
type Fr,
|
|
11
|
+
Gas,
|
|
7
12
|
type L2ToL1Message,
|
|
8
13
|
type LogHash,
|
|
9
14
|
type NoteHash,
|
|
10
15
|
type Nullifier,
|
|
11
|
-
|
|
16
|
+
PublicCallRequest,
|
|
17
|
+
PublicCallStackItemCompressed,
|
|
12
18
|
type ReadRequest,
|
|
19
|
+
RevertCode,
|
|
13
20
|
} from '@aztec/circuits.js';
|
|
21
|
+
import { computeVarArgsHash } from '@aztec/circuits.js/hash';
|
|
14
22
|
|
|
15
|
-
import { type Gas } from '../avm/avm_gas.js';
|
|
23
|
+
import { type Gas as AvmGas } from '../avm/avm_gas.js';
|
|
16
24
|
|
|
17
25
|
/**
|
|
18
26
|
* The public function execution result.
|
|
@@ -26,9 +34,9 @@ export interface PublicExecutionResult {
|
|
|
26
34
|
/** The side effect counter after executing this function call */
|
|
27
35
|
endSideEffectCounter: Fr;
|
|
28
36
|
/** How much gas was available for this public execution. */
|
|
29
|
-
startGasLeft:
|
|
37
|
+
startGasLeft: AvmGas;
|
|
30
38
|
/** How much gas was left after this public execution. */
|
|
31
|
-
endGasLeft:
|
|
39
|
+
endGasLeft: AvmGas;
|
|
32
40
|
/** Transaction fee set for this tx. */
|
|
33
41
|
transactionFee: Fr;
|
|
34
42
|
|
|
@@ -79,6 +87,8 @@ export interface PublicExecutionResult {
|
|
|
79
87
|
|
|
80
88
|
// TODO(dbanks12): add contract instance read requests
|
|
81
89
|
|
|
90
|
+
/** The requests to call public functions made by this call. */
|
|
91
|
+
publicCallRequests: PublicCallRequest[];
|
|
82
92
|
/** The results of nested calls. */
|
|
83
93
|
nestedExecutions: this[];
|
|
84
94
|
|
|
@@ -89,15 +99,6 @@ export interface PublicExecutionResult {
|
|
|
89
99
|
functionName: string;
|
|
90
100
|
}
|
|
91
101
|
|
|
92
|
-
/**
|
|
93
|
-
* The execution request of a public function.
|
|
94
|
-
* A subset of PublicCallRequest
|
|
95
|
-
*/
|
|
96
|
-
export type PublicExecutionRequest = Pick<
|
|
97
|
-
PublicCallRequest,
|
|
98
|
-
'contractAddress' | 'functionSelector' | 'callContext' | 'args'
|
|
99
|
-
>;
|
|
100
|
-
|
|
101
102
|
/**
|
|
102
103
|
* Returns if the input is a public execution result and not just a public execution.
|
|
103
104
|
* @param input - Public execution or public execution result.
|
|
@@ -131,3 +132,18 @@ export function checkValidStaticCall(
|
|
|
131
132
|
throw new Error('Static call cannot update the state, emit L2->L1 messages or generate logs');
|
|
132
133
|
}
|
|
133
134
|
}
|
|
135
|
+
|
|
136
|
+
export function resultToPublicCallRequest(result: PublicExecutionResult) {
|
|
137
|
+
const request = result.executionRequest;
|
|
138
|
+
const item = new PublicCallStackItemCompressed(
|
|
139
|
+
request.contractAddress,
|
|
140
|
+
request.callContext,
|
|
141
|
+
computeVarArgsHash(request.args),
|
|
142
|
+
computeVarArgsHash(result.returnValues),
|
|
143
|
+
// TODO(@just-mitch): need better mapping from simulator to revert code.
|
|
144
|
+
result.reverted ? RevertCode.APP_LOGIC_REVERTED : RevertCode.OK,
|
|
145
|
+
Gas.from(result.startGasLeft),
|
|
146
|
+
Gas.from(result.endGasLeft),
|
|
147
|
+
);
|
|
148
|
+
return new PublicCallRequest(item, result.startSideEffectCounter.toNumber());
|
|
149
|
+
}
|
package/src/public/executor.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type PublicExecutionRequest } from '@aztec/circuit-types';
|
|
1
2
|
import { type AvmSimulationStats } from '@aztec/circuit-types/stats';
|
|
2
3
|
import { Fr, Gas, type GlobalVariables, type Header, type Nullifier, type TxContext } from '@aztec/circuits.js';
|
|
3
4
|
import { createDebugLogger } from '@aztec/foundation/log';
|
|
@@ -10,7 +11,7 @@ import { AvmSimulator } from '../avm/avm_simulator.js';
|
|
|
10
11
|
import { HostStorage } from '../avm/journal/host_storage.js';
|
|
11
12
|
import { AvmPersistableStateManager } from '../avm/journal/index.js';
|
|
12
13
|
import { type CommitmentsDB, type PublicContractsDB, type PublicStateDB } from './db_interfaces.js';
|
|
13
|
-
import { type
|
|
14
|
+
import { type PublicExecutionResult } from './execution.js';
|
|
14
15
|
import { PublicSideEffectTrace } from './side_effect_trace.js';
|
|
15
16
|
|
|
16
17
|
/**
|
|
@@ -47,7 +48,7 @@ export class PublicExecutor {
|
|
|
47
48
|
startSideEffectCounter: number = 0,
|
|
48
49
|
): Promise<PublicExecutionResult> {
|
|
49
50
|
const address = executionRequest.contractAddress;
|
|
50
|
-
const selector = executionRequest.functionSelector;
|
|
51
|
+
const selector = executionRequest.callContext.functionSelector;
|
|
51
52
|
const fnName = (await this.contractsDb.getDebugFunctionName(address, selector)) ?? `${address}:${selector}`;
|
|
52
53
|
|
|
53
54
|
PublicExecutor.log.verbose(`[AVM] Executing public external function ${fnName}.`);
|
|
@@ -122,7 +123,7 @@ function createAvmExecutionEnvironment(
|
|
|
122
123
|
executionRequest.contractAddress,
|
|
123
124
|
executionRequest.callContext.storageContractAddress,
|
|
124
125
|
executionRequest.callContext.msgSender,
|
|
125
|
-
executionRequest.functionSelector,
|
|
126
|
+
executionRequest.callContext.functionSelector,
|
|
126
127
|
/*contractCallDepth=*/ Fr.zero(),
|
|
127
128
|
transactionFee,
|
|
128
129
|
header,
|
package/src/public/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * from './abstract_phase_manager.js';
|
|
2
2
|
export * from './db_interfaces.js';
|
|
3
|
-
export { isPublicExecutionResult, type
|
|
3
|
+
export { isPublicExecutionResult, type PublicExecutionResult } from './execution.js';
|
|
4
4
|
export { PublicExecutor } from './executor.js';
|
|
5
5
|
export * from './fee_payment.js';
|
|
6
6
|
export { HintsBuilder } from './hints_builder.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { UnencryptedFunctionL2Logs, UnencryptedL2Log } from '@aztec/circuit-types';
|
|
1
|
+
import { PublicExecutionRequest, UnencryptedFunctionL2Logs, UnencryptedL2Log } from '@aztec/circuit-types';
|
|
2
2
|
import {
|
|
3
3
|
AvmContractInstanceHint,
|
|
4
4
|
AvmExecutionHints,
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
LogHash,
|
|
15
15
|
NoteHash,
|
|
16
16
|
Nullifier,
|
|
17
|
+
type PublicCallRequest,
|
|
17
18
|
ReadRequest,
|
|
18
19
|
} from '@aztec/circuits.js';
|
|
19
20
|
import { Fr } from '@aztec/foundation/fields';
|
|
@@ -23,7 +24,7 @@ import { type ContractInstanceWithAddress } from '@aztec/types/contracts';
|
|
|
23
24
|
import { type AvmContractCallResult } from '../avm/avm_contract_call_result.js';
|
|
24
25
|
import { type AvmExecutionEnvironment } from '../avm/avm_execution_environment.js';
|
|
25
26
|
import { createSimulationError } from '../common/errors.js';
|
|
26
|
-
import { type
|
|
27
|
+
import { type PublicExecutionResult, resultToPublicCallRequest } from './execution.js';
|
|
27
28
|
import { type PublicSideEffectTraceInterface } from './side_effect_trace_interface.js';
|
|
28
29
|
|
|
29
30
|
export type TracedContractInstance = { exists: boolean } & ContractInstanceWithAddress;
|
|
@@ -51,6 +52,8 @@ export class PublicSideEffectTrace implements PublicSideEffectTraceInterface {
|
|
|
51
52
|
private allUnencryptedLogs: UnencryptedL2Log[] = [];
|
|
52
53
|
private unencryptedLogsHashes: LogHash[] = [];
|
|
53
54
|
|
|
55
|
+
private publicCallRequests: PublicCallRequest[] = [];
|
|
56
|
+
|
|
54
57
|
private gotContractInstances: ContractInstanceWithAddress[] = [];
|
|
55
58
|
|
|
56
59
|
private nestedExecutions: PublicExecutionResult[] = [];
|
|
@@ -247,6 +250,9 @@ export class PublicSideEffectTrace implements PublicSideEffectTraceInterface {
|
|
|
247
250
|
result.startGasLeft.daGas - result.endGasLeft.daGas,
|
|
248
251
|
result.startGasLeft.l2Gas - result.endGasLeft.l2Gas,
|
|
249
252
|
);
|
|
253
|
+
|
|
254
|
+
this.publicCallRequests.push(resultToPublicCallRequest(result));
|
|
255
|
+
|
|
250
256
|
this.avmCircuitHints.externalCalls.items.push(
|
|
251
257
|
new AvmExternalCallHint(
|
|
252
258
|
/*success=*/ new Fr(result.reverted ? 0 : 1),
|
|
@@ -305,6 +311,7 @@ export class PublicSideEffectTrace implements PublicSideEffectTraceInterface {
|
|
|
305
311
|
// TODO(dbanks12): process contract instance read requests in public kernel
|
|
306
312
|
//gotContractInstances: this.gotContractInstances,
|
|
307
313
|
|
|
314
|
+
publicCallRequests: this.publicCallRequests,
|
|
308
315
|
nestedExecutions: this.nestedExecutions,
|
|
309
316
|
|
|
310
317
|
avmCircuitHints: this.avmCircuitHints,
|
|
@@ -325,11 +332,10 @@ function createPublicExecutionRequest(avmEnvironment: AvmExecutionEnvironment):
|
|
|
325
332
|
isDelegateCall: avmEnvironment.isDelegateCall,
|
|
326
333
|
isStaticCall: avmEnvironment.isStaticCall,
|
|
327
334
|
});
|
|
328
|
-
return
|
|
329
|
-
|
|
330
|
-
functionSelector: avmEnvironment.functionSelector,
|
|
335
|
+
return new PublicExecutionRequest(
|
|
336
|
+
avmEnvironment.address,
|
|
331
337
|
callContext,
|
|
332
338
|
// execution request does not contain AvmContextInputs prefix
|
|
333
|
-
|
|
334
|
-
|
|
339
|
+
avmEnvironment.getCalldataWithoutPrefix(),
|
|
340
|
+
);
|
|
335
341
|
}
|