@aztec/simulator 0.66.0 → 0.67.1-devnet
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 +2 -2
- package/dest/acvm/oracle/oracle.d.ts.map +1 -1
- package/dest/acvm/oracle/oracle.js +5 -5
- package/dest/acvm/oracle/typed_oracle.d.ts +3 -3
- package/dest/acvm/oracle/typed_oracle.d.ts.map +1 -1
- package/dest/acvm/oracle/typed_oracle.js +5 -5
- 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 +3 -3
- package/dest/avm/avm_memory_types.d.ts.map +1 -1
- package/dest/avm/avm_memory_types.js +29 -29
- 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 +27 -15
- package/dest/avm/avm_tree.d.ts +2 -1
- package/dest/avm/avm_tree.d.ts.map +1 -1
- package/dest/avm/avm_tree.js +6 -2
- 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 +2 -0
- package/dest/avm/fixtures/index.d.ts.map +1 -1
- package/dest/avm/fixtures/index.js +7 -7
- package/dest/avm/journal/journal.d.ts +31 -8
- package/dest/avm/journal/journal.d.ts.map +1 -1
- package/dest/avm/journal/journal.js +139 -42
- package/dest/avm/opcodes/conversion.d.ts +4 -4
- package/dest/avm/opcodes/conversion.d.ts.map +1 -1
- package/dest/avm/opcodes/conversion.js +22 -18
- 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/avm/test_utils.d.ts +1 -0
- package/dest/avm/test_utils.d.ts.map +1 -1
- package/dest/avm/test_utils.js +4 -1
- package/dest/client/client_execution_context.d.ts +3 -3
- package/dest/client/client_execution_context.d.ts.map +1 -1
- package/dest/client/client_execution_context.js +15 -8
- package/dest/client/db_oracle.d.ts +9 -5
- 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/index.d.ts +1 -0
- package/dest/client/index.d.ts.map +1 -1
- package/dest/client/index.js +2 -1
- package/dest/client/private_execution.d.ts.map +1 -1
- package/dest/client/private_execution.js +4 -4
- 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 +4 -4
- package/dest/client/view_data_oracle.d.ts.map +1 -1
- package/dest/client/view_data_oracle.js +9 -9
- 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/acvm_wasm.js +2 -2
- 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/providers/index.d.ts +0 -1
- package/dest/providers/index.d.ts.map +1 -1
- package/dest/providers/index.js +1 -2
- package/dest/public/enqueued_call_side_effect_trace.d.ts +15 -26
- package/dest/public/enqueued_call_side_effect_trace.d.ts.map +1 -1
- package/dest/public/enqueued_call_side_effect_trace.js +42 -62
- package/dest/public/execution.d.ts +2 -2
- package/dest/public/execution.d.ts.map +1 -1
- package/dest/public/execution.js +1 -1
- package/dest/public/executor_metrics.d.ts.map +1 -1
- package/dest/public/executor_metrics.js +2 -5
- package/dest/public/fee_payment.d.ts.map +1 -1
- package/dest/public/fee_payment.js +4 -3
- package/dest/public/fixtures/index.d.ts +24 -1
- package/dest/public/fixtures/index.d.ts.map +1 -1
- package/dest/public/fixtures/index.js +17 -11
- 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 +10 -9
- package/dest/public/public_processor.d.ts +12 -12
- package/dest/public/public_processor.d.ts.map +1 -1
- package/dest/public/public_processor.js +80 -68
- 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 -10
- package/dest/public/public_tx_context.d.ts.map +1 -1
- package/dest/public/public_tx_context.js +72 -45
- 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 +54 -23
- package/dest/public/side_effect_trace_interface.d.ts +6 -18
- package/dest/public/side_effect_trace_interface.d.ts.map +1 -1
- package/dest/public/transitional_adapters.d.ts +2 -2
- package/dest/public/transitional_adapters.d.ts.map +1 -1
- package/dest/public/transitional_adapters.js +10 -39
- package/package.json +16 -9
- package/src/acvm/acvm.ts +2 -2
- package/src/acvm/oracle/oracle.ts +4 -4
- package/src/acvm/oracle/typed_oracle.ts +5 -5
- 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 +31 -29
- package/src/avm/avm_simulator.ts +28 -22
- package/src/avm/avm_tree.ts +6 -1
- package/src/avm/errors.ts +12 -14
- package/src/avm/fixtures/index.ts +6 -5
- package/src/avm/journal/journal.ts +230 -71
- package/src/avm/opcodes/conversion.ts +21 -16
- package/src/avm/opcodes/external_calls.ts +3 -19
- package/src/avm/opcodes/misc.ts +2 -2
- package/src/avm/test_utils.ts +4 -0
- package/src/client/client_execution_context.ts +19 -9
- package/src/client/db_oracle.ts +10 -5
- package/src/client/execution_note_cache.ts +13 -3
- package/src/client/index.ts +1 -0
- package/src/client/private_execution.ts +3 -3
- package/src/client/simulator.ts +4 -4
- package/src/client/unconstrained_execution.ts +2 -2
- package/src/client/view_data_oracle.ts +11 -9
- package/src/common/debug_fn_name.ts +7 -13
- package/src/providers/acvm_native.ts +3 -3
- package/src/providers/acvm_wasm.ts +2 -2
- package/src/providers/factory.ts +3 -3
- package/src/providers/index.ts +0 -1
- package/src/public/enqueued_call_side_effect_trace.ts +62 -86
- package/src/public/execution.ts +1 -2
- package/src/public/executor_metrics.ts +0 -4
- package/src/public/fee_payment.ts +3 -2
- package/src/public/fixtures/index.ts +25 -12
- package/src/public/index.ts +0 -1
- package/src/public/public_db_sources.ts +9 -8
- package/src/public/public_processor.ts +109 -105
- package/src/public/public_processor_metrics.ts +1 -1
- package/src/public/public_tx_context.ts +97 -50
- package/src/public/public_tx_simulator.ts +69 -38
- package/src/public/side_effect_trace_interface.ts +10 -16
- package/src/public/transitional_adapters.ts +12 -48
- 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
package/src/avm/opcodes/misc.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { applyStringFormatting,
|
|
1
|
+
import { applyStringFormatting, createLogger } from '@aztec/foundation/log';
|
|
2
2
|
|
|
3
3
|
import { type AvmContext } from '../avm_context.js';
|
|
4
4
|
import { TypeTag } from '../avm_memory_types.js';
|
|
@@ -9,7 +9,7 @@ import { Instruction } from './instruction.js';
|
|
|
9
9
|
export class DebugLog extends Instruction {
|
|
10
10
|
static type: string = 'DEBUGLOG';
|
|
11
11
|
static readonly opcode: Opcode = Opcode.DEBUGLOG;
|
|
12
|
-
static readonly logger =
|
|
12
|
+
static readonly logger = createLogger('simulator:avm:debug_log');
|
|
13
13
|
|
|
14
14
|
// Informs (de)serialization. See Instruction.deserialize.
|
|
15
15
|
static readonly wireFormat: OperandType[] = [
|
package/src/avm/test_utils.ts
CHANGED
|
@@ -28,6 +28,10 @@ export function mockStorageRead(worldStateDB: WorldStateDB, value: Fr) {
|
|
|
28
28
|
(worldStateDB as jest.Mocked<WorldStateDB>).storageRead.mockResolvedValue(value);
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
export function mockNoteHashCount(mockedTrace: PublicSideEffectTraceInterface, count: number) {
|
|
32
|
+
(mockedTrace as jest.Mocked<PublicSideEffectTraceInterface>).getNoteHashCount.mockReturnValue(count);
|
|
33
|
+
}
|
|
34
|
+
|
|
31
35
|
export function mockStorageReadWithMap(worldStateDB: WorldStateDB, mockedStorage: Map<bigint, Fr>) {
|
|
32
36
|
(worldStateDB as jest.Mocked<WorldStateDB>).storageRead.mockImplementation((_address, slot) =>
|
|
33
37
|
Promise.resolve(mockedStorage.get(slot.toBigInt()) ?? Fr.ZERO),
|
|
@@ -11,9 +11,9 @@ import {
|
|
|
11
11
|
type UnencryptedL2Log,
|
|
12
12
|
} from '@aztec/circuit-types';
|
|
13
13
|
import {
|
|
14
|
+
type BlockHeader,
|
|
14
15
|
CallContext,
|
|
15
16
|
FunctionSelector,
|
|
16
|
-
type Header,
|
|
17
17
|
PRIVATE_CONTEXT_INPUTS_LENGTH,
|
|
18
18
|
PUBLIC_DISPATCH_SELECTOR,
|
|
19
19
|
PrivateContextInputs,
|
|
@@ -23,7 +23,7 @@ import { computeUniqueNoteHash, siloNoteHash } from '@aztec/circuits.js/hash';
|
|
|
23
23
|
import { type FunctionAbi, type FunctionArtifact, type NoteSelector, countArgumentsSize } from '@aztec/foundation/abi';
|
|
24
24
|
import { AztecAddress } from '@aztec/foundation/aztec-address';
|
|
25
25
|
import { Fr } from '@aztec/foundation/fields';
|
|
26
|
-
import { applyStringFormatting,
|
|
26
|
+
import { applyStringFormatting, createLogger } from '@aztec/foundation/log';
|
|
27
27
|
|
|
28
28
|
import { type NoteData, toACVMWitness } from '../acvm/index.js';
|
|
29
29
|
import { type PackedValuesCache } from '../common/packed_values_cache.js';
|
|
@@ -66,7 +66,7 @@ export class ClientExecutionContext extends ViewDataOracle {
|
|
|
66
66
|
private readonly txContext: TxContext,
|
|
67
67
|
private readonly callContext: CallContext,
|
|
68
68
|
/** Header of a block whose state is used during private execution (not the block the transaction is included in). */
|
|
69
|
-
protected readonly historicalHeader:
|
|
69
|
+
protected readonly historicalHeader: BlockHeader,
|
|
70
70
|
/** List of transient auth witnesses to be used during this simulation */
|
|
71
71
|
authWitnesses: AuthWitness[],
|
|
72
72
|
private readonly packedValuesCache: PackedValuesCache,
|
|
@@ -74,7 +74,7 @@ export class ClientExecutionContext extends ViewDataOracle {
|
|
|
74
74
|
db: DBOracle,
|
|
75
75
|
private node: AztecNode,
|
|
76
76
|
protected sideEffectCounter: number = 0,
|
|
77
|
-
log =
|
|
77
|
+
log = createLogger('simulator:client_execution_context'),
|
|
78
78
|
scopes?: AztecAddress[],
|
|
79
79
|
) {
|
|
80
80
|
super(callContext.contractAddress, authWitnesses, db, node, log, scopes);
|
|
@@ -247,9 +247,10 @@ export class ClientExecutionContext extends ViewDataOracle {
|
|
|
247
247
|
|
|
248
248
|
notes.forEach(n => {
|
|
249
249
|
if (n.index !== undefined) {
|
|
250
|
-
const
|
|
251
|
-
const
|
|
252
|
-
|
|
250
|
+
const siloedNoteHash = siloNoteHash(n.contractAddress, n.noteHash);
|
|
251
|
+
const uniqueNoteHash = computeUniqueNoteHash(n.nonce, siloedNoteHash);
|
|
252
|
+
|
|
253
|
+
this.noteHashLeafIndexMap.set(uniqueNoteHash.toBigInt(), n.index);
|
|
253
254
|
}
|
|
254
255
|
});
|
|
255
256
|
|
|
@@ -419,7 +420,14 @@ export class ClientExecutionContext extends ViewDataOracle {
|
|
|
419
420
|
const args = this.packedValuesCache.unpack(argsHash);
|
|
420
421
|
|
|
421
422
|
this.log.verbose(
|
|
422
|
-
`Created
|
|
423
|
+
`Created ${callType} public execution request to ${targetArtifact.name}@${targetContractAddress}`,
|
|
424
|
+
{
|
|
425
|
+
sideEffectCounter,
|
|
426
|
+
isStaticCall,
|
|
427
|
+
functionSelector,
|
|
428
|
+
targetContractAddress,
|
|
429
|
+
callType,
|
|
430
|
+
},
|
|
423
431
|
);
|
|
424
432
|
|
|
425
433
|
const request = PublicExecutionRequest.from({
|
|
@@ -537,7 +545,7 @@ export class ClientExecutionContext extends ViewDataOracle {
|
|
|
537
545
|
}
|
|
538
546
|
|
|
539
547
|
public override debugLog(message: string, fields: Fr[]) {
|
|
540
|
-
this.log.verbose(
|
|
548
|
+
this.log.verbose(`${applyStringFormatting(message, fields)}`, { module: `${this.log.module}:debug_log` });
|
|
541
549
|
}
|
|
542
550
|
|
|
543
551
|
public getDebugFunctionName() {
|
|
@@ -557,5 +565,7 @@ export class ClientExecutionContext extends ViewDataOracle {
|
|
|
557
565
|
for (const [recipient, taggedLogs] of taggedLogsByRecipient.entries()) {
|
|
558
566
|
await this.db.processTaggedLogs(taggedLogs, AztecAddress.fromString(recipient));
|
|
559
567
|
}
|
|
568
|
+
|
|
569
|
+
await this.db.removeNullifiedNotes(this.contractAddress);
|
|
560
570
|
}
|
|
561
571
|
}
|
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
|
|
@@ -198,21 +198,21 @@ export interface DBOracle extends CommitmentsDB {
|
|
|
198
198
|
getBlockNumber(): Promise<number>;
|
|
199
199
|
|
|
200
200
|
/**
|
|
201
|
-
* Returns the tagging secret for a given sender and recipient pair. For this to work, the
|
|
201
|
+
* Returns the tagging secret for a given sender and recipient pair. For this to work, the ivsk_m of the sender must be known.
|
|
202
202
|
* Includes the next index to be used used for tagging with this secret.
|
|
203
203
|
* @param contractAddress - The contract address to silo the secret for
|
|
204
204
|
* @param sender - The address sending the note
|
|
205
205
|
* @param recipient - The address receiving the note
|
|
206
206
|
* @returns A tagging secret that can be used to tag notes.
|
|
207
207
|
*/
|
|
208
|
-
|
|
208
|
+
getIndexedTaggingSecretAsSender(
|
|
209
209
|
contractAddress: AztecAddress,
|
|
210
210
|
sender: AztecAddress,
|
|
211
211
|
recipient: AztecAddress,
|
|
212
212
|
): Promise<IndexedTaggingSecret>;
|
|
213
213
|
|
|
214
214
|
/**
|
|
215
|
-
* Increments the tagging secret for a given sender and recipient pair. For this to work, the
|
|
215
|
+
* Increments the tagging secret for a given sender and recipient pair. For this to work, the ivsk_m of the sender must be known.
|
|
216
216
|
* @param contractAddress - The contract address to silo the secret for
|
|
217
217
|
* @param sender - The address sending the note
|
|
218
218
|
* @param recipient - The address receiving the note
|
|
@@ -242,4 +242,9 @@ export interface DBOracle extends CommitmentsDB {
|
|
|
242
242
|
* @param recipient - The recipient of the logs.
|
|
243
243
|
*/
|
|
244
244
|
processTaggedLogs(logs: TxScopedL2Log[], recipient: AztecAddress): Promise<void>;
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Removes all of a contract's notes that have been nullified from the note database.
|
|
248
|
+
*/
|
|
249
|
+
removeNullifiedNotes(contractAddress: AztecAddress): Promise<void>;
|
|
245
250
|
}
|
|
@@ -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
|
}
|
package/src/client/index.ts
CHANGED
|
@@ -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);
|
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,23 +290,22 @@ 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
|
/**
|
|
298
297
|
* Returns the tagging secret for a given sender and recipient pair, siloed to the current contract address.
|
|
299
298
|
* Includes the next index to be used used for tagging with this secret.
|
|
300
|
-
* For this to work, the
|
|
299
|
+
* For this to work, the ivsk_m of the sender must be known.
|
|
301
300
|
* @param sender - The address sending the note
|
|
302
301
|
* @param recipient - The address receiving the note
|
|
303
302
|
* @returns A tagging secret that can be used to tag notes.
|
|
304
303
|
*/
|
|
305
|
-
public override async
|
|
304
|
+
public override async getIndexedTaggingSecretAsSender(
|
|
306
305
|
sender: AztecAddress,
|
|
307
306
|
recipient: AztecAddress,
|
|
308
307
|
): Promise<IndexedTaggingSecret> {
|
|
309
|
-
return await this.db.
|
|
308
|
+
return await this.db.getIndexedTaggingSecretAsSender(this.contractAddress, sender, recipient);
|
|
310
309
|
}
|
|
311
310
|
|
|
312
311
|
public override async syncNotes() {
|
|
@@ -315,8 +314,11 @@ export class ViewDataOracle extends TypedOracle {
|
|
|
315
314
|
await this.aztecNode.getBlockNumber(),
|
|
316
315
|
this.scopes,
|
|
317
316
|
);
|
|
317
|
+
|
|
318
318
|
for (const [recipient, taggedLogs] of taggedLogsByRecipient.entries()) {
|
|
319
319
|
await this.db.processTaggedLogs(taggedLogs, AztecAddress.fromString(recipient));
|
|
320
320
|
}
|
|
321
|
+
|
|
322
|
+
await this.db.removeNullifiedNotes(this.contractAddress);
|
|
321
323
|
}
|
|
322
324
|
}
|
|
@@ -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,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { foreignCallHandler } from '@aztec/noir-protocol-circuits-types';
|
|
1
|
+
import { foreignCallHandler } from '@aztec/noir-protocol-circuits-types/client';
|
|
2
2
|
import { type NoirCompiledCircuit } from '@aztec/types/noir';
|
|
3
3
|
|
|
4
4
|
import { executeCircuit } from '@noir-lang/acvm_js';
|
|
@@ -17,7 +17,7 @@ export class WASMSimulator implements SimulationProvider {
|
|
|
17
17
|
const _witnessMap = await executeCircuit(
|
|
18
18
|
decodedBytecode,
|
|
19
19
|
input,
|
|
20
|
-
foreignCallHandler, // handle calls to debug_log
|
|
20
|
+
foreignCallHandler, // handle calls to debug_log and evaluate_blobs mock
|
|
21
21
|
);
|
|
22
22
|
|
|
23
23
|
return _witnessMap;
|
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 {
|
package/src/providers/index.ts
CHANGED