@aztec/simulator 0.0.1-commit.1bea0213 → 0.0.1-commit.217f559981
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 +5 -3
- 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_gas.js +3 -3
- 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/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 +11 -16
- 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/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/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/utils.js +4 -4
- package/dest/public/hinting_db_sources.d.ts +2 -2
- package/dest/public/hinting_db_sources.d.ts.map +1 -1
- package/dest/public/hinting_db_sources.js +1 -1
- package/dest/public/public_db_sources.d.ts +4 -3
- package/dest/public/public_db_sources.d.ts.map +1 -1
- package/dest/public/public_db_sources.js +4 -4
- package/dest/public/public_processor/guarded_merkle_tree.d.ts +2 -2
- package/dest/public/public_processor/guarded_merkle_tree.d.ts.map +1 -1
- package/dest/public/public_processor/guarded_merkle_tree.js +1 -1
- package/dest/public/public_processor/public_processor.d.ts +7 -4
- package/dest/public/public_processor/public_processor.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor.js +20 -11
- package/dest/public/public_processor/public_processor_metrics.d.ts +2 -2
- package/dest/public/public_processor/public_processor_metrics.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor_metrics.js +20 -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 +2 -2
- 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 +8 -8
- 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 +5 -5
- 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 +3 -3
- package/dest/public/public_tx_simulator/public_tx_context.d.ts +4 -3
- package/dest/public/public_tx_simulator/public_tx_context.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_context.js +8 -8
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts +4 -3
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_simulator.js +5 -3
- 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 +3 -2
- package/dest/public/test_executor_metrics.d.ts.map +1 -1
- package/dest/public/test_executor_metrics.js +2 -2
- package/package.json +16 -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 +5 -3
- 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_gas.ts +2 -2
- 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/opcodes/accrued_substate.ts +10 -19
- package/src/public/avm/serialization/bytecode_serialization.ts +2 -2
- package/src/public/avm/serialization/instruction_serialization.ts +1 -1
- package/src/public/executor_metrics.ts +4 -1
- package/src/public/fixtures/amm_test.ts +2 -2
- package/src/public/fixtures/opcode_spammer.ts +18 -55
- package/src/public/fixtures/utils.ts +4 -4
- package/src/public/fuzzing/avm_fuzzer_simulator.ts +1 -1
- package/src/public/hinting_db_sources.ts +1 -1
- package/src/public/public_db_sources.ts +15 -5
- package/src/public/public_processor/guarded_merkle_tree.ts +1 -1
- package/src/public/public_processor/public_processor.ts +39 -20
- package/src/public/public_processor/public_processor_metrics.ts +10 -4
- package/src/public/public_tx_simulator/contract_provider_for_cpp.ts +6 -3
- package/src/public/public_tx_simulator/cpp_public_tx_simulator.ts +9 -6
- package/src/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.ts +6 -4
- 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 +4 -2
- package/src/public/public_tx_simulator/public_tx_context.ts +13 -6
- package/src/public/public_tx_simulator/public_tx_simulator.ts +6 -2
- 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 +3 -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 } 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,7 +138,7 @@ 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'> = {},
|
|
130
143
|
) {
|
|
131
144
|
this.metrics = new PublicProcessorMetrics(telemetryClient, 'PublicProcessor');
|
|
@@ -146,12 +159,13 @@ export class PublicProcessor implements Traceable {
|
|
|
146
159
|
txs: Iterable<Tx> | AsyncIterable<Tx>,
|
|
147
160
|
limits: PublicProcessorLimits = {},
|
|
148
161
|
validator: PublicProcessorValidator = {},
|
|
149
|
-
): Promise<[ProcessedTx[], FailedTx[], Tx[], NestedProcessReturnValues[], number]> {
|
|
162
|
+
): Promise<[ProcessedTx[], FailedTx[], Tx[], NestedProcessReturnValues[], number, DebugLog[]]> {
|
|
150
163
|
const { maxTransactions, maxBlockSize, deadline, maxBlockGas, maxBlobFields } = limits;
|
|
151
164
|
const { preprocessValidator, nullifierCache } = validator;
|
|
152
165
|
const result: ProcessedTx[] = [];
|
|
153
166
|
const usedTxs: Tx[] = [];
|
|
154
167
|
const failed: FailedTx[] = [];
|
|
168
|
+
const debugLogs: DebugLog[] = [];
|
|
155
169
|
const timer = new Timer();
|
|
156
170
|
|
|
157
171
|
let totalSizeInBytes = 0;
|
|
@@ -228,7 +242,7 @@ export class PublicProcessor implements Traceable {
|
|
|
228
242
|
this.contractsDB.createCheckpoint();
|
|
229
243
|
|
|
230
244
|
try {
|
|
231
|
-
const [processedTx, returnValues] = await this.processTx(tx, deadline);
|
|
245
|
+
const [processedTx, returnValues, txDebugLogs] = await this.processTx(tx, deadline);
|
|
232
246
|
|
|
233
247
|
// Inject a fake processing failure after N txs if requested
|
|
234
248
|
const fakeThrowAfter = this.opts.fakeThrowAfterProcessingTxCount;
|
|
@@ -277,6 +291,7 @@ export class PublicProcessor implements Traceable {
|
|
|
277
291
|
result.push(processedTx);
|
|
278
292
|
usedTxs.push(tx);
|
|
279
293
|
returns = returns.concat(returnValues);
|
|
294
|
+
debugLogs.push(...txDebugLogs);
|
|
280
295
|
|
|
281
296
|
totalPublicGas = totalPublicGas.add(processedTx.gasUsed.publicGas);
|
|
282
297
|
totalBlockGas = totalBlockGas.add(processedTx.gasUsed.totalGas);
|
|
@@ -350,7 +365,7 @@ export class PublicProcessor implements Traceable {
|
|
|
350
365
|
totalSizeInBytes,
|
|
351
366
|
});
|
|
352
367
|
|
|
353
|
-
return [result, failed, usedTxs, returns, totalBlobFields];
|
|
368
|
+
return [result, failed, usedTxs, returns, totalBlobFields, debugLogs];
|
|
354
369
|
}
|
|
355
370
|
|
|
356
371
|
private async checkWorldStateUnchanged(
|
|
@@ -370,8 +385,13 @@ export class PublicProcessor implements Traceable {
|
|
|
370
385
|
}
|
|
371
386
|
|
|
372
387
|
@trackSpan('PublicProcessor.processTx', tx => ({ [Attributes.TX_HASH]: tx.getTxHash().toString() }))
|
|
373
|
-
private async processTx(
|
|
374
|
-
|
|
388
|
+
private async processTx(
|
|
389
|
+
tx: Tx,
|
|
390
|
+
deadline: Date | undefined,
|
|
391
|
+
): Promise<[ProcessedTx, NestedProcessReturnValues[], DebugLog[]]> {
|
|
392
|
+
const [time, [processedTx, returnValues, debugLogs]] = await elapsed(() =>
|
|
393
|
+
this.processTxWithinDeadline(tx, deadline),
|
|
394
|
+
);
|
|
375
395
|
|
|
376
396
|
this.log.verbose(
|
|
377
397
|
!tx.hasPublicCalls()
|
|
@@ -394,7 +414,7 @@ export class PublicProcessor implements Traceable {
|
|
|
394
414
|
},
|
|
395
415
|
);
|
|
396
416
|
|
|
397
|
-
return [processedTx, returnValues ?? []];
|
|
417
|
+
return [processedTx, returnValues ?? [], debugLogs];
|
|
398
418
|
}
|
|
399
419
|
|
|
400
420
|
private async doTreeInsertionsForPrivateOnlyTx(processedTx: ProcessedTx): Promise<void> {
|
|
@@ -428,10 +448,9 @@ export class PublicProcessor implements Traceable {
|
|
|
428
448
|
private async processTxWithinDeadline(
|
|
429
449
|
tx: Tx,
|
|
430
450
|
deadline: Date | undefined,
|
|
431
|
-
): Promise<[ProcessedTx, NestedProcessReturnValues[] | undefined]> {
|
|
432
|
-
const innerProcessFn: () => Promise<[ProcessedTx, NestedProcessReturnValues[] | undefined]> =
|
|
433
|
-
? () => this.processTxWithPublicCalls(tx)
|
|
434
|
-
: () => this.processPrivateOnlyTx(tx);
|
|
451
|
+
): Promise<[ProcessedTx, NestedProcessReturnValues[] | undefined, DebugLog[]]> {
|
|
452
|
+
const innerProcessFn: () => Promise<[ProcessedTx, NestedProcessReturnValues[] | undefined, DebugLog[]]> =
|
|
453
|
+
tx.hasPublicCalls() ? () => this.processTxWithPublicCalls(tx) : () => this.processPrivateOnlyTx(tx);
|
|
435
454
|
|
|
436
455
|
// Fake a delay per tx if instructed (used for tests)
|
|
437
456
|
const fakeDelayPerTxMs = this.opts.fakeProcessingDelayPerTxMs;
|
|
@@ -499,7 +518,7 @@ export class PublicProcessor implements Traceable {
|
|
|
499
518
|
@trackSpan('PublicProcessor.processPrivateOnlyTx', (tx: Tx) => ({
|
|
500
519
|
[Attributes.TX_HASH]: tx.getTxHash().toString(),
|
|
501
520
|
}))
|
|
502
|
-
private async processPrivateOnlyTx(tx: Tx): Promise<[ProcessedTx, undefined]> {
|
|
521
|
+
private async processPrivateOnlyTx(tx: Tx): Promise<[ProcessedTx, undefined, DebugLog[]]> {
|
|
503
522
|
const gasFees = this.globalVariables.gasFees;
|
|
504
523
|
const transactionFee = computeTransactionFee(gasFees, tx.data.constants.txContext.gasSettings, tx.data.gasUsed);
|
|
505
524
|
|
|
@@ -524,13 +543,13 @@ export class PublicProcessor implements Traceable {
|
|
|
524
543
|
|
|
525
544
|
await this.contractsDB.addNewContracts(tx);
|
|
526
545
|
|
|
527
|
-
return [processedTx, undefined];
|
|
546
|
+
return [processedTx, undefined, []];
|
|
528
547
|
}
|
|
529
548
|
|
|
530
549
|
@trackSpan('PublicProcessor.processTxWithPublicCalls', tx => ({
|
|
531
550
|
[Attributes.TX_HASH]: tx.getTxHash().toString(),
|
|
532
551
|
}))
|
|
533
|
-
private async processTxWithPublicCalls(tx: Tx): Promise<[ProcessedTx, NestedProcessReturnValues[]]> {
|
|
552
|
+
private async processTxWithPublicCalls(tx: Tx): Promise<[ProcessedTx, NestedProcessReturnValues[], DebugLog[]]> {
|
|
534
553
|
const timer = new Timer();
|
|
535
554
|
|
|
536
555
|
const result = await this.publicTxSimulator.simulate(tx);
|
|
@@ -568,7 +587,7 @@ export class PublicProcessor implements Traceable {
|
|
|
568
587
|
revertReason,
|
|
569
588
|
);
|
|
570
589
|
|
|
571
|
-
return [processedTx, appLogicReturnValues];
|
|
590
|
+
return [processedTx, appLogicReturnValues, result.logs ?? []];
|
|
572
591
|
}
|
|
573
592
|
|
|
574
593
|
/**
|
|
@@ -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 {
|
|
@@ -35,13 +36,18 @@ export class PublicProcessorMetrics {
|
|
|
35
36
|
|
|
36
37
|
this.txDuration = meter.createHistogram(Metrics.PUBLIC_PROCESSOR_TX_DURATION);
|
|
37
38
|
|
|
38
|
-
this.txCount = meter
|
|
39
|
+
this.txCount = createUpDownCounterWithDefault(meter, Metrics.PUBLIC_PROCESSOR_TX_COUNT, {
|
|
40
|
+
[Attributes.OK]: [true, false],
|
|
41
|
+
});
|
|
39
42
|
|
|
40
|
-
this.txPhaseCount = meter
|
|
43
|
+
this.txPhaseCount = createUpDownCounterWithDefault(meter, Metrics.PUBLIC_PROCESSOR_TX_PHASE_COUNT);
|
|
41
44
|
|
|
42
45
|
this.phaseDuration = meter.createHistogram(Metrics.PUBLIC_PROCESSOR_PHASE_DURATION);
|
|
43
46
|
|
|
44
|
-
this.phaseCount = meter
|
|
47
|
+
this.phaseCount = createUpDownCounterWithDefault(meter, Metrics.PUBLIC_PROCESSOR_PHASE_COUNT, {
|
|
48
|
+
[Attributes.TX_PHASE_NAME]: [TxExecutionPhase.SETUP, TxExecutionPhase.APP_LOGIC, TxExecutionPhase.TEARDOWN],
|
|
49
|
+
[Attributes.OK]: [true, false],
|
|
50
|
+
});
|
|
45
51
|
|
|
46
52
|
this.bytecodeDeployed = meter.createHistogram(Metrics.PUBLIC_PROCESSOR_DEPLOY_BYTECODE_SIZE);
|
|
47
53
|
|
|
@@ -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})`);
|
|
@@ -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 { 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...`);
|
|
@@ -171,8 +172,9 @@ export class MeasuredCppPublicTxSimulator extends CppPublicTxSimulator implement
|
|
|
171
172
|
globalVariables: GlobalVariables,
|
|
172
173
|
protected readonly metrics: ExecutorMetricsInterface,
|
|
173
174
|
config?: Partial<PublicSimulatorConfig>,
|
|
175
|
+
bindings?: LoggerBindings,
|
|
174
176
|
) {
|
|
175
|
-
super(merkleTree, contractsDB, globalVariables, config);
|
|
177
|
+
super(merkleTree, contractsDB, globalVariables, config, bindings);
|
|
176
178
|
}
|
|
177
179
|
|
|
178
180
|
public override async simulate(tx: Tx, txLabel: string = 'unlabeledTx'): Promise<PublicTxResult> {
|
|
@@ -200,9 +202,10 @@ export class TelemetryCppPublicTxSimulator extends MeasuredCppPublicTxSimulator
|
|
|
200
202
|
globalVariables: GlobalVariables,
|
|
201
203
|
telemetryClient: TelemetryClient = getTelemetryClient(),
|
|
202
204
|
config?: Partial<PublicSimulatorConfig>,
|
|
205
|
+
bindings?: LoggerBindings,
|
|
203
206
|
) {
|
|
204
207
|
const metrics = new ExecutorMetrics(telemetryClient, 'CppPublicTxSimulator');
|
|
205
|
-
super(merkleTree, contractsDB, globalVariables, metrics, config);
|
|
208
|
+
super(merkleTree, contractsDB, globalVariables, metrics, config, bindings);
|
|
206
209
|
this.tracer = metrics.tracer;
|
|
207
210
|
}
|
|
208
211
|
}
|
|
@@ -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 { 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
|
/**
|
|
@@ -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;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { LoggerBindings } from '@aztec/foundation/log';
|
|
1
2
|
import { PublicSimulatorConfig } from '@aztec/stdlib/avm';
|
|
2
3
|
import type { MerkleTreeWriteOperations } from '@aztec/stdlib/trees';
|
|
3
4
|
import type { GlobalVariables } from '@aztec/stdlib/tx';
|
|
@@ -17,6 +18,7 @@ export function createPublicTxSimulatorForBlockBuilding(
|
|
|
17
18
|
contractsDB: PublicContractsDB,
|
|
18
19
|
globalVariables: GlobalVariables,
|
|
19
20
|
telemetryClient: TelemetryClient,
|
|
21
|
+
bindings?: LoggerBindings,
|
|
20
22
|
) {
|
|
21
23
|
const config = PublicSimulatorConfig.from({
|
|
22
24
|
skipFeeEnforcement: false,
|
|
@@ -35,7 +37,7 @@ export function createPublicTxSimulatorForBlockBuilding(
|
|
|
35
37
|
collectHints: true,
|
|
36
38
|
collectPublicInputs: true,
|
|
37
39
|
};
|
|
38
|
-
return new DumpingCppPublicTxSimulator(merkleTree, contractsDB, globalVariables, dumpingConfig, dumpDir);
|
|
40
|
+
return new DumpingCppPublicTxSimulator(merkleTree, contractsDB, globalVariables, dumpingConfig, dumpDir, bindings);
|
|
39
41
|
}
|
|
40
|
-
return new TelemetryCppPublicTxSimulator(merkleTree, contractsDB, globalVariables, telemetryClient, config);
|
|
42
|
+
return new TelemetryCppPublicTxSimulator(merkleTree, contractsDB, globalVariables, telemetryClient, config, bindings);
|
|
41
43
|
}
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from '@aztec/constants';
|
|
8
8
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
9
9
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
10
|
-
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
10
|
+
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
11
11
|
import {
|
|
12
12
|
AvmAccumulatedData,
|
|
13
13
|
AvmAccumulatedDataArrayLengths,
|
|
@@ -87,8 +87,9 @@ export class PublicTxContext {
|
|
|
87
87
|
public readonly revertibleAccumulatedDataFromPrivate: PrivateToPublicAccumulatedData,
|
|
88
88
|
public readonly feePayer: AztecAddress,
|
|
89
89
|
private readonly trace: SideEffectTrace,
|
|
90
|
+
bindings?: LoggerBindings,
|
|
90
91
|
) {
|
|
91
|
-
this.log = createLogger(`simulator:public_tx_context
|
|
92
|
+
this.log = createLogger(`simulator:public_tx_context`, bindings);
|
|
92
93
|
}
|
|
93
94
|
|
|
94
95
|
public static async create(
|
|
@@ -98,13 +99,14 @@ export class PublicTxContext {
|
|
|
98
99
|
globalVariables: GlobalVariables,
|
|
99
100
|
protocolContracts: ProtocolContracts,
|
|
100
101
|
proverId: Fr,
|
|
102
|
+
bindings?: LoggerBindings,
|
|
101
103
|
) {
|
|
102
104
|
const contractDeploymentData = AllContractDeploymentData.fromTx(tx);
|
|
103
105
|
const nonRevertibleContractDeploymentData = contractDeploymentData.getNonRevertibleContractDeploymentData();
|
|
104
106
|
const revertibleContractDeploymentData = contractDeploymentData.getRevertibleContractDeploymentData();
|
|
105
107
|
const nonRevertibleAccumulatedDataFromPrivate = tx.data.forPublic!.nonRevertibleAccumulatedData;
|
|
106
108
|
|
|
107
|
-
const trace = new SideEffectTrace();
|
|
109
|
+
const trace = new SideEffectTrace(0, bindings);
|
|
108
110
|
|
|
109
111
|
const firstNullifier = nonRevertibleAccumulatedDataFromPrivate.nullifiers[0];
|
|
110
112
|
|
|
@@ -115,6 +117,7 @@ export class PublicTxContext {
|
|
|
115
117
|
trace,
|
|
116
118
|
firstNullifier,
|
|
117
119
|
globalVariables.timestamp,
|
|
120
|
+
bindings,
|
|
118
121
|
);
|
|
119
122
|
|
|
120
123
|
const gasSettings = tx.data.constants.txContext.gasSettings;
|
|
@@ -124,7 +127,7 @@ export class PublicTxContext {
|
|
|
124
127
|
|
|
125
128
|
return new PublicTxContext(
|
|
126
129
|
tx.getTxHash(),
|
|
127
|
-
new PhaseStateManager(txStateManager),
|
|
130
|
+
new PhaseStateManager(txStateManager, bindings),
|
|
128
131
|
await txStateManager.getTreeSnapshots(),
|
|
129
132
|
globalVariables,
|
|
130
133
|
protocolContracts,
|
|
@@ -142,6 +145,7 @@ export class PublicTxContext {
|
|
|
142
145
|
tx.data.forPublic!.revertibleAccumulatedData,
|
|
143
146
|
tx.data.feePayer,
|
|
144
147
|
trace,
|
|
148
|
+
bindings,
|
|
145
149
|
);
|
|
146
150
|
}
|
|
147
151
|
|
|
@@ -441,8 +445,11 @@ class PhaseStateManager {
|
|
|
441
445
|
|
|
442
446
|
private currentlyActiveStateManager: PublicPersistableStateManager | undefined;
|
|
443
447
|
|
|
444
|
-
constructor(
|
|
445
|
-
|
|
448
|
+
constructor(
|
|
449
|
+
private readonly txStateManager: PublicPersistableStateManager,
|
|
450
|
+
bindings?: LoggerBindings,
|
|
451
|
+
) {
|
|
452
|
+
this.log = createLogger(`simulator:public_phase_state_manager`, bindings);
|
|
446
453
|
}
|
|
447
454
|
|
|
448
455
|
async fork() {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AVM_MAX_PROCESSABLE_L2_GAS } from '@aztec/constants';
|
|
2
2
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
-
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
3
|
+
import { type Logger, type LoggerBindings, 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
6
|
import { AvmExecutionHints, AvmTxHint, PublicSimulatorConfig, PublicTxEffect, PublicTxResult } from '@aztec/stdlib/avm';
|
|
@@ -81,6 +81,7 @@ type ProcessedPhase = {
|
|
|
81
81
|
export class PublicTxSimulator implements PublicTxSimulatorInterface {
|
|
82
82
|
protected log: Logger;
|
|
83
83
|
protected readonly config: PublicSimulatorConfig;
|
|
84
|
+
protected readonly bindings?: LoggerBindings;
|
|
84
85
|
|
|
85
86
|
constructor(
|
|
86
87
|
protected merkleTree: MerkleTreeWriteOperations,
|
|
@@ -88,9 +89,11 @@ export class PublicTxSimulator implements PublicTxSimulatorInterface {
|
|
|
88
89
|
protected globalVariables: GlobalVariables,
|
|
89
90
|
config?: Partial<PublicSimulatorConfig>,
|
|
90
91
|
protected protocolContracts: ProtocolContracts = ProtocolContractsList,
|
|
92
|
+
bindings?: LoggerBindings,
|
|
91
93
|
) {
|
|
92
94
|
this.config = PublicSimulatorConfig.from(config ?? {});
|
|
93
|
-
this.
|
|
95
|
+
this.bindings = bindings;
|
|
96
|
+
this.log = createLogger(`simulator:public_tx_simulator`, bindings);
|
|
94
97
|
}
|
|
95
98
|
|
|
96
99
|
/**
|
|
@@ -119,6 +122,7 @@ export class PublicTxSimulator implements PublicTxSimulatorInterface {
|
|
|
119
122
|
this.globalVariables,
|
|
120
123
|
this.protocolContracts,
|
|
121
124
|
this.config.proverId,
|
|
125
|
+
this.bindings,
|
|
122
126
|
);
|
|
123
127
|
|
|
124
128
|
// This will throw if there is a nullifier collision.
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
} from '@aztec/constants';
|
|
10
10
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
11
11
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
12
|
-
import { type LogLevel, createLogger } from '@aztec/foundation/log';
|
|
12
|
+
import { type LogLevel, type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
13
13
|
import { PublicDataUpdateRequest } from '@aztec/stdlib/avm';
|
|
14
14
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
15
15
|
import { computePublicDataTreeLeafSlot } from '@aztec/stdlib/hash';
|
|
@@ -61,7 +61,7 @@ export class SideEffectArrayLengths {
|
|
|
61
61
|
* Trace side effects for an enqueued public call's execution.
|
|
62
62
|
*/
|
|
63
63
|
export class SideEffectTrace implements PublicSideEffectTraceInterface {
|
|
64
|
-
public log
|
|
64
|
+
public log: Logger;
|
|
65
65
|
|
|
66
66
|
/** The side effect counter increments with every call to the trace. */
|
|
67
67
|
private sideEffectCounter: number;
|
|
@@ -79,6 +79,7 @@ export class SideEffectTrace implements PublicSideEffectTraceInterface {
|
|
|
79
79
|
constructor(
|
|
80
80
|
/** The counter of this trace's first side effect. */
|
|
81
81
|
public readonly startSideEffectCounter: number = 0,
|
|
82
|
+
bindings?: LoggerBindings,
|
|
82
83
|
/** Track parent's (or previous kernel's) lengths so the AVM can properly enforce TX-wide limits,
|
|
83
84
|
* otherwise the public kernel can fail to prove because TX limits are breached.
|
|
84
85
|
*/
|
|
@@ -90,11 +91,13 @@ export class SideEffectTrace implements PublicSideEffectTraceInterface {
|
|
|
90
91
|
private debugLogMemoryReads: number = 0,
|
|
91
92
|
) {
|
|
92
93
|
this.sideEffectCounter = startSideEffectCounter;
|
|
94
|
+
this.log = createLogger('simulator:side_effect_trace', bindings);
|
|
93
95
|
}
|
|
94
96
|
|
|
95
97
|
public fork() {
|
|
96
98
|
return new SideEffectTrace(
|
|
97
99
|
this.sideEffectCounter,
|
|
100
|
+
this.log.getBindings(),
|
|
98
101
|
new SideEffectArrayLengths(
|
|
99
102
|
this.previousSideEffectArrayLengths.publicDataWrites + this.userPublicDataWritesLength,
|
|
100
103
|
this.previousSideEffectArrayLengths.protocolPublicDataWrites + this.protocolPublicDataWritesLength,
|
|
@@ -2,7 +2,7 @@ import { CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS, MAX_PROTOCOL_CONTRACTS } f
|
|
|
2
2
|
import { poseidon2Hash } from '@aztec/foundation/crypto/poseidon';
|
|
3
3
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
4
|
import { jsonStringify } from '@aztec/foundation/json-rpc';
|
|
5
|
-
import { type LogLevel, createLogger } from '@aztec/foundation/log';
|
|
5
|
+
import { type LogLevel, type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
6
6
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
7
7
|
import { FunctionSelector } from '@aztec/stdlib/abi';
|
|
8
8
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
@@ -42,7 +42,7 @@ import { PublicStorage } from './public_storage.js';
|
|
|
42
42
|
* Manages merging of successful/reverted child state into current state.
|
|
43
43
|
*/
|
|
44
44
|
export class PublicPersistableStateManager {
|
|
45
|
-
private readonly log
|
|
45
|
+
private readonly log: Logger;
|
|
46
46
|
|
|
47
47
|
/** Make sure a forked state is never merged twice. */
|
|
48
48
|
private alreadyMergedIntoParent = false;
|
|
@@ -56,7 +56,10 @@ export class PublicPersistableStateManager {
|
|
|
56
56
|
private readonly doMerkleOperations: boolean = true,
|
|
57
57
|
private readonly publicStorage: PublicStorage = new PublicStorage(treesDB),
|
|
58
58
|
private readonly nullifiers: NullifierManager = new NullifierManager(treesDB),
|
|
59
|
-
|
|
59
|
+
bindings?: LoggerBindings,
|
|
60
|
+
) {
|
|
61
|
+
this.log = createLogger('simulator:state_manager', bindings);
|
|
62
|
+
}
|
|
60
63
|
|
|
61
64
|
/**
|
|
62
65
|
* Create a new state manager
|
|
@@ -67,8 +70,19 @@ export class PublicPersistableStateManager {
|
|
|
67
70
|
trace: PublicSideEffectTraceInterface,
|
|
68
71
|
firstNullifier: Fr,
|
|
69
72
|
timestamp: UInt64,
|
|
73
|
+
bindings?: LoggerBindings,
|
|
70
74
|
): PublicPersistableStateManager {
|
|
71
|
-
return new PublicPersistableStateManager(
|
|
75
|
+
return new PublicPersistableStateManager(
|
|
76
|
+
treesDB,
|
|
77
|
+
contractsDB,
|
|
78
|
+
trace,
|
|
79
|
+
firstNullifier,
|
|
80
|
+
timestamp,
|
|
81
|
+
undefined,
|
|
82
|
+
undefined,
|
|
83
|
+
undefined,
|
|
84
|
+
bindings,
|
|
85
|
+
);
|
|
72
86
|
}
|
|
73
87
|
|
|
74
88
|
/**
|
|
@@ -85,6 +99,7 @@ export class PublicPersistableStateManager {
|
|
|
85
99
|
this.doMerkleOperations,
|
|
86
100
|
this.publicStorage.fork(),
|
|
87
101
|
this.nullifiers.fork(),
|
|
102
|
+
this.log.getBindings(),
|
|
88
103
|
);
|
|
89
104
|
}
|
|
90
105
|
|
|
@@ -233,7 +248,15 @@ export class PublicPersistableStateManager {
|
|
|
233
248
|
public async checkNullifierExists(contractAddress: AztecAddress, nullifier: Fr): Promise<boolean> {
|
|
234
249
|
this.log.trace(`Checking existence of nullifier (address=${contractAddress}, nullifier=${nullifier})`);
|
|
235
250
|
const siloedNullifier = await siloNullifier(contractAddress, nullifier);
|
|
251
|
+
return this.checkSiloedNullifierExists(siloedNullifier);
|
|
252
|
+
}
|
|
236
253
|
|
|
254
|
+
/**
|
|
255
|
+
* Check if a siloed nullifier exists.
|
|
256
|
+
* @param siloedNullifier - the siloed nullifier to check
|
|
257
|
+
* @returns exists - whether the nullifier exists in the nullifier set
|
|
258
|
+
*/
|
|
259
|
+
public async checkSiloedNullifierExists(siloedNullifier: Fr): Promise<boolean> {
|
|
237
260
|
if (this.doMerkleOperations) {
|
|
238
261
|
const exists = await this.treesDB.checkNullifierExists(siloedNullifier);
|
|
239
262
|
this.log.trace(`Checked siloed nullifier ${siloedNullifier} (exists=${exists})`);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { sum } from '@aztec/foundation/collection';
|
|
2
|
-
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
2
|
+
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
3
3
|
import { Timer } from '@aztec/foundation/timer';
|
|
4
4
|
import type { RevertCode } from '@aztec/stdlib/avm';
|
|
5
5
|
import type { GasUsed } from '@aztec/stdlib/gas';
|
|
@@ -88,8 +88,8 @@ export class TestExecutorMetrics implements ExecutorMetricsInterface {
|
|
|
88
88
|
private currentTxLabel: string | undefined;
|
|
89
89
|
private txTimer: Timer | undefined;
|
|
90
90
|
|
|
91
|
-
constructor() {
|
|
92
|
-
this.logger = createLogger(`simulator:test_executor_metrics
|
|
91
|
+
constructor(bindings?: LoggerBindings) {
|
|
92
|
+
this.logger = createLogger(`simulator:test_executor_metrics`, bindings);
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
startRecordingTxSimulation(txLabel: string) {
|