@aztec/simulator 3.0.0-nightly.20251119 → 3.0.0-nightly.20251121
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/public/executor_metrics.d.ts +2 -1
- package/dest/public/executor_metrics.d.ts.map +1 -1
- package/dest/public/executor_metrics.js +1 -1
- package/dest/public/executor_metrics_interface.d.ts +2 -1
- package/dest/public/executor_metrics_interface.d.ts.map +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/public_db_sources.d.ts +0 -1
- package/dest/public/public_db_sources.d.ts.map +1 -1
- package/dest/public/public_db_sources.js +9 -15
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator.js +6 -2
- package/dest/public/public_tx_simulator/measured_public_tx_simulator.js +1 -1
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_simulator.js +6 -1
- package/dest/public/test_executor_metrics.d.ts +3 -2
- package/dest/public/test_executor_metrics.d.ts.map +1 -1
- package/dest/public/test_executor_metrics.js +5 -4
- package/package.json +16 -16
- package/src/public/executor_metrics.ts +2 -1
- package/src/public/executor_metrics_interface.ts +2 -1
- package/src/public/fixtures/public_tx_simulation_tester.ts +4 -1
- package/src/public/public_db_sources.ts +12 -15
- package/src/public/public_tx_simulator/cpp_public_tx_simulator.ts +6 -2
- package/src/public/public_tx_simulator/measured_public_tx_simulator.ts +1 -1
- package/src/public/public_tx_simulator/public_tx_simulator.ts +6 -1
- package/src/public/test_executor_metrics.ts +7 -5
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { RevertCode } from '@aztec/stdlib/avm';
|
|
2
|
+
import type { GasUsed } from '@aztec/stdlib/gas';
|
|
2
3
|
import { type TelemetryClient, type Tracer } from '@aztec/telemetry-client';
|
|
3
4
|
import type { ExecutorMetricsInterface } from './executor_metrics_interface.js';
|
|
4
5
|
export declare class ExecutorMetrics implements ExecutorMetricsInterface {
|
|
@@ -12,7 +13,7 @@ export declare class ExecutorMetrics implements ExecutorMetricsInterface {
|
|
|
12
13
|
private privateEffectsInsertions;
|
|
13
14
|
constructor(client: TelemetryClient, name?: string);
|
|
14
15
|
startRecordingTxSimulation(_txLabel: string): void;
|
|
15
|
-
stopRecordingTxSimulation(_txLabel: string, _revertedCode?: RevertCode): void;
|
|
16
|
+
stopRecordingTxSimulation(_txLabel: string, _gasUsed?: GasUsed, _revertedCode?: RevertCode): void;
|
|
16
17
|
recordEnqueuedCallSimulation(fnName: string, durationMs: number, manaUsed: number, totalInstructionsExecuted: number): void;
|
|
17
18
|
recordEnqueuedCallSimulationFailure(_fnName: string, _durationMs: number, _manaUsed: number, _totalInstructionsExecuted: number): void;
|
|
18
19
|
recordPrivateEffectsInsertion(durationUs: number, type: 'revertible' | 'non-revertible'): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executor_metrics.d.ts","sourceRoot":"","sources":["../../src/public/executor_metrics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAIL,KAAK,eAAe,EACpB,KAAK,MAAM,EAGZ,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAEhF,qBAAa,eAAgB,YAAW,wBAAwB;IAC9D,SAAgB,MAAM,EAAE,MAAM,CAAC;IAC/B,OAAO,CAAC,OAAO,CAAgB;IAC/B,OAAO,CAAC,UAAU,CAAY;IAC9B,OAAO,CAAC,aAAa,CAAY;IACjC,OAAO,CAAC,QAAQ,CAAY;IAC5B,OAAO,CAAC,yBAAyB,CAAY;IAC7C,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,wBAAwB,CAAY;gBAEhC,MAAM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AAE,MAAM,EAAE,IAAI,EAAE,YAAY,GAAG,gBAAgB;CAKxF"}
|
|
@@ -48,7 +48,7 @@ export class ExecutorMetrics {
|
|
|
48
48
|
startRecordingTxSimulation(_txLabel) {
|
|
49
49
|
// do nothing (unimplemented)
|
|
50
50
|
}
|
|
51
|
-
stopRecordingTxSimulation(_txLabel, _revertedCode) {
|
|
51
|
+
stopRecordingTxSimulation(_txLabel, _gasUsed, _revertedCode) {
|
|
52
52
|
// do nothing (unimplemented)
|
|
53
53
|
}
|
|
54
54
|
recordEnqueuedCallSimulation(fnName, durationMs, manaUsed, totalInstructionsExecuted) {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { RevertCode } from '@aztec/stdlib/avm';
|
|
2
|
+
import type { GasUsed } from '@aztec/stdlib/gas';
|
|
2
3
|
export interface ExecutorMetricsInterface {
|
|
3
4
|
startRecordingTxSimulation(txLabel: string): void;
|
|
4
|
-
stopRecordingTxSimulation(txLabel: string, revertedCode?: RevertCode): void;
|
|
5
|
+
stopRecordingTxSimulation(txLabel: string, gasUsed?: GasUsed, revertedCode?: RevertCode): void;
|
|
5
6
|
recordEnqueuedCallSimulation(fnName: string, durationMs: number, manaUsed: number, totalInstructions: number): void;
|
|
6
7
|
recordEnqueuedCallSimulationFailure(fnName: string, durationMs: number, manaUsed: number, totalInstructionsExecuted: number): void;
|
|
7
8
|
recordPrivateEffectsInsertion(durationUs: number, type: 'revertible' | 'non-revertible'): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executor_metrics_interface.d.ts","sourceRoot":"","sources":["../../src/public/executor_metrics_interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"executor_metrics_interface.d.ts","sourceRoot":"","sources":["../../src/public/executor_metrics_interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAEjD,MAAM,WAAW,wBAAwB;IACvC,0BAA0B,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAClD,yBAAyB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,YAAY,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC;IAC/F,4BAA4B,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IACpH,mCAAmC,CACjC,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,yBAAyB,EAAE,MAAM,GAChC,IAAI,CAAC;IACR,6BAA6B,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,GAAG,gBAAgB,GAAG,IAAI,CAAC;CAChG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public_tx_simulation_tester.d.ts","sourceRoot":"","sources":["../../../src/public/fixtures/public_tx_simulation_tester.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"public_tx_simulation_tester.d.ts","sourceRoot":"","sources":["../../../src/public/fixtures/public_tx_simulation_tester.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,gBAAgB,EAAmB,MAAM,mBAAmB,CAAC;AAC3E,OAAO,EAAyB,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC/E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAEjF,OAAO,EAAE,eAAe,EAAiC,KAAK,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAC3F,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAE7D,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CACrB,MAAM,EAAE,YAAY,EACpB,UAAU,GAAE,gBAAgB,EAAO,EACnC,QAAQ,GAAE,gBAAgB,EAAO,EACjC,YAAY,CAAC,EAAE,gBAAgB,EAC/B,QAAQ,GAAE,YAAqB,EAE/B,iBAAiB,CAAC,EAAE,qBAAqB,EACzC,OAAO,GAAE,MAAsB,GAC9B,OAAO,CAAC,cAAc,CAAC;IAyB1B;;;;;OAKG;IACU,mBAAmB,CAC9B,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,YAAY,EACpB,UAAU,CAAC,EAAE,gBAAgB,EAAE,EAC/B,QAAQ,CAAC,EAAE,gBAAgB,EAAE,EAC7B,YAAY,CAAC,EAAE,gBAAgB,EAC/B,QAAQ,CAAC,EAAE,YAAY,EACvB,iBAAiB,CAAC,EAAE,qBAAqB,GACxC,OAAO,CAAC,cAAc,CAAC;IAI1B;;;;;;OAMG;IACU,kBAAkB,CAC7B,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,YAAY,EACpB,UAAU,CAAC,EAAE,gBAAgB,EAAE,EAC/B,QAAQ,CAAC,EAAE,gBAAgB,EAAE,EAC7B,YAAY,CAAC,EAAE,gBAAgB,EAC/B,QAAQ,CAAC,EAAE,YAAY,EACvB,iBAAiB,CAAC,EAAE,qBAAqB,GACxC,OAAO,CAAC,cAAc,CAAC;IAYnB,kBAAkB;CAuB1B;AAED,wBAAgB,cAAc,oBAM7B"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DEFAULT_TEARDOWN_DA_GAS_LIMIT, DEFAULT_TEARDOWN_L2_GAS_LIMIT } from '@aztec/constants';
|
|
1
2
|
import { asyncMap } from '@aztec/foundation/async-map';
|
|
2
3
|
import { Fr } from '@aztec/foundation/fields';
|
|
3
4
|
import { encodeArguments } from '@aztec/stdlib/abi';
|
|
@@ -53,7 +54,7 @@ const DEFAULT_GAS_FEES = new GasFees(2, 3);
|
|
|
53
54
|
const appCallRequests = await asyncMap(appCalls, (call)=>this.#createPubicCallRequestForCall(call, call.sender ?? sender));
|
|
54
55
|
const teardownCallRequest = teardownCall ? await this.#createPubicCallRequestForCall(teardownCall, teardownCall.sender ?? sender) : undefined;
|
|
55
56
|
this.txCount++;
|
|
56
|
-
return createTxForPublicCalls(privateInsertions, setupCallRequests, appCallRequests, teardownCallRequest, feePayer, /*gasUsedByPrivate*/ Gas.empty(), defaultGlobals());
|
|
57
|
+
return createTxForPublicCalls(privateInsertions, setupCallRequests, appCallRequests, teardownCallRequest, feePayer, /*gasUsedByPrivate*/ teardownCall ? new Gas(DEFAULT_TEARDOWN_DA_GAS_LIMIT, DEFAULT_TEARDOWN_L2_GAS_LIMIT) : Gas.empty(), defaultGlobals());
|
|
57
58
|
}
|
|
58
59
|
async simulateTx(sender, setupCalls = [], appCalls = [], teardownCall, feePayer = sender, /* need some unique first nullifier for note-nonce computations */ privateInsertions, txLabel = 'unlabeledTx') {
|
|
59
60
|
const tx = await this.createTx(sender, setupCalls, appCalls, teardownCall, feePayer, privateInsertions);
|
|
@@ -14,7 +14,6 @@ import type { PublicContractsDBInterface, PublicStateDBInterface } from './db_in
|
|
|
14
14
|
export declare class PublicContractsDB implements PublicContractsDBInterface {
|
|
15
15
|
private dataSource;
|
|
16
16
|
private contractStateStack;
|
|
17
|
-
private bytecodeCommitmentCache;
|
|
18
17
|
private log;
|
|
19
18
|
constructor(dataSource: ContractDataSource);
|
|
20
19
|
addContracts(contractDeploymentData: ContractDeploymentData): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public_db_sources.d.ts","sourceRoot":"","sources":["../../src/public/public_db_sources.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAK9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,k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,EAAE,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC;IAkBlD,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC;IAkB3C,aAAa,CAAC,QAAQ,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAW1C,oBAAoB,CAAC,SAAS,EAAE,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;IAoBrD,cAAc,CAAC,eAAe,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAWlD,OAAO,CAAC,MAAM,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAmCpE,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;IAIjC,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;IAIjC,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;IAIjC,gBAAgB,IAAI,OAAO,CAAC,aAAa,CAAC;CASxD"}
|
|
@@ -18,14 +18,12 @@ import { L1ToL2MessageIndexOutOfRangeError, NoteHashIndexOutOfRangeError } from
|
|
|
18
18
|
*/ export class PublicContractsDB {
|
|
19
19
|
dataSource;
|
|
20
20
|
contractStateStack;
|
|
21
|
-
bytecodeCommitmentCache;
|
|
22
21
|
log;
|
|
23
22
|
constructor(dataSource){
|
|
24
23
|
this.dataSource = dataSource;
|
|
25
24
|
this.contractStateStack = [
|
|
26
25
|
new ContractsDbCheckpoint()
|
|
27
26
|
];
|
|
28
|
-
this.bytecodeCommitmentCache = new Map();
|
|
29
27
|
this.log = createLogger('simulator:contracts-data-source');
|
|
30
28
|
}
|
|
31
29
|
async addContracts(contractDeploymentData) {
|
|
@@ -97,25 +95,21 @@ import { L1ToL2MessageIndexOutOfRangeError, NoteHashIndexOutOfRangeError } from
|
|
|
97
95
|
return currentState.getClass(contractClassId) ?? await this.dataSource.getContractClass(contractClassId);
|
|
98
96
|
}
|
|
99
97
|
async getBytecodeCommitment(contractClassId) {
|
|
100
|
-
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
return result;
|
|
105
|
-
}
|
|
106
|
-
// Now try from the store
|
|
107
|
-
const fromStore = await this.dataSource.getBytecodeCommitment(contractClassId);
|
|
108
|
-
if (fromStore !== undefined) {
|
|
109
|
-
this.bytecodeCommitmentCache.set(key, fromStore);
|
|
110
|
-
return fromStore;
|
|
98
|
+
const currentState = this.getCurrentState();
|
|
99
|
+
const commitment = currentState.getBytecodeCommitment(contractClassId) ?? await this.dataSource.getBytecodeCommitment(contractClassId);
|
|
100
|
+
if (commitment !== undefined) {
|
|
101
|
+
return commitment;
|
|
111
102
|
}
|
|
112
|
-
// Not in
|
|
103
|
+
// Not in the current state or the store, compute it here
|
|
104
|
+
// Get the contract class
|
|
113
105
|
const contractClass = await this.getContractClass(contractClassId);
|
|
114
106
|
if (contractClass === undefined) {
|
|
107
|
+
// cannot compute bytecode commitment if contract class is not found
|
|
115
108
|
return undefined;
|
|
116
109
|
}
|
|
117
110
|
const value = await computePublicBytecodeCommitment(contractClass.packedBytecode);
|
|
118
|
-
|
|
111
|
+
// Add to cache (current checkpoint state) so we don't compute again
|
|
112
|
+
currentState.addBytecodeCommitment(contractClassId, value);
|
|
119
113
|
return value;
|
|
120
114
|
}
|
|
121
115
|
async getDebugFunctionName(address, selector) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cpp_public_tx_simulator.d.ts","sourceRoot":"","sources":["../../../src/public/public_tx_simulator/cpp_public_tx_simulator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAIlE,OAAO,EAIL,KAAK,qBAAqB,EAC1B,cAAc,EAEf,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,KAAK,EAAE,eAAe,EAAkB,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAK5E,OAA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O,CAAC,qBAAqB,CAAC;IAKnB,QAAQ,CAAC,EAAE,EAAE,EAAE,EAAE,OAAO,GAAE,MAAsB,GAAG,OAAO,CAAC,cAAc,CAAC;CAUjG"}
|
|
@@ -91,6 +91,10 @@ import { PublicTxSimulator } from './public_tx_simulator.js';
|
|
|
91
91
|
// TODO(fcarreiro): complete this.
|
|
92
92
|
assert(cppResult.revertCode.equals(tsResult.revertCode));
|
|
93
93
|
assert(cppResult.gasUsed.totalGas.equals(tsResult.gasUsed.totalGas));
|
|
94
|
+
assert(cppResult.gasUsed.publicGas.equals(tsResult.gasUsed.publicGas));
|
|
95
|
+
assert(cppResult.gasUsed.teardownGas.equals(tsResult.gasUsed.teardownGas));
|
|
96
|
+
assert(cppResult.gasUsed.billedGas.equals(tsResult.gasUsed.billedGas));
|
|
97
|
+
assert(cppResult.publicInputs.toBuffer().equals(tsResult.publicInputs.toBuffer()));
|
|
94
98
|
// FIXME(https://github.com/AztecProtocol/aztec-packages/issues/18441): a few but not all keccaks fail!
|
|
95
99
|
// expect(cppResult.appLogicReturnValues).toEqual(tsResult.appLogicReturnValues);
|
|
96
100
|
// Confirm that tree roots match
|
|
@@ -117,7 +121,7 @@ export class MeasuredCppPublicTxSimulator extends CppPublicTxSimulator {
|
|
|
117
121
|
try {
|
|
118
122
|
result = await super.simulate(tx);
|
|
119
123
|
} finally{
|
|
120
|
-
this.metrics.stopRecordingTxSimulation(txLabel, result?.revertCode);
|
|
124
|
+
this.metrics.stopRecordingTxSimulation(txLabel, result?.gasUsed, result?.revertCode);
|
|
121
125
|
}
|
|
122
126
|
return result;
|
|
123
127
|
}
|
|
@@ -197,7 +201,7 @@ export class MeasuredCppPublicTxSimulator extends CppPublicTxSimulator {
|
|
|
197
201
|
try {
|
|
198
202
|
result = await super.simulate(tx);
|
|
199
203
|
} finally{
|
|
200
|
-
this.metrics.stopRecordingTxSimulation(txLabel, result?.revertCode);
|
|
204
|
+
this.metrics.stopRecordingTxSimulation(txLabel, result?.gasUsed, result?.revertCode);
|
|
201
205
|
}
|
|
202
206
|
return result;
|
|
203
207
|
}
|
|
@@ -13,7 +13,7 @@ import { PublicTxSimulator } from './public_tx_simulator.js';
|
|
|
13
13
|
try {
|
|
14
14
|
avmResult = await super.simulate(tx);
|
|
15
15
|
} finally{
|
|
16
|
-
this.metrics.stopRecordingTxSimulation(txLabel, avmResult?.revertCode);
|
|
16
|
+
this.metrics.stopRecordingTxSimulation(txLabel, avmResult?.gasUsed, avmResult?.revertCode);
|
|
17
17
|
}
|
|
18
18
|
return avmResult;
|
|
19
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public_tx_simulator.d.ts","sourceRoot":"","sources":["../../../src/public/public_tx_simulator/public_tx_simulator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAGlE,OAAO,EAAgC,qBAAqB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxG,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EACL,KAAK,eAAe,EACpB,yBAAyB,EACzB,6BAA6B,EAC7B,EAAE,EACF,gBAAgB,EACjB,MAAM,kBAAkB,CAAC;AAI1B,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAIjF,OAAO,EAAE,KAAK,iBAAiB,EAAiB,MAAM,yBAAyB,CAAC;AAOhF,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,mCAAmC,CAAC;AACvF,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAqC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EG;cACa,+BAA+B,CAAC,OAAO,EAAE,eAAe;IA2BxE;;;;;;;;OAQG;cACa,4BAA4B,CAAC,OAAO,EAAE,eAAe;YA4EvD,MAAM;
|
|
1
|
+
{"version":3,"file":"public_tx_simulator.d.ts","sourceRoot":"","sources":["../../../src/public/public_tx_simulator/public_tx_simulator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAGlE,OAAO,EAAgC,qBAAqB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxG,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EACL,KAAK,eAAe,EACpB,yBAAyB,EACzB,6BAA6B,EAC7B,EAAE,EACF,gBAAgB,EACjB,MAAM,kBAAkB,CAAC;AAI1B,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAIjF,OAAO,EAAE,KAAK,iBAAiB,EAAiB,MAAM,yBAAyB,CAAC;AAOhF,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,mCAAmC,CAAC;AACvF,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAqCrF,4BAA4B;AAC5B,KAAK,cAAc,GAAG;IACpB,KAAK,EAAE,gBAAgB,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,yBAAyB,EAAE,CAAC;IAC1C,QAAQ,EAAE,OAAO,CAAC;IAClB,YAAY,CAAC,EAAE,eAAe,CAAC;CAChC,CAAC;AAEF,qBAAa,iBAAkB,YAAW,0BAA0B;IAKhE,SAAS,CAAC,UAAU,EAAE,yBAAyB;IAC/C,SAAS,CAAC,WAAW,EAAE,iBAAiB;IACxC,SAAS,CAAC,eAAe,EAAE,eAAe;IAN5C,SAAS,CAAC,GAAG,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,qBAAqB,CAAC;gBAGrC,UAAU,EAAE,yBAAyB,EACrC,WAAW,EAAE,iBAAiB,EAC9B,eAAe,EAAE,eAAe,EAC1C,MAAM,CAAC,EAAE,OAAO,CAAC,qBAAqB,CAAC;IAMzC;;;;OAIG;IACU,QAAQ,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC;IA6HtD,SAAS,CAAC,aAAa,CAAC,EAAE,EAAE,EAAE;IAI9B;;;;OAIG;cACa,aAAa,CAAC,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC;IAqCzG;;;;;;OAMG;cACa,oBAAoB,CAClC,KAAK,EAAE,gBAAgB,EACvB,OAAO,EAAE,eAAe,EACxB,WAAW,EAAE,6BAA6B,GACzC,OAAO,CAAC,sBAAsB,CAAC;IA6BlC;;;;;;;;;;;;OAYG;cACa,4BAA4B,CAC1C,YAAY,EAAE,6BAA6B,EAC3C,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,6BAA6B,EACpD,YAAY,EAAE,GAAG,EACjB,cAAc,EAAE,EAAE,EAClB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,sBAAsB,CAAC;IAuBlC;;OAEG;cACa,+BAA+B,CAAC,OAAO,EAAE,eAAe;IA2BxE;;;;;;;;OAQG;cACa,4BAA4B,CAAC,OAAO,EAAE,eAAe;YA4EvD,MAAM;CAmCrB"}
|
|
@@ -310,7 +310,10 @@ export class PublicTxSimulator {
|
|
|
310
310
|
async payFee(context) {
|
|
311
311
|
const txFee = context.getTransactionFee(TxExecutionPhase.TEARDOWN);
|
|
312
312
|
if (context.feePayer.isZero()) {
|
|
313
|
-
|
|
313
|
+
// Real transactions are enforced by private kernel to have nonzero fee payer.
|
|
314
|
+
// Real transactions cannot skip fee enforcement (skipping fee enforcement makes them unprovable).
|
|
315
|
+
assert(this.config.skipFeeEnforcement, 'Fee payer cannot be 0 unless skipping fee enforcement for simulation');
|
|
316
|
+
this.log.debug(`Fee payer is 0. Skipping fee enforcement. No one is paying the fee of ${txFee.toBigInt()}`);
|
|
314
317
|
return;
|
|
315
318
|
}
|
|
316
319
|
const feeJuiceAddress = ProtocolContractAddress.FeeJuice;
|
|
@@ -323,6 +326,8 @@ export class PublicTxSimulator {
|
|
|
323
326
|
if (currentBalance.lt(txFee)) {
|
|
324
327
|
// Without "skipFeeEnforcement", such transactions should be filtered by GasTxValidator.
|
|
325
328
|
assert(this.config.skipFeeEnforcement, `Not enough balance for fee payer to pay for transaction (got ${currentBalance.toBigInt()} needs ${txFee.toBigInt()})`);
|
|
329
|
+
this.log.debug(`Fee payer balance insufficient, but we're skipping fee enforcement`);
|
|
330
|
+
// We still proceed and perform the storage write to minimize deviation from normal execution.
|
|
326
331
|
currentBalance = txFee;
|
|
327
332
|
}
|
|
328
333
|
const updatedBalance = currentBalance.sub(txFee);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { RevertCode } from '@aztec/stdlib/avm';
|
|
2
|
+
import type { GasUsed } from '@aztec/stdlib/gas';
|
|
2
3
|
import type { ExecutorMetricsInterface } from './executor_metrics_interface.js';
|
|
3
4
|
export interface PublicEnqueuedCallMetrics {
|
|
4
5
|
fnName: string;
|
|
@@ -9,7 +10,7 @@ export interface PublicEnqueuedCallMetrics {
|
|
|
9
10
|
}
|
|
10
11
|
export interface PublicTxMetrics {
|
|
11
12
|
totalDurationMs: number;
|
|
12
|
-
manaUsed: number;
|
|
13
|
+
manaUsed: number | undefined;
|
|
13
14
|
totalInstructionsExecuted: number;
|
|
14
15
|
nonRevertiblePrivateInsertionsUs: number | undefined;
|
|
15
16
|
revertiblePrivateInsertionsUs: number | undefined;
|
|
@@ -41,7 +42,7 @@ export declare class TestExecutorMetrics implements ExecutorMetricsInterface {
|
|
|
41
42
|
private txTimer;
|
|
42
43
|
constructor();
|
|
43
44
|
startRecordingTxSimulation(txLabel: string): void;
|
|
44
|
-
stopRecordingTxSimulation(txLabel: string, revertedCode?: RevertCode): void;
|
|
45
|
+
stopRecordingTxSimulation(txLabel: string, gasUsed?: GasUsed, revertedCode?: RevertCode): void;
|
|
45
46
|
recordEnqueuedCallSimulation(fnName: string, durationMs: number, manaUsed: number, totalInstructionsExecuted: number): void;
|
|
46
47
|
recordEnqueuedCallSimulationFailure(fnName: string, durationMs: number, manaUsed: number, totalInstructionsExecuted: number): void;
|
|
47
48
|
recordPrivateEffectsInsertion(durationUs: number, type: 'revertible' | 'non-revertible'): void;
|
|
@@ -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;
|
|
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;AACpD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAIjD,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,GAAG,SAAS,CAAC;I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AAM,EACd,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,yBAAyB,EAAE,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;IAyGxE,MAAM,CAAC,MAAM,SAAI;IAIjB,2BAA2B,CAAC,MAAM,SAAI;CA6FvC"}
|
|
@@ -58,14 +58,14 @@ export class TestExecutorMetrics {
|
|
|
58
58
|
this.currentTxLabel = txLabel;
|
|
59
59
|
this.txTimer = new Timer();
|
|
60
60
|
}
|
|
61
|
-
stopRecordingTxSimulation(txLabel, revertedCode) {
|
|
61
|
+
stopRecordingTxSimulation(txLabel, gasUsed, revertedCode) {
|
|
62
62
|
assert(this.currentTxLabel === txLabel, 'Cannot stop recording metrics for tx when another is live');
|
|
63
63
|
const txMetrics = this.txMetrics.get(txLabel);
|
|
64
64
|
// total duration of tx
|
|
65
65
|
txMetrics.totalDurationMs = this.txTimer.ms();
|
|
66
66
|
this.logger.debug(`Public TX simulation of ${txLabel} took ${txMetrics.totalDurationMs}ms`);
|
|
67
67
|
// add manaUsed across all enqueued calls
|
|
68
|
-
txMetrics.manaUsed =
|
|
68
|
+
txMetrics.manaUsed = gasUsed?.publicGas.l2Gas;
|
|
69
69
|
// add totalInstructionsExecuted across all enqueued calls
|
|
70
70
|
txMetrics.totalInstructionsExecuted = sum(txMetrics.enqueuedCalls.map((call)=>call.totalInstructionsExecuted));
|
|
71
71
|
txMetrics.revertedCode = revertedCode;
|
|
@@ -124,8 +124,9 @@ export class TestExecutorMetrics {
|
|
|
124
124
|
pretty += `${INDENT0}Total duration: ${fmtNum(txMetrics.totalDurationMs, 'ms')}\n`;
|
|
125
125
|
}
|
|
126
126
|
if (filter === 1 || filter === 0) {
|
|
127
|
-
|
|
128
|
-
|
|
127
|
+
const manaUsed = txMetrics.manaUsed || 0;
|
|
128
|
+
pretty += `${INDENT0}Total mana used: ${fmtNum(manaUsed)}\n`;
|
|
129
|
+
const manaPerSecond = Math.round(manaUsed * 1000 / txMetrics.totalDurationMs);
|
|
129
130
|
pretty += `${INDENT0}Mana per second: ${fmtNum(manaPerSecond)}\n`;
|
|
130
131
|
}
|
|
131
132
|
if (filter === 3 || filter === 1 || filter === 0) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/simulator",
|
|
3
|
-
"version": "3.0.0-nightly.
|
|
3
|
+
"version": "3.0.0-nightly.20251121",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./server": "./dest/server.js",
|
|
@@ -64,26 +64,26 @@
|
|
|
64
64
|
]
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@aztec/constants": "3.0.0-nightly.
|
|
68
|
-
"@aztec/foundation": "3.0.0-nightly.
|
|
69
|
-
"@aztec/native": "3.0.0-nightly.
|
|
70
|
-
"@aztec/noir-acvm_js": "3.0.0-nightly.
|
|
71
|
-
"@aztec/noir-noirc_abi": "3.0.0-nightly.
|
|
72
|
-
"@aztec/noir-protocol-circuits-types": "3.0.0-nightly.
|
|
73
|
-
"@aztec/noir-types": "3.0.0-nightly.
|
|
74
|
-
"@aztec/protocol-contracts": "3.0.0-nightly.
|
|
75
|
-
"@aztec/stdlib": "3.0.0-nightly.
|
|
76
|
-
"@aztec/telemetry-client": "3.0.0-nightly.
|
|
77
|
-
"@aztec/world-state": "3.0.0-nightly.
|
|
67
|
+
"@aztec/constants": "3.0.0-nightly.20251121",
|
|
68
|
+
"@aztec/foundation": "3.0.0-nightly.20251121",
|
|
69
|
+
"@aztec/native": "3.0.0-nightly.20251121",
|
|
70
|
+
"@aztec/noir-acvm_js": "3.0.0-nightly.20251121",
|
|
71
|
+
"@aztec/noir-noirc_abi": "3.0.0-nightly.20251121",
|
|
72
|
+
"@aztec/noir-protocol-circuits-types": "3.0.0-nightly.20251121",
|
|
73
|
+
"@aztec/noir-types": "3.0.0-nightly.20251121",
|
|
74
|
+
"@aztec/protocol-contracts": "3.0.0-nightly.20251121",
|
|
75
|
+
"@aztec/stdlib": "3.0.0-nightly.20251121",
|
|
76
|
+
"@aztec/telemetry-client": "3.0.0-nightly.20251121",
|
|
77
|
+
"@aztec/world-state": "3.0.0-nightly.20251121",
|
|
78
78
|
"lodash.clonedeep": "^4.5.0",
|
|
79
79
|
"lodash.merge": "^4.6.2",
|
|
80
80
|
"tslib": "^2.4.0"
|
|
81
81
|
},
|
|
82
82
|
"devDependencies": {
|
|
83
|
-
"@aztec/kv-store": "3.0.0-nightly.
|
|
84
|
-
"@aztec/merkle-tree": "3.0.0-nightly.
|
|
85
|
-
"@aztec/noir-contracts.js": "3.0.0-nightly.
|
|
86
|
-
"@aztec/noir-test-contracts.js": "3.0.0-nightly.
|
|
83
|
+
"@aztec/kv-store": "3.0.0-nightly.20251121",
|
|
84
|
+
"@aztec/merkle-tree": "3.0.0-nightly.20251121",
|
|
85
|
+
"@aztec/noir-contracts.js": "3.0.0-nightly.20251121",
|
|
86
|
+
"@aztec/noir-test-contracts.js": "3.0.0-nightly.20251121",
|
|
87
87
|
"@jest/globals": "^30.0.0",
|
|
88
88
|
"@types/jest": "^30.0.0",
|
|
89
89
|
"@types/lodash.clonedeep": "^4.5.7",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { RevertCode } from '@aztec/stdlib/avm';
|
|
2
|
+
import type { GasUsed } from '@aztec/stdlib/gas';
|
|
2
3
|
import {
|
|
3
4
|
Attributes,
|
|
4
5
|
type Histogram,
|
|
@@ -70,7 +71,7 @@ export class ExecutorMetrics implements ExecutorMetricsInterface {
|
|
|
70
71
|
// do nothing (unimplemented)
|
|
71
72
|
}
|
|
72
73
|
|
|
73
|
-
stopRecordingTxSimulation(_txLabel: string, _revertedCode?: RevertCode) {
|
|
74
|
+
stopRecordingTxSimulation(_txLabel: string, _gasUsed?: GasUsed, _revertedCode?: RevertCode) {
|
|
74
75
|
// do nothing (unimplemented)
|
|
75
76
|
}
|
|
76
77
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { RevertCode } from '@aztec/stdlib/avm';
|
|
2
|
+
import type { GasUsed } from '@aztec/stdlib/gas';
|
|
2
3
|
|
|
3
4
|
export interface ExecutorMetricsInterface {
|
|
4
5
|
startRecordingTxSimulation(txLabel: string): void;
|
|
5
|
-
stopRecordingTxSimulation(txLabel: string, revertedCode?: RevertCode): void;
|
|
6
|
+
stopRecordingTxSimulation(txLabel: string, gasUsed?: GasUsed, revertedCode?: RevertCode): void;
|
|
6
7
|
recordEnqueuedCallSimulation(fnName: string, durationMs: number, manaUsed: number, totalInstructions: number): void;
|
|
7
8
|
recordEnqueuedCallSimulationFailure(
|
|
8
9
|
fnName: string,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DEFAULT_TEARDOWN_DA_GAS_LIMIT, DEFAULT_TEARDOWN_L2_GAS_LIMIT } from '@aztec/constants';
|
|
1
2
|
import { asyncMap } from '@aztec/foundation/async-map';
|
|
2
3
|
import { Fr } from '@aztec/foundation/fields';
|
|
3
4
|
import { type ContractArtifact, encodeArguments } from '@aztec/stdlib/abi';
|
|
@@ -107,7 +108,9 @@ export class PublicTxSimulationTester extends BaseAvmSimulationTester {
|
|
|
107
108
|
appCallRequests,
|
|
108
109
|
teardownCallRequest,
|
|
109
110
|
feePayer,
|
|
110
|
-
/*gasUsedByPrivate*/
|
|
111
|
+
/*gasUsedByPrivate*/ teardownCall
|
|
112
|
+
? new Gas(DEFAULT_TEARDOWN_DA_GAS_LIMIT, DEFAULT_TEARDOWN_L2_GAS_LIMIT)
|
|
113
|
+
: Gas.empty(),
|
|
111
114
|
defaultGlobals(),
|
|
112
115
|
);
|
|
113
116
|
}
|
|
@@ -45,7 +45,6 @@ import { L1ToL2MessageIndexOutOfRangeError, NoteHashIndexOutOfRangeError } from
|
|
|
45
45
|
*/
|
|
46
46
|
export class PublicContractsDB implements PublicContractsDBInterface {
|
|
47
47
|
private contractStateStack: ContractsDbCheckpoint[] = [new ContractsDbCheckpoint()];
|
|
48
|
-
private bytecodeCommitmentCache = new Map<string, Fr>();
|
|
49
48
|
|
|
50
49
|
private log = createLogger('simulator:contracts-data-source');
|
|
51
50
|
|
|
@@ -144,27 +143,25 @@ export class PublicContractsDB implements PublicContractsDBInterface {
|
|
|
144
143
|
}
|
|
145
144
|
|
|
146
145
|
public async getBytecodeCommitment(contractClassId: Fr): Promise<Fr | undefined> {
|
|
147
|
-
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
// Now try from the store
|
|
154
|
-
const fromStore = await this.dataSource.getBytecodeCommitment(contractClassId);
|
|
155
|
-
if (fromStore !== undefined) {
|
|
156
|
-
this.bytecodeCommitmentCache.set(key, fromStore);
|
|
157
|
-
return fromStore;
|
|
146
|
+
const currentState = this.getCurrentState();
|
|
147
|
+
const commitment =
|
|
148
|
+
currentState.getBytecodeCommitment(contractClassId) ??
|
|
149
|
+
(await this.dataSource.getBytecodeCommitment(contractClassId));
|
|
150
|
+
if (commitment !== undefined) {
|
|
151
|
+
return commitment;
|
|
158
152
|
}
|
|
159
|
-
|
|
160
|
-
//
|
|
153
|
+
// Not in the current state or the store, compute it here
|
|
154
|
+
// Get the contract class
|
|
161
155
|
const contractClass = await this.getContractClass(contractClassId);
|
|
156
|
+
|
|
162
157
|
if (contractClass === undefined) {
|
|
158
|
+
// cannot compute bytecode commitment if contract class is not found
|
|
163
159
|
return undefined;
|
|
164
160
|
}
|
|
165
161
|
|
|
166
162
|
const value = await computePublicBytecodeCommitment(contractClass.packedBytecode);
|
|
167
|
-
|
|
163
|
+
// Add to cache (current checkpoint state) so we don't compute again
|
|
164
|
+
currentState.addBytecodeCommitment(contractClassId, value);
|
|
168
165
|
return value;
|
|
169
166
|
}
|
|
170
167
|
|
|
@@ -143,6 +143,10 @@ export class CppPublicTxSimulator extends PublicTxSimulator implements PublicTxS
|
|
|
143
143
|
// TODO(fcarreiro): complete this.
|
|
144
144
|
assert(cppResult.revertCode.equals(tsResult.revertCode));
|
|
145
145
|
assert(cppResult.gasUsed.totalGas.equals(tsResult.gasUsed.totalGas));
|
|
146
|
+
assert(cppResult.gasUsed.publicGas.equals(tsResult.gasUsed.publicGas));
|
|
147
|
+
assert(cppResult.gasUsed.teardownGas.equals(tsResult.gasUsed.teardownGas));
|
|
148
|
+
assert(cppResult.gasUsed.billedGas.equals(tsResult.gasUsed.billedGas));
|
|
149
|
+
assert(cppResult.publicInputs.toBuffer().equals(tsResult.publicInputs.toBuffer()));
|
|
146
150
|
// FIXME(https://github.com/AztecProtocol/aztec-packages/issues/18441): a few but not all keccaks fail!
|
|
147
151
|
// expect(cppResult.appLogicReturnValues).toEqual(tsResult.appLogicReturnValues);
|
|
148
152
|
|
|
@@ -182,7 +186,7 @@ export class MeasuredCppPublicTxSimulator extends CppPublicTxSimulator implement
|
|
|
182
186
|
try {
|
|
183
187
|
result = await super.simulate(tx);
|
|
184
188
|
} finally {
|
|
185
|
-
this.metrics.stopRecordingTxSimulation(txLabel, result?.revertCode);
|
|
189
|
+
this.metrics.stopRecordingTxSimulation(txLabel, result?.gasUsed, result?.revertCode);
|
|
186
190
|
}
|
|
187
191
|
return result;
|
|
188
192
|
}
|
|
@@ -293,7 +297,7 @@ export class MeasuredCppPublicTxSimulatorHintedDbs
|
|
|
293
297
|
try {
|
|
294
298
|
result = await super.simulate(tx);
|
|
295
299
|
} finally {
|
|
296
|
-
this.metrics.stopRecordingTxSimulation(txLabel, result?.revertCode);
|
|
300
|
+
this.metrics.stopRecordingTxSimulation(txLabel, result?.gasUsed, result?.revertCode);
|
|
297
301
|
}
|
|
298
302
|
return result;
|
|
299
303
|
}
|
|
@@ -34,7 +34,7 @@ export class MeasuredPublicTxSimulator extends PublicTxSimulator implements Meas
|
|
|
34
34
|
try {
|
|
35
35
|
avmResult = await super.simulate(tx);
|
|
36
36
|
} finally {
|
|
37
|
-
this.metrics.stopRecordingTxSimulation(txLabel, avmResult?.revertCode);
|
|
37
|
+
this.metrics.stopRecordingTxSimulation(txLabel, avmResult?.gasUsed, avmResult?.revertCode);
|
|
38
38
|
}
|
|
39
39
|
return avmResult;
|
|
40
40
|
}
|
|
@@ -467,7 +467,10 @@ export class PublicTxSimulator implements PublicTxSimulatorInterface {
|
|
|
467
467
|
const txFee = context.getTransactionFee(TxExecutionPhase.TEARDOWN);
|
|
468
468
|
|
|
469
469
|
if (context.feePayer.isZero()) {
|
|
470
|
-
|
|
470
|
+
// Real transactions are enforced by private kernel to have nonzero fee payer.
|
|
471
|
+
// Real transactions cannot skip fee enforcement (skipping fee enforcement makes them unprovable).
|
|
472
|
+
assert(this.config.skipFeeEnforcement, 'Fee payer cannot be 0 unless skipping fee enforcement for simulation');
|
|
473
|
+
this.log.debug(`Fee payer is 0. Skipping fee enforcement. No one is paying the fee of ${txFee.toBigInt()}`);
|
|
471
474
|
return;
|
|
472
475
|
}
|
|
473
476
|
|
|
@@ -487,6 +490,8 @@ export class PublicTxSimulator implements PublicTxSimulatorInterface {
|
|
|
487
490
|
this.config.skipFeeEnforcement,
|
|
488
491
|
`Not enough balance for fee payer to pay for transaction (got ${currentBalance.toBigInt()} needs ${txFee.toBigInt()})`,
|
|
489
492
|
);
|
|
493
|
+
this.log.debug(`Fee payer balance insufficient, but we're skipping fee enforcement`);
|
|
494
|
+
// We still proceed and perform the storage write to minimize deviation from normal execution.
|
|
490
495
|
currentBalance = txFee;
|
|
491
496
|
}
|
|
492
497
|
|
|
@@ -2,6 +2,7 @@ import { sum } from '@aztec/foundation/collection';
|
|
|
2
2
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
3
3
|
import { Timer } from '@aztec/foundation/timer';
|
|
4
4
|
import type { RevertCode } from '@aztec/stdlib/avm';
|
|
5
|
+
import type { GasUsed } from '@aztec/stdlib/gas';
|
|
5
6
|
|
|
6
7
|
import { strict as assert } from 'assert';
|
|
7
8
|
|
|
@@ -18,7 +19,7 @@ export interface PublicEnqueuedCallMetrics {
|
|
|
18
19
|
export interface PublicTxMetrics {
|
|
19
20
|
// TS simulation
|
|
20
21
|
totalDurationMs: number;
|
|
21
|
-
manaUsed: number;
|
|
22
|
+
manaUsed: number | undefined;
|
|
22
23
|
totalInstructionsExecuted: number;
|
|
23
24
|
nonRevertiblePrivateInsertionsUs: number | undefined;
|
|
24
25
|
revertiblePrivateInsertionsUs: number | undefined;
|
|
@@ -99,7 +100,7 @@ export class TestExecutorMetrics implements ExecutorMetricsInterface {
|
|
|
99
100
|
this.txTimer = new Timer();
|
|
100
101
|
}
|
|
101
102
|
|
|
102
|
-
stopRecordingTxSimulation(txLabel: string, revertedCode?: RevertCode) {
|
|
103
|
+
stopRecordingTxSimulation(txLabel: string, gasUsed?: GasUsed, revertedCode?: RevertCode) {
|
|
103
104
|
assert(this.currentTxLabel === txLabel, 'Cannot stop recording metrics for tx when another is live');
|
|
104
105
|
|
|
105
106
|
const txMetrics = this.txMetrics.get(txLabel)!;
|
|
@@ -109,7 +110,7 @@ export class TestExecutorMetrics implements ExecutorMetricsInterface {
|
|
|
109
110
|
this.logger.debug(`Public TX simulation of ${txLabel} took ${txMetrics.totalDurationMs}ms`);
|
|
110
111
|
|
|
111
112
|
// add manaUsed across all enqueued calls
|
|
112
|
-
txMetrics.manaUsed =
|
|
113
|
+
txMetrics.manaUsed = gasUsed?.publicGas.l2Gas;
|
|
113
114
|
// add totalInstructionsExecuted across all enqueued calls
|
|
114
115
|
txMetrics.totalInstructionsExecuted = sum(txMetrics.enqueuedCalls.map(call => call.totalInstructionsExecuted));
|
|
115
116
|
txMetrics.revertedCode = revertedCode;
|
|
@@ -202,8 +203,9 @@ export class TestExecutorMetrics implements ExecutorMetricsInterface {
|
|
|
202
203
|
pretty += `${INDENT0}Total duration: ${fmtNum(txMetrics.totalDurationMs, 'ms')}\n`;
|
|
203
204
|
}
|
|
204
205
|
if (filter === PublicTxMetricsFilter.TOTALS || filter === PublicTxMetricsFilter.ALL) {
|
|
205
|
-
|
|
206
|
-
|
|
206
|
+
const manaUsed = txMetrics.manaUsed || 0;
|
|
207
|
+
pretty += `${INDENT0}Total mana used: ${fmtNum(manaUsed)}\n`;
|
|
208
|
+
const manaPerSecond = Math.round((manaUsed * 1000) / txMetrics.totalDurationMs);
|
|
207
209
|
pretty += `${INDENT0}Mana per second: ${fmtNum(manaPerSecond)}\n`;
|
|
208
210
|
}
|
|
209
211
|
|