@aztec/simulator 0.40.1 → 0.42.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/acvm/acvm.d.ts +2 -2
- package/dest/acvm/acvm.d.ts.map +1 -1
- package/dest/acvm/acvm.js +3 -3
- package/dest/acvm/oracle/oracle.d.ts +6 -2
- package/dest/acvm/oracle/oracle.d.ts.map +1 -1
- package/dest/acvm/oracle/oracle.js +31 -19
- package/dest/acvm/oracle/typed_oracle.d.ts +8 -11
- package/dest/acvm/oracle/typed_oracle.d.ts.map +1 -1
- package/dest/acvm/oracle/typed_oracle.js +17 -5
- package/dest/acvm/serialize.js +2 -2
- package/dest/avm/avm_execution_environment.d.ts +4 -3
- package/dest/avm/avm_execution_environment.d.ts.map +1 -1
- package/dest/avm/avm_execution_environment.js +7 -5
- package/dest/avm/avm_gas.d.ts +1 -5
- package/dest/avm/avm_gas.d.ts.map +1 -1
- package/dest/avm/avm_gas.js +67 -73
- package/dest/avm/avm_simulator.d.ts +5 -0
- package/dest/avm/avm_simulator.d.ts.map +1 -1
- package/dest/avm/avm_simulator.js +12 -4
- package/dest/avm/errors.d.ts +6 -0
- package/dest/avm/errors.d.ts.map +1 -1
- package/dest/avm/errors.js +10 -1
- package/dest/avm/fixtures/index.d.ts +3 -0
- package/dest/avm/fixtures/index.d.ts.map +1 -1
- package/dest/avm/fixtures/index.js +15 -3
- package/dest/avm/index.d.ts +2 -0
- package/dest/avm/index.d.ts.map +1 -0
- package/dest/avm/index.js +2 -0
- package/dest/avm/journal/host_storage.d.ts +1 -1
- package/dest/avm/journal/host_storage.d.ts.map +1 -1
- package/dest/avm/journal/journal.d.ts +4 -3
- package/dest/avm/journal/journal.d.ts.map +1 -1
- package/dest/avm/journal/journal.js +10 -11
- package/dest/avm/journal/nullifiers.d.ts +17 -5
- package/dest/avm/journal/nullifiers.d.ts.map +1 -1
- package/dest/avm/journal/nullifiers.js +27 -10
- package/dest/avm/journal/public_storage.d.ts +19 -6
- package/dest/avm/journal/public_storage.d.ts.map +1 -1
- package/dest/avm/journal/public_storage.js +30 -12
- package/dest/avm/journal/trace.d.ts +2 -0
- package/dest/avm/journal/trace.d.ts.map +1 -1
- package/dest/avm/journal/trace.js +7 -1
- package/dest/avm/journal/trace_types.d.ts +1 -0
- package/dest/avm/journal/trace_types.d.ts.map +1 -1
- package/dest/avm/journal/trace_types.js +1 -1
- package/dest/avm/opcodes/accrued_substate.d.ts.map +1 -1
- package/dest/avm/opcodes/accrued_substate.js +6 -7
- package/dest/avm/opcodes/arithmetic.d.ts +1 -7
- package/dest/avm/opcodes/arithmetic.d.ts.map +1 -1
- package/dest/avm/opcodes/arithmetic.js +1 -12
- package/dest/avm/opcodes/conversion.js +2 -2
- package/dest/avm/opcodes/external_calls.d.ts +2 -2
- package/dest/avm/opcodes/external_calls.d.ts.map +1 -1
- package/dest/avm/opcodes/external_calls.js +25 -13
- package/dest/avm/opcodes/instruction.d.ts +1 -1
- package/dest/avm/opcodes/instruction.d.ts.map +1 -1
- package/dest/avm/opcodes/instruction.js +6 -4
- package/dest/avm/opcodes/memory.d.ts +0 -4
- package/dest/avm/opcodes/memory.d.ts.map +1 -1
- package/dest/avm/opcodes/memory.js +1 -7
- package/dest/avm/opcodes/storage.d.ts +0 -12
- package/dest/avm/opcodes/storage.d.ts.map +1 -1
- package/dest/avm/opcodes/storage.js +3 -18
- package/dest/avm/serialization/bytecode_serialization.js +2 -2
- package/dest/client/client_execution_context.d.ts +30 -20
- package/dest/client/client_execution_context.d.ts.map +1 -1
- package/dest/client/client_execution_context.js +59 -39
- package/dest/client/db_oracle.d.ts +17 -12
- package/dest/client/db_oracle.d.ts.map +1 -1
- package/dest/client/execution_note_cache.js +2 -2
- package/dest/client/execution_result.d.ts +17 -2
- package/dest/client/execution_result.d.ts.map +1 -1
- package/dest/client/execution_result.js +32 -4
- package/dest/client/private_execution.d.ts +2 -3
- package/dest/client/private_execution.d.ts.map +1 -1
- package/dest/client/private_execution.js +22 -8
- package/dest/client/simulator.d.ts +0 -16
- package/dest/client/simulator.d.ts.map +1 -1
- package/dest/client/simulator.js +13 -30
- package/dest/client/unconstrained_execution.d.ts +2 -3
- package/dest/client/unconstrained_execution.d.ts.map +1 -1
- package/dest/client/unconstrained_execution.js +5 -7
- package/dest/client/view_data_oracle.d.ts +12 -10
- package/dest/client/view_data_oracle.d.ts.map +1 -1
- package/dest/client/view_data_oracle.js +17 -11
- package/dest/common/index.d.ts +1 -0
- package/dest/common/index.d.ts.map +1 -1
- package/dest/common/index.js +2 -1
- package/dest/common/return_values.d.ts +11 -0
- package/dest/common/return_values.d.ts.map +1 -0
- package/dest/common/return_values.js +13 -0
- package/dest/index.d.ts +3 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +4 -2
- package/dest/mocks/fixtures.d.ts +15 -10
- package/dest/mocks/fixtures.d.ts.map +1 -1
- package/dest/mocks/fixtures.js +22 -17
- package/dest/{simulator → providers}/acvm_native.d.ts.map +1 -1
- package/dest/{simulator → providers}/acvm_native.js +13 -14
- package/dest/providers/acvm_wasm.d.ts.map +1 -0
- package/dest/providers/acvm_wasm.js +15 -0
- package/dest/providers/index.d.ts.map +1 -0
- package/dest/{simulator → providers}/index.js +1 -1
- package/dest/{simulator → providers}/simulation_provider.d.ts.map +1 -1
- package/dest/{simulator → providers}/simulation_provider.js +1 -1
- package/dest/public/abstract_phase_manager.d.ts +43 -42
- package/dest/public/abstract_phase_manager.d.ts.map +1 -1
- package/dest/public/abstract_phase_manager.js +81 -103
- package/dest/public/app_logic_phase_manager.d.ts +7 -8
- package/dest/public/app_logic_phase_manager.d.ts.map +1 -1
- package/dest/public/app_logic_phase_manager.js +14 -14
- package/dest/public/{db.d.ts → db_interfaces.d.ts} +3 -3
- package/dest/public/db_interfaces.d.ts.map +1 -0
- package/dest/public/db_interfaces.js +2 -0
- package/dest/public/execution.d.ts +17 -14
- package/dest/public/execution.d.ts.map +1 -1
- package/dest/public/execution.js +1 -1
- package/dest/public/executor.d.ts +3 -30
- package/dest/public/executor.d.ts.map +1 -1
- package/dest/public/executor.js +32 -279
- package/dest/public/fee_payment.d.ts +11 -0
- package/dest/public/fee_payment.d.ts.map +1 -0
- package/dest/public/fee_payment.js +24 -0
- package/dest/public/hints_builder.d.ts +3 -2
- package/dest/public/hints_builder.d.ts.map +1 -1
- package/dest/public/hints_builder.js +8 -4
- package/dest/public/index.d.ts +4 -2
- package/dest/public/index.d.ts.map +1 -1
- package/dest/public/index.js +5 -3
- package/dest/public/phase_manager_factory.d.ts +1 -1
- package/dest/public/phase_manager_factory.d.ts.map +1 -1
- package/dest/public/{public_executor.d.ts → public_db_sources.d.ts} +3 -2
- package/dest/public/public_db_sources.d.ts.map +1 -0
- package/dest/public/public_db_sources.js +198 -0
- package/dest/public/public_kernel.js +14 -14
- package/dest/public/public_processor.d.ts +8 -6
- package/dest/public/public_processor.d.ts.map +1 -1
- package/dest/public/public_processor.js +48 -29
- package/dest/public/setup_phase_manager.d.ts +7 -9
- package/dest/public/setup_phase_manager.d.ts.map +1 -1
- package/dest/public/setup_phase_manager.js +11 -20
- package/dest/public/tail_phase_manager.d.ts +5 -11
- package/dest/public/tail_phase_manager.d.ts.map +1 -1
- package/dest/public/tail_phase_manager.js +16 -36
- package/dest/public/teardown_phase_manager.d.ts +7 -9
- package/dest/public/teardown_phase_manager.d.ts.map +1 -1
- package/dest/public/teardown_phase_manager.js +15 -21
- package/dest/public/transitional_adaptors.d.ts +3 -2
- package/dest/public/transitional_adaptors.d.ts.map +1 -1
- package/dest/public/transitional_adaptors.js +24 -8
- package/dest/public/utils.d.ts +2 -2
- package/dest/public/utils.d.ts.map +1 -1
- package/dest/public/utils.js +21 -14
- package/package.json +12 -9
- package/src/acvm/acvm.ts +0 -3
- package/src/acvm/oracle/oracle.ts +53 -27
- package/src/acvm/oracle/typed_oracle.ts +25 -16
- package/src/acvm/serialize.ts +1 -1
- package/src/avm/avm_execution_environment.ts +9 -5
- package/src/avm/avm_gas.ts +66 -73
- package/src/avm/avm_simulator.ts +14 -3
- package/src/avm/errors.ts +10 -0
- package/src/avm/fixtures/index.ts +22 -2
- package/src/avm/index.ts +1 -0
- package/src/avm/journal/host_storage.ts +1 -1
- package/src/avm/journal/journal.ts +15 -14
- package/src/avm/journal/nullifiers.ts +27 -14
- package/src/avm/journal/public_storage.ts +30 -16
- package/src/avm/journal/trace.ts +12 -0
- package/src/avm/journal/trace_types.ts +1 -0
- package/src/avm/opcodes/accrued_substate.ts +5 -6
- package/src/avm/opcodes/arithmetic.ts +1 -14
- package/src/avm/opcodes/conversion.ts +1 -1
- package/src/avm/opcodes/external_calls.ts +26 -10
- package/src/avm/opcodes/instruction.ts +5 -3
- package/src/avm/opcodes/memory.ts +1 -8
- package/src/avm/opcodes/storage.ts +3 -20
- package/src/avm/serialization/bytecode_serialization.ts +1 -1
- package/src/client/client_execution_context.ts +70 -44
- package/src/client/db_oracle.ts +18 -12
- package/src/client/execution_note_cache.ts +1 -1
- package/src/client/execution_result.ts +41 -3
- package/src/client/private_execution.ts +38 -20
- package/src/client/simulator.ts +11 -32
- package/src/client/unconstrained_execution.ts +9 -12
- package/src/client/view_data_oracle.ts +20 -12
- package/src/common/index.ts +1 -0
- package/src/common/return_values.ts +18 -0
- package/src/index.ts +3 -1
- package/src/mocks/fixtures.ts +31 -33
- package/src/{simulator → providers}/acvm_native.ts +21 -19
- package/src/{simulator → providers}/acvm_wasm.ts +2 -16
- package/src/public/abstract_phase_manager.ts +146 -207
- package/src/public/app_logic_phase_manager.ts +23 -39
- package/src/public/{db.ts → db_interfaces.ts} +2 -2
- package/src/public/execution.ts +17 -14
- package/src/public/executor.ts +51 -391
- package/src/public/fee_payment.ts +26 -0
- package/src/public/hints_builder.ts +17 -3
- package/src/public/index.ts +4 -2
- package/src/public/phase_manager_factory.ts +1 -1
- package/src/public/{public_executor.ts → public_db_sources.ts} +3 -2
- package/src/public/public_kernel.ts +24 -24
- package/src/public/public_processor.ts +82 -38
- package/src/public/setup_phase_manager.ts +20 -45
- package/src/public/tail_phase_manager.ts +18 -68
- package/src/public/teardown_phase_manager.ts +22 -41
- package/src/public/transitional_adaptors.ts +24 -13
- package/src/public/utils.ts +20 -14
- package/dest/client/logs_cache.d.ts +0 -33
- package/dest/client/logs_cache.d.ts.map +0 -1
- package/dest/client/logs_cache.js +0 -59
- package/dest/public/db.d.ts.map +0 -1
- package/dest/public/db.js +0 -2
- package/dest/public/public_execution_context.d.ts +0 -121
- package/dest/public/public_execution_context.d.ts.map +0 -1
- package/dest/public/public_execution_context.js +0 -214
- package/dest/public/public_executor.d.ts.map +0 -1
- package/dest/public/public_executor.js +0 -197
- package/dest/public/state_actions.d.ts +0 -39
- package/dest/public/state_actions.d.ts.map +0 -1
- package/dest/public/state_actions.js +0 -80
- package/dest/simulator/acvm_wasm.d.ts.map +0 -1
- package/dest/simulator/acvm_wasm.js +0 -22
- package/dest/simulator/index.d.ts.map +0 -1
- package/src/client/logs_cache.ts +0 -65
- package/src/public/public_execution_context.ts +0 -289
- package/src/public/state_actions.ts +0 -102
- /package/dest/{simulator → providers}/acvm_native.d.ts +0 -0
- /package/dest/{simulator → providers}/acvm_wasm.d.ts +0 -0
- /package/dest/{simulator → providers}/index.d.ts +0 -0
- /package/dest/{simulator → providers}/simulation_provider.d.ts +0 -0
- /package/src/{simulator → providers}/index.ts +0 -0
- /package/src/{simulator → providers}/simulation_provider.ts +0 -0
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
type AuthWitness,
|
|
3
3
|
type AztecNode,
|
|
4
|
-
EncryptedFunctionL2Logs,
|
|
5
4
|
EncryptedL2Log,
|
|
5
|
+
EncryptedL2NoteLog,
|
|
6
6
|
L1NotePayload,
|
|
7
7
|
Note,
|
|
8
8
|
type NoteStatus,
|
|
9
9
|
TaggedNote,
|
|
10
|
-
UnencryptedFunctionL2Logs,
|
|
11
10
|
type UnencryptedL2Log,
|
|
12
11
|
} from '@aztec/circuit-types';
|
|
13
12
|
import {
|
|
14
13
|
CallContext,
|
|
15
|
-
FunctionData,
|
|
16
14
|
FunctionSelector,
|
|
17
15
|
type Header,
|
|
16
|
+
type KeyValidationRequest,
|
|
18
17
|
PrivateContextInputs,
|
|
19
18
|
PublicCallRequest,
|
|
20
19
|
type TxContext,
|
|
@@ -22,16 +21,16 @@ import {
|
|
|
22
21
|
import { Aes128 } from '@aztec/circuits.js/barretenberg';
|
|
23
22
|
import { computePublicDataTreeLeafSlot, computeUniqueNoteHash, siloNoteHash } from '@aztec/circuits.js/hash';
|
|
24
23
|
import { type FunctionAbi, type FunctionArtifact, countArgumentsSize } from '@aztec/foundation/abi';
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
24
|
+
import { AztecAddress } from '@aztec/foundation/aztec-address';
|
|
25
|
+
import { pedersenHash } from '@aztec/foundation/crypto';
|
|
26
|
+
import { Fr, GrumpkinScalar, type Point } from '@aztec/foundation/fields';
|
|
27
27
|
import { applyStringFormatting, createDebugLogger } from '@aztec/foundation/log';
|
|
28
28
|
|
|
29
29
|
import { type NoteData, toACVMWitness } from '../acvm/index.js';
|
|
30
30
|
import { type PackedValuesCache } from '../common/packed_values_cache.js';
|
|
31
31
|
import { type DBOracle } from './db_oracle.js';
|
|
32
32
|
import { type ExecutionNoteCache } from './execution_note_cache.js';
|
|
33
|
-
import { CountedLog, type ExecutionResult, type NoteAndSlot } from './execution_result.js';
|
|
34
|
-
import { type LogsCache } from './logs_cache.js';
|
|
33
|
+
import { CountedLog, CountedNoteLog, type ExecutionResult, type NoteAndSlot } from './execution_result.js';
|
|
35
34
|
import { pickNotes } from './pick_notes.js';
|
|
36
35
|
import { executePrivateFunction } from './private_execution.js';
|
|
37
36
|
import { ViewDataOracle } from './view_data_oracle.js';
|
|
@@ -59,6 +58,7 @@ export class ClientExecutionContext extends ViewDataOracle {
|
|
|
59
58
|
*/
|
|
60
59
|
private noteHashLeafIndexMap: Map<bigint, bigint> = new Map();
|
|
61
60
|
private nullifiedNoteHashCounters: Map<number, number> = new Map();
|
|
61
|
+
private noteEncryptedLogs: CountedNoteLog[] = [];
|
|
62
62
|
private encryptedLogs: CountedLog<EncryptedL2Log>[] = [];
|
|
63
63
|
private unencryptedLogs: CountedLog<UnencryptedL2Log>[] = [];
|
|
64
64
|
private nestedExecutions: ExecutionResult[] = [];
|
|
@@ -76,7 +76,6 @@ export class ClientExecutionContext extends ViewDataOracle {
|
|
|
76
76
|
authWitnesses: AuthWitness[],
|
|
77
77
|
private readonly packedValuesCache: PackedValuesCache,
|
|
78
78
|
private readonly noteCache: ExecutionNoteCache,
|
|
79
|
-
private readonly logsCache: LogsCache,
|
|
80
79
|
db: DBOracle,
|
|
81
80
|
private node: AztecNode,
|
|
82
81
|
protected sideEffectCounter: number = 0,
|
|
@@ -133,17 +132,17 @@ export class ClientExecutionContext extends ViewDataOracle {
|
|
|
133
132
|
}
|
|
134
133
|
|
|
135
134
|
/**
|
|
136
|
-
* Return the encrypted logs emitted during this execution.
|
|
135
|
+
* Return the note encrypted logs emitted during this execution.
|
|
137
136
|
*/
|
|
138
|
-
public
|
|
139
|
-
return this.
|
|
137
|
+
public getNoteEncryptedLogs() {
|
|
138
|
+
return this.noteEncryptedLogs;
|
|
140
139
|
}
|
|
141
140
|
|
|
142
141
|
/**
|
|
143
|
-
* Return the encrypted logs emitted during this execution
|
|
142
|
+
* Return the encrypted logs emitted during this execution.
|
|
144
143
|
*/
|
|
145
|
-
public
|
|
146
|
-
return
|
|
144
|
+
public getEncryptedLogs() {
|
|
145
|
+
return this.encryptedLogs;
|
|
147
146
|
}
|
|
148
147
|
|
|
149
148
|
/**
|
|
@@ -153,13 +152,6 @@ export class ClientExecutionContext extends ViewDataOracle {
|
|
|
153
152
|
return this.unencryptedLogs;
|
|
154
153
|
}
|
|
155
154
|
|
|
156
|
-
/**
|
|
157
|
-
* Return the unencrypted logs emitted during this execution and nested executions.
|
|
158
|
-
*/
|
|
159
|
-
public getAllUnencryptedLogs() {
|
|
160
|
-
return new UnencryptedFunctionL2Logs(this.logsCache.getUnencryptedLogs());
|
|
161
|
-
}
|
|
162
|
-
|
|
163
155
|
/**
|
|
164
156
|
* Return the nested execution results during this execution.
|
|
165
157
|
*/
|
|
@@ -337,29 +329,63 @@ export class ClientExecutionContext extends ViewDataOracle {
|
|
|
337
329
|
}
|
|
338
330
|
|
|
339
331
|
/**
|
|
340
|
-
*
|
|
332
|
+
* Emit encrypted data
|
|
333
|
+
* @param encryptedNote - The encrypted data.
|
|
334
|
+
* @param counter - The effects counter.
|
|
335
|
+
*/
|
|
336
|
+
public override emitEncryptedLog(
|
|
337
|
+
contractAddress: AztecAddress,
|
|
338
|
+
randomness: Fr,
|
|
339
|
+
encryptedData: Buffer,
|
|
340
|
+
counter: number,
|
|
341
|
+
) {
|
|
342
|
+
// In some cases, we actually want to reveal the contract address we are siloing with:
|
|
343
|
+
// e.g. 'handshaking' contract w/ known address
|
|
344
|
+
// An app providing randomness = 0 signals to not mask the address.
|
|
345
|
+
const maskedContractAddress = randomness.isZero()
|
|
346
|
+
? contractAddress.toField()
|
|
347
|
+
: pedersenHash([contractAddress, randomness], 0);
|
|
348
|
+
const encryptedLog = new CountedLog(new EncryptedL2Log(encryptedData, maskedContractAddress), counter);
|
|
349
|
+
this.encryptedLogs.push(encryptedLog);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* Emit encrypted note data
|
|
354
|
+
* @param noteHashCounter - The note hash counter.
|
|
355
|
+
* @param encryptedNote - The encrypted note data.
|
|
356
|
+
* @param counter - The log counter.
|
|
357
|
+
*/
|
|
358
|
+
public override emitEncryptedNoteLog(noteHashCounter: number, encryptedNote: Buffer, counter: number) {
|
|
359
|
+
const encryptedLog = new CountedNoteLog(new EncryptedL2NoteLog(encryptedNote), counter, noteHashCounter);
|
|
360
|
+
this.noteEncryptedLogs.push(encryptedLog);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* Encrypt a note
|
|
341
365
|
* @param contractAddress - The contract address of the note.
|
|
342
366
|
* @param storageSlot - The storage slot the note is at.
|
|
343
367
|
* @param noteTypeId - The type ID of the note.
|
|
344
|
-
* @param
|
|
345
|
-
* @param
|
|
368
|
+
* @param ovKeys - The outgoing viewing keys to use to encrypt.
|
|
369
|
+
* @param ivpkM - The master incoming viewing public key.
|
|
370
|
+
* @param preimage - The note preimage.
|
|
346
371
|
*/
|
|
347
|
-
public override
|
|
372
|
+
public override computeEncryptedLog(
|
|
348
373
|
contractAddress: AztecAddress,
|
|
349
374
|
storageSlot: Fr,
|
|
350
375
|
noteTypeId: Fr,
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
376
|
+
ovKeys: KeyValidationRequest,
|
|
377
|
+
ivpkM: Point,
|
|
378
|
+
preimage: Fr[],
|
|
354
379
|
) {
|
|
355
|
-
const note = new Note(
|
|
380
|
+
const note = new Note(preimage);
|
|
356
381
|
const l1NotePayload = new L1NotePayload(note, contractAddress, storageSlot, noteTypeId);
|
|
357
382
|
const taggedNote = new TaggedNote(l1NotePayload);
|
|
358
|
-
|
|
359
|
-
const
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
383
|
+
|
|
384
|
+
const ephSk = GrumpkinScalar.random();
|
|
385
|
+
|
|
386
|
+
const recipient = AztecAddress.random();
|
|
387
|
+
|
|
388
|
+
return taggedNote.encrypt(ephSk, recipient, ivpkM, ovKeys);
|
|
363
389
|
}
|
|
364
390
|
|
|
365
391
|
/**
|
|
@@ -368,7 +394,6 @@ export class ClientExecutionContext extends ViewDataOracle {
|
|
|
368
394
|
*/
|
|
369
395
|
public override emitUnencryptedLog(log: UnencryptedL2Log, counter: number) {
|
|
370
396
|
this.unencryptedLogs.push(new CountedLog(log, counter));
|
|
371
|
-
this.logsCache.addUnencryptedLog(log);
|
|
372
397
|
const text = log.toHumanReadable();
|
|
373
398
|
this.log.verbose(`Emitted unencrypted log: "${text.length > 100 ? text.slice(0, 100) + '...' : text}"`);
|
|
374
399
|
}
|
|
@@ -382,7 +407,6 @@ export class ClientExecutionContext extends ViewDataOracle {
|
|
|
382
407
|
*/
|
|
383
408
|
public override emitContractClassUnencryptedLog(log: UnencryptedL2Log, counter: number) {
|
|
384
409
|
this.unencryptedLogs.push(new CountedLog(log, counter));
|
|
385
|
-
this.logsCache.addUnencryptedLog(log);
|
|
386
410
|
const text = log.toHumanReadable();
|
|
387
411
|
this.log.verbose(
|
|
388
412
|
`Emitted unencrypted log from ContractClassRegisterer: "${
|
|
@@ -397,10 +421,10 @@ export class ClientExecutionContext extends ViewDataOracle {
|
|
|
397
421
|
childExecutionResult.callStackItem.publicInputs.newNoteHashes.some(item => !item.isEmpty()) ||
|
|
398
422
|
childExecutionResult.callStackItem.publicInputs.newNullifiers.some(item => !item.isEmpty()) ||
|
|
399
423
|
childExecutionResult.callStackItem.publicInputs.newL2ToL1Msgs.some(item => !item.isEmpty()) ||
|
|
400
|
-
|
|
401
|
-
|
|
424
|
+
childExecutionResult.callStackItem.publicInputs.encryptedLogsHashes.some(item => !item.isEmpty()) ||
|
|
425
|
+
childExecutionResult.callStackItem.publicInputs.unencryptedLogsHashes.some(item => !item.isEmpty())
|
|
402
426
|
) {
|
|
403
|
-
throw new Error(`Static call cannot
|
|
427
|
+
throw new Error(`Static call cannot update the state, emit L2->L1 messages or generate logs`);
|
|
404
428
|
}
|
|
405
429
|
}
|
|
406
430
|
|
|
@@ -411,7 +435,7 @@ export class ClientExecutionContext extends ViewDataOracle {
|
|
|
411
435
|
* @param argsHash - The packed arguments to pass to the function.
|
|
412
436
|
* @param sideEffectCounter - The side effect counter at the start of the call.
|
|
413
437
|
* @param isStaticCall - Whether the call is a static call.
|
|
414
|
-
* @param
|
|
438
|
+
* @param isDelegateCall - Whether the call is a delegate call.
|
|
415
439
|
* @returns The execution result.
|
|
416
440
|
*/
|
|
417
441
|
override async callPrivateFunction(
|
|
@@ -429,7 +453,6 @@ export class ClientExecutionContext extends ViewDataOracle {
|
|
|
429
453
|
isStaticCall = isStaticCall || this.callContext.isStaticCall;
|
|
430
454
|
|
|
431
455
|
const targetArtifact = await this.db.getFunctionArtifact(targetContractAddress, functionSelector);
|
|
432
|
-
const targetFunctionData = FunctionData.fromAbi(targetArtifact);
|
|
433
456
|
|
|
434
457
|
const derivedTxContext = this.txContext.clone();
|
|
435
458
|
|
|
@@ -450,7 +473,6 @@ export class ClientExecutionContext extends ViewDataOracle {
|
|
|
450
473
|
this.authWitnesses,
|
|
451
474
|
this.packedValuesCache,
|
|
452
475
|
this.noteCache,
|
|
453
|
-
this.logsCache,
|
|
454
476
|
this.db,
|
|
455
477
|
this.node,
|
|
456
478
|
sideEffectCounter,
|
|
@@ -460,7 +482,7 @@ export class ClientExecutionContext extends ViewDataOracle {
|
|
|
460
482
|
context,
|
|
461
483
|
targetArtifact,
|
|
462
484
|
targetContractAddress,
|
|
463
|
-
|
|
485
|
+
functionSelector,
|
|
464
486
|
);
|
|
465
487
|
|
|
466
488
|
if (isStaticCall) {
|
|
@@ -514,7 +536,7 @@ export class ClientExecutionContext extends ViewDataOracle {
|
|
|
514
536
|
args,
|
|
515
537
|
callContext: derivedCallContext,
|
|
516
538
|
parentCallContext: this.callContext,
|
|
517
|
-
|
|
539
|
+
functionSelector,
|
|
518
540
|
contractAddress: targetContractAddress,
|
|
519
541
|
});
|
|
520
542
|
}
|
|
@@ -646,4 +668,8 @@ export class ClientExecutionContext extends ViewDataOracle {
|
|
|
646
668
|
public override debugLog(message: string, fields: Fr[]) {
|
|
647
669
|
this.log.verbose(`debug_log ${applyStringFormatting(message, fields)}`);
|
|
648
670
|
}
|
|
671
|
+
|
|
672
|
+
public getDebugFunctionName() {
|
|
673
|
+
return this.db.getDebugFunctionName(this.contractAddress, this.callContext.functionSelector);
|
|
674
|
+
}
|
|
649
675
|
}
|
package/src/client/db_oracle.ts
CHANGED
|
@@ -5,14 +5,14 @@ import {
|
|
|
5
5
|
type NullifierMembershipWitness,
|
|
6
6
|
type PublicDataWitness,
|
|
7
7
|
} from '@aztec/circuit-types';
|
|
8
|
-
import { type CompleteAddress, type Header } from '@aztec/circuits.js';
|
|
8
|
+
import { type CompleteAddress, type Header, type KeyValidationRequest } from '@aztec/circuits.js';
|
|
9
9
|
import { type FunctionArtifact, type FunctionSelector } from '@aztec/foundation/abi';
|
|
10
10
|
import { type AztecAddress } from '@aztec/foundation/aztec-address';
|
|
11
11
|
import { type Fr } from '@aztec/foundation/fields';
|
|
12
12
|
import { type ContractInstance } from '@aztec/types/contracts';
|
|
13
13
|
|
|
14
|
-
import { type NoteData
|
|
15
|
-
import { type CommitmentsDB } from '../public/
|
|
14
|
+
import { type NoteData } from '../acvm/index.js';
|
|
15
|
+
import { type CommitmentsDB } from '../public/db_interfaces.js';
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Error thrown when a contract is not found in the database.
|
|
@@ -45,10 +45,11 @@ export interface DBOracle extends CommitmentsDB {
|
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
47
|
* Retrieve the complete address associated to a given address.
|
|
48
|
-
* @param
|
|
48
|
+
* @param account - The account address.
|
|
49
49
|
* @returns A complete address associated with the input address.
|
|
50
|
+
* @throws An error if the account is not registered in the database.
|
|
50
51
|
*/
|
|
51
|
-
getCompleteAddress(
|
|
52
|
+
getCompleteAddress(account: AztecAddress): Promise<CompleteAddress>;
|
|
52
53
|
|
|
53
54
|
/**
|
|
54
55
|
* Retrieve the auth witness for a given message hash.
|
|
@@ -65,14 +66,12 @@ export interface DBOracle extends CommitmentsDB {
|
|
|
65
66
|
popCapsule(): Promise<Fr[]>;
|
|
66
67
|
|
|
67
68
|
/**
|
|
68
|
-
* Retrieve
|
|
69
|
-
*
|
|
70
|
-
* @
|
|
71
|
-
* @
|
|
72
|
-
* @returns A Promise that resolves to nullifier keys of a requested account and contract.
|
|
73
|
-
* @throws An error if the account is not registered in the database.
|
|
69
|
+
* Retrieve keys associated with a specific master public key and app address.
|
|
70
|
+
* @param pkMHash - The master public key hash.
|
|
71
|
+
* @returns A Promise that resolves to nullifier keys.
|
|
72
|
+
* @throws If the keys are not registered in the key store.
|
|
74
73
|
*/
|
|
75
|
-
|
|
74
|
+
getKeyValidationRequest(pkMHash: Fr, contractAddress: AztecAddress): Promise<KeyValidationRequest>;
|
|
76
75
|
|
|
77
76
|
/**
|
|
78
77
|
* Retrieves a set of notes stored in the database for a given contract address and storage slot.
|
|
@@ -96,6 +95,13 @@ export interface DBOracle extends CommitmentsDB {
|
|
|
96
95
|
*/
|
|
97
96
|
getFunctionArtifact(contractAddress: AztecAddress, selector: FunctionSelector): Promise<FunctionArtifact>;
|
|
98
97
|
|
|
98
|
+
/**
|
|
99
|
+
* Generates a stable function name for debug purposes.
|
|
100
|
+
* @param contractAddress - The contract address.
|
|
101
|
+
* @param selector - The corresponding function selector.
|
|
102
|
+
*/
|
|
103
|
+
getDebugFunctionName(contractAddress: AztecAddress, selector: FunctionSelector): Promise<string>;
|
|
104
|
+
|
|
99
105
|
/**
|
|
100
106
|
* Retrieves the artifact of a specified function within a given contract.
|
|
101
107
|
* The function is identified by its name, which is unique within a contract.
|
|
@@ -52,7 +52,7 @@ export class ExecutionNoteCache {
|
|
|
52
52
|
this.nullifiers.set(contractAddress.toBigInt(), nullifiers);
|
|
53
53
|
|
|
54
54
|
let nullifiedNoteHashCounter: number | undefined = undefined;
|
|
55
|
-
// Find and remove the matching new note if the emitted innerNoteHash is not empty.
|
|
55
|
+
// Find and remove the matching new note and log(s) if the emitted innerNoteHash is not empty.
|
|
56
56
|
if (!innerNoteHash.equals(Fr.ZERO)) {
|
|
57
57
|
const notes = this.newNotes.get(contractAddress.toBigInt()) ?? [];
|
|
58
58
|
const noteIndexToRemove = notes.findIndex(n => n.note.innerNoteHash.equals(innerNoteHash));
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
EncryptedFunctionL2Logs,
|
|
3
3
|
type EncryptedL2Log,
|
|
4
|
+
type EncryptedL2NoteLog,
|
|
5
|
+
EncryptedNoteFunctionL2Logs,
|
|
4
6
|
type Note,
|
|
5
7
|
UnencryptedFunctionL2Logs,
|
|
6
8
|
type UnencryptedL2Log,
|
|
@@ -22,7 +24,7 @@ export interface NoteAndSlot {
|
|
|
22
24
|
noteTypeId: Fr;
|
|
23
25
|
}
|
|
24
26
|
|
|
25
|
-
export class CountedLog<TLog extends UnencryptedL2Log | EncryptedL2Log> implements IsEmpty {
|
|
27
|
+
export class CountedLog<TLog extends UnencryptedL2Log | EncryptedL2NoteLog | EncryptedL2Log> implements IsEmpty {
|
|
26
28
|
constructor(public log: TLog, public counter: number) {}
|
|
27
29
|
|
|
28
30
|
isEmpty(): boolean {
|
|
@@ -30,6 +32,11 @@ export class CountedLog<TLog extends UnencryptedL2Log | EncryptedL2Log> implemen
|
|
|
30
32
|
}
|
|
31
33
|
}
|
|
32
34
|
|
|
35
|
+
export class CountedNoteLog extends CountedLog<EncryptedL2NoteLog> {
|
|
36
|
+
constructor(log: EncryptedL2NoteLog, counter: number, public noteHashCounter: number) {
|
|
37
|
+
super(log, counter);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
33
40
|
/**
|
|
34
41
|
* The result of executing a private function.
|
|
35
42
|
*/
|
|
@@ -58,6 +65,11 @@ export interface ExecutionResult {
|
|
|
58
65
|
enqueuedPublicFunctionCalls: PublicCallRequest[];
|
|
59
66
|
/** Public function execution requested for teardown */
|
|
60
67
|
publicTeardownFunctionCall: PublicCallRequest;
|
|
68
|
+
/**
|
|
69
|
+
* Encrypted note logs emitted during execution of this function call.
|
|
70
|
+
* Note: These are preimages to `noteEncryptedLogsHashes`.
|
|
71
|
+
*/
|
|
72
|
+
noteEncryptedLogs: CountedNoteLog[];
|
|
61
73
|
/**
|
|
62
74
|
* Encrypted logs emitted during execution of this function call.
|
|
63
75
|
* Note: These are preimages to `encryptedLogsHashes`.
|
|
@@ -82,13 +94,39 @@ export function collectNullifiedNoteHashCounters(execResult: ExecutionResult, ac
|
|
|
82
94
|
return accum;
|
|
83
95
|
}
|
|
84
96
|
|
|
97
|
+
/**
|
|
98
|
+
* Collect all encrypted logs across all nested executions.
|
|
99
|
+
* @param execResult - The topmost execution result.
|
|
100
|
+
* @returns All encrypted logs.
|
|
101
|
+
*/
|
|
102
|
+
function collectNoteEncryptedLogs(
|
|
103
|
+
execResult: ExecutionResult,
|
|
104
|
+
nullifiedNoteHashCounters: Map<number, number>,
|
|
105
|
+
): CountedLog<EncryptedL2NoteLog>[] {
|
|
106
|
+
return [
|
|
107
|
+
execResult.noteEncryptedLogs.filter(noteLog => !nullifiedNoteHashCounters.has(noteLog.noteHashCounter)),
|
|
108
|
+
...execResult.nestedExecutions.flatMap(res => collectNoteEncryptedLogs(res, nullifiedNoteHashCounters)),
|
|
109
|
+
].flat();
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Collect all encrypted logs across all nested executions and sorts by counter.
|
|
114
|
+
* @param execResult - The topmost execution result.
|
|
115
|
+
* @returns All encrypted logs.
|
|
116
|
+
*/
|
|
117
|
+
export function collectSortedNoteEncryptedLogs(execResult: ExecutionResult): EncryptedNoteFunctionL2Logs {
|
|
118
|
+
const nullifiedNoteHashCounters = collectNullifiedNoteHashCounters(execResult);
|
|
119
|
+
const allLogs = collectNoteEncryptedLogs(execResult, nullifiedNoteHashCounters);
|
|
120
|
+
const sortedLogs = sortByCounter(allLogs);
|
|
121
|
+
return new EncryptedNoteFunctionL2Logs(sortedLogs.map(l => l.log));
|
|
122
|
+
}
|
|
85
123
|
/**
|
|
86
124
|
* Collect all encrypted logs across all nested executions.
|
|
87
125
|
* @param execResult - The topmost execution result.
|
|
88
126
|
* @returns All encrypted logs.
|
|
89
127
|
*/
|
|
90
128
|
function collectEncryptedLogs(execResult: ExecutionResult): CountedLog<EncryptedL2Log>[] {
|
|
91
|
-
return [execResult.encryptedLogs, ...
|
|
129
|
+
return [execResult.encryptedLogs, ...execResult.nestedExecutions.flatMap(collectEncryptedLogs)].flat();
|
|
92
130
|
}
|
|
93
131
|
|
|
94
132
|
/**
|
|
@@ -108,7 +146,7 @@ export function collectSortedEncryptedLogs(execResult: ExecutionResult): Encrypt
|
|
|
108
146
|
* @returns All unencrypted logs.
|
|
109
147
|
*/
|
|
110
148
|
function collectUnencryptedLogs(execResult: ExecutionResult): CountedLog<UnencryptedL2Log>[] {
|
|
111
|
-
return [execResult.unencryptedLogs, ...
|
|
149
|
+
return [execResult.unencryptedLogs, ...execResult.nestedExecutions.flatMap(collectUnencryptedLogs)].flat();
|
|
112
150
|
}
|
|
113
151
|
|
|
114
152
|
/**
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import {
|
|
1
|
+
import { type CircuitWitnessGenerationStats } from '@aztec/circuit-types/stats';
|
|
2
|
+
import { Fr, FunctionData, PrivateCallStackItem, PrivateCircuitPublicInputs } from '@aztec/circuits.js';
|
|
3
|
+
import type { FunctionArtifact, FunctionSelector } from '@aztec/foundation/abi';
|
|
3
4
|
import { type AztecAddress } from '@aztec/foundation/aztec-address';
|
|
4
5
|
import { createDebugLogger } from '@aztec/foundation/log';
|
|
6
|
+
import { Timer } from '@aztec/foundation/timer';
|
|
5
7
|
|
|
6
8
|
import { witnessMapToFields } from '../acvm/deserialize.js';
|
|
7
9
|
import { Oracle, acvm, extractCallStack } from '../acvm/index.js';
|
|
8
10
|
import { ExecutionError } from '../common/errors.js';
|
|
9
11
|
import { type ClientExecutionContext } from './client_execution_context.js';
|
|
10
12
|
import { type ExecutionResult } from './execution_result.js';
|
|
11
|
-
import { AcirSimulator } from './simulator.js';
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* Execute a private function and return the execution result.
|
|
@@ -17,35 +18,51 @@ export async function executePrivateFunction(
|
|
|
17
18
|
context: ClientExecutionContext,
|
|
18
19
|
artifact: FunctionArtifact,
|
|
19
20
|
contractAddress: AztecAddress,
|
|
20
|
-
|
|
21
|
+
functionSelector: FunctionSelector,
|
|
21
22
|
log = createDebugLogger('aztec:simulator:secret_execution'),
|
|
22
23
|
): Promise<ExecutionResult> {
|
|
23
|
-
const
|
|
24
|
-
log.verbose(`Executing external function ${contractAddress}:${functionSelector}(${
|
|
24
|
+
const functionName = await context.getDebugFunctionName();
|
|
25
|
+
log.verbose(`Executing external function ${contractAddress}:${functionSelector}(${functionName})`);
|
|
25
26
|
const acir = artifact.bytecode;
|
|
26
27
|
const initialWitness = context.getInitialWitness(artifact);
|
|
27
28
|
const acvmCallback = new Oracle(context);
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
);
|
|
29
|
+
const timer = new Timer();
|
|
30
|
+
const acirExecutionResult = await acvm(acir, initialWitness, acvmCallback).catch((err: Error) => {
|
|
31
|
+
throw new ExecutionError(
|
|
32
|
+
err.message,
|
|
33
|
+
{
|
|
34
|
+
contractAddress,
|
|
35
|
+
functionSelector,
|
|
36
|
+
},
|
|
37
|
+
extractCallStack(err, artifact.debug),
|
|
38
|
+
{ cause: err },
|
|
39
|
+
);
|
|
40
|
+
});
|
|
41
|
+
const duration = timer.ms();
|
|
41
42
|
const partialWitness = acirExecutionResult.partialWitness;
|
|
42
43
|
const returnWitness = witnessMapToFields(acirExecutionResult.returnWitness);
|
|
43
44
|
const publicInputs = PrivateCircuitPublicInputs.fromFields(returnWitness);
|
|
44
45
|
|
|
46
|
+
// TODO (alexg) estimate this size
|
|
47
|
+
const initialWitnessSize = witnessMapToFields(initialWitness).length * Fr.SIZE_IN_BYTES;
|
|
48
|
+
log.debug(`Ran external function ${contractAddress.toString()}:${functionSelector}`, {
|
|
49
|
+
circuitName: 'app-circuit',
|
|
50
|
+
duration,
|
|
51
|
+
eventName: 'circuit-witness-generation',
|
|
52
|
+
inputSize: initialWitnessSize,
|
|
53
|
+
outputSize: publicInputs.toBuffer().length,
|
|
54
|
+
appCircuitName: functionName,
|
|
55
|
+
} satisfies CircuitWitnessGenerationStats);
|
|
56
|
+
|
|
57
|
+
const noteEncryptedLogs = context.getNoteEncryptedLogs();
|
|
45
58
|
const encryptedLogs = context.getEncryptedLogs();
|
|
46
59
|
const unencryptedLogs = context.getUnencryptedLogs();
|
|
47
60
|
|
|
48
|
-
const callStackItem = new PrivateCallStackItem(
|
|
61
|
+
const callStackItem = new PrivateCallStackItem(
|
|
62
|
+
contractAddress,
|
|
63
|
+
new FunctionData(functionSelector, true),
|
|
64
|
+
publicInputs,
|
|
65
|
+
);
|
|
49
66
|
|
|
50
67
|
const rawReturnValues = await context.unpackReturns(publicInputs.returnsHash);
|
|
51
68
|
|
|
@@ -69,6 +86,7 @@ export async function executePrivateFunction(
|
|
|
69
86
|
vk: Buffer.from(artifact.verificationKey!, 'hex'),
|
|
70
87
|
nestedExecutions,
|
|
71
88
|
enqueuedPublicFunctionCalls,
|
|
89
|
+
noteEncryptedLogs,
|
|
72
90
|
publicTeardownFunctionCall,
|
|
73
91
|
encryptedLogs,
|
|
74
92
|
unencryptedLogs,
|
package/src/client/simulator.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type AztecNode, type FunctionCall, type Note, type TxExecutionRequest } from '@aztec/circuit-types';
|
|
2
|
-
import { CallContext
|
|
2
|
+
import { CallContext } from '@aztec/circuits.js';
|
|
3
3
|
import {
|
|
4
4
|
type ArrayType,
|
|
5
5
|
type FunctionArtifact,
|
|
@@ -11,15 +11,12 @@ import { AztecAddress } from '@aztec/foundation/aztec-address';
|
|
|
11
11
|
import { Fr } from '@aztec/foundation/fields';
|
|
12
12
|
import { type DebugLogger, createDebugLogger } from '@aztec/foundation/log';
|
|
13
13
|
|
|
14
|
-
import { type WasmBlackBoxFunctionSolver, createBlackBoxSolver } from '@noir-lang/acvm_js';
|
|
15
|
-
|
|
16
14
|
import { createSimulationError } from '../common/errors.js';
|
|
17
15
|
import { PackedValuesCache } from '../common/packed_values_cache.js';
|
|
18
16
|
import { ClientExecutionContext } from './client_execution_context.js';
|
|
19
17
|
import { type DBOracle } from './db_oracle.js';
|
|
20
18
|
import { ExecutionNoteCache } from './execution_note_cache.js';
|
|
21
19
|
import { type ExecutionResult } from './execution_result.js';
|
|
22
|
-
import { LogsCache } from './logs_cache.js';
|
|
23
20
|
import { executePrivateFunction } from './private_execution.js';
|
|
24
21
|
import { executeUnconstrainedFunction } from './unconstrained_execution.js';
|
|
25
22
|
import { ViewDataOracle } from './view_data_oracle.js';
|
|
@@ -28,33 +25,12 @@ import { ViewDataOracle } from './view_data_oracle.js';
|
|
|
28
25
|
* The ACIR simulator.
|
|
29
26
|
*/
|
|
30
27
|
export class AcirSimulator {
|
|
31
|
-
private static solver: Promise<WasmBlackBoxFunctionSolver>; // ACVM's backend
|
|
32
28
|
private log: DebugLogger;
|
|
33
29
|
|
|
34
30
|
constructor(private db: DBOracle, private node: AztecNode) {
|
|
35
31
|
this.log = createDebugLogger('aztec:simulator');
|
|
36
32
|
}
|
|
37
33
|
|
|
38
|
-
/**
|
|
39
|
-
* Gets or initializes the ACVM WasmBlackBoxFunctionSolver.
|
|
40
|
-
*
|
|
41
|
-
* @remarks
|
|
42
|
-
*
|
|
43
|
-
* Occurs only once across all instances of AcirSimulator.
|
|
44
|
-
* Speeds up execution by only performing setup tasks (like pedersen
|
|
45
|
-
* generator initialization) one time.
|
|
46
|
-
* TODO(https://github.com/AztecProtocol/aztec-packages/issues/1627):
|
|
47
|
-
* determine whether this requires a lock
|
|
48
|
-
*
|
|
49
|
-
* @returns ACVM WasmBlackBoxFunctionSolver
|
|
50
|
-
*/
|
|
51
|
-
public static getSolver(): Promise<WasmBlackBoxFunctionSolver> {
|
|
52
|
-
if (!this.solver) {
|
|
53
|
-
this.solver = createBlackBoxSolver();
|
|
54
|
-
}
|
|
55
|
-
return this.solver;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
34
|
/**
|
|
59
35
|
* Runs a private function.
|
|
60
36
|
* @param request - The transaction request.
|
|
@@ -69,8 +45,8 @@ export class AcirSimulator {
|
|
|
69
45
|
contractAddress: AztecAddress,
|
|
70
46
|
msgSender = AztecAddress.ZERO,
|
|
71
47
|
): Promise<ExecutionResult> {
|
|
72
|
-
if (entryPointArtifact.functionType !== FunctionType.
|
|
73
|
-
throw new Error(`Cannot run ${entryPointArtifact.functionType} function as
|
|
48
|
+
if (entryPointArtifact.functionType !== FunctionType.PRIVATE) {
|
|
49
|
+
throw new Error(`Cannot run ${entryPointArtifact.functionType} function as private`);
|
|
74
50
|
}
|
|
75
51
|
|
|
76
52
|
if (request.origin !== contractAddress) {
|
|
@@ -89,7 +65,7 @@ export class AcirSimulator {
|
|
|
89
65
|
contractAddress,
|
|
90
66
|
FunctionSelector.fromNameAndParameters(entryPointArtifact.name, entryPointArtifact.parameters),
|
|
91
67
|
false,
|
|
92
|
-
|
|
68
|
+
entryPointArtifact.isStatic,
|
|
93
69
|
startSideEffectCounter,
|
|
94
70
|
);
|
|
95
71
|
const context = new ClientExecutionContext(
|
|
@@ -101,7 +77,6 @@ export class AcirSimulator {
|
|
|
101
77
|
request.authWitnesses,
|
|
102
78
|
PackedValuesCache.create(request.argsOfCalls),
|
|
103
79
|
new ExecutionNoteCache(),
|
|
104
|
-
new LogsCache(),
|
|
105
80
|
this.db,
|
|
106
81
|
this.node,
|
|
107
82
|
startSideEffectCounter,
|
|
@@ -112,7 +87,7 @@ export class AcirSimulator {
|
|
|
112
87
|
context,
|
|
113
88
|
entryPointArtifact,
|
|
114
89
|
contractAddress,
|
|
115
|
-
request.
|
|
90
|
+
request.functionSelector,
|
|
116
91
|
);
|
|
117
92
|
return executionResult;
|
|
118
93
|
} catch (err) {
|
|
@@ -143,7 +118,7 @@ export class AcirSimulator {
|
|
|
143
118
|
context,
|
|
144
119
|
entryPointArtifact,
|
|
145
120
|
contractAddress,
|
|
146
|
-
request.
|
|
121
|
+
request.selector,
|
|
147
122
|
request.args,
|
|
148
123
|
);
|
|
149
124
|
} catch (err) {
|
|
@@ -195,9 +170,13 @@ export class AcirSimulator {
|
|
|
195
170
|
const extendedNoteItems = note.items.concat(Array(maxNoteFields - note.items.length).fill(Fr.ZERO));
|
|
196
171
|
|
|
197
172
|
const execRequest: FunctionCall = {
|
|
173
|
+
name: artifact.name,
|
|
198
174
|
to: contractAddress,
|
|
199
|
-
|
|
175
|
+
selector: FunctionSelector.empty(),
|
|
176
|
+
type: FunctionType.UNCONSTRAINED,
|
|
177
|
+
isStatic: artifact.isStatic,
|
|
200
178
|
args: encodeArguments(artifact, [contractAddress, nonce, storageSlot, noteTypeId, extendedNoteItems]),
|
|
179
|
+
returnTypes: artifact.returnTypes,
|
|
201
180
|
};
|
|
202
181
|
|
|
203
182
|
const [innerNoteHash, uniqueNoteHash, siloedNoteHash, innerNullifier] = (await this.runUnconstrained(
|