@aztec/simulator 0.65.2 → 0.67.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.js +3 -3
- package/dest/acvm/oracle/oracle.d.ts +1 -4
- package/dest/acvm/oracle/oracle.d.ts.map +1 -1
- package/dest/acvm/oracle/oracle.js +3 -19
- package/dest/acvm/oracle/typed_oracle.d.ts +2 -7
- package/dest/acvm/oracle/typed_oracle.d.ts.map +1 -1
- package/dest/acvm/oracle/typed_oracle.js +3 -12
- package/dest/acvm/serialize.js +2 -2
- package/dest/avm/avm_context.d.ts +2 -2
- package/dest/avm/avm_context.d.ts.map +1 -1
- package/dest/avm/avm_context.js +3 -4
- package/dest/avm/avm_execution_environment.d.ts +4 -6
- package/dest/avm/avm_execution_environment.d.ts.map +1 -1
- package/dest/avm/avm_execution_environment.js +8 -13
- package/dest/avm/avm_memory_types.d.ts +2 -2
- package/dest/avm/avm_memory_types.d.ts.map +1 -1
- package/dest/avm/avm_memory_types.js +7 -7
- package/dest/avm/avm_simulator.d.ts +3 -3
- package/dest/avm/avm_simulator.d.ts.map +1 -1
- package/dest/avm/avm_simulator.js +26 -16
- package/dest/avm/avm_tree.d.ts +31 -14
- package/dest/avm/avm_tree.d.ts.map +1 -1
- package/dest/avm/avm_tree.js +34 -40
- package/dest/avm/errors.d.ts +3 -3
- package/dest/avm/errors.d.ts.map +1 -1
- package/dest/avm/errors.js +8 -15
- package/dest/avm/fixtures/index.d.ts.map +1 -1
- package/dest/avm/fixtures/index.js +4 -4
- package/dest/avm/journal/journal.d.ts +15 -4
- package/dest/avm/journal/journal.d.ts.map +1 -1
- package/dest/avm/journal/journal.js +121 -36
- package/dest/avm/opcodes/environment_getters.d.ts +10 -11
- package/dest/avm/opcodes/environment_getters.d.ts.map +1 -1
- package/dest/avm/opcodes/environment_getters.js +12 -15
- package/dest/avm/opcodes/external_calls.d.ts.map +1 -1
- package/dest/avm/opcodes/external_calls.js +4 -11
- package/dest/avm/opcodes/misc.d.ts.map +1 -1
- package/dest/avm/opcodes/misc.js +3 -3
- package/dest/client/client_execution_context.d.ts +6 -33
- package/dest/client/client_execution_context.d.ts.map +1 -1
- package/dest/client/client_execution_context.js +18 -54
- package/dest/client/db_oracle.d.ts +2 -2
- package/dest/client/db_oracle.d.ts.map +1 -1
- package/dest/client/execution_note_cache.d.ts +9 -1
- package/dest/client/execution_note_cache.d.ts.map +1 -1
- package/dest/client/execution_note_cache.js +10 -3
- package/dest/client/private_execution.d.ts.map +1 -1
- package/dest/client/private_execution.js +5 -7
- package/dest/client/simulator.d.ts.map +1 -1
- package/dest/client/simulator.js +4 -4
- package/dest/client/unconstrained_execution.d.ts.map +1 -1
- package/dest/client/unconstrained_execution.js +3 -3
- package/dest/client/view_data_oracle.d.ts +2 -2
- package/dest/client/view_data_oracle.d.ts.map +1 -1
- package/dest/client/view_data_oracle.js +5 -6
- package/dest/common/debug_fn_name.d.ts +2 -2
- package/dest/common/debug_fn_name.d.ts.map +1 -1
- package/dest/common/debug_fn_name.js +8 -14
- package/dest/providers/acvm_native.js +4 -4
- package/dest/providers/factory.d.ts +2 -2
- package/dest/providers/factory.d.ts.map +1 -1
- package/dest/providers/factory.js +4 -4
- package/dest/public/enqueued_call_side_effect_trace.d.ts +11 -23
- package/dest/public/enqueued_call_side_effect_trace.d.ts.map +1 -1
- package/dest/public/enqueued_call_side_effect_trace.js +51 -72
- package/dest/public/executor_metrics.d.ts.map +1 -1
- package/dest/public/executor_metrics.js +2 -5
- package/dest/public/fixtures/index.d.ts +25 -7
- package/dest/public/fixtures/index.d.ts.map +1 -1
- package/dest/public/fixtures/index.js +20 -17
- package/dest/public/index.d.ts +0 -1
- package/dest/public/index.d.ts.map +1 -1
- package/dest/public/index.js +1 -2
- package/dest/public/public_db_sources.d.ts.map +1 -1
- package/dest/public/public_db_sources.js +30 -16
- package/dest/public/public_processor.d.ts +7 -8
- package/dest/public/public_processor.d.ts.map +1 -1
- package/dest/public/public_processor.js +37 -26
- package/dest/public/public_processor_metrics.d.ts +1 -1
- package/dest/public/public_processor_metrics.d.ts.map +1 -1
- package/dest/public/public_tx_context.d.ts +13 -14
- package/dest/public/public_tx_context.d.ts.map +1 -1
- package/dest/public/public_tx_context.js +63 -54
- package/dest/public/public_tx_simulator.d.ts +2 -2
- package/dest/public/public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator.js +43 -25
- package/dest/public/side_effect_trace_interface.d.ts +4 -17
- package/dest/public/side_effect_trace_interface.d.ts.map +1 -1
- package/dest/public/transitional_adapters.d.ts +2 -6
- package/dest/public/transitional_adapters.d.ts.map +1 -1
- package/dest/public/transitional_adapters.js +29 -88
- package/package.json +16 -9
- package/src/acvm/acvm.ts +2 -2
- package/src/acvm/oracle/oracle.ts +2 -32
- package/src/acvm/oracle/typed_oracle.ts +3 -20
- package/src/acvm/serialize.ts +1 -1
- package/src/avm/avm_context.ts +2 -3
- package/src/avm/avm_execution_environment.ts +6 -31
- package/src/avm/avm_memory_types.ts +6 -6
- package/src/avm/avm_simulator.ts +28 -23
- package/src/avm/avm_tree.ts +67 -53
- package/src/avm/errors.ts +12 -14
- package/src/avm/fixtures/index.ts +2 -3
- package/src/avm/journal/journal.ts +206 -68
- package/src/avm/opcodes/environment_getters.ts +1 -4
- package/src/avm/opcodes/external_calls.ts +3 -19
- package/src/avm/opcodes/misc.ts +2 -2
- package/src/client/client_execution_context.ts +22 -68
- package/src/client/db_oracle.ts +2 -2
- package/src/client/execution_note_cache.ts +13 -3
- package/src/client/private_execution.ts +3 -7
- package/src/client/simulator.ts +4 -4
- package/src/client/unconstrained_execution.ts +2 -2
- package/src/client/view_data_oracle.ts +5 -6
- package/src/common/debug_fn_name.ts +7 -13
- package/src/providers/acvm_native.ts +3 -3
- package/src/providers/factory.ts +3 -3
- package/src/public/enqueued_call_side_effect_trace.ts +68 -90
- package/src/public/executor_metrics.ts +0 -4
- package/src/public/fixtures/index.ts +28 -17
- package/src/public/index.ts +0 -1
- package/src/public/public_db_sources.ts +32 -19
- package/src/public/public_processor.ts +52 -55
- package/src/public/public_processor_metrics.ts +1 -1
- package/src/public/public_tx_context.ts +89 -76
- package/src/public/public_tx_simulator.ts +58 -49
- package/src/public/side_effect_trace_interface.ts +8 -15
- package/src/public/transitional_adapters.ts +43 -215
- package/dest/public/dual_side_effect_trace.d.ts +0 -77
- package/dest/public/dual_side_effect_trace.d.ts.map +0 -1
- package/dest/public/dual_side_effect_trace.js +0 -119
- package/dest/public/side_effect_trace.d.ts +0 -96
- package/dest/public/side_effect_trace.d.ts.map +0 -1
- package/dest/public/side_effect_trace.js +0 -309
- package/src/public/dual_side_effect_trace.ts +0 -242
- package/src/public/side_effect_trace.ts +0 -536
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
type AuthWitness,
|
|
3
3
|
type AztecNode,
|
|
4
|
-
|
|
5
|
-
CountedNoteLog,
|
|
4
|
+
CountedContractClassLog,
|
|
6
5
|
CountedPublicExecutionRequest,
|
|
7
|
-
EncryptedL2Log,
|
|
8
|
-
EncryptedL2NoteLog,
|
|
9
6
|
Note,
|
|
10
7
|
NoteAndSlot,
|
|
11
8
|
type NoteStatus,
|
|
@@ -14,9 +11,9 @@ import {
|
|
|
14
11
|
type UnencryptedL2Log,
|
|
15
12
|
} from '@aztec/circuit-types';
|
|
16
13
|
import {
|
|
14
|
+
type BlockHeader,
|
|
17
15
|
CallContext,
|
|
18
16
|
FunctionSelector,
|
|
19
|
-
type Header,
|
|
20
17
|
PRIVATE_CONTEXT_INPUTS_LENGTH,
|
|
21
18
|
PUBLIC_DISPATCH_SELECTOR,
|
|
22
19
|
PrivateContextInputs,
|
|
@@ -25,9 +22,8 @@ import {
|
|
|
25
22
|
import { computeUniqueNoteHash, siloNoteHash } from '@aztec/circuits.js/hash';
|
|
26
23
|
import { type FunctionAbi, type FunctionArtifact, type NoteSelector, countArgumentsSize } from '@aztec/foundation/abi';
|
|
27
24
|
import { AztecAddress } from '@aztec/foundation/aztec-address';
|
|
28
|
-
import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto';
|
|
29
25
|
import { Fr } from '@aztec/foundation/fields';
|
|
30
|
-
import { applyStringFormatting,
|
|
26
|
+
import { applyStringFormatting, createLogger } from '@aztec/foundation/log';
|
|
31
27
|
|
|
32
28
|
import { type NoteData, toACVMWitness } from '../acvm/index.js';
|
|
33
29
|
import { type PackedValuesCache } from '../common/packed_values_cache.js';
|
|
@@ -60,9 +56,7 @@ export class ClientExecutionContext extends ViewDataOracle {
|
|
|
60
56
|
*/
|
|
61
57
|
private noteHashLeafIndexMap: Map<bigint, bigint> = new Map();
|
|
62
58
|
private noteHashNullifierCounterMap: Map<number, number> = new Map();
|
|
63
|
-
private
|
|
64
|
-
private encryptedLogs: CountedLog<EncryptedL2Log>[] = [];
|
|
65
|
-
private contractClassLogs: CountedLog<UnencryptedL2Log>[] = [];
|
|
59
|
+
private contractClassLogs: CountedContractClassLog[] = [];
|
|
66
60
|
private nestedExecutions: PrivateExecutionResult[] = [];
|
|
67
61
|
private enqueuedPublicFunctionCalls: CountedPublicExecutionRequest[] = [];
|
|
68
62
|
private publicTeardownFunctionCall: PublicExecutionRequest = PublicExecutionRequest.empty();
|
|
@@ -72,7 +66,7 @@ export class ClientExecutionContext extends ViewDataOracle {
|
|
|
72
66
|
private readonly txContext: TxContext,
|
|
73
67
|
private readonly callContext: CallContext,
|
|
74
68
|
/** Header of a block whose state is used during private execution (not the block the transaction is included in). */
|
|
75
|
-
protected readonly historicalHeader:
|
|
69
|
+
protected readonly historicalHeader: BlockHeader,
|
|
76
70
|
/** List of transient auth witnesses to be used during this simulation */
|
|
77
71
|
authWitnesses: AuthWitness[],
|
|
78
72
|
private readonly packedValuesCache: PackedValuesCache,
|
|
@@ -80,7 +74,7 @@ export class ClientExecutionContext extends ViewDataOracle {
|
|
|
80
74
|
db: DBOracle,
|
|
81
75
|
private node: AztecNode,
|
|
82
76
|
protected sideEffectCounter: number = 0,
|
|
83
|
-
log =
|
|
77
|
+
log = createLogger('simulator:client_execution_context'),
|
|
84
78
|
scopes?: AztecAddress[],
|
|
85
79
|
) {
|
|
86
80
|
super(callContext.contractAddress, authWitnesses, db, node, log, scopes);
|
|
@@ -136,20 +130,6 @@ export class ClientExecutionContext extends ViewDataOracle {
|
|
|
136
130
|
return this.noteHashNullifierCounterMap;
|
|
137
131
|
}
|
|
138
132
|
|
|
139
|
-
/**
|
|
140
|
-
* Return the note encrypted logs emitted during this execution.
|
|
141
|
-
*/
|
|
142
|
-
public getNoteEncryptedLogs() {
|
|
143
|
-
return this.noteEncryptedLogs;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* Return the encrypted logs emitted during this execution.
|
|
148
|
-
*/
|
|
149
|
-
public getEncryptedLogs() {
|
|
150
|
-
return this.encryptedLogs;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
133
|
/**
|
|
154
134
|
* Return the contract class logs emitted during this execution.
|
|
155
135
|
*/
|
|
@@ -267,9 +247,10 @@ export class ClientExecutionContext extends ViewDataOracle {
|
|
|
267
247
|
|
|
268
248
|
notes.forEach(n => {
|
|
269
249
|
if (n.index !== undefined) {
|
|
270
|
-
const
|
|
271
|
-
const
|
|
272
|
-
|
|
250
|
+
const siloedNoteHash = siloNoteHash(n.contractAddress, n.noteHash);
|
|
251
|
+
const uniqueNoteHash = computeUniqueNoteHash(n.nonce, siloedNoteHash);
|
|
252
|
+
|
|
253
|
+
this.noteHashLeafIndexMap.set(uniqueNoteHash.toBigInt(), n.index);
|
|
273
254
|
}
|
|
274
255
|
});
|
|
275
256
|
|
|
@@ -326,49 +307,15 @@ export class ClientExecutionContext extends ViewDataOracle {
|
|
|
326
307
|
return Promise.resolve();
|
|
327
308
|
}
|
|
328
309
|
|
|
329
|
-
/**
|
|
330
|
-
* Emit encrypted data
|
|
331
|
-
* @param contractAddress - The contract emitting the encrypted event.
|
|
332
|
-
* @param randomness - A value used to mask the contract address we are siloing with.
|
|
333
|
-
* @param encryptedEvent - The encrypted event data.
|
|
334
|
-
* @param counter - The effects counter.
|
|
335
|
-
*/
|
|
336
|
-
public override emitEncryptedEventLog(
|
|
337
|
-
contractAddress: AztecAddress,
|
|
338
|
-
randomness: Fr,
|
|
339
|
-
encryptedEvent: 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
|
-
: poseidon2HashWithSeparator([contractAddress, randomness], 0);
|
|
348
|
-
const encryptedLog = new CountedLog(new EncryptedL2Log(encryptedEvent, 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
310
|
/**
|
|
364
311
|
* Emit a contract class unencrypted log.
|
|
365
|
-
* This fn exists
|
|
312
|
+
* This fn exists because sha hashing the preimage
|
|
366
313
|
* is too large to compile (16,200 fields, 518,400 bytes) => the oracle hashes it.
|
|
367
314
|
* See private_context.nr
|
|
368
315
|
* @param log - The unencrypted log to be emitted.
|
|
369
316
|
*/
|
|
370
317
|
public override emitContractClassLog(log: UnencryptedL2Log, counter: number) {
|
|
371
|
-
this.contractClassLogs.push(new
|
|
318
|
+
this.contractClassLogs.push(new CountedContractClassLog(log, counter));
|
|
372
319
|
const text = log.toHumanReadable();
|
|
373
320
|
this.log.verbose(
|
|
374
321
|
`Emitted log from ContractClassRegisterer: "${text.length > 100 ? text.slice(0, 100) + '...' : text}"`,
|
|
@@ -381,7 +328,7 @@ export class ClientExecutionContext extends ViewDataOracle {
|
|
|
381
328
|
childExecutionResult.publicInputs.noteHashes.some(item => !item.isEmpty()) ||
|
|
382
329
|
childExecutionResult.publicInputs.nullifiers.some(item => !item.isEmpty()) ||
|
|
383
330
|
childExecutionResult.publicInputs.l2ToL1Msgs.some(item => !item.isEmpty()) ||
|
|
384
|
-
childExecutionResult.publicInputs.
|
|
331
|
+
childExecutionResult.publicInputs.privateLogs.some(item => !item.isEmpty()) ||
|
|
385
332
|
childExecutionResult.publicInputs.contractClassLogsHashes.some(item => !item.isEmpty())
|
|
386
333
|
) {
|
|
387
334
|
throw new Error(`Static call cannot update the state, emit L2->L1 messages or generate logs`);
|
|
@@ -473,7 +420,14 @@ export class ClientExecutionContext extends ViewDataOracle {
|
|
|
473
420
|
const args = this.packedValuesCache.unpack(argsHash);
|
|
474
421
|
|
|
475
422
|
this.log.verbose(
|
|
476
|
-
`Created
|
|
423
|
+
`Created ${callType} public execution request to ${targetArtifact.name}@${targetContractAddress}`,
|
|
424
|
+
{
|
|
425
|
+
sideEffectCounter,
|
|
426
|
+
isStaticCall,
|
|
427
|
+
functionSelector,
|
|
428
|
+
targetContractAddress,
|
|
429
|
+
callType,
|
|
430
|
+
},
|
|
477
431
|
);
|
|
478
432
|
|
|
479
433
|
const request = PublicExecutionRequest.from({
|
|
@@ -591,7 +545,7 @@ export class ClientExecutionContext extends ViewDataOracle {
|
|
|
591
545
|
}
|
|
592
546
|
|
|
593
547
|
public override debugLog(message: string, fields: Fr[]) {
|
|
594
|
-
this.log.verbose(
|
|
548
|
+
this.log.verbose(`${applyStringFormatting(message, fields)}`, { module: `${this.log.module}:debug_log` });
|
|
595
549
|
}
|
|
596
550
|
|
|
597
551
|
public getDebugFunctionName() {
|
package/src/client/db_oracle.ts
CHANGED
|
@@ -8,9 +8,9 @@ import {
|
|
|
8
8
|
type TxScopedL2Log,
|
|
9
9
|
} from '@aztec/circuit-types';
|
|
10
10
|
import {
|
|
11
|
+
type BlockHeader,
|
|
11
12
|
type CompleteAddress,
|
|
12
13
|
type ContractInstance,
|
|
13
|
-
type Header,
|
|
14
14
|
type IndexedTaggingSecret,
|
|
15
15
|
type KeyValidationRequest,
|
|
16
16
|
} from '@aztec/circuits.js';
|
|
@@ -138,7 +138,7 @@ export interface DBOracle extends CommitmentsDB {
|
|
|
138
138
|
*
|
|
139
139
|
* @returns A Promise that resolves to a Header object.
|
|
140
140
|
*/
|
|
141
|
-
|
|
141
|
+
getBlockHeader(): Promise<BlockHeader>;
|
|
142
142
|
|
|
143
143
|
/**
|
|
144
144
|
* Fetch the index of the leaf in the respective tree
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { computeNoteHashNonce, computeUniqueNoteHash, siloNoteHash, siloNullifier } from '@aztec/circuits.js/hash';
|
|
2
2
|
import { type AztecAddress } from '@aztec/foundation/aztec-address';
|
|
3
|
-
import {
|
|
3
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
4
4
|
|
|
5
5
|
import { type NoteData } from '../acvm/index.js';
|
|
6
6
|
|
|
@@ -51,11 +51,11 @@ export class ExecutionNoteCache {
|
|
|
51
51
|
// The nonces will be used to create the "complete" nullifier.
|
|
52
52
|
const updatedNotes = this.notes.map(({ note, counter }, i) => {
|
|
53
53
|
const nonce = computeNoteHashNonce(this.txHash, i);
|
|
54
|
-
const uniqueNoteHash = computeUniqueNoteHash(nonce, note.noteHash);
|
|
54
|
+
const uniqueNoteHash = computeUniqueNoteHash(nonce, siloNoteHash(note.contractAddress, note.noteHash));
|
|
55
55
|
return {
|
|
56
56
|
counter,
|
|
57
57
|
note: { ...note, nonce },
|
|
58
|
-
noteHashForConsumption:
|
|
58
|
+
noteHashForConsumption: uniqueNoteHash,
|
|
59
59
|
};
|
|
60
60
|
});
|
|
61
61
|
// Rebuild the data.
|
|
@@ -146,4 +146,14 @@ export class ExecutionNoteCache {
|
|
|
146
146
|
notes.push(note);
|
|
147
147
|
this.noteMap.set(note.note.contractAddress.toBigInt(), notes);
|
|
148
148
|
}
|
|
149
|
+
|
|
150
|
+
getAllNotes(): PendingNote[] {
|
|
151
|
+
return this.notes;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
getAllNullifiers(): Fr[] {
|
|
155
|
+
return [...this.nullifierMap.values()].flatMap(nullifierArray =>
|
|
156
|
+
[...nullifierArray.values()].map(val => new Fr(val)),
|
|
157
|
+
);
|
|
158
|
+
}
|
|
149
159
|
}
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
} from '@aztec/circuits.js';
|
|
9
9
|
import { type FunctionArtifact, type FunctionSelector, countArgumentsSize } from '@aztec/foundation/abi';
|
|
10
10
|
import { type AztecAddress } from '@aztec/foundation/aztec-address';
|
|
11
|
-
import {
|
|
11
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
12
12
|
import { Timer } from '@aztec/foundation/timer';
|
|
13
13
|
|
|
14
14
|
import { fromACVMField, witnessMapToFields } from '../acvm/deserialize.js';
|
|
@@ -24,10 +24,10 @@ export async function executePrivateFunction(
|
|
|
24
24
|
artifact: FunctionArtifact,
|
|
25
25
|
contractAddress: AztecAddress,
|
|
26
26
|
functionSelector: FunctionSelector,
|
|
27
|
-
log =
|
|
27
|
+
log = createLogger('simulator:private_execution'),
|
|
28
28
|
): Promise<PrivateExecutionResult> {
|
|
29
29
|
const functionName = await context.getDebugFunctionName();
|
|
30
|
-
log.verbose(`Executing
|
|
30
|
+
log.verbose(`Executing private function ${functionName}@${contractAddress}`);
|
|
31
31
|
const acir = artifact.bytecode;
|
|
32
32
|
const initialWitness = context.getInitialWitness(artifact);
|
|
33
33
|
const acvmCallback = new Oracle(context);
|
|
@@ -59,8 +59,6 @@ export async function executePrivateFunction(
|
|
|
59
59
|
appCircuitName: functionName,
|
|
60
60
|
} satisfies CircuitWitnessGenerationStats);
|
|
61
61
|
|
|
62
|
-
const noteEncryptedLogs = context.getNoteEncryptedLogs();
|
|
63
|
-
const encryptedLogs = context.getEncryptedLogs();
|
|
64
62
|
const contractClassLogs = context.getContractClassLogs();
|
|
65
63
|
|
|
66
64
|
const rawReturnValues = await context.unpackReturns(publicInputs.returnsHash);
|
|
@@ -86,8 +84,6 @@ export async function executePrivateFunction(
|
|
|
86
84
|
nestedExecutions,
|
|
87
85
|
enqueuedPublicFunctionCalls,
|
|
88
86
|
publicTeardownFunctionCall,
|
|
89
|
-
noteEncryptedLogs,
|
|
90
|
-
encryptedLogs,
|
|
91
87
|
contractClassLogs,
|
|
92
88
|
);
|
|
93
89
|
}
|
package/src/client/simulator.ts
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
} from '@aztec/foundation/abi';
|
|
11
11
|
import { AztecAddress } from '@aztec/foundation/aztec-address';
|
|
12
12
|
import { Fr } from '@aztec/foundation/fields';
|
|
13
|
-
import { type
|
|
13
|
+
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
14
14
|
|
|
15
15
|
import { createSimulationError } from '../common/errors.js';
|
|
16
16
|
import { PackedValuesCache } from '../common/packed_values_cache.js';
|
|
@@ -25,10 +25,10 @@ import { ViewDataOracle } from './view_data_oracle.js';
|
|
|
25
25
|
* The ACIR simulator.
|
|
26
26
|
*/
|
|
27
27
|
export class AcirSimulator {
|
|
28
|
-
private log:
|
|
28
|
+
private log: Logger;
|
|
29
29
|
|
|
30
30
|
constructor(private db: DBOracle, private node: AztecNode) {
|
|
31
|
-
this.log =
|
|
31
|
+
this.log = createLogger('simulator');
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
/**
|
|
@@ -57,7 +57,7 @@ export class AcirSimulator {
|
|
|
57
57
|
);
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
const header = await this.db.
|
|
60
|
+
const header = await this.db.getBlockHeader();
|
|
61
61
|
|
|
62
62
|
// reserve the first side effect for the tx hash (inserted by the private kernel)
|
|
63
63
|
const startSideEffectCounter = 1;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type AbiDecoded, type FunctionArtifact, type FunctionSelector, decodeFromAbi } from '@aztec/foundation/abi';
|
|
2
2
|
import { type AztecAddress } from '@aztec/foundation/aztec-address';
|
|
3
3
|
import { type Fr } from '@aztec/foundation/fields';
|
|
4
|
-
import {
|
|
4
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
5
5
|
|
|
6
6
|
import { witnessMapToFields } from '../acvm/deserialize.js';
|
|
7
7
|
import { Oracle, acvm, extractCallStack, toACVMWitness } from '../acvm/index.js';
|
|
@@ -18,7 +18,7 @@ export async function executeUnconstrainedFunction(
|
|
|
18
18
|
contractAddress: AztecAddress,
|
|
19
19
|
functionSelector: FunctionSelector,
|
|
20
20
|
args: Fr[],
|
|
21
|
-
log =
|
|
21
|
+
log = createLogger('simulator:unconstrained_execution'),
|
|
22
22
|
): Promise<AbiDecoded> {
|
|
23
23
|
log.verbose(`Executing unconstrained function ${contractAddress}:${functionSelector}(${artifact.name})`);
|
|
24
24
|
|
|
@@ -8,15 +8,15 @@ import {
|
|
|
8
8
|
type PublicDataWitness,
|
|
9
9
|
} from '@aztec/circuit-types';
|
|
10
10
|
import {
|
|
11
|
+
type BlockHeader,
|
|
11
12
|
type ContractInstance,
|
|
12
|
-
type Header,
|
|
13
13
|
type IndexedTaggingSecret,
|
|
14
14
|
type KeyValidationRequest,
|
|
15
15
|
} from '@aztec/circuits.js';
|
|
16
16
|
import { siloNullifier } from '@aztec/circuits.js/hash';
|
|
17
17
|
import { AztecAddress } from '@aztec/foundation/aztec-address';
|
|
18
18
|
import { Fr } from '@aztec/foundation/fields';
|
|
19
|
-
import { applyStringFormatting,
|
|
19
|
+
import { applyStringFormatting, createLogger } from '@aztec/foundation/log';
|
|
20
20
|
|
|
21
21
|
import { type NoteData, TypedOracle } from '../acvm/index.js';
|
|
22
22
|
import { type DBOracle } from './db_oracle.js';
|
|
@@ -33,7 +33,7 @@ export class ViewDataOracle extends TypedOracle {
|
|
|
33
33
|
protected readonly authWitnesses: AuthWitness[],
|
|
34
34
|
protected readonly db: DBOracle,
|
|
35
35
|
protected readonly aztecNode: AztecNode,
|
|
36
|
-
protected log =
|
|
36
|
+
protected log = createLogger('simulator:client_view_context'),
|
|
37
37
|
protected readonly scopes?: AztecAddress[],
|
|
38
38
|
) {
|
|
39
39
|
super();
|
|
@@ -139,7 +139,7 @@ export class ViewDataOracle extends TypedOracle {
|
|
|
139
139
|
* @param blockNumber - The number of a block of which to get the block header.
|
|
140
140
|
* @returns Block extracted from a block with block number `blockNumber`.
|
|
141
141
|
*/
|
|
142
|
-
public override async
|
|
142
|
+
public override async getBlockHeader(blockNumber: number): Promise<BlockHeader | undefined> {
|
|
143
143
|
const block = await this.db.getBlock(blockNumber);
|
|
144
144
|
if (!block) {
|
|
145
145
|
return undefined;
|
|
@@ -290,8 +290,7 @@ export class ViewDataOracle extends TypedOracle {
|
|
|
290
290
|
}
|
|
291
291
|
|
|
292
292
|
public override debugLog(message: string, fields: Fr[]): void {
|
|
293
|
-
|
|
294
|
-
this.log.verbose(`debug_log ${formattedStr}`);
|
|
293
|
+
this.log.verbose(`${applyStringFormatting(message, fields)}`, { module: `${this.log.module}:debug_log` });
|
|
295
294
|
}
|
|
296
295
|
|
|
297
296
|
/**
|
|
@@ -1,22 +1,16 @@
|
|
|
1
|
-
import { type AztecAddress, Fr, FunctionSelector
|
|
1
|
+
import { type AztecAddress, type Fr, FunctionSelector } from '@aztec/circuits.js';
|
|
2
2
|
|
|
3
3
|
import { type WorldStateDB } from '../public/public_db_sources.js';
|
|
4
4
|
|
|
5
5
|
export async function getPublicFunctionDebugName(
|
|
6
6
|
db: WorldStateDB,
|
|
7
7
|
contractAddress: AztecAddress,
|
|
8
|
-
fn: FunctionSelector,
|
|
9
8
|
calldata: Fr[],
|
|
10
9
|
): Promise<string> {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
calldata[0]
|
|
16
|
-
|
|
17
|
-
: `<calldata[0] undefined>`;
|
|
18
|
-
return `${targetFunction} (via dispatch)`;
|
|
19
|
-
} else {
|
|
20
|
-
return (await db.getDebugFunctionName(contractAddress, fn)) ?? `${contractAddress}:${fn}`;
|
|
21
|
-
}
|
|
10
|
+
// Public function is dispatched and therefore the target function is passed in the first argument.
|
|
11
|
+
const targetFunction =
|
|
12
|
+
calldata[0] !== undefined
|
|
13
|
+
? await db.getDebugFunctionName(contractAddress, FunctionSelector.fromField(calldata[0]))
|
|
14
|
+
: `<calldata[0] undefined> (Contract Address: ${contractAddress})`;
|
|
15
|
+
return `${targetFunction}`;
|
|
22
16
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { runInDirectory } from '@aztec/foundation/fs';
|
|
2
|
-
import {
|
|
2
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
3
3
|
import { Timer } from '@aztec/foundation/timer';
|
|
4
4
|
import { type NoirCompiledCircuit } from '@aztec/types/noir';
|
|
5
5
|
|
|
6
6
|
import { type WitnessMap } from '@noir-lang/types';
|
|
7
7
|
import * as proc from 'child_process';
|
|
8
|
-
import fs from 'fs
|
|
8
|
+
import { promises as fs } from 'fs';
|
|
9
9
|
|
|
10
10
|
import { type SimulationProvider } from './simulation_provider.js';
|
|
11
11
|
|
|
12
|
-
const logger =
|
|
12
|
+
const logger = createLogger('simulator:acvm-native');
|
|
13
13
|
|
|
14
14
|
export enum ACVM_RESULT {
|
|
15
15
|
SUCCESS,
|
package/src/providers/factory.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { promises as fs } from 'fs';
|
|
4
4
|
|
|
5
5
|
import { NativeACVMSimulator } from './acvm_native.js';
|
|
6
6
|
import { WASMSimulator } from './acvm_wasm.js';
|
|
@@ -21,7 +21,7 @@ export function getSimulationProviderConfigFromEnv() {
|
|
|
21
21
|
|
|
22
22
|
export async function createSimulationProvider(
|
|
23
23
|
config: SimulationProviderConfig,
|
|
24
|
-
logger:
|
|
24
|
+
logger: Logger = createLogger('simulator'),
|
|
25
25
|
): Promise<SimulationProvider> {
|
|
26
26
|
if (config.acvmBinaryPath && config.acvmWorkingDirectory) {
|
|
27
27
|
try {
|