@aztec/simulator 1.2.0 → 2.0.0-nightly.20250813
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/private/circuit_recording/circuit_recorder.js +2 -2
- package/dest/public/avm/fixtures/base_avm_simulation_tester.js +2 -2
- package/dest/public/avm/fixtures/utils.js +2 -2
- package/dest/public/avm/opcodes/accrued_substate.d.ts.map +1 -1
- package/dest/public/avm/opcodes/accrued_substate.js +5 -3
- package/dest/public/avm/opcodes/comparators.js +1 -1
- package/dest/public/avm/opcodes/environment_getters.d.ts +2 -2
- package/dest/public/avm/opcodes/environment_getters.d.ts.map +1 -1
- package/dest/public/avm/opcodes/environment_getters.js +6 -6
- package/dest/public/avm/opcodes/misc.js +1 -1
- package/dest/public/avm/test_utils.d.ts +2 -2
- package/dest/public/avm/test_utils.d.ts.map +1 -1
- package/dest/public/avm/test_utils.js +2 -2
- package/dest/public/executor_metrics.d.ts +0 -1
- package/dest/public/executor_metrics.d.ts.map +1 -1
- package/dest/public/executor_metrics.js +0 -3
- package/dest/public/executor_metrics_interface.d.ts +0 -1
- package/dest/public/executor_metrics_interface.d.ts.map +1 -1
- package/dest/public/fixtures/index.d.ts +1 -0
- package/dest/public/fixtures/index.d.ts.map +1 -1
- package/dest/public/fixtures/index.js +1 -0
- package/dest/public/fixtures/minimal_public_tx.d.ts.map +1 -1
- package/dest/public/fixtures/minimal_public_tx.js +1 -1
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts +1 -1
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts.map +1 -1
- package/dest/public/fixtures/public_tx_simulation_tester.js +2 -1
- package/dest/public/fixtures/utils.d.ts +5 -2
- package/dest/public/fixtures/utils.d.ts.map +1 -1
- package/dest/public/fixtures/utils.js +37 -13
- package/dest/public/public_db_sources.js +4 -4
- package/dest/public/public_processor/public_processor.d.ts +3 -2
- package/dest/public/public_processor/public_processor.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor.js +30 -19
- package/dest/public/public_processor/public_processor_metrics.d.ts +2 -2
- package/dest/public/public_processor/public_processor_metrics.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor_metrics.js +1 -1
- package/dest/public/public_tx_simulator/apps_tests/amm_test.js +4 -4
- package/dest/public/public_tx_simulator/apps_tests/token_test.d.ts +1 -1
- package/dest/public/public_tx_simulator/apps_tests/token_test.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/apps_tests/token_test.js +2 -2
- package/dest/public/public_tx_simulator/measured_public_tx_simulator.d.ts +0 -1
- package/dest/public/public_tx_simulator/measured_public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/measured_public_tx_simulator.js +0 -6
- package/dest/public/public_tx_simulator/public_tx_context.d.ts +1 -1
- package/dest/public/public_tx_simulator/public_tx_context.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_context.js +6 -12
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts +1 -20
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_simulator.js +49 -81
- package/dest/public/side_effect_trace.d.ts.map +1 -1
- package/dest/public/side_effect_trace.js +17 -11
- package/dest/public/state_manager/state_manager.d.ts +1 -1
- package/dest/public/state_manager/state_manager.d.ts.map +1 -1
- package/dest/public/state_manager/state_manager.js +16 -16
- package/dest/public/test_executor_metrics.d.ts +13 -3
- package/dest/public/test_executor_metrics.d.ts.map +1 -1
- package/dest/public/test_executor_metrics.js +159 -47
- package/package.json +15 -15
- package/src/private/circuit_recording/circuit_recorder.ts +2 -2
- package/src/public/avm/fixtures/base_avm_simulation_tester.ts +2 -2
- package/src/public/avm/fixtures/utils.ts +2 -2
- package/src/public/avm/opcodes/accrued_substate.ts +6 -3
- package/src/public/avm/opcodes/comparators.ts +1 -1
- package/src/public/avm/opcodes/environment_getters.ts +8 -8
- package/src/public/avm/opcodes/misc.ts +1 -1
- package/src/public/avm/test_utils.ts +4 -4
- package/src/public/executor_metrics.ts +0 -4
- package/src/public/executor_metrics_interface.ts +0 -1
- package/src/public/fixtures/index.ts +1 -0
- package/src/public/fixtures/minimal_public_tx.ts +2 -0
- package/src/public/fixtures/public_tx_simulation_tester.ts +3 -2
- package/src/public/fixtures/utils.ts +45 -16
- package/src/public/public_db_sources.ts +7 -7
- package/src/public/public_processor/public_processor.ts +38 -29
- package/src/public/public_processor/public_processor_metrics.ts +2 -2
- package/src/public/public_tx_simulator/apps_tests/amm_test.ts +4 -4
- package/src/public/public_tx_simulator/apps_tests/token_test.ts +2 -2
- package/src/public/public_tx_simulator/measured_public_tx_simulator.ts +0 -7
- package/src/public/public_tx_simulator/public_tx_context.ts +13 -19
- package/src/public/public_tx_simulator/public_tx_simulator.ts +63 -105
- package/src/public/side_effect_trace.ts +29 -23
- package/src/public/state_manager/state_manager.ts +23 -21
- package/src/public/test_executor_metrics.ts +172 -46
|
@@ -74,14 +74,17 @@ export class SideEffectArrayLengths {
|
|
|
74
74
|
forkedTrace.alreadyMergedIntoParent = true;
|
|
75
75
|
this.sideEffectCounter = forkedTrace.sideEffectCounter;
|
|
76
76
|
this.uniqueClassIds.acceptAndMerge(forkedTrace.uniqueClassIds);
|
|
77
|
-
// Accept even if reverted, since the user already paid for the writes
|
|
78
|
-
this.writtenPublicDataSlots = new Set(forkedTrace.writtenPublicDataSlots);
|
|
79
77
|
if (!reverted) {
|
|
80
78
|
this.publicDataWrites.push(...forkedTrace.publicDataWrites);
|
|
81
79
|
this.noteHashes.push(...forkedTrace.noteHashes);
|
|
82
80
|
this.nullifiers.push(...forkedTrace.nullifiers);
|
|
83
81
|
this.l2ToL1Messages.push(...forkedTrace.l2ToL1Messages);
|
|
84
82
|
this.publicLogs.push(...forkedTrace.publicLogs);
|
|
83
|
+
this.userPublicDataWritesLength += forkedTrace.userPublicDataWritesLength;
|
|
84
|
+
this.protocolPublicDataWritesLength += forkedTrace.protocolPublicDataWritesLength;
|
|
85
|
+
for (const slot of forkedTrace.writtenPublicDataSlots){
|
|
86
|
+
this.writtenPublicDataSlots.add(slot);
|
|
87
|
+
}
|
|
85
88
|
}
|
|
86
89
|
}
|
|
87
90
|
getCounter() {
|
|
@@ -94,16 +97,19 @@ export class SideEffectArrayLengths {
|
|
|
94
97
|
return this.previousSideEffectArrayLengths.noteHashes + this.noteHashes.length;
|
|
95
98
|
}
|
|
96
99
|
async tracePublicStorageWrite(contractAddress, slot, value, protocolWrite) {
|
|
97
|
-
if
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
100
|
+
// Only increment counts if the storage slot has not been written to before.
|
|
101
|
+
if (this.isStorageCold(contractAddress, slot)) {
|
|
102
|
+
if (protocolWrite) {
|
|
103
|
+
if (this.protocolPublicDataWritesLength + this.previousSideEffectArrayLengths.protocolPublicDataWrites >= PROTOCOL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX) {
|
|
104
|
+
throw new SideEffectLimitReachedError('protocol public data (contract storage) write', PROTOCOL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX);
|
|
105
|
+
}
|
|
106
|
+
this.protocolPublicDataWritesLength++;
|
|
107
|
+
} else {
|
|
108
|
+
if (this.userPublicDataWritesLength + this.previousSideEffectArrayLengths.publicDataWrites >= MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX) {
|
|
109
|
+
throw new SideEffectLimitReachedError('public data (contract storage) write', MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX);
|
|
110
|
+
}
|
|
111
|
+
this.userPublicDataWritesLength++;
|
|
105
112
|
}
|
|
106
|
-
this.userPublicDataWritesLength++;
|
|
107
113
|
}
|
|
108
114
|
const leafSlot = await computePublicDataTreeLeafSlot(contractAddress, slot);
|
|
109
115
|
this.publicDataWrites.push(new PublicDataUpdateRequest(leafSlot, value, this.sideEffectCounter));
|
|
@@ -78,7 +78,7 @@ export declare class PublicPersistableStateManager {
|
|
|
78
78
|
* @param leafIndex - the leaf index being checked
|
|
79
79
|
* @returns true if the note hash exists at the given leaf index, false otherwise
|
|
80
80
|
*/
|
|
81
|
-
checkNoteHashExists(contractAddress: AztecAddress, noteHash: Fr, leafIndex:
|
|
81
|
+
checkNoteHashExists(contractAddress: AztecAddress, noteHash: Fr, leafIndex: bigint): Promise<boolean>;
|
|
82
82
|
/**
|
|
83
83
|
* Write a raw note hash, silo it and make it unique, then trace the write.
|
|
84
84
|
* @param noteHash - the unsiloed note hash to write
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state_manager.d.ts","sourceRoot":"","sources":["../../../src/public/state_manager/state_manager.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAI9C,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,iCAAiC,EAA+B,MAAM,wBAAwB,CAAC;AAC7G,OAAO,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"state_manager.d.ts","sourceRoot":"","sources":["../../../src/public/state_manager/state_manager.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAI9C,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,iCAAiC,EAA+B,MAAM,wBAAwB,CAAC;AAC7G,OAAO,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAC;AAGtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAIlD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AACnF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EAAE,OAAO,EAAE,EAAE;IAKnF;;;OAGG;IACI,wBAAwB,CAAC,aAAa,EAAE,mBAAmB;IAQlE;;;;OAIG;IACI,cAAc,CAAC,eAAe,EAAE,YAAY,EAAE,GAAG,EAAE,EAAE,EAAE;IAK9D;;;;OAIG;IACU,mBAAmB,CAAC,eAAe,EAAE,YAAY,GAAG,OAAO,CAAC,4BAA4B,GAAG,SAAS,CAAC;YAkCpG,8BAA8B;IA0D5C;;;;OAIG;IACU,gBAAgB,CAAC,OAAO,EAAE,EAAE,GAAG,OAAO,CAAC,iCAAiC,GAAG,SAAS,CAAC;IA4BlG;;OAEG;IACU,WAAW,CAAC,eAAe,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAiBvE,0BAA0B,CAAC,cAAc,EAAE,uBAAuB,GAAG,OAAO,CAAC,MAAM,CAAC;IAIpF,OAAO,CAAC,MAAM,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIpE,gBAAgB,IAAI,OAAO,CAAC,aAAa,CAAC;CAGxD"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { CANONICAL_AUTH_REGISTRY_ADDRESS,
|
|
1
|
+
import { CANONICAL_AUTH_REGISTRY_ADDRESS, CONTRACT_CLASS_REGISTRY_CONTRACT_ADDRESS, CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS, FEE_JUICE_ADDRESS, MULTI_CALL_ENTRYPOINT_ADDRESS, ROUTER_ADDRESS } from '@aztec/constants';
|
|
2
2
|
import { poseidon2Hash } from '@aztec/foundation/crypto';
|
|
3
3
|
import { jsonStringify } from '@aztec/foundation/json-rpc';
|
|
4
4
|
import { createLogger } from '@aztec/foundation/log';
|
|
5
5
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
6
6
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
7
7
|
import { SerializableContractInstance } from '@aztec/stdlib/contract';
|
|
8
|
+
import { DelayedPublicMutableValues, DelayedPublicMutableValuesWithHash } from '@aztec/stdlib/delayed-public-mutable';
|
|
8
9
|
import { computeNoteHashNonce, computeUniqueNoteHash, siloNoteHash, siloNullifier } from '@aztec/stdlib/hash';
|
|
9
|
-
import { SharedMutableValues, SharedMutableValuesWithHash } from '@aztec/stdlib/shared-mutable';
|
|
10
10
|
import { strict as assert } from 'assert';
|
|
11
11
|
import { getPublicFunctionDebugName } from '../debug_fn_name.js';
|
|
12
12
|
import { NullifierCollisionError, NullifierManager } from './nullifiers.js';
|
|
@@ -123,7 +123,7 @@ import { PublicStorage } from './public_storage.js';
|
|
|
123
123
|
* @param leafIndex - the leaf index being checked
|
|
124
124
|
* @returns true if the note hash exists at the given leaf index, false otherwise
|
|
125
125
|
*/ async checkNoteHashExists(contractAddress, noteHash, leafIndex) {
|
|
126
|
-
const gotLeafValue = await this.treesDB.getNoteHash(leafIndex
|
|
126
|
+
const gotLeafValue = await this.treesDB.getNoteHash(leafIndex);
|
|
127
127
|
const exists = gotLeafValue !== undefined && gotLeafValue.equals(noteHash);
|
|
128
128
|
this.log.trace(`noteHashes(${contractAddress})@${noteHash} ?? leafIndex: ${leafIndex} | gotLeafValue: ${gotLeafValue}, exists: ${exists}.`);
|
|
129
129
|
return Promise.resolve(exists);
|
|
@@ -253,7 +253,7 @@ import { PublicStorage } from './public_storage.js';
|
|
|
253
253
|
return instance;
|
|
254
254
|
}
|
|
255
255
|
// This will decide internally whether to check the nullifier tree or not depending on doMerkleOperations.
|
|
256
|
-
const nullifierExistsInTree = await this.checkNullifierExists(AztecAddress.fromNumber(
|
|
256
|
+
const nullifierExistsInTree = await this.checkNullifierExists(AztecAddress.fromNumber(CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS), contractAddress.toField());
|
|
257
257
|
assert(exists == nullifierExistsInTree, `Contract instance for address ${contractAddress} in DB: ${exists} != nullifier tree: ${nullifierExistsInTree}. This is a bug!`);
|
|
258
258
|
// All that is left is tocheck that the contract updatability information is correct.
|
|
259
259
|
// That is, that the current and original contract class ids are correct.
|
|
@@ -267,19 +267,19 @@ import { PublicStorage } from './public_storage.js';
|
|
|
267
267
|
// All failures are fatal and the simulation is not expected to be provable.
|
|
268
268
|
if (this.doMerkleOperations) {
|
|
269
269
|
// Conceptually, we want to do the following:
|
|
270
|
-
// * Read a
|
|
271
|
-
// * Obtain the expected current class id from the
|
|
270
|
+
// * Read a DelayedPublicMutable at the contract update slot.
|
|
271
|
+
// * Obtain the expected current class id from the DelayedPublicMutable, at the current block.
|
|
272
272
|
// * if expectedId == 0 then currentClassId should be original contract class id
|
|
273
273
|
// * if expectedId != 0 then currentClassId should be expectedId
|
|
274
274
|
//
|
|
275
|
-
// However, we will also be checking the hash of the
|
|
275
|
+
// However, we will also be checking the hash of the delayed public mutable values.
|
|
276
276
|
// This is a bit of a leak of information, since the circuit will use it to prove
|
|
277
|
-
// one public read insted of N of the
|
|
278
|
-
const {
|
|
279
|
-
const readDeployerStorage = async (storageSlot)=>await this.readStorage(ProtocolContractAddress.
|
|
280
|
-
const hash = await readDeployerStorage(
|
|
281
|
-
const
|
|
282
|
-
const preImage =
|
|
277
|
+
// one public read insted of N of the delayed public mutable values.
|
|
278
|
+
const { delayedPublicMutableSlot, delayedPublicMutableHashSlot } = await DelayedPublicMutableValuesWithHash.getContractUpdateSlots(instance.address);
|
|
279
|
+
const readDeployerStorage = async (storageSlot)=>await this.readStorage(ProtocolContractAddress.ContractInstanceRegistry, storageSlot);
|
|
280
|
+
const hash = await readDeployerStorage(delayedPublicMutableHashSlot);
|
|
281
|
+
const delayedPublicMutableValues = await DelayedPublicMutableValues.readFromTree(delayedPublicMutableSlot, readDeployerStorage);
|
|
282
|
+
const preImage = delayedPublicMutableValues.toFields();
|
|
283
283
|
// 1) update never scheduled: hash == 0 and preimage should be empty (but poseidon2hash(preimage) will not be 0s)
|
|
284
284
|
if (hash.isZero()) {
|
|
285
285
|
assert(preImage.every((f)=>f.isZero()), `Found updatability hash 0 but preimage is not empty for contract instance ${instance.address}.`);
|
|
@@ -288,9 +288,9 @@ import { PublicStorage } from './public_storage.js';
|
|
|
288
288
|
}
|
|
289
289
|
// 2) At this point we know that the hash is not zero and this means that an update has at some point been scheduled.
|
|
290
290
|
const computedHash = await poseidon2Hash(preImage);
|
|
291
|
-
assert(hash.equals(computedHash), `
|
|
291
|
+
assert(hash.equals(computedHash), `Delayed public mutable values hash mismatch for contract instance ${instance.address}. Expected: ${hash}, computed: ${computedHash}`);
|
|
292
292
|
// We now check that, depending on the current block, the current class id is correct.
|
|
293
|
-
const expectedClassIdRaw =
|
|
293
|
+
const expectedClassIdRaw = delayedPublicMutableValues.svc.getCurrentAt(this.timestamp).at(0);
|
|
294
294
|
const expectedClassId = expectedClassIdRaw.isZero() ? instance.originalContractClassId : expectedClassIdRaw;
|
|
295
295
|
assert(instance.currentContractClassId.equals(expectedClassId), `Current class id mismatch
|
|
296
296
|
for contract instance ${instance.address}. Expected: ${expectedClassId}, current: ${instance.currentContractClassId}`);
|
|
@@ -345,5 +345,5 @@ import { PublicStorage } from './public_storage.js';
|
|
|
345
345
|
}
|
|
346
346
|
}
|
|
347
347
|
function contractAddressIsCanonical(contractAddress) {
|
|
348
|
-
return contractAddress.equals(AztecAddress.fromNumber(CANONICAL_AUTH_REGISTRY_ADDRESS)) || contractAddress.equals(AztecAddress.fromNumber(
|
|
348
|
+
return contractAddress.equals(AztecAddress.fromNumber(CANONICAL_AUTH_REGISTRY_ADDRESS)) || contractAddress.equals(AztecAddress.fromNumber(CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS)) || contractAddress.equals(AztecAddress.fromNumber(CONTRACT_CLASS_REGISTRY_CONTRACT_ADDRESS)) || contractAddress.equals(AztecAddress.fromNumber(MULTI_CALL_ENTRYPOINT_ADDRESS)) || contractAddress.equals(AztecAddress.fromNumber(FEE_JUICE_ADDRESS)) || contractAddress.equals(AztecAddress.fromNumber(ROUTER_ADDRESS));
|
|
349
349
|
}
|
|
@@ -11,17 +11,27 @@ export interface PublicTxMetrics {
|
|
|
11
11
|
totalDurationMs: number;
|
|
12
12
|
manaUsed: number;
|
|
13
13
|
totalInstructionsExecuted: number;
|
|
14
|
-
txHashMs: number | undefined;
|
|
15
14
|
nonRevertiblePrivateInsertionsUs: number | undefined;
|
|
16
15
|
revertiblePrivateInsertionsUs: number | undefined;
|
|
17
16
|
enqueuedCalls: PublicEnqueuedCallMetrics[];
|
|
18
17
|
revertedCode: RevertCode | undefined;
|
|
18
|
+
proverSimulationStepMs: number | undefined;
|
|
19
|
+
proverProvingStepMs: number | undefined;
|
|
20
|
+
proverTraceGenerationStepMs: number | undefined;
|
|
21
|
+
traceGenerationInteractionsMs: number | undefined;
|
|
22
|
+
traceGenerationTracesMs: number | undefined;
|
|
23
|
+
provingSumcheckMs: number | undefined;
|
|
24
|
+
provingPcsMs: number | undefined;
|
|
25
|
+
provingLogDerivativeInverseMs: number | undefined;
|
|
26
|
+
provingLogDerivativeInverseCommitmentsMs: number | undefined;
|
|
27
|
+
provingWireCommitmentsMs: number | undefined;
|
|
19
28
|
}
|
|
20
29
|
export declare enum PublicTxMetricsFilter {
|
|
21
30
|
ALL = 0,
|
|
22
31
|
TOTALS = 1,
|
|
23
32
|
DURATIONS = 2,
|
|
24
|
-
INSTRUCTIONS = 3
|
|
33
|
+
INSTRUCTIONS = 3,
|
|
34
|
+
PROVING = 4
|
|
25
35
|
}
|
|
26
36
|
export declare class TestExecutorMetrics implements ExecutorMetricsInterface {
|
|
27
37
|
#private;
|
|
@@ -34,8 +44,8 @@ export declare class TestExecutorMetrics implements ExecutorMetricsInterface {
|
|
|
34
44
|
stopRecordingTxSimulation(txLabel: string, revertedCode?: RevertCode): void;
|
|
35
45
|
recordEnqueuedCallSimulation(fnName: string, durationMs: number, manaUsed: number, totalInstructionsExecuted: number): void;
|
|
36
46
|
recordEnqueuedCallSimulationFailure(fnName: string, durationMs: number, manaUsed: number, totalInstructionsExecuted: number): void;
|
|
37
|
-
recordTxHashComputation(durationMs: number): void;
|
|
38
47
|
recordPrivateEffectsInsertion(durationUs: number, type: 'revertible' | 'non-revertible'): void;
|
|
48
|
+
recordProverMetrics(txLabel: string, metrics: Partial<PublicTxMetrics>): void;
|
|
39
49
|
prettyPrint(filter?: PublicTxMetricsFilter): void;
|
|
40
50
|
toPrettyString(filter?: PublicTxMetricsFilter): string;
|
|
41
51
|
toJSON(indent?: number): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test_executor_metrics.d.ts","sourceRoot":"","sources":["../../src/public/test_executor_metrics.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAIpD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAEhF,MAAM,WAAW,yBAAyB;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,yBAAyB,EAAE,MAAM,CAAC;IAClC,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,eAAe;
|
|
1
|
+
{"version":3,"file":"test_executor_metrics.d.ts","sourceRoot":"","sources":["../../src/public/test_executor_metrics.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAIpD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAEhF,MAAM,WAAW,yBAAyB;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,yBAAyB,EAAE,MAAM,CAAC;IAClC,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,eAAe;IAE9B,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,yBAAyB,EAAE,MAAM,CAAC;IAClC,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AAE,MAAM;IAuBnC,6BAA6B,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,GAAG,gBAAgB;IAkBvF,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,eAAe,CAAC;IAYtE,WAAW,CAAC,MAAM,GAAE,qBAAiD;IAIrE,cAAc,CAAC,MAAM,GAAE,qBAAiD;IAwGxE,MAAM,CAAC,MAAM,SAAI;IAIjB,2BAA2B,CAAC,MAAM,SAAI;CA6FvC"}
|
|
@@ -15,8 +15,33 @@ export var PublicTxMetricsFilter = /*#__PURE__*/ function(PublicTxMetricsFilter)
|
|
|
15
15
|
PublicTxMetricsFilter[PublicTxMetricsFilter["TOTALS"] = 1] = "TOTALS";
|
|
16
16
|
PublicTxMetricsFilter[PublicTxMetricsFilter["DURATIONS"] = 2] = "DURATIONS";
|
|
17
17
|
PublicTxMetricsFilter[PublicTxMetricsFilter["INSTRUCTIONS"] = 3] = "INSTRUCTIONS";
|
|
18
|
+
PublicTxMetricsFilter[PublicTxMetricsFilter["PROVING"] = 4] = "PROVING";
|
|
18
19
|
return PublicTxMetricsFilter;
|
|
19
20
|
}({});
|
|
21
|
+
function createEmptyTxMetrics() {
|
|
22
|
+
return {
|
|
23
|
+
// TS simulation
|
|
24
|
+
totalDurationMs: 0,
|
|
25
|
+
manaUsed: 0,
|
|
26
|
+
totalInstructionsExecuted: 0,
|
|
27
|
+
nonRevertiblePrivateInsertionsUs: undefined,
|
|
28
|
+
revertiblePrivateInsertionsUs: undefined,
|
|
29
|
+
enqueuedCalls: [],
|
|
30
|
+
revertedCode: undefined,
|
|
31
|
+
// Proving
|
|
32
|
+
proverSimulationStepMs: undefined,
|
|
33
|
+
proverProvingStepMs: undefined,
|
|
34
|
+
proverTraceGenerationStepMs: undefined,
|
|
35
|
+
// Proving (detail)
|
|
36
|
+
traceGenerationInteractionsMs: undefined,
|
|
37
|
+
traceGenerationTracesMs: undefined,
|
|
38
|
+
provingSumcheckMs: undefined,
|
|
39
|
+
provingPcsMs: undefined,
|
|
40
|
+
provingLogDerivativeInverseMs: undefined,
|
|
41
|
+
provingLogDerivativeInverseCommitmentsMs: undefined,
|
|
42
|
+
provingWireCommitmentsMs: undefined
|
|
43
|
+
};
|
|
44
|
+
}
|
|
20
45
|
export class TestExecutorMetrics {
|
|
21
46
|
logger;
|
|
22
47
|
// tx label -> tx metrics
|
|
@@ -29,16 +54,7 @@ export class TestExecutorMetrics {
|
|
|
29
54
|
startRecordingTxSimulation(txLabel) {
|
|
30
55
|
assert(!this.currentTxLabel, 'Cannot start recording tx simulation when another is live');
|
|
31
56
|
assert(!this.txMetrics.has(txLabel), 'Cannot start recording metrics for tx with duplicate label');
|
|
32
|
-
this.txMetrics.set(txLabel,
|
|
33
|
-
totalDurationMs: 0,
|
|
34
|
-
manaUsed: 0,
|
|
35
|
-
totalInstructionsExecuted: 0,
|
|
36
|
-
txHashMs: undefined,
|
|
37
|
-
nonRevertiblePrivateInsertionsUs: undefined,
|
|
38
|
-
revertiblePrivateInsertionsUs: undefined,
|
|
39
|
-
enqueuedCalls: [],
|
|
40
|
-
revertedCode: undefined
|
|
41
|
-
});
|
|
57
|
+
this.txMetrics.set(txLabel, createEmptyTxMetrics());
|
|
42
58
|
this.currentTxLabel = txLabel;
|
|
43
59
|
this.txTimer = new Timer();
|
|
44
60
|
}
|
|
@@ -72,12 +88,6 @@ export class TestExecutorMetrics {
|
|
|
72
88
|
reverted
|
|
73
89
|
});
|
|
74
90
|
}
|
|
75
|
-
recordTxHashComputation(durationMs) {
|
|
76
|
-
assert(this.currentTxLabel, 'Cannot record tx hash computation time when no tx is live');
|
|
77
|
-
const txMetrics = this.txMetrics.get(this.currentTxLabel);
|
|
78
|
-
assert(txMetrics.txHashMs === undefined, 'Cannot RE-record tx hash computation time');
|
|
79
|
-
txMetrics.txHashMs = durationMs;
|
|
80
|
-
}
|
|
81
91
|
recordPrivateEffectsInsertion(durationUs, type) {
|
|
82
92
|
assert(this.currentTxLabel, 'Cannot record private effects insertion when no tx is live');
|
|
83
93
|
const txMetrics = this.txMetrics.get(this.currentTxLabel);
|
|
@@ -89,6 +99,17 @@ export class TestExecutorMetrics {
|
|
|
89
99
|
txMetrics.nonRevertiblePrivateInsertionsUs = durationUs;
|
|
90
100
|
}
|
|
91
101
|
}
|
|
102
|
+
recordProverMetrics(txLabel, metrics) {
|
|
103
|
+
if (!this.txMetrics.has(txLabel)) {
|
|
104
|
+
this.txMetrics.set(txLabel, createEmptyTxMetrics());
|
|
105
|
+
}
|
|
106
|
+
const txMetrics = this.txMetrics.get(txLabel);
|
|
107
|
+
for (const [key, value] of Object.entries(metrics)){
|
|
108
|
+
if (key in txMetrics) {
|
|
109
|
+
txMetrics[key] = value;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
92
113
|
prettyPrint(filter = 0) {
|
|
93
114
|
this.logger.info(this.toPrettyString(filter));
|
|
94
115
|
}
|
|
@@ -111,11 +132,46 @@ export class TestExecutorMetrics {
|
|
|
111
132
|
pretty += `${INDENT0}Total instructions executed: ${fmtNum(txMetrics.totalInstructionsExecuted)}\n`;
|
|
112
133
|
}
|
|
113
134
|
if (filter === 2 || filter === 0) {
|
|
114
|
-
pretty += `${INDENT0}Tx hash computation: ${fmtNum(txMetrics.txHashMs, 'ms')}\n`;
|
|
115
135
|
pretty += `${INDENT0}Private insertions:\n`;
|
|
116
136
|
pretty += `${INDENT1}Non-revertible: ${fmtNum(txMetrics.nonRevertiblePrivateInsertionsUs / 1_000, 'ms')}\n`;
|
|
117
137
|
pretty += `${INDENT1}Revertible: ${fmtNum(txMetrics.revertiblePrivateInsertionsUs / 1_000, 'ms')}\n`;
|
|
118
138
|
}
|
|
139
|
+
if (filter === 4 || filter === 0) {
|
|
140
|
+
let provingPretty = '';
|
|
141
|
+
if (txMetrics.proverSimulationStepMs !== undefined) {
|
|
142
|
+
provingPretty += `${INDENT1}Simulation (all): ${fmtNum(txMetrics.proverSimulationStepMs, 'ms')}\n`;
|
|
143
|
+
}
|
|
144
|
+
if (txMetrics.proverProvingStepMs !== undefined) {
|
|
145
|
+
provingPretty += `${INDENT1}Proving (all): ${fmtNum(txMetrics.proverProvingStepMs, 'ms')}\n`;
|
|
146
|
+
}
|
|
147
|
+
if (txMetrics.proverTraceGenerationStepMs !== undefined) {
|
|
148
|
+
provingPretty += `${INDENT1}Trace generation (all): ${fmtNum(txMetrics.proverTraceGenerationStepMs, 'ms')}\n`;
|
|
149
|
+
}
|
|
150
|
+
if (txMetrics.traceGenerationInteractionsMs !== undefined) {
|
|
151
|
+
provingPretty += `${INDENT1}Trace generation interactions: ${fmtNum(txMetrics.traceGenerationInteractionsMs, 'ms')}\n`;
|
|
152
|
+
}
|
|
153
|
+
if (txMetrics.traceGenerationTracesMs !== undefined) {
|
|
154
|
+
provingPretty += `${INDENT1}Trace generation traces: ${fmtNum(txMetrics.traceGenerationTracesMs, 'ms')}\n`;
|
|
155
|
+
}
|
|
156
|
+
if (txMetrics.provingSumcheckMs !== undefined) {
|
|
157
|
+
provingPretty += `${INDENT1}Sumcheck: ${fmtNum(txMetrics.provingSumcheckMs, 'ms')}\n`;
|
|
158
|
+
}
|
|
159
|
+
if (txMetrics.provingPcsMs !== undefined) {
|
|
160
|
+
provingPretty += `${INDENT1}PCS: ${fmtNum(txMetrics.provingPcsMs, 'ms')}\n`;
|
|
161
|
+
}
|
|
162
|
+
if (txMetrics.provingLogDerivativeInverseMs !== undefined) {
|
|
163
|
+
provingPretty += `${INDENT1}Log derivative inverse: ${fmtNum(txMetrics.provingLogDerivativeInverseMs, 'ms')}\n`;
|
|
164
|
+
}
|
|
165
|
+
if (txMetrics.provingLogDerivativeInverseCommitmentsMs !== undefined) {
|
|
166
|
+
provingPretty += `${INDENT1}Log derivative inverse commitments: ${fmtNum(txMetrics.provingLogDerivativeInverseCommitmentsMs, 'ms')}\n`;
|
|
167
|
+
}
|
|
168
|
+
if (txMetrics.provingWireCommitmentsMs !== undefined) {
|
|
169
|
+
provingPretty += `${INDENT1}Wire commitments: ${fmtNum(txMetrics.provingWireCommitmentsMs, 'ms')}\n`;
|
|
170
|
+
}
|
|
171
|
+
if (provingPretty.length > 0) {
|
|
172
|
+
pretty += `${INDENT0}Proving:\n${provingPretty}`;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
119
175
|
if (filter !== 1) {
|
|
120
176
|
// totals exclude enqueued calls
|
|
121
177
|
pretty += this.#enqueuedCallsToPrettyString(txMetrics, filter);
|
|
@@ -153,38 +209,94 @@ export class TestExecutorMetrics {
|
|
|
153
209
|
return JSON.stringify(Object.fromEntries(this.txMetrics.entries()), null, indent);
|
|
154
210
|
}
|
|
155
211
|
toGithubActionBenchmarkJSON(indent = 2) {
|
|
212
|
+
const metricsInfo = {
|
|
213
|
+
totalInstructionsExecuted: {
|
|
214
|
+
name: 'totalInstructionsExecuted',
|
|
215
|
+
unit: '#instructions',
|
|
216
|
+
category: 3
|
|
217
|
+
},
|
|
218
|
+
totalDurationMs: {
|
|
219
|
+
name: 'totalDurationMs',
|
|
220
|
+
unit: 'ms',
|
|
221
|
+
category: 2
|
|
222
|
+
},
|
|
223
|
+
manaUsed: {
|
|
224
|
+
name: 'manaUsed',
|
|
225
|
+
unit: 'mana',
|
|
226
|
+
category: 1
|
|
227
|
+
},
|
|
228
|
+
nonRevertiblePrivateInsertionsUs: {
|
|
229
|
+
name: 'nonRevertiblePrivateInsertionsUs',
|
|
230
|
+
unit: 'us',
|
|
231
|
+
category: 2
|
|
232
|
+
},
|
|
233
|
+
revertiblePrivateInsertionsUs: {
|
|
234
|
+
name: 'revertiblePrivateInsertionsUs',
|
|
235
|
+
unit: 'us',
|
|
236
|
+
category: 2
|
|
237
|
+
},
|
|
238
|
+
proverSimulationStepMs: {
|
|
239
|
+
name: 'proverSimulationStepMs',
|
|
240
|
+
unit: 'ms',
|
|
241
|
+
category: 4
|
|
242
|
+
},
|
|
243
|
+
proverProvingStepMs: {
|
|
244
|
+
name: 'proverProvingStepMs',
|
|
245
|
+
unit: 'ms',
|
|
246
|
+
category: 4
|
|
247
|
+
},
|
|
248
|
+
proverTraceGenerationStepMs: {
|
|
249
|
+
name: 'proverTraceGenerationStepMs',
|
|
250
|
+
unit: 'ms',
|
|
251
|
+
category: 4
|
|
252
|
+
},
|
|
253
|
+
traceGenerationInteractionsMs: {
|
|
254
|
+
name: 'traceGenerationInteractionsMs',
|
|
255
|
+
unit: 'ms',
|
|
256
|
+
category: 4
|
|
257
|
+
},
|
|
258
|
+
traceGenerationTracesMs: {
|
|
259
|
+
name: 'traceGenerationTracesMs',
|
|
260
|
+
unit: 'ms',
|
|
261
|
+
category: 4
|
|
262
|
+
},
|
|
263
|
+
provingSumcheckMs: {
|
|
264
|
+
name: 'provingSumcheckMs',
|
|
265
|
+
unit: 'ms',
|
|
266
|
+
category: 4
|
|
267
|
+
},
|
|
268
|
+
provingPcsMs: {
|
|
269
|
+
name: 'provingPcsMs',
|
|
270
|
+
unit: 'ms',
|
|
271
|
+
category: 4
|
|
272
|
+
},
|
|
273
|
+
provingLogDerivativeInverseMs: {
|
|
274
|
+
name: 'provingLogDerivativeInverseMs',
|
|
275
|
+
unit: 'ms',
|
|
276
|
+
category: 4
|
|
277
|
+
},
|
|
278
|
+
provingLogDerivativeInverseCommitmentsMs: {
|
|
279
|
+
name: 'provingLogDerivativeInverseCommitmentsMs',
|
|
280
|
+
unit: 'ms',
|
|
281
|
+
category: 4
|
|
282
|
+
},
|
|
283
|
+
provingWireCommitmentsMs: {
|
|
284
|
+
name: 'provingWireCommitmentsMs',
|
|
285
|
+
unit: 'ms',
|
|
286
|
+
category: 4
|
|
287
|
+
}
|
|
288
|
+
};
|
|
156
289
|
const data = [];
|
|
157
290
|
for (const [txLabel, txMetrics] of this.txMetrics.entries()){
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
});
|
|
168
|
-
data.push({
|
|
169
|
-
name: `${txLabel}/manaUsed`,
|
|
170
|
-
value: txMetrics.manaUsed,
|
|
171
|
-
unit: 'mana'
|
|
172
|
-
});
|
|
173
|
-
data.push({
|
|
174
|
-
name: `${txLabel}/txHashMs`,
|
|
175
|
-
value: txMetrics.txHashMs,
|
|
176
|
-
unit: 'ms'
|
|
177
|
-
});
|
|
178
|
-
data.push({
|
|
179
|
-
name: `${txLabel}/nonRevertiblePrivateInsertionsUs`,
|
|
180
|
-
value: txMetrics.nonRevertiblePrivateInsertionsUs,
|
|
181
|
-
unit: 'us'
|
|
182
|
-
});
|
|
183
|
-
data.push({
|
|
184
|
-
name: `${txLabel}/revertiblePrivateInsertionsUs`,
|
|
185
|
-
value: txMetrics.revertiblePrivateInsertionsUs,
|
|
186
|
-
unit: 'us'
|
|
187
|
-
});
|
|
291
|
+
for (const [key, value] of Object.entries(txMetrics)){
|
|
292
|
+
if (value !== undefined && key in metricsInfo) {
|
|
293
|
+
data.push({
|
|
294
|
+
name: `${txLabel}/${metricsInfo[key].name}`,
|
|
295
|
+
value: value,
|
|
296
|
+
unit: metricsInfo[key].unit
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
}
|
|
188
300
|
}
|
|
189
301
|
return JSON.stringify(data, null, indent);
|
|
190
302
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/simulator",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-nightly.20250813",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./server": "./dest/server.js",
|
|
@@ -63,25 +63,25 @@
|
|
|
63
63
|
]
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@aztec/constants": "
|
|
67
|
-
"@aztec/foundation": "
|
|
68
|
-
"@aztec/noir-acvm_js": "
|
|
69
|
-
"@aztec/noir-noirc_abi": "
|
|
70
|
-
"@aztec/noir-protocol-circuits-types": "
|
|
71
|
-
"@aztec/noir-types": "
|
|
72
|
-
"@aztec/protocol-contracts": "
|
|
73
|
-
"@aztec/stdlib": "
|
|
74
|
-
"@aztec/telemetry-client": "
|
|
75
|
-
"@aztec/world-state": "
|
|
66
|
+
"@aztec/constants": "2.0.0-nightly.20250813",
|
|
67
|
+
"@aztec/foundation": "2.0.0-nightly.20250813",
|
|
68
|
+
"@aztec/noir-acvm_js": "2.0.0-nightly.20250813",
|
|
69
|
+
"@aztec/noir-noirc_abi": "2.0.0-nightly.20250813",
|
|
70
|
+
"@aztec/noir-protocol-circuits-types": "2.0.0-nightly.20250813",
|
|
71
|
+
"@aztec/noir-types": "2.0.0-nightly.20250813",
|
|
72
|
+
"@aztec/protocol-contracts": "2.0.0-nightly.20250813",
|
|
73
|
+
"@aztec/stdlib": "2.0.0-nightly.20250813",
|
|
74
|
+
"@aztec/telemetry-client": "2.0.0-nightly.20250813",
|
|
75
|
+
"@aztec/world-state": "2.0.0-nightly.20250813",
|
|
76
76
|
"lodash.clonedeep": "^4.5.0",
|
|
77
77
|
"lodash.merge": "^4.6.2",
|
|
78
78
|
"tslib": "^2.4.0"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
|
-
"@aztec/kv-store": "
|
|
82
|
-
"@aztec/merkle-tree": "
|
|
83
|
-
"@aztec/noir-contracts.js": "
|
|
84
|
-
"@aztec/noir-test-contracts.js": "
|
|
81
|
+
"@aztec/kv-store": "2.0.0-nightly.20250813",
|
|
82
|
+
"@aztec/merkle-tree": "2.0.0-nightly.20250813",
|
|
83
|
+
"@aztec/noir-contracts.js": "2.0.0-nightly.20250813",
|
|
84
|
+
"@aztec/noir-test-contracts.js": "2.0.0-nightly.20250813",
|
|
85
85
|
"@jest/globals": "^30.0.0",
|
|
86
86
|
"@types/jest": "^30.0.0",
|
|
87
87
|
"@types/lodash.clonedeep": "^4.5.7",
|
|
@@ -159,11 +159,11 @@ export class CircuitRecorder {
|
|
|
159
159
|
throw new Error(`Oracle method ${name} not found when setting up recording callback`);
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
-
const isExternalCall = (name as keyof ACIRCallback) === '
|
|
162
|
+
const isExternalCall = (name as keyof ACIRCallback) === 'privateCallPrivateFunction';
|
|
163
163
|
|
|
164
164
|
recordingCallback[name as keyof ACIRCallback] = (...args: ForeignCallInput[]): ReturnType<typeof fn> => {
|
|
165
165
|
const timer = new Timer();
|
|
166
|
-
// If we're entering another circuit via `
|
|
166
|
+
// If we're entering another circuit via `privateCallPrivateFunction`, we increase the stack depth and set the
|
|
167
167
|
// newCircuit variable to ensure we are creating a new recording object.
|
|
168
168
|
if (isExternalCall) {
|
|
169
169
|
this.stackDepth++;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS } from '@aztec/constants';
|
|
2
2
|
import { Fr } from '@aztec/foundation/fields';
|
|
3
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
@@ -95,7 +95,7 @@ export abstract class BaseAvmSimulationTester {
|
|
|
95
95
|
|
|
96
96
|
private async insertContractAddressNullifier(contractAddress: AztecAddress) {
|
|
97
97
|
const contractAddressNullifier = await siloNullifier(
|
|
98
|
-
AztecAddress.fromNumber(
|
|
98
|
+
AztecAddress.fromNumber(CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS),
|
|
99
99
|
contractAddress.toField(),
|
|
100
100
|
);
|
|
101
101
|
await this.merkleTrees.sequentialInsert(MerkleTreeId.NULLIFIER_TREE, [contractAddressNullifier.toBuffer()]);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS } from '@aztec/constants';
|
|
2
2
|
import { Fr } from '@aztec/foundation/fields';
|
|
3
3
|
import {
|
|
4
4
|
type ContractArtifact,
|
|
@@ -141,7 +141,7 @@ export async function createContractClassAndInstance(
|
|
|
141
141
|
});
|
|
142
142
|
|
|
143
143
|
const contractAddressNullifier = await siloNullifier(
|
|
144
|
-
AztecAddress.fromNumber(
|
|
144
|
+
AztecAddress.fromNumber(CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS),
|
|
145
145
|
contractInstance.address.toField(),
|
|
146
146
|
);
|
|
147
147
|
|
|
@@ -36,11 +36,12 @@ export class NoteHashExists extends Instruction {
|
|
|
36
36
|
);
|
|
37
37
|
const operands = [this.noteHashOffset, this.leafIndexOffset, this.existsOffset];
|
|
38
38
|
const [noteHashOffset, leafIndexOffset, existsOffset] = addressing.resolve(operands, memory);
|
|
39
|
-
memory.
|
|
39
|
+
memory.checkTag(TypeTag.FIELD, noteHashOffset);
|
|
40
|
+
memory.checkTag(TypeTag.UINT64, leafIndexOffset);
|
|
40
41
|
|
|
41
42
|
// Note that this instruction accepts any type in memory, and converts to Field.
|
|
42
43
|
const noteHash = memory.get(noteHashOffset).toFr();
|
|
43
|
-
const leafIndex = memory.get(leafIndexOffset).
|
|
44
|
+
const leafIndex = memory.get(leafIndexOffset).toBigInt();
|
|
44
45
|
|
|
45
46
|
const exists = await context.persistableState.checkNoteHashExists(context.environment.address, noteHash, leafIndex);
|
|
46
47
|
memory.set(existsOffset, exists ? new Uint1(1) : new Uint1(0));
|
|
@@ -198,7 +199,9 @@ export class L1ToL2MessageExists extends Instruction {
|
|
|
198
199
|
|
|
199
200
|
const operands = [this.msgHashOffset, this.msgLeafIndexOffset, this.existsOffset];
|
|
200
201
|
const [msgHashOffset, msgLeafIndexOffset, existsOffset] = addressing.resolve(operands, memory);
|
|
201
|
-
|
|
202
|
+
|
|
203
|
+
memory.checkTag(TypeTag.FIELD, msgHashOffset);
|
|
204
|
+
memory.checkTag(TypeTag.UINT64, msgLeafIndexOffset);
|
|
202
205
|
|
|
203
206
|
const msgHash = memory.get(msgHashOffset).toFr();
|
|
204
207
|
const msgLeafIndex = memory.get(msgLeafIndexOffset).toFr();
|
|
@@ -15,7 +15,7 @@ abstract class ComparatorInstruction extends ThreeOperandInstruction {
|
|
|
15
15
|
|
|
16
16
|
const operands = [this.aOffset, this.bOffset, this.dstOffset];
|
|
17
17
|
const [aOffset, bOffset, dstOffset] = addressing.resolve(operands, memory);
|
|
18
|
-
memory.checkTagsAreSame(aOffset, bOffset);
|
|
18
|
+
memory.checkTagsAreSame(aOffset, bOffset); // Brillig semantic enforces that tags match.
|
|
19
19
|
|
|
20
20
|
const a = memory.get(aOffset);
|
|
21
21
|
const b = memory.get(bOffset);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AvmContext } from '../avm_context.js';
|
|
2
|
-
import { Field, Uint32, Uint64, Uint128 } from '../avm_memory_types.js';
|
|
2
|
+
import { Field, Uint1, Uint32, Uint64, Uint128 } from '../avm_memory_types.js';
|
|
3
3
|
import { InstructionExecutionError } from '../errors.js';
|
|
4
4
|
import { Opcode, OperandType } from '../serialization/instruction_serialization.js';
|
|
5
5
|
import { Addressing } from './addressing_mode.js';
|
|
@@ -13,8 +13,8 @@ export enum EnvironmentVariable {
|
|
|
13
13
|
VERSION,
|
|
14
14
|
BLOCKNUMBER,
|
|
15
15
|
TIMESTAMP,
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
BASEFEEPERL2GAS,
|
|
17
|
+
BASEFEEPERDAGAS,
|
|
18
18
|
ISSTATICCALL,
|
|
19
19
|
L2GASLEFT,
|
|
20
20
|
DAGASLEFT,
|
|
@@ -36,16 +36,16 @@ function getValue(e: EnvironmentVariable, ctx: AvmContext) {
|
|
|
36
36
|
return new Uint32(ctx.environment.globals.blockNumber);
|
|
37
37
|
case EnvironmentVariable.TIMESTAMP:
|
|
38
38
|
return new Uint64(ctx.environment.globals.timestamp);
|
|
39
|
-
case EnvironmentVariable.
|
|
39
|
+
case EnvironmentVariable.BASEFEEPERL2GAS:
|
|
40
40
|
return new Uint128(ctx.environment.globals.gasFees.feePerL2Gas);
|
|
41
|
-
case EnvironmentVariable.
|
|
41
|
+
case EnvironmentVariable.BASEFEEPERDAGAS:
|
|
42
42
|
return new Uint128(ctx.environment.globals.gasFees.feePerDaGas);
|
|
43
43
|
case EnvironmentVariable.ISSTATICCALL:
|
|
44
|
-
return new
|
|
44
|
+
return new Uint1(ctx.environment.isStaticCall ? 1 : 0);
|
|
45
45
|
case EnvironmentVariable.L2GASLEFT:
|
|
46
|
-
return new
|
|
46
|
+
return new Uint32(ctx.machineState.l2GasLeft);
|
|
47
47
|
case EnvironmentVariable.DAGASLEFT:
|
|
48
|
-
return new
|
|
48
|
+
return new Uint32(ctx.machineState.daGasLeft);
|
|
49
49
|
default:
|
|
50
50
|
throw new Error(`Unknown environment variable ${e}`);
|
|
51
51
|
}
|