@aztec/simulator 0.0.1-commit.d1f2d6c → 0.0.1-commit.d20b825a7
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/README.md +4 -4
- package/dest/private/acvm/acvm.d.ts +4 -2
- package/dest/private/acvm/acvm.d.ts.map +1 -1
- package/dest/private/acvm/acvm.js +4 -3
- package/dest/private/acvm_native.d.ts +5 -3
- package/dest/private/acvm_native.d.ts.map +1 -1
- package/dest/private/acvm_native.js +8 -6
- package/dest/private/acvm_wasm.d.ts +4 -3
- package/dest/private/acvm_wasm.d.ts.map +1 -1
- package/dest/private/acvm_wasm.js +4 -4
- package/dest/private/circuit_recording/circuit_recorder.d.ts +4 -3
- package/dest/private/circuit_recording/circuit_recorder.d.ts.map +1 -1
- package/dest/private/circuit_recording/circuit_recorder.js +7 -5
- package/dest/private/circuit_recording/file_circuit_recorder.d.ts +3 -2
- package/dest/private/circuit_recording/file_circuit_recorder.d.ts.map +1 -1
- package/dest/private/circuit_recording/file_circuit_recorder.js +2 -2
- package/dest/private/circuit_recording/memory_circuit_recorder.d.ts +7 -2
- package/dest/private/circuit_recording/memory_circuit_recorder.d.ts.map +1 -1
- package/dest/private/circuit_recording/memory_circuit_recorder.js +4 -4
- package/dest/private/factory.d.ts +3 -3
- package/dest/private/factory.d.ts.map +1 -1
- package/dest/private/factory.js +7 -4
- package/dest/public/avm/avm_context.d.ts +3 -3
- package/dest/public/avm/avm_context.d.ts.map +1 -1
- package/dest/public/avm/avm_contract_call_result.d.ts +6 -6
- package/dest/public/avm/avm_contract_call_result.d.ts.map +1 -1
- package/dest/public/avm/avm_contract_call_result.js +3 -3
- package/dest/public/avm/avm_execution_environment.d.ts +6 -5
- package/dest/public/avm/avm_execution_environment.d.ts.map +1 -1
- package/dest/public/avm/avm_gas.js +3 -3
- package/dest/public/avm/avm_machine_state.d.ts +6 -5
- package/dest/public/avm/avm_machine_state.d.ts.map +1 -1
- package/dest/public/avm/avm_machine_state.js +3 -2
- package/dest/public/avm/avm_simulator.d.ts +3 -2
- package/dest/public/avm/avm_simulator.d.ts.map +1 -1
- package/dest/public/avm/avm_simulator.js +6 -5
- package/dest/public/avm/calldata.d.ts +51 -0
- package/dest/public/avm/calldata.d.ts.map +1 -0
- package/dest/public/avm/calldata.js +64 -0
- package/dest/public/avm/fixtures/account_proof_fetcher.d.ts +2 -0
- package/dest/public/avm/fixtures/account_proof_fetcher.d.ts.map +1 -0
- package/dest/public/avm/fixtures/account_proof_fetcher.js +152 -0
- package/dest/public/avm/fixtures/avm_simulation_tester.d.ts +1 -1
- package/dest/public/avm/fixtures/avm_simulation_tester.d.ts.map +1 -1
- package/dest/public/avm/fixtures/avm_simulation_tester.js +3 -2
- package/dest/public/avm/fixtures/initializers.d.ts +1 -1
- package/dest/public/avm/fixtures/initializers.d.ts.map +1 -1
- package/dest/public/avm/fixtures/initializers.js +2 -1
- package/dest/public/avm/opcodes/accrued_substate.d.ts +4 -5
- package/dest/public/avm/opcodes/accrued_substate.d.ts.map +1 -1
- package/dest/public/avm/opcodes/accrued_substate.js +15 -16
- package/dest/public/avm/opcodes/external_calls.d.ts +1 -1
- package/dest/public/avm/opcodes/external_calls.d.ts.map +1 -1
- package/dest/public/avm/opcodes/external_calls.js +7 -7
- package/dest/public/avm/opcodes/memory.js +1 -1
- package/dest/public/avm/serialization/bytecode_serialization.js +3 -3
- package/dest/public/avm/serialization/instruction_serialization.d.ts +2 -2
- package/dest/public/avm/serialization/instruction_serialization.d.ts.map +1 -1
- package/dest/public/avm/serialization/instruction_serialization.js +1 -1
- package/dest/public/contracts_db_checkpoint.d.ts +2 -2
- package/dest/public/contracts_db_checkpoint.d.ts.map +1 -1
- package/dest/public/contracts_db_checkpoint.js +1 -1
- package/dest/public/debug_fn_name.d.ts +4 -4
- package/dest/public/debug_fn_name.d.ts.map +1 -1
- package/dest/public/debug_fn_name.js +7 -5
- package/dest/public/executor_metrics.d.ts +1 -1
- package/dest/public/executor_metrics.d.ts.map +1 -1
- package/dest/public/executor_metrics.js +7 -2
- package/dest/public/fixtures/amm_test.js +2 -2
- package/dest/public/fixtures/bulk_test.d.ts +1 -1
- package/dest/public/fixtures/bulk_test.d.ts.map +1 -1
- package/dest/public/fixtures/bulk_test.js +4 -4
- package/dest/public/fixtures/custom_bytecode_tests.d.ts +3 -1
- package/dest/public/fixtures/custom_bytecode_tests.d.ts.map +1 -1
- package/dest/public/fixtures/custom_bytecode_tests.js +61 -1
- package/dest/public/fixtures/opcode_spammer.d.ts +3 -4
- package/dest/public/fixtures/opcode_spammer.d.ts.map +1 -1
- package/dest/public/fixtures/opcode_spammer.js +16 -56
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts +6 -5
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts.map +1 -1
- package/dest/public/fixtures/public_tx_simulation_tester.js +37 -10
- package/dest/public/fixtures/utils.d.ts +2 -2
- package/dest/public/fixtures/utils.d.ts.map +1 -1
- package/dest/public/fixtures/utils.js +10 -10
- package/dest/public/hinting_db_sources.d.ts +5 -5
- package/dest/public/hinting_db_sources.d.ts.map +1 -1
- package/dest/public/hinting_db_sources.js +7 -6
- package/dest/public/public_db_sources.d.ts +6 -5
- package/dest/public/public_db_sources.d.ts.map +1 -1
- package/dest/public/public_db_sources.js +14 -14
- package/dest/public/public_processor/guarded_merkle_tree.d.ts +5 -5
- package/dest/public/public_processor/guarded_merkle_tree.d.ts.map +1 -1
- package/dest/public/public_processor/guarded_merkle_tree.js +5 -5
- package/dest/public/public_processor/public_processor.d.ts +8 -4
- package/dest/public/public_processor/public_processor.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor.js +75 -50
- package/dest/public/public_processor/public_processor_metrics.d.ts +5 -2
- package/dest/public/public_processor/public_processor_metrics.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor_metrics.js +28 -4
- package/dest/public/public_tx_simulator/contract_provider_for_cpp.d.ts +3 -2
- package/dest/public/public_tx_simulator/contract_provider_for_cpp.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/contract_provider_for_cpp.js +4 -3
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator.d.ts +5 -5
- 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 +10 -11
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.d.ts +4 -4
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.js +7 -7
- package/dest/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.d.ts +4 -4
- package/dest/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.js +6 -6
- package/dest/public/public_tx_simulator/dumping_cpp_public_tx_simulator.d.ts +3 -2
- package/dest/public/public_tx_simulator/dumping_cpp_public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/dumping_cpp_public_tx_simulator.js +2 -2
- package/dest/public/public_tx_simulator/factories.d.ts +3 -2
- package/dest/public/public_tx_simulator/factories.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/factories.js +4 -4
- package/dest/public/public_tx_simulator/public_tx_context.d.ts +10 -5
- package/dest/public/public_tx_simulator/public_tx_context.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_context.js +16 -18
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts +9 -4
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_simulator.js +23 -15
- package/dest/public/side_effect_trace.d.ts +4 -4
- package/dest/public/side_effect_trace.d.ts.map +1 -1
- package/dest/public/side_effect_trace.js +3 -3
- package/dest/public/state_manager/state_manager.d.ts +10 -4
- package/dest/public/state_manager/state_manager.d.ts.map +1 -1
- package/dest/public/state_manager/state_manager.js +12 -5
- package/dest/public/test_executor_metrics.d.ts +8 -2
- package/dest/public/test_executor_metrics.d.ts.map +1 -1
- package/dest/public/test_executor_metrics.js +24 -2
- package/package.json +15 -16
- package/src/private/acvm/acvm.ts +4 -3
- package/src/private/acvm_native.ts +11 -5
- package/src/private/acvm_wasm.ts +7 -3
- package/src/private/circuit_recording/circuit_recorder.ts +7 -5
- package/src/private/circuit_recording/file_circuit_recorder.ts +7 -2
- package/src/private/circuit_recording/memory_circuit_recorder.ts +6 -4
- package/src/private/factory.ts +7 -4
- package/src/public/avm/avm_context.ts +2 -2
- package/src/public/avm/avm_contract_call_result.ts +8 -6
- package/src/public/avm/avm_execution_environment.ts +9 -4
- package/src/public/avm/avm_gas.ts +2 -2
- package/src/public/avm/avm_machine_state.ts +6 -5
- package/src/public/avm/avm_simulator.ts +9 -6
- package/src/public/avm/calldata.ts +101 -0
- package/src/public/avm/fixtures/account_proof.json +553 -0
- package/src/public/avm/fixtures/account_proof_fetcher.ts +166 -0
- package/src/public/avm/fixtures/avm_simulation_tester.ts +8 -2
- package/src/public/avm/fixtures/initializers.ts +2 -1
- package/src/public/avm/opcodes/accrued_substate.ts +16 -19
- package/src/public/avm/opcodes/external_calls.ts +9 -8
- package/src/public/avm/opcodes/memory.ts +1 -1
- package/src/public/avm/serialization/bytecode_serialization.ts +2 -2
- package/src/public/avm/serialization/instruction_serialization.ts +1 -1
- package/src/public/contracts_db_checkpoint.ts +1 -1
- package/src/public/debug_fn_name.ts +10 -8
- package/src/public/executor_metrics.ts +4 -1
- package/src/public/fixtures/amm_test.ts +2 -2
- package/src/public/fixtures/bulk_test.ts +2 -4
- package/src/public/fixtures/custom_bytecode_tests.ts +139 -1
- package/src/public/fixtures/opcode_spammer.ts +18 -55
- package/src/public/fixtures/public_tx_simulation_tester.ts +47 -6
- package/src/public/fixtures/utils.ts +17 -12
- package/src/public/fuzzing/avm_fuzzer_simulator.ts +1 -1
- package/src/public/hinting_db_sources.ts +9 -7
- package/src/public/public_db_sources.ts +27 -19
- package/src/public/public_processor/guarded_merkle_tree.ts +6 -6
- package/src/public/public_processor/public_processor.ts +112 -67
- package/src/public/public_processor/public_processor_metrics.ts +22 -4
- package/src/public/public_tx_simulator/contract_provider_for_cpp.ts +8 -4
- package/src/public/public_tx_simulator/cpp_public_tx_simulator.ts +10 -8
- package/src/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.ts +7 -5
- package/src/public/public_tx_simulator/cpp_vs_ts_public_tx_simulator.ts +7 -5
- package/src/public/public_tx_simulator/dumping_cpp_public_tx_simulator.ts +3 -1
- package/src/public/public_tx_simulator/factories.ts +6 -3
- package/src/public/public_tx_simulator/public_tx_context.ts +21 -16
- package/src/public/public_tx_simulator/public_tx_simulator.ts +28 -15
- package/src/public/side_effect_trace.ts +5 -2
- package/src/public/state_manager/state_manager.ts +27 -4
- package/src/public/test_executor_metrics.ts +27 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, NULLIFIER_SUBTREE_HEIGHT } from '@aztec/constants';
|
|
2
2
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
3
3
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
4
|
+
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
5
5
|
import { sleep } from '@aztec/foundation/sleep';
|
|
6
6
|
import { DateProvider, Timer, elapsed, executeTimeout } from '@aztec/foundation/timer';
|
|
7
7
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
@@ -25,6 +25,7 @@ import type {
|
|
|
25
25
|
PublicProcessorValidator,
|
|
26
26
|
SequencerConfig,
|
|
27
27
|
} from '@aztec/stdlib/interfaces/server';
|
|
28
|
+
import { type DebugLog, type DebugLogStore, NullDebugLogStore } from '@aztec/stdlib/logs';
|
|
28
29
|
import { ProvingRequestType } from '@aztec/stdlib/proofs';
|
|
29
30
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
30
31
|
import {
|
|
@@ -62,11 +63,15 @@ import { PublicProcessorMetrics } from './public_processor_metrics.js';
|
|
|
62
63
|
* Creates new instances of PublicProcessor given the provided merkle tree db and contract data source.
|
|
63
64
|
*/
|
|
64
65
|
export class PublicProcessorFactory {
|
|
66
|
+
private log: Logger;
|
|
65
67
|
constructor(
|
|
66
68
|
private contractDataSource: ContractDataSource,
|
|
67
69
|
private dateProvider: DateProvider = new DateProvider(),
|
|
68
70
|
protected telemetryClient: TelemetryClient = getTelemetryClient(),
|
|
69
|
-
|
|
71
|
+
bindings?: LoggerBindings,
|
|
72
|
+
) {
|
|
73
|
+
this.log = createLogger('simulator:public-processor-factory', bindings);
|
|
74
|
+
}
|
|
70
75
|
|
|
71
76
|
/**
|
|
72
77
|
* Creates a new instance of a PublicProcessor.
|
|
@@ -79,7 +84,8 @@ export class PublicProcessorFactory {
|
|
|
79
84
|
globalVariables: GlobalVariables,
|
|
80
85
|
config: PublicSimulatorConfig,
|
|
81
86
|
): PublicProcessor {
|
|
82
|
-
const
|
|
87
|
+
const bindings = this.log.getBindings();
|
|
88
|
+
const contractsDB = new PublicContractsDB(this.contractDataSource, bindings);
|
|
83
89
|
|
|
84
90
|
const guardedFork = new GuardedMerkleTreeOperations(merkleTree);
|
|
85
91
|
const publicTxSimulator = this.createPublicTxSimulator(guardedFork, contractsDB, globalVariables, config);
|
|
@@ -91,6 +97,7 @@ export class PublicProcessorFactory {
|
|
|
91
97
|
publicTxSimulator,
|
|
92
98
|
this.dateProvider,
|
|
93
99
|
this.telemetryClient,
|
|
100
|
+
createLogger('simulator:public-processor', bindings),
|
|
94
101
|
);
|
|
95
102
|
}
|
|
96
103
|
|
|
@@ -100,7 +107,14 @@ export class PublicProcessorFactory {
|
|
|
100
107
|
globalVariables: GlobalVariables,
|
|
101
108
|
config?: Partial<PublicTxSimulatorConfig>,
|
|
102
109
|
): PublicTxSimulatorInterface {
|
|
103
|
-
return new TelemetryCppPublicTxSimulator(
|
|
110
|
+
return new TelemetryCppPublicTxSimulator(
|
|
111
|
+
merkleTree,
|
|
112
|
+
contractsDB,
|
|
113
|
+
globalVariables,
|
|
114
|
+
this.telemetryClient,
|
|
115
|
+
config,
|
|
116
|
+
this.log.getBindings(),
|
|
117
|
+
);
|
|
104
118
|
}
|
|
105
119
|
}
|
|
106
120
|
|
|
@@ -117,7 +131,6 @@ class PublicProcessorTimeoutError extends Error {
|
|
|
117
131
|
*/
|
|
118
132
|
export class PublicProcessor implements Traceable {
|
|
119
133
|
private metrics: PublicProcessorMetrics;
|
|
120
|
-
|
|
121
134
|
constructor(
|
|
122
135
|
protected globalVariables: GlobalVariables,
|
|
123
136
|
private guardedMerkleTree: GuardedMerkleTreeOperations,
|
|
@@ -125,8 +138,9 @@ export class PublicProcessor implements Traceable {
|
|
|
125
138
|
protected publicTxSimulator: PublicTxSimulatorInterface,
|
|
126
139
|
private dateProvider: DateProvider,
|
|
127
140
|
telemetryClient: TelemetryClient = getTelemetryClient(),
|
|
128
|
-
private log
|
|
141
|
+
private log: Logger,
|
|
129
142
|
private opts: Pick<SequencerConfig, 'fakeProcessingDelayPerTxMs' | 'fakeThrowAfterProcessingTxCount'> = {},
|
|
143
|
+
private debugLogStore: DebugLogStore = new NullDebugLogStore(),
|
|
130
144
|
) {
|
|
131
145
|
this.metrics = new PublicProcessorMetrics(telemetryClient, 'PublicProcessor');
|
|
132
146
|
}
|
|
@@ -146,12 +160,13 @@ export class PublicProcessor implements Traceable {
|
|
|
146
160
|
txs: Iterable<Tx> | AsyncIterable<Tx>,
|
|
147
161
|
limits: PublicProcessorLimits = {},
|
|
148
162
|
validator: PublicProcessorValidator = {},
|
|
149
|
-
): Promise<[ProcessedTx[], FailedTx[], Tx[], NestedProcessReturnValues[],
|
|
150
|
-
const { maxTransactions,
|
|
163
|
+
): Promise<[ProcessedTx[], FailedTx[], Tx[], NestedProcessReturnValues[], DebugLog[]]> {
|
|
164
|
+
const { maxTransactions, deadline, maxBlockGas, maxBlobFields, isBuildingProposal } = limits;
|
|
151
165
|
const { preprocessValidator, nullifierCache } = validator;
|
|
152
166
|
const result: ProcessedTx[] = [];
|
|
153
167
|
const usedTxs: Tx[] = [];
|
|
154
168
|
const failed: FailedTx[] = [];
|
|
169
|
+
const debugLogs: DebugLog[] = [];
|
|
155
170
|
const timer = new Timer();
|
|
156
171
|
|
|
157
172
|
let totalSizeInBytes = 0;
|
|
@@ -159,6 +174,8 @@ export class PublicProcessor implements Traceable {
|
|
|
159
174
|
let totalPublicGas = new Gas(0, 0);
|
|
160
175
|
let totalBlockGas = new Gas(0, 0);
|
|
161
176
|
let totalBlobFields = 0;
|
|
177
|
+
let silentlySkippedCount = 0;
|
|
178
|
+
let totalSilentlySkippedDurationMs = 0;
|
|
162
179
|
|
|
163
180
|
for await (const tx of txs) {
|
|
164
181
|
// Only process up to the max tx limit
|
|
@@ -173,22 +190,23 @@ export class PublicProcessor implements Traceable {
|
|
|
173
190
|
break;
|
|
174
191
|
}
|
|
175
192
|
|
|
176
|
-
// Skip this tx if it'd exceed max block size
|
|
177
193
|
const txHash = tx.getTxHash().toString();
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
194
|
+
|
|
195
|
+
// Skip this tx if its estimated blob fields would exceed the limit.
|
|
196
|
+
// Only done during proposal building: during re-execution we must process the exact txs from the proposal.
|
|
197
|
+
const txBlobFields = tx.getPrivateTxEffectsSizeInFields();
|
|
198
|
+
if (isBuildingProposal && maxBlobFields !== undefined && totalBlobFields + txBlobFields > maxBlobFields) {
|
|
199
|
+
this.log.warn(
|
|
200
|
+
`Skipping tx ${txHash} with ${txBlobFields} fields from private side effects due to blob fields limit`,
|
|
201
|
+
{ txHash, txBlobFields, totalBlobFields, maxBlobFields },
|
|
202
|
+
);
|
|
186
203
|
continue;
|
|
187
204
|
}
|
|
188
205
|
|
|
189
|
-
// Skip this tx if its gas limit would exceed the block gas limit
|
|
206
|
+
// Skip this tx if its gas limit would exceed the block gas limit (either da or l2).
|
|
207
|
+
// Only done during proposal building: during re-execution we must process the exact txs from the proposal.
|
|
190
208
|
const txGasLimit = tx.data.constants.txContext.gasSettings.gasLimits;
|
|
191
|
-
if (maxBlockGas !== undefined && totalBlockGas.add(txGasLimit).gtAny(maxBlockGas)) {
|
|
209
|
+
if (isBuildingProposal && maxBlockGas !== undefined && totalBlockGas.add(txGasLimit).gtAny(maxBlockGas)) {
|
|
192
210
|
this.log.warn(`Skipping processing of tx ${txHash} due to block gas limit`, {
|
|
193
211
|
txHash,
|
|
194
212
|
txGasLimit,
|
|
@@ -228,7 +246,9 @@ export class PublicProcessor implements Traceable {
|
|
|
228
246
|
this.contractsDB.createCheckpoint();
|
|
229
247
|
|
|
230
248
|
try {
|
|
231
|
-
const [processedTx, returnValues] = await
|
|
249
|
+
const [txProcessingTimeMs, [processedTx, returnValues, txDebugLogs]] = await elapsed(() =>
|
|
250
|
+
this.processTx(tx, deadline),
|
|
251
|
+
);
|
|
232
252
|
|
|
233
253
|
// Inject a fake processing failure after N txs if requested
|
|
234
254
|
const fakeThrowAfter = this.opts.fakeThrowAfterProcessingTxCount;
|
|
@@ -237,23 +257,9 @@ export class PublicProcessor implements Traceable {
|
|
|
237
257
|
}
|
|
238
258
|
|
|
239
259
|
const txBlobFields = processedTx.txEffect.getNumBlobFields();
|
|
240
|
-
|
|
241
|
-
// If the actual size of this tx would exceed block size, skip it
|
|
242
260
|
const txSize = txBlobFields * Fr.SIZE_IN_BYTES;
|
|
243
|
-
if (maxBlockSize !== undefined && totalSizeInBytes + txSize > maxBlockSize) {
|
|
244
|
-
this.log.debug(`Skipping processed tx ${txHash} sized ${txSize} due to max block size.`, {
|
|
245
|
-
txHash,
|
|
246
|
-
sizeInBytes: txSize,
|
|
247
|
-
totalSizeInBytes,
|
|
248
|
-
maxBlockSize,
|
|
249
|
-
});
|
|
250
|
-
// Need to revert the checkpoint here and don't go any further
|
|
251
|
-
await checkpoint.revert();
|
|
252
|
-
this.contractsDB.revertCheckpoint();
|
|
253
|
-
continue;
|
|
254
|
-
}
|
|
255
261
|
|
|
256
|
-
// If the actual blob fields of this tx would exceed the limit, skip it
|
|
262
|
+
// If the actual blob fields of this tx would exceed the limit, skip it.
|
|
257
263
|
// Note: maxBlobFields already accounts for block end blob fields and previous blocks in checkpoint.
|
|
258
264
|
if (maxBlobFields !== undefined && totalBlobFields + txBlobFields > maxBlobFields) {
|
|
259
265
|
this.log.debug(
|
|
@@ -263,25 +269,54 @@ export class PublicProcessor implements Traceable {
|
|
|
263
269
|
txBlobFields,
|
|
264
270
|
totalBlobFields,
|
|
265
271
|
maxBlobFields,
|
|
272
|
+
txProcessingTimeMs,
|
|
266
273
|
},
|
|
267
274
|
);
|
|
275
|
+
silentlySkippedCount += 1;
|
|
276
|
+
totalSilentlySkippedDurationMs += txProcessingTimeMs;
|
|
277
|
+
this.metrics.recordSilentlySkipped(txProcessingTimeMs);
|
|
268
278
|
// Need to revert the checkpoint here and don't go any further
|
|
269
279
|
await checkpoint.revert();
|
|
270
280
|
this.contractsDB.revertCheckpoint();
|
|
271
281
|
continue;
|
|
272
282
|
}
|
|
273
283
|
|
|
284
|
+
// During re-execution, check if the actual gas used by this tx would push the block over the gas limit.
|
|
285
|
+
// Unlike the proposal-building check (which uses declared gas limits pessimistically before processing),
|
|
286
|
+
// this uses actual gas and stops processing when the limit is exceeded.
|
|
287
|
+
if (
|
|
288
|
+
!isBuildingProposal &&
|
|
289
|
+
maxBlockGas !== undefined &&
|
|
290
|
+
totalBlockGas.add(processedTx.gasUsed.totalGas).gtAny(maxBlockGas)
|
|
291
|
+
) {
|
|
292
|
+
this.log.warn(`Stopping re-execution since tx ${txHash} would push block gas over limit`, {
|
|
293
|
+
txHash,
|
|
294
|
+
txGas: processedTx.gasUsed.totalGas,
|
|
295
|
+
totalBlockGas,
|
|
296
|
+
maxBlockGas,
|
|
297
|
+
});
|
|
298
|
+
await checkpoint.revert();
|
|
299
|
+
this.contractsDB.revertCheckpoint();
|
|
300
|
+
break;
|
|
301
|
+
}
|
|
302
|
+
|
|
274
303
|
// FIXME(fcarreiro): it's ugly to have to notify the validator of nullifiers.
|
|
275
304
|
// I'd rather pass the validators the processedTx as well and let them deal with it.
|
|
276
305
|
nullifierCache?.addNullifiers(processedTx.txEffect.nullifiers.map(n => n.toBuffer()));
|
|
277
306
|
result.push(processedTx);
|
|
278
307
|
usedTxs.push(tx);
|
|
279
308
|
returns = returns.concat(returnValues);
|
|
309
|
+
debugLogs.push(...txDebugLogs);
|
|
310
|
+
|
|
311
|
+
this.debugLogStore.storeLogs(processedTx.hash.toString(), txDebugLogs);
|
|
280
312
|
|
|
281
313
|
totalPublicGas = totalPublicGas.add(processedTx.gasUsed.publicGas);
|
|
282
314
|
totalBlockGas = totalBlockGas.add(processedTx.gasUsed.totalGas);
|
|
283
315
|
totalSizeInBytes += txSize;
|
|
284
316
|
totalBlobFields += txBlobFields;
|
|
317
|
+
|
|
318
|
+
// Commit the tx-level contracts checkpoint on success
|
|
319
|
+
this.contractsDB.commitCheckpoint();
|
|
285
320
|
} catch (err: any) {
|
|
286
321
|
if (err?.name === 'PublicProcessorTimeoutError') {
|
|
287
322
|
this.log.warn(`Stopping tx processing due to timeout.`);
|
|
@@ -301,14 +336,10 @@ export class PublicProcessor implements Traceable {
|
|
|
301
336
|
// 1. At least one outstanding checkpoint that has not been committed (the one created before we processed the tx).
|
|
302
337
|
// 2. Possible state updates on that checkpoint or any others created during execution.
|
|
303
338
|
|
|
304
|
-
//
|
|
305
|
-
//
|
|
306
|
-
//
|
|
307
|
-
await checkpoint.
|
|
308
|
-
|
|
309
|
-
// Now we want to revert any/all remaining checkpoints, destroying any outstanding state updates.
|
|
310
|
-
// This needs to be done directly on the underlying fork as the guarded fork has been stopped.
|
|
311
|
-
await this.guardedMerkleTree.getUnderlyingFork().revertAllCheckpoints();
|
|
339
|
+
// Revert all checkpoints at or above this checkpoint's depth (inclusive), destroying any outstanding state
|
|
340
|
+
// updates from this tx and any nested checkpoints created during execution. This preserves any checkpoints
|
|
341
|
+
// created by callers below our depth.
|
|
342
|
+
await checkpoint.revertToCheckpoint();
|
|
312
343
|
|
|
313
344
|
// Revert any contracts added to the DB for the tx.
|
|
314
345
|
this.contractsDB.revertCheckpoint();
|
|
@@ -320,9 +351,9 @@ export class PublicProcessor implements Traceable {
|
|
|
320
351
|
break;
|
|
321
352
|
}
|
|
322
353
|
|
|
323
|
-
// Roll back state to start of TX before proceeding to next TX
|
|
324
|
-
|
|
325
|
-
await
|
|
354
|
+
// Roll back state to start of TX before proceeding to next TX.
|
|
355
|
+
// Reverts all checkpoints at or above this checkpoint's depth, preserving any caller checkpoints below.
|
|
356
|
+
await checkpoint.revertToCheckpoint();
|
|
326
357
|
this.contractsDB.revertCheckpoint();
|
|
327
358
|
const errorMessage = err instanceof Error || err instanceof AssertionError ? err.message : 'Unknown error';
|
|
328
359
|
this.log.warn(`Failed to process tx ${txHash.toString()}: ${errorMessage} ${err?.stack}`);
|
|
@@ -334,7 +365,6 @@ export class PublicProcessor implements Traceable {
|
|
|
334
365
|
} finally {
|
|
335
366
|
// Base case is we always commit the checkpoint. Using the ForkCheckpoint means this has no effect if the tx was previously reverted
|
|
336
367
|
await checkpoint.commit();
|
|
337
|
-
this.contractsDB.commitCheckpointOkIfNone();
|
|
338
368
|
}
|
|
339
369
|
}
|
|
340
370
|
|
|
@@ -342,15 +372,26 @@ export class PublicProcessor implements Traceable {
|
|
|
342
372
|
const rate = duration > 0 ? totalPublicGas.l2Gas / duration : 0;
|
|
343
373
|
this.metrics.recordAllTxs(totalPublicGas, rate);
|
|
344
374
|
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
375
|
+
const silentlySkippedDurationMs = Math.round(totalSilentlySkippedDurationMs);
|
|
376
|
+
this.log.info(
|
|
377
|
+
`Processed ${result.length} successful txs and ${failed.length} failed txs ` +
|
|
378
|
+
`(${silentlySkippedCount} silently skipped, ${silentlySkippedDurationMs}ms wasted) ` +
|
|
379
|
+
`in ${duration}s`,
|
|
380
|
+
{
|
|
381
|
+
blockNumber: this.globalVariables.blockNumber,
|
|
382
|
+
successfulCount: result.length,
|
|
383
|
+
failedCount: failed.length,
|
|
384
|
+
duration,
|
|
385
|
+
rate,
|
|
386
|
+
totalPublicGas,
|
|
387
|
+
totalBlockGas,
|
|
388
|
+
totalSizeInBytes,
|
|
389
|
+
silentlySkippedCount,
|
|
390
|
+
silentlySkippedDurationMs,
|
|
391
|
+
},
|
|
392
|
+
);
|
|
352
393
|
|
|
353
|
-
return [result, failed, usedTxs, returns,
|
|
394
|
+
return [result, failed, usedTxs, returns, debugLogs];
|
|
354
395
|
}
|
|
355
396
|
|
|
356
397
|
private async checkWorldStateUnchanged(
|
|
@@ -370,8 +411,13 @@ export class PublicProcessor implements Traceable {
|
|
|
370
411
|
}
|
|
371
412
|
|
|
372
413
|
@trackSpan('PublicProcessor.processTx', tx => ({ [Attributes.TX_HASH]: tx.getTxHash().toString() }))
|
|
373
|
-
private async processTx(
|
|
374
|
-
|
|
414
|
+
private async processTx(
|
|
415
|
+
tx: Tx,
|
|
416
|
+
deadline: Date | undefined,
|
|
417
|
+
): Promise<[ProcessedTx, NestedProcessReturnValues[], DebugLog[]]> {
|
|
418
|
+
const [time, [processedTx, returnValues, debugLogs]] = await elapsed(() =>
|
|
419
|
+
this.processTxWithinDeadline(tx, deadline),
|
|
420
|
+
);
|
|
375
421
|
|
|
376
422
|
this.log.verbose(
|
|
377
423
|
!tx.hasPublicCalls()
|
|
@@ -394,7 +440,7 @@ export class PublicProcessor implements Traceable {
|
|
|
394
440
|
},
|
|
395
441
|
);
|
|
396
442
|
|
|
397
|
-
return [processedTx, returnValues ?? []];
|
|
443
|
+
return [processedTx, returnValues ?? [], debugLogs];
|
|
398
444
|
}
|
|
399
445
|
|
|
400
446
|
private async doTreeInsertionsForPrivateOnlyTx(processedTx: ProcessedTx): Promise<void> {
|
|
@@ -428,10 +474,9 @@ export class PublicProcessor implements Traceable {
|
|
|
428
474
|
private async processTxWithinDeadline(
|
|
429
475
|
tx: Tx,
|
|
430
476
|
deadline: Date | undefined,
|
|
431
|
-
): Promise<[ProcessedTx, NestedProcessReturnValues[] | undefined]> {
|
|
432
|
-
const innerProcessFn: () => Promise<[ProcessedTx, NestedProcessReturnValues[] | undefined]> =
|
|
433
|
-
? () => this.processTxWithPublicCalls(tx)
|
|
434
|
-
: () => this.processPrivateOnlyTx(tx);
|
|
477
|
+
): Promise<[ProcessedTx, NestedProcessReturnValues[] | undefined, DebugLog[]]> {
|
|
478
|
+
const innerProcessFn: () => Promise<[ProcessedTx, NestedProcessReturnValues[] | undefined, DebugLog[]]> =
|
|
479
|
+
tx.hasPublicCalls() ? () => this.processTxWithPublicCalls(tx) : () => this.processPrivateOnlyTx(tx);
|
|
435
480
|
|
|
436
481
|
// Fake a delay per tx if instructed (used for tests)
|
|
437
482
|
const fakeDelayPerTxMs = this.opts.fakeProcessingDelayPerTxMs;
|
|
@@ -499,7 +544,7 @@ export class PublicProcessor implements Traceable {
|
|
|
499
544
|
@trackSpan('PublicProcessor.processPrivateOnlyTx', (tx: Tx) => ({
|
|
500
545
|
[Attributes.TX_HASH]: tx.getTxHash().toString(),
|
|
501
546
|
}))
|
|
502
|
-
private async processPrivateOnlyTx(tx: Tx): Promise<[ProcessedTx, undefined]> {
|
|
547
|
+
private async processPrivateOnlyTx(tx: Tx): Promise<[ProcessedTx, undefined, DebugLog[]]> {
|
|
503
548
|
const gasFees = this.globalVariables.gasFees;
|
|
504
549
|
const transactionFee = computeTransactionFee(gasFees, tx.data.constants.txContext.gasSettings, tx.data.gasUsed);
|
|
505
550
|
|
|
@@ -522,15 +567,15 @@ export class PublicProcessor implements Traceable {
|
|
|
522
567
|
// Fee payment insertion has already been done. Do the rest.
|
|
523
568
|
await this.doTreeInsertionsForPrivateOnlyTx(processedTx);
|
|
524
569
|
|
|
525
|
-
|
|
570
|
+
this.contractsDB.addNewContracts(tx);
|
|
526
571
|
|
|
527
|
-
return [processedTx, undefined];
|
|
572
|
+
return [processedTx, undefined, []];
|
|
528
573
|
}
|
|
529
574
|
|
|
530
575
|
@trackSpan('PublicProcessor.processTxWithPublicCalls', tx => ({
|
|
531
576
|
[Attributes.TX_HASH]: tx.getTxHash().toString(),
|
|
532
577
|
}))
|
|
533
|
-
private async processTxWithPublicCalls(tx: Tx): Promise<[ProcessedTx, NestedProcessReturnValues[]]> {
|
|
578
|
+
private async processTxWithPublicCalls(tx: Tx): Promise<[ProcessedTx, NestedProcessReturnValues[], DebugLog[]]> {
|
|
534
579
|
const timer = new Timer();
|
|
535
580
|
|
|
536
581
|
const result = await this.publicTxSimulator.simulate(tx);
|
|
@@ -568,7 +613,7 @@ export class PublicProcessor implements Traceable {
|
|
|
568
613
|
revertReason,
|
|
569
614
|
);
|
|
570
615
|
|
|
571
|
-
return [processedTx, appLogicReturnValues];
|
|
616
|
+
return [processedTx, appLogicReturnValues, result.logs ?? []];
|
|
572
617
|
}
|
|
573
618
|
|
|
574
619
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ContractClassPublishedEvent } from '@aztec/protocol-contracts/class-registry';
|
|
2
2
|
import type { Gas } from '@aztec/stdlib/gas';
|
|
3
|
-
import
|
|
3
|
+
import { TxExecutionPhase } from '@aztec/stdlib/tx';
|
|
4
4
|
import {
|
|
5
5
|
Attributes,
|
|
6
6
|
type Gauge,
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
type TelemetryClient,
|
|
10
10
|
type Tracer,
|
|
11
11
|
type UpDownCounter,
|
|
12
|
+
createUpDownCounterWithDefault,
|
|
12
13
|
} from '@aztec/telemetry-client';
|
|
13
14
|
|
|
14
15
|
export class PublicProcessorMetrics {
|
|
@@ -29,19 +30,27 @@ export class PublicProcessorMetrics {
|
|
|
29
30
|
|
|
30
31
|
private treeInsertionDuration: Histogram;
|
|
31
32
|
|
|
33
|
+
private silentlySkippedCount: UpDownCounter;
|
|
34
|
+
private silentlySkippedDuration: Histogram;
|
|
35
|
+
|
|
32
36
|
constructor(client: TelemetryClient, name = 'PublicProcessor') {
|
|
33
37
|
this.tracer = client.getTracer(name);
|
|
34
38
|
const meter = client.getMeter(name);
|
|
35
39
|
|
|
36
40
|
this.txDuration = meter.createHistogram(Metrics.PUBLIC_PROCESSOR_TX_DURATION);
|
|
37
41
|
|
|
38
|
-
this.txCount = meter
|
|
42
|
+
this.txCount = createUpDownCounterWithDefault(meter, Metrics.PUBLIC_PROCESSOR_TX_COUNT, {
|
|
43
|
+
[Attributes.OK]: [true, false],
|
|
44
|
+
});
|
|
39
45
|
|
|
40
|
-
this.txPhaseCount = meter
|
|
46
|
+
this.txPhaseCount = createUpDownCounterWithDefault(meter, Metrics.PUBLIC_PROCESSOR_TX_PHASE_COUNT);
|
|
41
47
|
|
|
42
48
|
this.phaseDuration = meter.createHistogram(Metrics.PUBLIC_PROCESSOR_PHASE_DURATION);
|
|
43
49
|
|
|
44
|
-
this.phaseCount = meter
|
|
50
|
+
this.phaseCount = createUpDownCounterWithDefault(meter, Metrics.PUBLIC_PROCESSOR_PHASE_COUNT, {
|
|
51
|
+
[Attributes.TX_PHASE_NAME]: [TxExecutionPhase.SETUP, TxExecutionPhase.APP_LOGIC, TxExecutionPhase.TEARDOWN],
|
|
52
|
+
[Attributes.OK]: [true, false],
|
|
53
|
+
});
|
|
45
54
|
|
|
46
55
|
this.bytecodeDeployed = meter.createHistogram(Metrics.PUBLIC_PROCESSOR_DEPLOY_BYTECODE_SIZE);
|
|
47
56
|
|
|
@@ -54,6 +63,10 @@ export class PublicProcessorMetrics {
|
|
|
54
63
|
this.gasRate = meter.createHistogram(Metrics.PUBLIC_PROCESSOR_GAS_RATE);
|
|
55
64
|
|
|
56
65
|
this.treeInsertionDuration = meter.createHistogram(Metrics.PUBLIC_PROCESSOR_TREE_INSERTION);
|
|
66
|
+
|
|
67
|
+
this.silentlySkippedCount = createUpDownCounterWithDefault(meter, Metrics.PUBLIC_PROCESSOR_SILENTLY_SKIPPED_COUNT);
|
|
68
|
+
|
|
69
|
+
this.silentlySkippedDuration = meter.createHistogram(Metrics.PUBLIC_PROCESSOR_SILENTLY_SKIPPED_DURATION);
|
|
57
70
|
}
|
|
58
71
|
|
|
59
72
|
recordPhaseDuration(phaseName: TxExecutionPhase, durationMs: number) {
|
|
@@ -117,4 +130,9 @@ export class PublicProcessorMetrics {
|
|
|
117
130
|
recordTreeInsertions(durationUs: number) {
|
|
118
131
|
this.treeInsertionDuration.record(Math.ceil(durationUs));
|
|
119
132
|
}
|
|
133
|
+
|
|
134
|
+
recordSilentlySkipped(durationMs: number) {
|
|
135
|
+
this.silentlySkippedCount.add(1);
|
|
136
|
+
this.silentlySkippedDuration.record(Math.ceil(durationMs));
|
|
137
|
+
}
|
|
120
138
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
-
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
2
|
+
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
3
3
|
import type { ContractProvider } from '@aztec/native';
|
|
4
4
|
import { FunctionSelector } from '@aztec/stdlib/abi';
|
|
5
5
|
import { deserializeFromMessagePack, serializeWithMessagePack } from '@aztec/stdlib/avm';
|
|
@@ -10,12 +10,15 @@ import type { GlobalVariables } from '@aztec/stdlib/tx';
|
|
|
10
10
|
import type { PublicContractsDB } from '../public_db_sources.js';
|
|
11
11
|
|
|
12
12
|
export class ContractProviderForCpp implements ContractProvider {
|
|
13
|
-
private log: Logger
|
|
13
|
+
private log: Logger;
|
|
14
14
|
|
|
15
15
|
constructor(
|
|
16
16
|
private contractsDB: PublicContractsDB,
|
|
17
17
|
private globalVariables: GlobalVariables,
|
|
18
|
-
|
|
18
|
+
bindings?: LoggerBindings,
|
|
19
|
+
) {
|
|
20
|
+
this.log = createLogger('simulator:contract_provider_for_cpp', bindings);
|
|
21
|
+
}
|
|
19
22
|
|
|
20
23
|
public getContractInstance = async (address: string): Promise<Buffer | undefined> => {
|
|
21
24
|
this.log.trace(`Contract provider callback: getContractInstance(${address})`);
|
|
@@ -49,6 +52,7 @@ export class ContractProviderForCpp implements ContractProvider {
|
|
|
49
52
|
return serializeWithMessagePack(contractClass);
|
|
50
53
|
};
|
|
51
54
|
|
|
55
|
+
// eslint-disable-next-line require-await
|
|
52
56
|
public addContracts = async (contractDeploymentDataBuffer: Buffer): Promise<void> => {
|
|
53
57
|
this.log.trace(`Contract provider callback: addContracts`);
|
|
54
58
|
|
|
@@ -59,7 +63,7 @@ export class ContractProviderForCpp implements ContractProvider {
|
|
|
59
63
|
|
|
60
64
|
// Add contracts to the contracts DB
|
|
61
65
|
this.log.trace(`Calling contractsDB.addContracts`);
|
|
62
|
-
|
|
66
|
+
this.contractsDB.addContracts(contractDeploymentData);
|
|
63
67
|
};
|
|
64
68
|
|
|
65
69
|
public getBytecodeCommitment = async (classId: string): Promise<Buffer | undefined> => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Logger,
|
|
1
|
+
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
2
2
|
import { sleep } from '@aztec/foundation/sleep';
|
|
3
3
|
import { type CancellationToken, avmSimulate, cancelSimulation, createCancellationToken } from '@aztec/native';
|
|
4
4
|
import { ProtocolContractsList } from '@aztec/protocol-contracts';
|
|
@@ -44,9 +44,10 @@ export class CppPublicTxSimulator extends PublicTxSimulator implements PublicTxS
|
|
|
44
44
|
contractsDB: PublicContractsDB,
|
|
45
45
|
globalVariables: GlobalVariables,
|
|
46
46
|
config?: Partial<PublicSimulatorConfig>,
|
|
47
|
+
bindings?: LoggerBindings,
|
|
47
48
|
) {
|
|
48
|
-
super(merkleTree, contractsDB, globalVariables, config);
|
|
49
|
-
this.log = createLogger(`simulator:cpp_public_tx_simulator
|
|
49
|
+
super(merkleTree, contractsDB, globalVariables, config, undefined, bindings);
|
|
50
|
+
this.log = createLogger(`simulator:cpp_public_tx_simulator`, bindings);
|
|
50
51
|
}
|
|
51
52
|
|
|
52
53
|
/**
|
|
@@ -84,7 +85,7 @@ export class CppPublicTxSimulator extends PublicTxSimulator implements PublicTxS
|
|
|
84
85
|
);
|
|
85
86
|
|
|
86
87
|
// Create contract provider for callbacks to TypeScript PublicContractsDB from C++
|
|
87
|
-
const contractProvider = new ContractProviderForCpp(this.contractsDB, this.globalVariables);
|
|
88
|
+
const contractProvider = new ContractProviderForCpp(this.contractsDB, this.globalVariables, this.bindings);
|
|
88
89
|
|
|
89
90
|
// Serialize to msgpack and call the C++ simulator
|
|
90
91
|
this.log.trace(`Serializing fast simulation inputs to msgpack...`);
|
|
@@ -99,8 +100,7 @@ export class CppPublicTxSimulator extends PublicTxSimulator implements PublicTxS
|
|
|
99
100
|
inputBuffer,
|
|
100
101
|
contractProvider,
|
|
101
102
|
wsCppHandle,
|
|
102
|
-
|
|
103
|
-
// TODO: re-enable logging
|
|
103
|
+
this.log.level,
|
|
104
104
|
undefined,
|
|
105
105
|
this.cancellationToken,
|
|
106
106
|
);
|
|
@@ -171,8 +171,9 @@ export class MeasuredCppPublicTxSimulator extends CppPublicTxSimulator implement
|
|
|
171
171
|
globalVariables: GlobalVariables,
|
|
172
172
|
protected readonly metrics: ExecutorMetricsInterface,
|
|
173
173
|
config?: Partial<PublicSimulatorConfig>,
|
|
174
|
+
bindings?: LoggerBindings,
|
|
174
175
|
) {
|
|
175
|
-
super(merkleTree, contractsDB, globalVariables, config);
|
|
176
|
+
super(merkleTree, contractsDB, globalVariables, config, bindings);
|
|
176
177
|
}
|
|
177
178
|
|
|
178
179
|
public override async simulate(tx: Tx, txLabel: string = 'unlabeledTx'): Promise<PublicTxResult> {
|
|
@@ -200,9 +201,10 @@ export class TelemetryCppPublicTxSimulator extends MeasuredCppPublicTxSimulator
|
|
|
200
201
|
globalVariables: GlobalVariables,
|
|
201
202
|
telemetryClient: TelemetryClient = getTelemetryClient(),
|
|
202
203
|
config?: Partial<PublicSimulatorConfig>,
|
|
204
|
+
bindings?: LoggerBindings,
|
|
203
205
|
) {
|
|
204
206
|
const metrics = new ExecutorMetrics(telemetryClient, 'CppPublicTxSimulator');
|
|
205
|
-
super(merkleTree, contractsDB, globalVariables, metrics, config);
|
|
207
|
+
super(merkleTree, contractsDB, globalVariables, metrics, config, bindings);
|
|
206
208
|
this.tracer = metrics.tracer;
|
|
207
209
|
}
|
|
208
210
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Logger,
|
|
1
|
+
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
2
2
|
import { avmSimulateWithHintedDbs } from '@aztec/native';
|
|
3
3
|
import {
|
|
4
4
|
AvmCircuitInputs,
|
|
@@ -34,9 +34,10 @@ export class CppPublicTxSimulatorHintedDbs extends PublicTxSimulator implements
|
|
|
34
34
|
contractsDB: PublicContractsDB,
|
|
35
35
|
globalVariables: GlobalVariables,
|
|
36
36
|
config?: Partial<PublicSimulatorConfig>,
|
|
37
|
+
bindings?: LoggerBindings,
|
|
37
38
|
) {
|
|
38
|
-
super(merkleTree, contractsDB, globalVariables, config);
|
|
39
|
-
this.log = createLogger(`simulator:cpp_public_tx_simulator_hinted_dbs
|
|
39
|
+
super(merkleTree, contractsDB, globalVariables, config, undefined, bindings);
|
|
40
|
+
this.log = createLogger(`simulator:cpp_public_tx_simulator_hinted_dbs`, bindings);
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
/**
|
|
@@ -74,7 +75,7 @@ export class CppPublicTxSimulatorHintedDbs extends PublicTxSimulator implements
|
|
|
74
75
|
|
|
75
76
|
let resultBuffer: Buffer;
|
|
76
77
|
try {
|
|
77
|
-
resultBuffer = await avmSimulateWithHintedDbs(inputBuffer,
|
|
78
|
+
resultBuffer = await avmSimulateWithHintedDbs(inputBuffer, this.log.level);
|
|
78
79
|
} catch (error: any) {
|
|
79
80
|
throw new SimulationError(`C++ hinted simulation failed: ${error.message}`, []);
|
|
80
81
|
}
|
|
@@ -115,8 +116,9 @@ export class MeasuredCppPublicTxSimulatorHintedDbs
|
|
|
115
116
|
globalVariables: GlobalVariables,
|
|
116
117
|
protected readonly metrics: ExecutorMetricsInterface,
|
|
117
118
|
config?: Partial<PublicSimulatorConfig>,
|
|
119
|
+
bindings?: LoggerBindings,
|
|
118
120
|
) {
|
|
119
|
-
super(merkleTree, contractsDB, globalVariables, config);
|
|
121
|
+
super(merkleTree, contractsDB, globalVariables, config, bindings);
|
|
120
122
|
}
|
|
121
123
|
|
|
122
124
|
public override async simulate(tx: Tx, txLabel: string = 'unlabeledTx'): Promise<PublicTxResult> {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Logger, createLogger, logLevel } from '@aztec/foundation/log';
|
|
1
|
+
import { type Logger, type LoggerBindings, createLogger, logLevel } from '@aztec/foundation/log';
|
|
2
2
|
import { avmSimulate } from '@aztec/native';
|
|
3
3
|
import { ProtocolContractsList } from '@aztec/protocol-contracts';
|
|
4
4
|
import {
|
|
@@ -37,9 +37,10 @@ export class CppVsTsPublicTxSimulator extends PublicTxSimulator implements Publi
|
|
|
37
37
|
contractsDB: PublicContractsDB,
|
|
38
38
|
globalVariables: GlobalVariables,
|
|
39
39
|
config?: Partial<PublicSimulatorConfig>,
|
|
40
|
+
bindings?: LoggerBindings,
|
|
40
41
|
) {
|
|
41
|
-
super(merkleTree, contractsDB, globalVariables, config);
|
|
42
|
-
this.log = createLogger(`simulator:cpp_vs_public_tx_simulator
|
|
42
|
+
super(merkleTree, contractsDB, globalVariables, config, undefined, bindings);
|
|
43
|
+
this.log = createLogger(`simulator:cpp_vs_public_tx_simulator`, bindings);
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
/**
|
|
@@ -103,7 +104,7 @@ export class CppVsTsPublicTxSimulator extends PublicTxSimulator implements Publi
|
|
|
103
104
|
);
|
|
104
105
|
|
|
105
106
|
// Create contract provider for callbacks to TypeScript PublicContractsDB from C++
|
|
106
|
-
const contractProvider = new ContractProviderForCpp(this.contractsDB, this.globalVariables);
|
|
107
|
+
const contractProvider = new ContractProviderForCpp(this.contractsDB, this.globalVariables, this.bindings);
|
|
107
108
|
|
|
108
109
|
// Serialize to msgpack and call the C++ simulator
|
|
109
110
|
this.log.debug(`Serializing fast simulation inputs to msgpack...`);
|
|
@@ -220,8 +221,9 @@ export class MeasuredCppVsTsPublicTxSimulator
|
|
|
220
221
|
globalVariables: GlobalVariables,
|
|
221
222
|
protected readonly metrics: ExecutorMetricsInterface,
|
|
222
223
|
config?: Partial<PublicSimulatorConfig>,
|
|
224
|
+
bindings?: LoggerBindings,
|
|
223
225
|
) {
|
|
224
|
-
super(merkleTree, contractsDB, globalVariables, config);
|
|
226
|
+
super(merkleTree, contractsDB, globalVariables, config, bindings);
|
|
225
227
|
}
|
|
226
228
|
|
|
227
229
|
public override async simulate(tx: Tx, txLabel: string = 'unlabeledTx'): Promise<PublicTxResult> {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { LoggerBindings } from '@aztec/foundation/log';
|
|
1
2
|
import {
|
|
2
3
|
AvmCircuitInputs,
|
|
3
4
|
AvmCircuitPublicInputs,
|
|
@@ -29,8 +30,9 @@ export class DumpingCppPublicTxSimulator extends CppPublicTxSimulator {
|
|
|
29
30
|
globalVariables: GlobalVariables,
|
|
30
31
|
config: Partial<PublicSimulatorConfig>,
|
|
31
32
|
outputDir: string,
|
|
33
|
+
bindings?: LoggerBindings,
|
|
32
34
|
) {
|
|
33
|
-
super(merkleTree, contractsDB, globalVariables, config);
|
|
35
|
+
super(merkleTree, contractsDB, globalVariables, config, bindings);
|
|
34
36
|
assert(config.collectHints === true, 'collectHints must be enabled to dump AVM circuit inputs');
|
|
35
37
|
assert(config.collectPublicInputs === true, 'collectPublicInputs must be enabled to dump AVM circuit inputs');
|
|
36
38
|
this.outputDir = outputDir;
|