@aztec/simulator 0.46.7 → 0.47.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/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 +2 -2
- package/dest/acvm/oracle/typed_oracle.d.ts.map +1 -1
- package/dest/acvm/oracle/typed_oracle.js +3 -3
- package/dest/avm/avm_gas.d.ts.map +1 -1
- package/dest/avm/avm_gas.js +4 -1
- package/dest/avm/fixtures/index.d.ts +2 -1
- package/dest/avm/fixtures/index.d.ts.map +1 -1
- package/dest/avm/fixtures/index.js +5 -2
- package/dest/avm/opcodes/hashing.d.ts +11 -0
- package/dest/avm/opcodes/hashing.d.ts.map +1 -1
- package/dest/avm/opcodes/hashing.js +42 -3
- package/dest/avm/serialization/bytecode_serialization.d.ts.map +1 -1
- package/dest/avm/serialization/bytecode_serialization.js +5 -2
- package/dest/avm/serialization/instruction_serialization.d.ts +3 -1
- package/dest/avm/serialization/instruction_serialization.d.ts.map +1 -1
- package/dest/avm/serialization/instruction_serialization.js +4 -1
- package/dest/client/client_execution_context.d.ts +5 -3
- package/dest/client/client_execution_context.d.ts.map +1 -1
- package/dest/client/client_execution_context.js +5 -9
- package/dest/providers/factory.d.ts +12 -0
- package/dest/providers/factory.d.ts.map +1 -0
- package/dest/providers/factory.js +27 -0
- package/dest/providers/index.d.ts +1 -0
- package/dest/providers/index.d.ts.map +1 -1
- package/dest/providers/index.js +2 -1
- package/dest/public/public_processor.d.ts +1 -1
- package/dest/public/public_processor.d.ts.map +1 -1
- package/dest/public/public_processor.js +9 -3
- package/package.json +9 -9
- package/src/acvm/oracle/oracle.ts +4 -0
- package/src/acvm/oracle/typed_oracle.ts +2 -0
- package/src/avm/avm_gas.ts +3 -0
- package/src/avm/fixtures/index.ts +5 -1
- package/src/avm/opcodes/hashing.ts +53 -2
- package/src/avm/serialization/bytecode_serialization.ts +4 -1
- package/src/avm/serialization/instruction_serialization.ts +3 -0
- package/src/client/client_execution_context.ts +5 -8
- package/src/providers/factory.ts +38 -0
- package/src/providers/index.ts +1 -0
- package/src/public/public_processor.ts +8 -5
|
@@ -80,6 +80,9 @@ export enum Opcode {
|
|
|
80
80
|
MSM,
|
|
81
81
|
// Conversion
|
|
82
82
|
TORADIXLE,
|
|
83
|
+
// Future Gadgets -- pending changes in noir
|
|
84
|
+
SHA256COMPRESSION,
|
|
85
|
+
KECCAKF1600, // Here for when we eventually support this
|
|
83
86
|
}
|
|
84
87
|
|
|
85
88
|
// Possible types for an instruction's operand in its wire format. (Keep in sync with CPP code.
|
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
type NoteSelector,
|
|
30
30
|
countArgumentsSize,
|
|
31
31
|
} from '@aztec/foundation/abi';
|
|
32
|
-
import { AztecAddress } from '@aztec/foundation/aztec-address';
|
|
32
|
+
import { type AztecAddress } from '@aztec/foundation/aztec-address';
|
|
33
33
|
import { pedersenHash } from '@aztec/foundation/crypto';
|
|
34
34
|
import { Fr, GrumpkinScalar, type Point } from '@aztec/foundation/fields';
|
|
35
35
|
import { applyStringFormatting, createDebugLogger } from '@aztec/foundation/log';
|
|
@@ -377,6 +377,7 @@ export class ClientExecutionContext extends ViewDataOracle {
|
|
|
377
377
|
* @param eventTypeId - The type ID of the event (function selector).
|
|
378
378
|
* @param ovKeys - The outgoing viewing keys to use to encrypt.
|
|
379
379
|
* @param ivpkM - The master incoming viewing public key.
|
|
380
|
+
* @param recipient - The recipient of the encrypted event log.
|
|
380
381
|
* @param preimage - The event preimage.
|
|
381
382
|
*/
|
|
382
383
|
public override computeEncryptedEventLog(
|
|
@@ -385,6 +386,7 @@ export class ClientExecutionContext extends ViewDataOracle {
|
|
|
385
386
|
eventTypeId: Fr,
|
|
386
387
|
ovKeys: KeyValidationRequest,
|
|
387
388
|
ivpkM: Point,
|
|
389
|
+
recipient: AztecAddress,
|
|
388
390
|
preimage: Fr[],
|
|
389
391
|
) {
|
|
390
392
|
const event = new Event(preimage);
|
|
@@ -393,8 +395,6 @@ export class ClientExecutionContext extends ViewDataOracle {
|
|
|
393
395
|
|
|
394
396
|
const ephSk = GrumpkinScalar.random();
|
|
395
397
|
|
|
396
|
-
const recipient = AztecAddress.random();
|
|
397
|
-
|
|
398
398
|
return taggedEvent.encrypt(ephSk, recipient, ivpkM, ovKeys);
|
|
399
399
|
}
|
|
400
400
|
|
|
@@ -405,6 +405,7 @@ export class ClientExecutionContext extends ViewDataOracle {
|
|
|
405
405
|
* @param noteTypeId - The type ID of the note.
|
|
406
406
|
* @param ovKeys - The outgoing viewing keys to use to encrypt.
|
|
407
407
|
* @param ivpkM - The master incoming viewing public key.
|
|
408
|
+
* @param recipient - The recipient of the encrypted note log.
|
|
408
409
|
* @param preimage - The note preimage.
|
|
409
410
|
*/
|
|
410
411
|
public override computeEncryptedNoteLog(
|
|
@@ -413,6 +414,7 @@ export class ClientExecutionContext extends ViewDataOracle {
|
|
|
413
414
|
noteTypeId: NoteSelector,
|
|
414
415
|
ovKeys: KeyValidationRequest,
|
|
415
416
|
ivpkM: Point,
|
|
417
|
+
recipient: AztecAddress,
|
|
416
418
|
preimage: Fr[],
|
|
417
419
|
) {
|
|
418
420
|
const note = new Note(preimage);
|
|
@@ -421,11 +423,6 @@ export class ClientExecutionContext extends ViewDataOracle {
|
|
|
421
423
|
|
|
422
424
|
const ephSk = GrumpkinScalar.random();
|
|
423
425
|
|
|
424
|
-
// @todo This should be populated properly.
|
|
425
|
-
// Note that this encryption function SHOULD not be used, but is currently used
|
|
426
|
-
// as oracle for encrypted event logs.
|
|
427
|
-
const recipient = AztecAddress.random();
|
|
428
|
-
|
|
429
426
|
return taggedNote.encrypt(ephSk, recipient, ivpkM, ovKeys);
|
|
430
427
|
}
|
|
431
428
|
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type DebugLogger, createDebugLogger } from '@aztec/foundation/log';
|
|
2
|
+
|
|
3
|
+
import * as fs from 'fs/promises';
|
|
4
|
+
|
|
5
|
+
import { NativeACVMSimulator } from './acvm_native.js';
|
|
6
|
+
import { WASMSimulator } from './acvm_wasm.js';
|
|
7
|
+
import { type SimulationProvider } from './simulation_provider.js';
|
|
8
|
+
|
|
9
|
+
export type SimulationProviderConfig = {
|
|
10
|
+
acvmBinaryPath?: string;
|
|
11
|
+
acvmWorkingDirectory?: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export function getSimulationProviderConfigFromEnv() {
|
|
15
|
+
const { ACVM_BINARY_PATH, ACVM_WORKING_DIRECTORY } = process.env;
|
|
16
|
+
return {
|
|
17
|
+
acvmWorkingDirectory: ACVM_WORKING_DIRECTORY ? ACVM_WORKING_DIRECTORY : undefined,
|
|
18
|
+
acvmBinaryPath: ACVM_BINARY_PATH ? ACVM_BINARY_PATH : undefined,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export async function createSimulationProvider(
|
|
23
|
+
config: SimulationProviderConfig,
|
|
24
|
+
logger: DebugLogger = createDebugLogger('aztec:simulator'),
|
|
25
|
+
): Promise<SimulationProvider> {
|
|
26
|
+
if (config.acvmBinaryPath && config.acvmWorkingDirectory) {
|
|
27
|
+
try {
|
|
28
|
+
await fs.access(config.acvmBinaryPath, fs.constants.R_OK);
|
|
29
|
+
await fs.mkdir(config.acvmWorkingDirectory, { recursive: true });
|
|
30
|
+
logger.info(`Using native ACVM at ${config.acvmBinaryPath} and working directory ${config.acvmWorkingDirectory}`);
|
|
31
|
+
return new NativeACVMSimulator(config.acvmWorkingDirectory, config.acvmBinaryPath);
|
|
32
|
+
} catch {
|
|
33
|
+
logger.warn(`Failed to access ACVM at ${config.acvmBinaryPath}, falling back to WASM`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
logger.info('Using WASM ACVM simulation');
|
|
37
|
+
return new WASMSimulator();
|
|
38
|
+
}
|
package/src/providers/index.ts
CHANGED
|
@@ -59,11 +59,8 @@ export class PublicProcessorFactory {
|
|
|
59
59
|
* @param newContracts - Provides access to contract bytecode for public executions.
|
|
60
60
|
* @returns A new instance of a PublicProcessor.
|
|
61
61
|
*/
|
|
62
|
-
public
|
|
63
|
-
historicalHeader
|
|
64
|
-
globalVariables: GlobalVariables,
|
|
65
|
-
): Promise<PublicProcessor> {
|
|
66
|
-
historicalHeader = historicalHeader ?? (await this.merkleTree.buildInitialHeader());
|
|
62
|
+
public create(historicalHeader: Header | undefined, globalVariables: GlobalVariables): PublicProcessor {
|
|
63
|
+
historicalHeader = historicalHeader ?? this.merkleTree.getInitialHeader();
|
|
67
64
|
|
|
68
65
|
const publicContractsDB = new ContractsDataSourcePublicDB(this.contractDataSource);
|
|
69
66
|
const worldStatePublicDB = new WorldStatePublicDB(this.merkleTree);
|
|
@@ -128,6 +125,12 @@ export class PublicProcessor {
|
|
|
128
125
|
const [processedTx, returnValues] = !tx.hasPublicCalls()
|
|
129
126
|
? [makeProcessedTx(tx, tx.data.toKernelCircuitPublicInputs(), [])]
|
|
130
127
|
: await this.processTxWithPublicCalls(tx);
|
|
128
|
+
this.log.debug(`Processed tx`, {
|
|
129
|
+
txHash: processedTx.hash,
|
|
130
|
+
historicalHeaderHash: processedTx.data.constants.historicalHeader.hash(),
|
|
131
|
+
blockNumber: processedTx.data.constants.globalVariables.blockNumber,
|
|
132
|
+
lastArchiveRoot: processedTx.data.constants.historicalHeader.lastArchive.root,
|
|
133
|
+
});
|
|
131
134
|
|
|
132
135
|
// Set fee payment update request into the processed tx
|
|
133
136
|
processedTx.finalPublicDataUpdateRequests = await this.createFinalDataUpdateRequests(processedTx);
|