@aztec/simulator 3.0.0-nightly.20251118 → 3.0.0-nightly.20251120
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/avm/fixtures/avm_simulation_tester.d.ts.map +1 -1
- package/dest/public/avm/fixtures/avm_simulation_tester.js +2 -1
- 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/fixtures/token_test.js +3 -4
- 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_processor/public_processor.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor.js +5 -12
- 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 +8 -2
- package/dest/public/public_tx_simulator/measured_public_tx_simulator.d.ts +8 -2
- 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 +1 -1
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts +12 -2
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_simulator.js +9 -2
- 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/avm/fixtures/avm_simulation_tester.ts +1 -0
- 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/fixtures/token_test.ts +3 -4
- package/src/public/public_db_sources.ts +12 -15
- package/src/public/public_processor/public_processor.ts +4 -14
- package/src/public/public_tx_simulator/cpp_public_tx_simulator.ts +8 -2
- package/src/public/public_tx_simulator/measured_public_tx_simulator.ts +3 -3
- package/src/public/public_tx_simulator/public_tx_simulator.ts +21 -9
- package/src/public/test_executor_metrics.ts +7 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"avm_simulation_tester.d.ts","sourceRoot":"","sources":["../../../../src/public/avm/fixtures/avm_simulation_tester.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAEjF,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAG7D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AACnF,OAAO,EAAE,wBAAwB,EAAE,MAAM,+CAA+C,CAAC;AAEzF,OAAO,EAAE,6BAA6B,EAAE,MAAM,sCAAsC,CAAC;AAErF,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAW1E;;;;GAIG;AACH,qBAAa,mBAAoB,SAAQ,uBAAuB;IAI5D,OAAO,CAAC,YAAY;gBAFpB,kBAAkB,EAAE,wBAAwB,EAC5C,WAAW,EAAE,yBAAyB,EAC9B,YAAY,EAAE,6BAA6B;WAKxC,MAAM,CACjB,iBAAiB,EAAE,uBAAuB,GACzC,OAAO,CAAC,mBAAmB,CAAC;IAkB/B;;OAEG;IACG,YAAY,CAChB,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,YAAY,EACrB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,GAAG,EAAE,EACX,YAAY,UAAQ,GACnB,OAAO,CAAC,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"avm_simulation_tester.d.ts","sourceRoot":"","sources":["../../../../src/public/avm/fixtures/avm_simulation_tester.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAEjF,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAG7D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AACnF,OAAO,EAAE,wBAAwB,EAAE,MAAM,+CAA+C,CAAC;AAEzF,OAAO,EAAE,6BAA6B,EAAE,MAAM,sCAAsC,CAAC;AAErF,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAW1E;;;;GAIG;AACH,qBAAa,mBAAoB,SAAQ,uBAAuB;IAI5D,OAAO,CAAC,YAAY;gBAFpB,kBAAkB,EAAE,wBAAwB,EAC5C,WAAW,EAAE,yBAAyB,EAC9B,YAAY,EAAE,6BAA6B;WAKxC,MAAM,CACjB,iBAAiB,EAAE,uBAAuB,GACzC,OAAO,CAAC,mBAAmB,CAAC;IAkB/B;;OAEG;IACG,YAAY,CAChB,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,YAAY,EACrB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,GAAG,EAAE,EACX,YAAY,UAAQ,GACnB,OAAO,CAAC,qBAAqB,CAAC;CA8ClC"}
|
|
@@ -52,7 +52,8 @@ const DEFAULT_GAS_FEES = new GasFees(2, 3);
|
|
|
52
52
|
skipFeeEnforcement: false,
|
|
53
53
|
collectDebugLogs: true,
|
|
54
54
|
collectHints: false,
|
|
55
|
-
collectStatistics: false
|
|
55
|
+
collectStatistics: false,
|
|
56
|
+
collectCallMetadata: true
|
|
56
57
|
});
|
|
57
58
|
const environment = initExecutionEnvironment({
|
|
58
59
|
calldata,
|
|
@@ -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,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,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,0BAA0B,EAAE,MAAM;IAOpC,6BAA6B,CAAC,UAAU,EAAE,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,E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AQ,GAAE,YAAqB,EAE/B,iBAAiB,GAAE,qBAA0F,GAC5G,OAAO,CAAC,EAAE,CAAC;IAyBD,UAAU,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);
|
|
@@ -88,8 +88,7 @@ async function checkBalance(tester, token, sender, account, expectedBalance, exp
|
|
|
88
88
|
]);
|
|
89
89
|
expectToBeTrue(balResult.revertCode.isOK());
|
|
90
90
|
// should be 1 call with 1 return value that is expectedBalance
|
|
91
|
-
expectToBeTrue(balResult.
|
|
92
|
-
expectToBeTrue(balResult.
|
|
93
|
-
expectToBeTrue(balResult.
|
|
94
|
-
expectToBeTrue(balResult.processedPhases[0].returnValues[0].values[0].toBigInt() == expectedBalance);
|
|
91
|
+
expectToBeTrue(balResult.appLogicReturnValues.length == 1);
|
|
92
|
+
expectToBeTrue(balResult.appLogicReturnValues[0].values.length == 1);
|
|
93
|
+
expectToBeTrue(balResult.appLogicReturnValues[0].values[0].toBigInt() == expectedBalance);
|
|
95
94
|
}
|
|
@@ -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,kBAAkB,EACvB,KAAK,sBAAsB,EAC3B,KAAK,2BAA2B,EAEjC,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAEjF,OAAO,EACL,YAAY,EAKb,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAKlD,OAAO,KAAK,EAAE,0BAA0B,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAG7F;;;GAGG;AACH,qBAAa,iBAAkB,YAAW,0BAA0B;
|
|
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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eError, 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":"public_processor.d.ts","sourceRoot":"","sources":["../../../src/public/public_processor/public_processor.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAkC,MAAM,yBAAyB,CAAC;AAIvF,OAAO,EAML,qBAAqB,EACtB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAGjE,OAAO,KAAK,EACV,yBAAyB,EACzB,qBAAqB,EACrB,wBAAwB,EACxB,eAAe,EAChB,MAAM,iCAAiC,CAAC;AAGzC,OAAO,EACL,KAAK,QAAQ,EACb,eAAe,EACf,yBAAyB,EACzB,KAAK,WAAW,EAEhB,EAAE,
|
|
1
|
+
{"version":3,"file":"public_processor.d.ts","sourceRoot":"","sources":["../../../src/public/public_processor/public_processor.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAkC,MAAM,yBAAyB,CAAC;AAIvF,OAAO,EAML,qBAAqB,EACtB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAGjE,OAAO,KAAK,EACV,yBAAyB,EACzB,qBAAqB,EACrB,wBAAwB,EACxB,eAAe,EAChB,MAAM,iCAAiC,CAAC;AAGzC,OAAO,EACL,KAAK,QAAQ,EACb,eAAe,EACf,yBAAyB,EACzB,KAAK,WAAW,EAEhB,EAAE,EAGH,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,KAAK,MAAM,EAGZ,MAAM,yBAAyB,CAAC;AAKjC,OAAO,EAAE,iBAAiB,EAAiB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;IAED;;;;;;OAMG;IACU,OAAO,CAClB,GAAG,EAAE,QAAQ,CAAC,EAAE,CAAC,GAAG,aAAa,CAAC,EAAE,CAAC,EACrC,MAAM,GAAE,qBAA0B,EAClC,SAAS,GAAE,wBAA6B,GACvC,OAAO,CAAC,CAAC,WAAW,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,EAAE,EAAE,yBAAyB,EAAE,CAAC,CAAC;YAmM5D,wBAAwB;YAiBxB,SAAS;YA2BT,gCAAgC;IA2B9C,kFAAkF;YACpE,uBAAuB;IA2CrC;;;;OAIG;YACW,gCAAgC;YA0BhC,oBAAoB;YA+BpB,wBAAwB;IAoCtC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,sBAAsB;CAStC"}
|
|
@@ -18,7 +18,7 @@ import { computeTransactionFee } from '@aztec/stdlib/fees';
|
|
|
18
18
|
import { Gas } from '@aztec/stdlib/gas';
|
|
19
19
|
import { ProvingRequestType } from '@aztec/stdlib/proofs';
|
|
20
20
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
21
|
-
import { NestedProcessReturnValues, Tx,
|
|
21
|
+
import { NestedProcessReturnValues, Tx, makeProcessedTxFromPrivateOnlyTx, makeProcessedTxFromTxWithPublicCalls } from '@aztec/stdlib/tx';
|
|
22
22
|
import { Attributes, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
23
23
|
import { ForkCheckpoint } from '@aztec/world-state/native';
|
|
24
24
|
import { AssertionError } from 'assert';
|
|
@@ -379,28 +379,21 @@ class PublicProcessorTimeoutError extends Error {
|
|
|
379
379
|
}
|
|
380
380
|
async processTxWithPublicCalls(tx) {
|
|
381
381
|
const timer = new Timer();
|
|
382
|
-
const { hints, publicInputs, gasUsed, revertCode, revertReason,
|
|
382
|
+
const { hints, publicInputs, gasUsed, revertCode, revertReason, appLogicReturnValues } = await this.publicTxSimulator.simulate(tx);
|
|
383
383
|
if (!hints) {
|
|
384
384
|
this.metrics.recordFailedTx();
|
|
385
385
|
throw new Error('Avm proving result was not generated.');
|
|
386
386
|
}
|
|
387
|
-
processedPhases?.forEach((phase)=>{
|
|
388
|
-
if (phase.reverted) {
|
|
389
|
-
this.metrics.recordRevertedPhase(phase.phase);
|
|
390
|
-
} else {
|
|
391
|
-
this.metrics.recordPhaseDuration(phase.phase, phase.durationMs ?? 0);
|
|
392
|
-
}
|
|
393
|
-
});
|
|
394
387
|
const contractClassLogs = revertCode.isOK() ? tx.getContractClassLogs() : tx.getSplitContractClassLogs(false);
|
|
395
388
|
this.metrics.recordClassPublication(...contractClassLogs.filter((log)=>ContractClassPublishedEvent.isContractClassPublishedEvent(log)).map((log)=>ContractClassPublishedEvent.fromLog(log)));
|
|
396
|
-
|
|
389
|
+
// TODO(fcarreiro): remove phase count metric.
|
|
390
|
+
const phaseCount = 1;
|
|
397
391
|
const durationMs = timer.ms();
|
|
398
392
|
this.metrics.recordTx(phaseCount, durationMs, gasUsed.publicGas);
|
|
399
393
|
const processedTx = makeProcessedTxFromTxWithPublicCalls(tx, PublicProcessor.generateProvingRequest(publicInputs, hints), gasUsed, revertCode, revertReason);
|
|
400
|
-
const returnValues = processedPhases?.find(({ phase })=>phase === TxExecutionPhase.APP_LOGIC)?.returnValues ?? [];
|
|
401
394
|
return [
|
|
402
395
|
processedTx,
|
|
403
|
-
|
|
396
|
+
appLogicReturnValues ?? []
|
|
404
397
|
];
|
|
405
398
|
}
|
|
406
399
|
/**
|
|
@@ -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,E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E,eAAe,EACb,OAAO,EAAE,wBAAwB,EACpD,MAAM,CAAC,EAAE,OAAO,CAAC,qBAAqB,CAAC;IAKnB,QAAQ,CAAC,EAAE,EAAE,EAAE,EAAE,OAAO,GAAE,MAAsB,GAAG,OAAO,CAAC,cAAc,CAAC;CAUjG"}
|
|
@@ -91,6 +91,12 @@ 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()));
|
|
98
|
+
// FIXME(https://github.com/AztecProtocol/aztec-packages/issues/18441): a few but not all keccaks fail!
|
|
99
|
+
// expect(cppResult.appLogicReturnValues).toEqual(tsResult.appLogicReturnValues);
|
|
94
100
|
// Confirm that tree roots match
|
|
95
101
|
const cppStateRef = await this.merkleTree.getStateReference();
|
|
96
102
|
assert(cppStateRef.equals(tsStateRef), `Tree roots mismatch between TS and C++ public simulations for tx ${txHash}`);
|
|
@@ -115,7 +121,7 @@ export class MeasuredCppPublicTxSimulator extends CppPublicTxSimulator {
|
|
|
115
121
|
try {
|
|
116
122
|
result = await super.simulate(tx);
|
|
117
123
|
} finally{
|
|
118
|
-
this.metrics.stopRecordingTxSimulation(txLabel, result?.revertCode);
|
|
124
|
+
this.metrics.stopRecordingTxSimulation(txLabel, result?.gasUsed, result?.revertCode);
|
|
119
125
|
}
|
|
120
126
|
return result;
|
|
121
127
|
}
|
|
@@ -195,7 +201,7 @@ export class MeasuredCppPublicTxSimulator extends CppPublicTxSimulator {
|
|
|
195
201
|
try {
|
|
196
202
|
result = await super.simulate(tx);
|
|
197
203
|
} finally{
|
|
198
|
-
this.metrics.stopRecordingTxSimulation(txLabel, result?.revertCode);
|
|
204
|
+
this.metrics.stopRecordingTxSimulation(txLabel, result?.gasUsed, result?.revertCode);
|
|
199
205
|
}
|
|
200
206
|
return result;
|
|
201
207
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Fr } from '@aztec/foundation/fields';
|
|
2
|
-
import type {
|
|
2
|
+
import type { PublicSimulatorConfig, PublicTxResult } from '@aztec/stdlib/avm';
|
|
3
3
|
import type { Gas } from '@aztec/stdlib/gas';
|
|
4
4
|
import type { MerkleTreeWriteOperations } from '@aztec/stdlib/trees';
|
|
5
5
|
import { type GlobalVariables, PublicCallRequestWithCalldata, Tx, TxExecutionPhase } from '@aztec/stdlib/tx';
|
|
@@ -19,7 +19,13 @@ export declare class MeasuredPublicTxSimulator extends PublicTxSimulator impleme
|
|
|
19
19
|
simulate(tx: Tx, txLabel?: string): Promise<PublicTxResult>;
|
|
20
20
|
protected insertNonRevertiblesFromPrivate(context: PublicTxContext): Promise<void>;
|
|
21
21
|
protected insertRevertiblesFromPrivate(context: PublicTxContext): Promise<void>;
|
|
22
|
-
protected simulatePhase(phase: TxExecutionPhase, context: PublicTxContext): Promise<
|
|
22
|
+
protected simulatePhase(phase: TxExecutionPhase, context: PublicTxContext): Promise<{
|
|
23
|
+
phase: TxExecutionPhase;
|
|
24
|
+
durationMs?: number;
|
|
25
|
+
returnValues: import("@aztec/stdlib/tx").NestedProcessReturnValues[];
|
|
26
|
+
reverted: boolean;
|
|
27
|
+
revertReason?: import("@aztec/stdlib/errors").SimulationError;
|
|
28
|
+
}>;
|
|
23
29
|
protected simulateEnqueuedCallInternal(stateManager: PublicPersistableStateManager, callRequest: PublicCallRequestWithCalldata, allocatedGas: Gas, transactionFee: Fr, fnName: string): Promise<AvmFinalizedCallResult>;
|
|
24
30
|
}
|
|
25
31
|
//# sourceMappingURL=measured_public_tx_simulator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"measured_public_tx_simulator.d.ts","sourceRoot":"","sources":["../../../src/public/public_tx_simulator/measured_public_tx_simulator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAEnD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"measured_public_tx_simulator.d.ts","sourceRoot":"","sources":["../../../src/public/public_tx_simulator/measured_public_tx_simulator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAEnD,OAAO,KAAK,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC/E,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EAAE,KAAK,eAAe,EAAE,6BAA6B,EAAE,EAAE,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAE7G,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AACjF,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AACjF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,mCAAmC,CAAC;AACvF,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,oCAAoC,CAAC;AAE7F;;GAEG;AACH,qBAAa,yBAA0B,SAAQ,iBAAkB,YAAW,kCAAkC;IAK1G,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,wBAAwB;gBAHpD,UAAU,EAAE,yBAAyB,EACrC,WAAW,EAAE,iBAAiB,EAC9B,eAAe,EAAE,eAAe,EACb,OAAO,EAAE,wBAAwB,EACpD,MAAM,CAAC,EAAE,OAAO,CAAC,qBAAqB,CAAC;IAKnB,QAAQ,CAAC,EAAE,EAAE,EAAE,EAAE,OAAO,GAAE,MAAsB,GAAG,OAAO,CAAC,cAAc,CAAC;cAWvE,+BAA+B,CAAC,OAAO,EAAE,eAAe;cAMxD,4BAA4B,CAAC,OAAO,EAAE,eAAe;cAMrD,aAAa,CAAC,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,eAAe;;;;;;;cAO/D,4BAA4B,CACnD,YAAY,EAAE,6BAA6B,EAC3C,WAAW,EAAE,6BAA6B,EAC1C,YAAY,EAAE,GAAG,EACjB,cAAc,EAAE,EAAE,EAClB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,sBAAsB,CAAC;CAsCnC"}
|
|
@@ -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,14 +1,23 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/fields';
|
|
2
2
|
import { type Logger } from '@aztec/foundation/log';
|
|
3
|
-
import {
|
|
3
|
+
import { PublicSimulatorConfig, PublicTxResult } from '@aztec/stdlib/avm';
|
|
4
|
+
import { SimulationError } from '@aztec/stdlib/errors';
|
|
4
5
|
import type { Gas } from '@aztec/stdlib/gas';
|
|
5
6
|
import type { MerkleTreeWriteOperations } from '@aztec/stdlib/trees';
|
|
6
|
-
import { type GlobalVariables, PublicCallRequestWithCalldata, Tx, TxExecutionPhase } from '@aztec/stdlib/tx';
|
|
7
|
+
import { type GlobalVariables, NestedProcessReturnValues, PublicCallRequestWithCalldata, Tx, TxExecutionPhase } from '@aztec/stdlib/tx';
|
|
7
8
|
import type { AvmFinalizedCallResult } from '../avm/avm_contract_call_result.js';
|
|
8
9
|
import { type PublicContractsDB } from '../public_db_sources.js';
|
|
9
10
|
import type { PublicPersistableStateManager } from '../state_manager/state_manager.js';
|
|
10
11
|
import { PublicTxContext } from './public_tx_context.js';
|
|
11
12
|
import type { PublicTxSimulatorInterface } from './public_tx_simulator_interface.js';
|
|
13
|
+
/** Only used internally. */
|
|
14
|
+
type ProcessedPhase = {
|
|
15
|
+
phase: TxExecutionPhase;
|
|
16
|
+
durationMs?: number;
|
|
17
|
+
returnValues: NestedProcessReturnValues[];
|
|
18
|
+
reverted: boolean;
|
|
19
|
+
revertReason?: SimulationError;
|
|
20
|
+
};
|
|
12
21
|
export declare class PublicTxSimulator implements PublicTxSimulatorInterface {
|
|
13
22
|
protected merkleTree: MerkleTreeWriteOperations;
|
|
14
23
|
protected contractsDB: PublicContractsDB;
|
|
@@ -67,4 +76,5 @@ export declare class PublicTxSimulator implements PublicTxSimulatorInterface {
|
|
|
67
76
|
protected insertRevertiblesFromPrivate(context: PublicTxContext): Promise<void>;
|
|
68
77
|
private payFee;
|
|
69
78
|
}
|
|
79
|
+
export {};
|
|
70
80
|
//# sourceMappingURL=public_tx_simulator.d.ts.map
|
|
@@ -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,
|
|
1
|
+
{"version":3,"file":"public_tx_simulator.d.ts","sourceRoot":"","sources":["../../../src/public/public_tx_simulator/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AM,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"}
|
|
@@ -136,12 +136,14 @@ export class PublicTxSimulator {
|
|
|
136
136
|
await this.payFee(context);
|
|
137
137
|
const publicInputs = await context.generateAvmCircuitPublicInputs();
|
|
138
138
|
const revertCode = context.getFinalRevertCode();
|
|
139
|
+
// We only return the app logic phase information.
|
|
140
|
+
const appLogicReturnValues = processedPhases.find(({ phase })=>phase === TxExecutionPhase.APP_LOGIC)?.returnValues ?? [];
|
|
139
141
|
return new PublicTxResult(/*gasUsed=*/ {
|
|
140
142
|
totalGas: context.getActualGasUsed(),
|
|
141
143
|
teardownGas: context.teardownGasUsed,
|
|
142
144
|
publicGas: context.getActualPublicGasUsed(),
|
|
143
145
|
billedGas: context.getTotalGasUsed()
|
|
144
|
-
}, /*revertCode=*/ revertCode, /*revertReason=*/ context.revertReason, /*
|
|
146
|
+
}, /*revertCode=*/ revertCode, /*revertReason=*/ context.revertReason, /*appLogicReturnValues=*/ appLogicReturnValues, /*logs=*/ context.state.getActiveStateManager().getLogs(), /*hints=*/ hints, /*publicInputs=*/ publicInputs);
|
|
145
147
|
}
|
|
146
148
|
computeTxHash(tx) {
|
|
147
149
|
return tx.getTxHash();
|
|
@@ -308,7 +310,10 @@ export class PublicTxSimulator {
|
|
|
308
310
|
async payFee(context) {
|
|
309
311
|
const txFee = context.getTransactionFee(TxExecutionPhase.TEARDOWN);
|
|
310
312
|
if (context.feePayer.isZero()) {
|
|
311
|
-
|
|
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()}`);
|
|
312
317
|
return;
|
|
313
318
|
}
|
|
314
319
|
const feeJuiceAddress = ProtocolContractAddress.FeeJuice;
|
|
@@ -321,6 +326,8 @@ export class PublicTxSimulator {
|
|
|
321
326
|
if (currentBalance.lt(txFee)) {
|
|
322
327
|
// Without "skipFeeEnforcement", such transactions should be filtered by GasTxValidator.
|
|
323
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.
|
|
324
331
|
currentBalance = txFee;
|
|
325
332
|
}
|
|
326
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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IACN,SAAS,IAAA;IACT,YAAY,IAAA;IACZ,OAAO,IAAA;CACR;AA2BD,qBAAa,mBAAoB,YAAW,wBAAwB;;IAClE,OAAO,CAAC,MAAM,CAAS;IAEvB,OAAO,CAAC,SAAS,CAA2C;IAC5D,OAAO,CAAC,cAAc,CAAqB;IAC3C,OAAO,CAAC,OAAO,CAAoB;;IAMnC,0BAA0B,CAAC,OAAO,EAAE,MAAM;IAQ1C,yBAAyB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,YAAY,CAAC,EAAE,UAAU;IAkBvF,4BAA4B,CAC1B,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,yBAAyB,EAAE,MAAM;IAKnC,mCAAmC,CACjC,MAAM,EAAE,MAAM,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.20251120",
|
|
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.20251120",
|
|
68
|
+
"@aztec/foundation": "3.0.0-nightly.20251120",
|
|
69
|
+
"@aztec/native": "3.0.0-nightly.20251120",
|
|
70
|
+
"@aztec/noir-acvm_js": "3.0.0-nightly.20251120",
|
|
71
|
+
"@aztec/noir-noirc_abi": "3.0.0-nightly.20251120",
|
|
72
|
+
"@aztec/noir-protocol-circuits-types": "3.0.0-nightly.20251120",
|
|
73
|
+
"@aztec/noir-types": "3.0.0-nightly.20251120",
|
|
74
|
+
"@aztec/protocol-contracts": "3.0.0-nightly.20251120",
|
|
75
|
+
"@aztec/stdlib": "3.0.0-nightly.20251120",
|
|
76
|
+
"@aztec/telemetry-client": "3.0.0-nightly.20251120",
|
|
77
|
+
"@aztec/world-state": "3.0.0-nightly.20251120",
|
|
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.20251120",
|
|
84
|
+
"@aztec/merkle-tree": "3.0.0-nightly.20251120",
|
|
85
|
+
"@aztec/noir-contracts.js": "3.0.0-nightly.20251120",
|
|
86
|
+
"@aztec/noir-test-contracts.js": "3.0.0-nightly.20251120",
|
|
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
|
}
|
|
@@ -133,8 +133,7 @@ async function checkBalance(
|
|
|
133
133
|
);
|
|
134
134
|
expectToBeTrue(balResult.revertCode.isOK());
|
|
135
135
|
// should be 1 call with 1 return value that is expectedBalance
|
|
136
|
-
expectToBeTrue(balResult.
|
|
137
|
-
expectToBeTrue(balResult.
|
|
138
|
-
expectToBeTrue(balResult.
|
|
139
|
-
expectToBeTrue(balResult.processedPhases![0].returnValues[0].values![0].toBigInt() == expectedBalance);
|
|
136
|
+
expectToBeTrue(balResult.appLogicReturnValues.length == 1);
|
|
137
|
+
expectToBeTrue(balResult.appLogicReturnValues[0].values!.length == 1);
|
|
138
|
+
expectToBeTrue(balResult.appLogicReturnValues[0].values![0].toBigInt() == expectedBalance);
|
|
140
139
|
}
|
|
@@ -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
|
|
|
@@ -34,7 +34,6 @@ import {
|
|
|
34
34
|
type ProcessedTx,
|
|
35
35
|
StateReference,
|
|
36
36
|
Tx,
|
|
37
|
-
TxExecutionPhase,
|
|
38
37
|
makeProcessedTxFromPrivateOnlyTx,
|
|
39
38
|
makeProcessedTxFromTxWithPublicCalls,
|
|
40
39
|
} from '@aztec/stdlib/tx';
|
|
@@ -522,7 +521,7 @@ export class PublicProcessor implements Traceable {
|
|
|
522
521
|
private async processTxWithPublicCalls(tx: Tx): Promise<[ProcessedTx, NestedProcessReturnValues[]]> {
|
|
523
522
|
const timer = new Timer();
|
|
524
523
|
|
|
525
|
-
const { hints, publicInputs, gasUsed, revertCode, revertReason,
|
|
524
|
+
const { hints, publicInputs, gasUsed, revertCode, revertReason, appLogicReturnValues } =
|
|
526
525
|
await this.publicTxSimulator.simulate(tx);
|
|
527
526
|
|
|
528
527
|
if (!hints) {
|
|
@@ -530,14 +529,6 @@ export class PublicProcessor implements Traceable {
|
|
|
530
529
|
throw new Error('Avm proving result was not generated.');
|
|
531
530
|
}
|
|
532
531
|
|
|
533
|
-
processedPhases?.forEach(phase => {
|
|
534
|
-
if (phase.reverted) {
|
|
535
|
-
this.metrics.recordRevertedPhase(phase.phase);
|
|
536
|
-
} else {
|
|
537
|
-
this.metrics.recordPhaseDuration(phase.phase, phase.durationMs ?? 0);
|
|
538
|
-
}
|
|
539
|
-
});
|
|
540
|
-
|
|
541
532
|
const contractClassLogs = revertCode.isOK()
|
|
542
533
|
? tx.getContractClassLogs()
|
|
543
534
|
: tx.getSplitContractClassLogs(false /* revertible */);
|
|
@@ -547,7 +538,8 @@ export class PublicProcessor implements Traceable {
|
|
|
547
538
|
.map(log => ContractClassPublishedEvent.fromLog(log)),
|
|
548
539
|
);
|
|
549
540
|
|
|
550
|
-
|
|
541
|
+
// TODO(fcarreiro): remove phase count metric.
|
|
542
|
+
const phaseCount = 1;
|
|
551
543
|
const durationMs = timer.ms();
|
|
552
544
|
this.metrics.recordTx(phaseCount, durationMs, gasUsed.publicGas);
|
|
553
545
|
|
|
@@ -559,9 +551,7 @@ export class PublicProcessor implements Traceable {
|
|
|
559
551
|
revertReason,
|
|
560
552
|
);
|
|
561
553
|
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
return [processedTx, returnValues];
|
|
554
|
+
return [processedTx, appLogicReturnValues ?? []];
|
|
565
555
|
}
|
|
566
556
|
|
|
567
557
|
/**
|
|
@@ -143,6 +143,12 @@ 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()));
|
|
150
|
+
// FIXME(https://github.com/AztecProtocol/aztec-packages/issues/18441): a few but not all keccaks fail!
|
|
151
|
+
// expect(cppResult.appLogicReturnValues).toEqual(tsResult.appLogicReturnValues);
|
|
146
152
|
|
|
147
153
|
// Confirm that tree roots match
|
|
148
154
|
const cppStateRef = await this.merkleTree.getStateReference();
|
|
@@ -180,7 +186,7 @@ export class MeasuredCppPublicTxSimulator extends CppPublicTxSimulator implement
|
|
|
180
186
|
try {
|
|
181
187
|
result = await super.simulate(tx);
|
|
182
188
|
} finally {
|
|
183
|
-
this.metrics.stopRecordingTxSimulation(txLabel, result?.revertCode);
|
|
189
|
+
this.metrics.stopRecordingTxSimulation(txLabel, result?.gasUsed, result?.revertCode);
|
|
184
190
|
}
|
|
185
191
|
return result;
|
|
186
192
|
}
|
|
@@ -291,7 +297,7 @@ export class MeasuredCppPublicTxSimulatorHintedDbs
|
|
|
291
297
|
try {
|
|
292
298
|
result = await super.simulate(tx);
|
|
293
299
|
} finally {
|
|
294
|
-
this.metrics.stopRecordingTxSimulation(txLabel, result?.revertCode);
|
|
300
|
+
this.metrics.stopRecordingTxSimulation(txLabel, result?.gasUsed, result?.revertCode);
|
|
295
301
|
}
|
|
296
302
|
return result;
|
|
297
303
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Fr } from '@aztec/foundation/fields';
|
|
2
2
|
import { Timer } from '@aztec/foundation/timer';
|
|
3
|
-
import type {
|
|
3
|
+
import type { PublicSimulatorConfig, PublicTxResult } from '@aztec/stdlib/avm';
|
|
4
4
|
import type { Gas } from '@aztec/stdlib/gas';
|
|
5
5
|
import type { AvmSimulationStats } from '@aztec/stdlib/stats';
|
|
6
6
|
import type { MerkleTreeWriteOperations } from '@aztec/stdlib/trees';
|
|
@@ -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
|
}
|
|
@@ -51,7 +51,7 @@ export class MeasuredPublicTxSimulator extends PublicTxSimulator implements Meas
|
|
|
51
51
|
this.metrics.recordPrivateEffectsInsertion(timer.us(), 'revertible');
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
protected override async simulatePhase(phase: TxExecutionPhase, context: PublicTxContext)
|
|
54
|
+
protected override async simulatePhase(phase: TxExecutionPhase, context: PublicTxContext) {
|
|
55
55
|
const timer = new Timer();
|
|
56
56
|
const result = await super.simulatePhase(phase, context);
|
|
57
57
|
result.durationMs = timer.ms();
|
|
@@ -3,13 +3,7 @@ import { Fr } from '@aztec/foundation/fields';
|
|
|
3
3
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import { ProtocolContractAddress, ProtocolContractsList } from '@aztec/protocol-contracts';
|
|
5
5
|
import { computeFeePayerBalanceStorageSlot } from '@aztec/protocol-contracts/fee-juice';
|
|
6
|
-
import {
|
|
7
|
-
AvmExecutionHints,
|
|
8
|
-
AvmTxHint,
|
|
9
|
-
type ProcessedPhase,
|
|
10
|
-
PublicSimulatorConfig,
|
|
11
|
-
PublicTxResult,
|
|
12
|
-
} from '@aztec/stdlib/avm';
|
|
6
|
+
import { AvmExecutionHints, AvmTxHint, PublicSimulatorConfig, PublicTxResult } from '@aztec/stdlib/avm';
|
|
13
7
|
import { SimulationError } from '@aztec/stdlib/errors';
|
|
14
8
|
import type { Gas } from '@aztec/stdlib/gas';
|
|
15
9
|
import type { MerkleTreeWriteOperations } from '@aztec/stdlib/trees';
|
|
@@ -73,6 +67,15 @@ class TxSimTeardownRevert extends Error {
|
|
|
73
67
|
}
|
|
74
68
|
}
|
|
75
69
|
|
|
70
|
+
/** Only used internally. */
|
|
71
|
+
type ProcessedPhase = {
|
|
72
|
+
phase: TxExecutionPhase;
|
|
73
|
+
durationMs?: number;
|
|
74
|
+
returnValues: NestedProcessReturnValues[];
|
|
75
|
+
reverted: boolean;
|
|
76
|
+
revertReason?: SimulationError;
|
|
77
|
+
};
|
|
78
|
+
|
|
76
79
|
export class PublicTxSimulator implements PublicTxSimulatorInterface {
|
|
77
80
|
protected log: Logger;
|
|
78
81
|
protected readonly config: PublicSimulatorConfig;
|
|
@@ -197,6 +200,10 @@ export class PublicTxSimulator implements PublicTxSimulatorInterface {
|
|
|
197
200
|
const publicInputs = await context.generateAvmCircuitPublicInputs();
|
|
198
201
|
const revertCode = context.getFinalRevertCode();
|
|
199
202
|
|
|
203
|
+
// We only return the app logic phase information.
|
|
204
|
+
const appLogicReturnValues =
|
|
205
|
+
processedPhases.find(({ phase }) => phase === TxExecutionPhase.APP_LOGIC)?.returnValues ?? [];
|
|
206
|
+
|
|
200
207
|
return new PublicTxResult(
|
|
201
208
|
/*gasUsed=*/ {
|
|
202
209
|
totalGas: context.getActualGasUsed(),
|
|
@@ -206,7 +213,7 @@ export class PublicTxSimulator implements PublicTxSimulatorInterface {
|
|
|
206
213
|
},
|
|
207
214
|
/*revertCode=*/ revertCode,
|
|
208
215
|
/*revertReason=*/ context.revertReason,
|
|
209
|
-
/*
|
|
216
|
+
/*appLogicReturnValues=*/ appLogicReturnValues,
|
|
210
217
|
/*logs=*/ context.state.getActiveStateManager().getLogs(),
|
|
211
218
|
/*hints=*/ hints,
|
|
212
219
|
/*publicInputs=*/ publicInputs,
|
|
@@ -460,7 +467,10 @@ export class PublicTxSimulator implements PublicTxSimulatorInterface {
|
|
|
460
467
|
const txFee = context.getTransactionFee(TxExecutionPhase.TEARDOWN);
|
|
461
468
|
|
|
462
469
|
if (context.feePayer.isZero()) {
|
|
463
|
-
|
|
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()}`);
|
|
464
474
|
return;
|
|
465
475
|
}
|
|
466
476
|
|
|
@@ -480,6 +490,8 @@ export class PublicTxSimulator implements PublicTxSimulatorInterface {
|
|
|
480
490
|
this.config.skipFeeEnforcement,
|
|
481
491
|
`Not enough balance for fee payer to pay for transaction (got ${currentBalance.toBigInt()} needs ${txFee.toBigInt()})`,
|
|
482
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.
|
|
483
495
|
currentBalance = txFee;
|
|
484
496
|
}
|
|
485
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
|
|