@aztec/simulator 0.86.0-starknet.1 → 0.87.0-nightly.20250521
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/common/errors.d.ts.map +1 -1
- package/dest/private/acvm/acvm.d.ts +0 -2
- package/dest/private/acvm/acvm.d.ts.map +1 -1
- package/dest/private/acvm/acvm.js +1 -1
- package/dest/private/acvm/deserialize.d.ts +0 -2
- package/dest/private/acvm/deserialize.d.ts.map +1 -1
- package/dest/private/acvm/oracle/oracle.d.ts +2 -2
- package/dest/private/acvm/oracle/oracle.d.ts.map +1 -1
- package/dest/private/acvm/oracle/oracle.js +30 -33
- package/dest/private/acvm/oracle/typed_oracle.d.ts +1 -3
- package/dest/private/acvm/oracle/typed_oracle.d.ts.map +1 -1
- package/dest/private/acvm/serialize.d.ts +8 -2
- package/dest/private/acvm/serialize.d.ts.map +1 -1
- package/dest/private/acvm/serialize.js +26 -0
- package/dest/private/index.d.ts +3 -0
- package/dest/private/index.d.ts.map +1 -1
- package/dest/private/index.js +3 -0
- package/dest/private/providers/acvm_native.d.ts +0 -2
- package/dest/private/providers/acvm_native.d.ts.map +1 -1
- package/dest/private/providers/acvm_native.js +1 -1
- package/dest/private/providers/circuit_recording/circuit_recorder.d.ts +0 -2
- package/dest/private/providers/circuit_recording/circuit_recorder.d.ts.map +1 -1
- package/dest/private/providers/simulation_provider.js +2 -2
- package/dest/private/simulator.d.ts.map +1 -1
- package/dest/private/utility_execution_oracle.d.ts +0 -2
- package/dest/private/utility_execution_oracle.d.ts.map +1 -1
- package/dest/public/avm/avm_contract_call_result.d.ts.map +1 -1
- package/dest/public/avm/avm_contract_call_result.js +2 -2
- package/dest/public/avm/avm_execution_environment.d.ts +2 -1
- package/dest/public/avm/avm_execution_environment.d.ts.map +1 -1
- package/dest/public/avm/avm_execution_environment.js +4 -2
- package/dest/public/avm/avm_gas.d.ts +0 -15
- package/dest/public/avm/avm_gas.d.ts.map +1 -1
- package/dest/public/avm/avm_gas.js +0 -18
- package/dest/public/avm/avm_memory_types.d.ts +84 -86
- package/dest/public/avm/avm_memory_types.d.ts.map +1 -1
- package/dest/public/avm/avm_simulator.d.ts +1 -3
- package/dest/public/avm/avm_simulator.d.ts.map +1 -1
- package/dest/public/avm/avm_simulator.js +3 -3
- package/dest/public/avm/avm_simulator_interface.d.ts +0 -2
- package/dest/public/avm/avm_simulator_interface.d.ts.map +1 -1
- package/dest/public/avm/fixtures/initializers.d.ts.map +1 -1
- package/dest/public/avm/fixtures/initializers.js +1 -1
- package/dest/public/avm/opcodes/accrued_substate.d.ts.map +1 -1
- package/dest/public/avm/opcodes/accrued_substate.js +7 -7
- package/dest/public/avm/opcodes/addressing_mode.d.ts +7 -6
- package/dest/public/avm/opcodes/addressing_mode.d.ts.map +1 -1
- package/dest/public/avm/opcodes/addressing_mode.js +18 -15
- package/dest/public/avm/opcodes/arithmetic.d.ts.map +1 -1
- package/dest/public/avm/opcodes/arithmetic.js +1 -1
- package/dest/public/avm/opcodes/bitwise.d.ts.map +1 -1
- package/dest/public/avm/opcodes/bitwise.js +2 -2
- package/dest/public/avm/opcodes/comparators.d.ts.map +1 -1
- package/dest/public/avm/opcodes/comparators.js +1 -1
- package/dest/public/avm/opcodes/contract.d.ts.map +1 -1
- package/dest/public/avm/opcodes/contract.js +1 -1
- package/dest/public/avm/opcodes/control_flow.d.ts.map +1 -1
- package/dest/public/avm/opcodes/control_flow.js +1 -1
- package/dest/public/avm/opcodes/conversion.d.ts.map +1 -1
- package/dest/public/avm/opcodes/conversion.js +1 -1
- package/dest/public/avm/opcodes/ec_add.d.ts.map +1 -1
- package/dest/public/avm/opcodes/ec_add.js +1 -1
- package/dest/public/avm/opcodes/environment_getters.d.ts.map +1 -1
- package/dest/public/avm/opcodes/environment_getters.js +1 -1
- package/dest/public/avm/opcodes/external_calls.d.ts.map +1 -1
- package/dest/public/avm/opcodes/external_calls.js +4 -4
- package/dest/public/avm/opcodes/hashing.d.ts.map +1 -1
- package/dest/public/avm/opcodes/hashing.js +3 -3
- package/dest/public/avm/opcodes/instruction.d.ts +0 -2
- package/dest/public/avm/opcodes/instruction.d.ts.map +1 -1
- package/dest/public/avm/opcodes/memory.d.ts.map +1 -1
- package/dest/public/avm/opcodes/memory.js +6 -6
- package/dest/public/avm/opcodes/misc.d.ts.map +1 -1
- package/dest/public/avm/opcodes/misc.js +18 -11
- package/dest/public/avm/opcodes/storage.d.ts.map +1 -1
- package/dest/public/avm/opcodes/storage.js +2 -2
- package/dest/public/avm/serialization/buffer_cursor.d.ts +0 -2
- package/dest/public/avm/serialization/buffer_cursor.d.ts.map +1 -1
- package/dest/public/avm/serialization/bytecode_serialization.d.ts +0 -2
- package/dest/public/avm/serialization/bytecode_serialization.d.ts.map +1 -1
- package/dest/public/avm/serialization/instruction_serialization.d.ts +0 -2
- package/dest/public/avm/serialization/instruction_serialization.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 +1 -1
- package/dest/public/fixtures/utils.d.ts.map +1 -1
- package/dest/public/fixtures/utils.js +19 -26
- package/dest/public/hinting_db_sources.d.ts +0 -2
- package/dest/public/hinting_db_sources.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor.d.ts +3 -5
- package/dest/public/public_processor/public_processor.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor.js +8 -5
- package/dest/public/public_tx_simulator/measured_public_tx_simulator.d.ts +1 -1
- package/dest/public/public_tx_simulator/measured_public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/measured_public_tx_simulator.js +3 -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 +5 -9
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts +2 -1
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_simulator.js +15 -3
- package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.d.ts +1 -1
- package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.js +2 -2
- package/dest/public/side_effect_trace.d.ts.map +1 -1
- package/dest/public/side_effect_trace.js +5 -5
- package/dest/public/state_manager/nullifiers.d.ts.map +1 -1
- package/dest/public/state_manager/public_storage.d.ts.map +1 -1
- package/dest/public/state_manager/state_manager.d.ts +6 -2
- package/dest/public/state_manager/state_manager.d.ts.map +1 -1
- package/dest/public/state_manager/state_manager.js +6 -0
- package/dest/public/unique_class_ids.d.ts.map +1 -1
- package/dest/test/utils.d.ts.map +1 -1
- package/package.json +18 -18
- package/src/private/acvm/acvm.ts +1 -1
- package/src/private/acvm/oracle/oracle.ts +38 -31
- package/src/private/acvm/oracle/typed_oracle.ts +1 -1
- package/src/private/acvm/serialize.ts +35 -0
- package/src/private/index.ts +3 -0
- package/src/private/pick_notes.ts +4 -4
- package/src/private/providers/acvm_native.ts +6 -2
- package/src/private/providers/simulation_provider.ts +2 -2
- package/src/private/simulator.ts +4 -1
- package/src/public/avm/avm_contract_call_result.ts +2 -2
- package/src/public/avm/avm_execution_environment.ts +7 -1
- package/src/public/avm/avm_gas.ts +0 -20
- package/src/public/avm/avm_simulator.ts +3 -1
- package/src/public/avm/fixtures/initializers.ts +1 -0
- package/src/public/avm/opcodes/accrued_substate.ts +31 -11
- package/src/public/avm/opcodes/addressing_mode.ts +23 -20
- package/src/public/avm/opcodes/arithmetic.ts +2 -1
- package/src/public/avm/opcodes/bitwise.ts +9 -3
- package/src/public/avm/opcodes/comparators.ts +2 -1
- package/src/public/avm/opcodes/contract.ts +2 -1
- package/src/public/avm/opcodes/control_flow.ts +7 -2
- package/src/public/avm/opcodes/conversion.ts +2 -1
- package/src/public/avm/opcodes/ec_add.ts +2 -1
- package/src/public/avm/opcodes/environment_getters.ts +7 -2
- package/src/public/avm/opcodes/external_calls.ts +19 -7
- package/src/public/avm/opcodes/hashing.ts +17 -5
- package/src/public/avm/opcodes/memory.ts +27 -9
- package/src/public/avm/opcodes/misc.ts +23 -15
- package/src/public/avm/opcodes/storage.ts +9 -3
- package/src/public/avm/serialization/buffer_cursor.ts +4 -1
- package/src/public/fixtures/public_tx_simulation_tester.ts +1 -0
- package/src/public/fixtures/utils.ts +21 -28
- package/src/public/hinting_db_sources.ts +8 -2
- package/src/public/public_processor/public_processor.ts +9 -3
- package/src/public/public_tx_simulator/measured_public_tx_simulator.ts +3 -2
- package/src/public/public_tx_simulator/public_tx_context.ts +4 -23
- package/src/public/public_tx_simulator/public_tx_simulator.ts +14 -1
- package/src/public/public_tx_simulator/telemetry_public_tx_simulator.ts +10 -1
- package/src/public/side_effect_trace.ts +5 -7
- package/src/public/state_manager/state_manager.ts +13 -0
- package/src/public/avm/opcodes/.eslintrc.cjs +0 -8
|
@@ -58,6 +58,7 @@ export class PublicProcessorFactory {
|
|
|
58
58
|
merkleTree: MerkleTreeWriteOperations,
|
|
59
59
|
globalVariables: GlobalVariables,
|
|
60
60
|
skipFeeEnforcement: boolean,
|
|
61
|
+
clientInitiatedSimulation: boolean = false,
|
|
61
62
|
): PublicProcessor {
|
|
62
63
|
const contractsDB = new PublicContractsDB(this.contractDataSource);
|
|
63
64
|
const publicTxSimulator = this.createPublicTxSimulator(
|
|
@@ -66,6 +67,7 @@ export class PublicProcessorFactory {
|
|
|
66
67
|
globalVariables,
|
|
67
68
|
/*doMerkleOperations=*/ true,
|
|
68
69
|
skipFeeEnforcement,
|
|
70
|
+
clientInitiatedSimulation,
|
|
69
71
|
);
|
|
70
72
|
|
|
71
73
|
return new PublicProcessor(
|
|
@@ -84,6 +86,7 @@ export class PublicProcessorFactory {
|
|
|
84
86
|
globalVariables: GlobalVariables,
|
|
85
87
|
doMerkleOperations: boolean,
|
|
86
88
|
skipFeeEnforcement: boolean,
|
|
89
|
+
clientInitiatedSimulation: boolean,
|
|
87
90
|
): PublicTxSimulator {
|
|
88
91
|
return new TelemetryPublicTxSimulator(
|
|
89
92
|
merkleTree,
|
|
@@ -91,6 +94,7 @@ export class PublicProcessorFactory {
|
|
|
91
94
|
globalVariables,
|
|
92
95
|
doMerkleOperations,
|
|
93
96
|
skipFeeEnforcement,
|
|
97
|
+
clientInitiatedSimulation,
|
|
94
98
|
this.telemetryClient,
|
|
95
99
|
);
|
|
96
100
|
}
|
|
@@ -145,10 +149,11 @@ export class PublicProcessor implements Traceable {
|
|
|
145
149
|
preprocessValidator?: TxValidator<Tx>;
|
|
146
150
|
nullifierCache?: { addNullifiers: (nullifiers: Buffer[]) => void };
|
|
147
151
|
} = {},
|
|
148
|
-
): Promise<[ProcessedTx[], FailedTx[], NestedProcessReturnValues[]]> {
|
|
152
|
+
): Promise<[ProcessedTx[], FailedTx[], Tx[], NestedProcessReturnValues[]]> {
|
|
149
153
|
const { maxTransactions, maxBlockSize, deadline, maxBlockGas } = limits;
|
|
150
154
|
const { preprocessValidator, nullifierCache } = validator;
|
|
151
155
|
const result: ProcessedTx[] = [];
|
|
156
|
+
const usedTxs: Tx[] = [];
|
|
152
157
|
const failed: FailedTx[] = [];
|
|
153
158
|
const timer = new Timer();
|
|
154
159
|
|
|
@@ -244,6 +249,7 @@ export class PublicProcessor implements Traceable {
|
|
|
244
249
|
// I'd rather pass the validators the processedTx as well and let them deal with it.
|
|
245
250
|
nullifierCache?.addNullifiers(processedTx.txEffect.nullifiers.map(n => n.toBuffer()));
|
|
246
251
|
result.push(processedTx);
|
|
252
|
+
usedTxs.push(tx);
|
|
247
253
|
returns = returns.concat(returnValues);
|
|
248
254
|
|
|
249
255
|
totalPublicGas = totalPublicGas.add(processedTx.gasUsed.publicGas);
|
|
@@ -281,7 +287,7 @@ export class PublicProcessor implements Traceable {
|
|
|
281
287
|
totalSizeInBytes,
|
|
282
288
|
});
|
|
283
289
|
|
|
284
|
-
return [result, failed, returns];
|
|
290
|
+
return [result, failed, usedTxs, returns];
|
|
285
291
|
}
|
|
286
292
|
|
|
287
293
|
@trackSpan('PublicProcessor.processTx', async tx => ({ [Attributes.TX_HASH]: (await tx.getTxHash()).toString() }))
|
|
@@ -334,7 +340,7 @@ export class PublicProcessor implements Traceable {
|
|
|
334
340
|
padArrayEnd(processedTx.txEffect.nullifiers, Fr.ZERO, MAX_NULLIFIERS_PER_TX).map(n => n.toBuffer()),
|
|
335
341
|
NULLIFIER_SUBTREE_HEIGHT,
|
|
336
342
|
);
|
|
337
|
-
} catch
|
|
343
|
+
} catch {
|
|
338
344
|
if (txValidator) {
|
|
339
345
|
// Ideally the validator has already caught this above, but just in case:
|
|
340
346
|
throw new Error(`Transaction ${processedTx.hash} invalid after processing public functions`);
|
|
@@ -22,9 +22,10 @@ export class MeasuredPublicTxSimulator extends PublicTxSimulator {
|
|
|
22
22
|
globalVariables: GlobalVariables,
|
|
23
23
|
doMerkleOperations: boolean = false,
|
|
24
24
|
skipFeeEnforcement: boolean = false,
|
|
25
|
+
clientInitiatedSimulation: boolean = false,
|
|
25
26
|
protected readonly metrics: ExecutorMetricsInterface,
|
|
26
27
|
) {
|
|
27
|
-
super(merkleTree, contractsDB, globalVariables, doMerkleOperations, skipFeeEnforcement);
|
|
28
|
+
super(merkleTree, contractsDB, globalVariables, doMerkleOperations, skipFeeEnforcement, clientInitiatedSimulation);
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
public override async simulate(tx: Tx, txLabel: string = 'unlabeledTx'): Promise<PublicTxResult> {
|
|
@@ -83,7 +84,7 @@ export class MeasuredPublicTxSimulator extends PublicTxSimulator {
|
|
|
83
84
|
|
|
84
85
|
this.log.verbose(
|
|
85
86
|
result.reverted
|
|
86
|
-
? `Simulation of enqueued public call ${fnName} reverted with reason ${result.revertReason}.`
|
|
87
|
+
? `Simulation of enqueued public call ${fnName} reverted with reason ${result.revertReason?.message}.`
|
|
87
88
|
: `Simulation of enqueued public call ${fnName} completed successfully.`,
|
|
88
89
|
{
|
|
89
90
|
eventName: 'avm-simulation',
|
|
@@ -21,7 +21,6 @@ import {
|
|
|
21
21
|
type PrivateToPublicAccumulatedData,
|
|
22
22
|
PublicCallRequest,
|
|
23
23
|
countAccumulatedItems,
|
|
24
|
-
mergeAccumulatedData,
|
|
25
24
|
} from '@aztec/stdlib/kernel';
|
|
26
25
|
import { PublicLog } from '@aztec/stdlib/logs';
|
|
27
26
|
import { ScopedL2ToL1Message } from '@aztec/stdlib/messaging';
|
|
@@ -40,7 +39,7 @@ import { inspect } from 'util';
|
|
|
40
39
|
|
|
41
40
|
import type { PublicContractsDBInterface } from '../db_interfaces.js';
|
|
42
41
|
import type { PublicTreesDB } from '../public_db_sources.js';
|
|
43
|
-
import {
|
|
42
|
+
import { SideEffectTrace } from '../side_effect_trace.js';
|
|
44
43
|
import { PublicPersistableStateManager } from '../state_manager/state_manager.js';
|
|
45
44
|
import { getCallRequestsWithCalldataByPhase } from '../utils.js';
|
|
46
45
|
|
|
@@ -89,16 +88,7 @@ export class PublicTxContext {
|
|
|
89
88
|
) {
|
|
90
89
|
const nonRevertibleAccumulatedDataFromPrivate = tx.data.forPublic!.nonRevertibleAccumulatedData;
|
|
91
90
|
|
|
92
|
-
const
|
|
93
|
-
/*publicDataWrites*/ 0,
|
|
94
|
-
/*protocolPublicDataWrites*/ 0,
|
|
95
|
-
/*noteHashes*/ 0,
|
|
96
|
-
/*nullifiers=*/ 0,
|
|
97
|
-
countAccumulatedItems(nonRevertibleAccumulatedDataFromPrivate.l2ToL1Msgs),
|
|
98
|
-
/*publicLogs*/ 0,
|
|
99
|
-
);
|
|
100
|
-
|
|
101
|
-
const trace = new SideEffectTrace(/*startSideEffectCounter=*/ 0, previousAccumulatedDataArrayLengths);
|
|
91
|
+
const trace = new SideEffectTrace();
|
|
102
92
|
|
|
103
93
|
const firstNullifier = nonRevertibleAccumulatedDataFromPrivate.nullifiers[0];
|
|
104
94
|
|
|
@@ -153,7 +143,7 @@ export class PublicTxContext {
|
|
|
153
143
|
* NOTE: this does not "halt" the entire transaction execution.
|
|
154
144
|
*/
|
|
155
145
|
revert(phase: TxExecutionPhase, revertReason: SimulationError | undefined = undefined, culprit = '') {
|
|
156
|
-
this.log.warn(`${TxExecutionPhase[phase]} phase reverted! ${culprit} failed with reason: ${revertReason}`);
|
|
146
|
+
this.log.warn(`${TxExecutionPhase[phase]} phase reverted! ${culprit} failed with reason: ${revertReason?.message}`);
|
|
157
147
|
|
|
158
148
|
if (revertReason && !this.revertReason) {
|
|
159
149
|
// don't override revertReason
|
|
@@ -315,15 +305,6 @@ export class PublicTxContext {
|
|
|
315
305
|
publicLogs: avmPublicLogs,
|
|
316
306
|
} = this.trace.getSideEffects();
|
|
317
307
|
|
|
318
|
-
// We concatenate messages.
|
|
319
|
-
const msgsFromPrivate = this.revertCode.isOK()
|
|
320
|
-
? mergeAccumulatedData(
|
|
321
|
-
this.nonRevertibleAccumulatedDataFromPrivate.l2ToL1Msgs,
|
|
322
|
-
this.revertibleAccumulatedDataFromPrivate.l2ToL1Msgs,
|
|
323
|
-
)
|
|
324
|
-
: this.nonRevertibleAccumulatedDataFromPrivate.l2ToL1Msgs;
|
|
325
|
-
const finalL2ToL1Msgs = mergeAccumulatedData(msgsFromPrivate, avmL2ToL1Msgs);
|
|
326
|
-
|
|
327
308
|
// Private generates PrivateLogs, and public execution generates PublicLogs.
|
|
328
309
|
// Since these are two different categories, they should not be merged.
|
|
329
310
|
const finalPublicLogs = avmPublicLogs;
|
|
@@ -354,7 +335,7 @@ export class PublicTxContext {
|
|
|
354
335
|
Fr.zero(),
|
|
355
336
|
MAX_NULLIFIERS_PER_TX,
|
|
356
337
|
),
|
|
357
|
-
/*l2ToL1Msgs=*/ padArrayEnd(
|
|
338
|
+
/*l2ToL1Msgs=*/ padArrayEnd(avmL2ToL1Msgs, ScopedL2ToL1Message.empty(), MAX_L2_TO_L1_MSGS_PER_TX),
|
|
358
339
|
/*publicLogs=*/ padArrayEnd(finalPublicLogs, PublicLog.empty(), MAX_PUBLIC_LOGS_PER_TX),
|
|
359
340
|
/*publicDataWrites=*/ padArrayEnd(
|
|
360
341
|
finalPublicDataWrites,
|
|
@@ -60,6 +60,7 @@ export class PublicTxSimulator {
|
|
|
60
60
|
private globalVariables: GlobalVariables,
|
|
61
61
|
private doMerkleOperations: boolean = false,
|
|
62
62
|
private skipFeeEnforcement: boolean = false,
|
|
63
|
+
private clientInitiatedSimulation: boolean = false,
|
|
63
64
|
) {
|
|
64
65
|
this.log = createLogger(`simulator:public_tx_simulator`);
|
|
65
66
|
}
|
|
@@ -230,7 +231,7 @@ export class PublicTxSimulator {
|
|
|
230
231
|
const returnValues: NestedProcessReturnValues[] = [];
|
|
231
232
|
let reverted = false;
|
|
232
233
|
let revertReason: SimulationError | undefined;
|
|
233
|
-
for (let i =
|
|
234
|
+
for (let i = 0; i < callRequests.length; i++) {
|
|
234
235
|
if (reverted) {
|
|
235
236
|
break;
|
|
236
237
|
}
|
|
@@ -331,6 +332,7 @@ export class PublicTxSimulator {
|
|
|
331
332
|
request.isStaticCall,
|
|
332
333
|
calldata,
|
|
333
334
|
allocatedGas,
|
|
335
|
+
this.clientInitiatedSimulation,
|
|
334
336
|
);
|
|
335
337
|
const avmCallResult = await simulator.execute();
|
|
336
338
|
return avmCallResult.finalize();
|
|
@@ -359,6 +361,12 @@ export class PublicTxSimulator {
|
|
|
359
361
|
await stateManager.writeUniqueNoteHash(noteHash);
|
|
360
362
|
}
|
|
361
363
|
}
|
|
364
|
+
for (const l2ToL1Message of context.nonRevertibleAccumulatedDataFromPrivate.l2ToL1Msgs) {
|
|
365
|
+
if (!l2ToL1Message.isEmpty()) {
|
|
366
|
+
stateManager.writeScopedL2ToL1Message(l2ToL1Message);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
362
370
|
// add new contracts to the contracts db so that their functions may be found and called
|
|
363
371
|
// TODO(#6464): Should we allow emitting contracts in the private setup phase?
|
|
364
372
|
// FIXME(fcarreiro): this should conceptually use the hinted contracts db.
|
|
@@ -400,6 +408,11 @@ export class PublicTxSimulator {
|
|
|
400
408
|
await stateManager.writeSiloedNoteHash(noteHash);
|
|
401
409
|
}
|
|
402
410
|
}
|
|
411
|
+
for (const l2ToL1Message of context.revertibleAccumulatedDataFromPrivate.l2ToL1Msgs) {
|
|
412
|
+
if (!l2ToL1Message.isEmpty()) {
|
|
413
|
+
stateManager.writeScopedL2ToL1Message(l2ToL1Message);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
403
416
|
// add new contracts to the contracts db so that their functions may be found and called
|
|
404
417
|
// FIXME(fcarreiro): this should conceptually use the hinted contracts db.
|
|
405
418
|
// However things should work as they are now because the hinted db would still pick up the new contracts.
|
|
@@ -24,10 +24,19 @@ export class TelemetryPublicTxSimulator extends MeasuredPublicTxSimulator {
|
|
|
24
24
|
globalVariables: GlobalVariables,
|
|
25
25
|
doMerkleOperations: boolean = false,
|
|
26
26
|
skipFeeEnforcement: boolean = false,
|
|
27
|
+
clientInitiatedSimulation: boolean = false,
|
|
27
28
|
telemetryClient: TelemetryClient = getTelemetryClient(),
|
|
28
29
|
) {
|
|
29
30
|
const metrics = new ExecutorMetrics(telemetryClient, 'PublicTxSimulator');
|
|
30
|
-
super(
|
|
31
|
+
super(
|
|
32
|
+
merkleTree,
|
|
33
|
+
contractsDB,
|
|
34
|
+
globalVariables,
|
|
35
|
+
doMerkleOperations,
|
|
36
|
+
skipFeeEnforcement,
|
|
37
|
+
clientInitiatedSimulation,
|
|
38
|
+
metrics,
|
|
39
|
+
);
|
|
31
40
|
this.tracer = metrics.tracer;
|
|
32
41
|
}
|
|
33
42
|
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX,
|
|
7
7
|
MAX_PUBLIC_LOGS_PER_TX,
|
|
8
8
|
PROTOCOL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX,
|
|
9
|
-
|
|
9
|
+
PUBLIC_LOG_SIZE_IN_FIELDS,
|
|
10
10
|
} from '@aztec/constants';
|
|
11
11
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
12
12
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
@@ -199,9 +199,7 @@ export class SideEffectTrace implements PublicSideEffectTraceInterface {
|
|
|
199
199
|
}
|
|
200
200
|
|
|
201
201
|
const recipientAddress = EthAddress.fromField(recipient);
|
|
202
|
-
this.l2ToL1Messages.push(
|
|
203
|
-
new L2ToL1Message(recipientAddress, content, this.sideEffectCounter).scope(contractAddress),
|
|
204
|
-
);
|
|
202
|
+
this.l2ToL1Messages.push(new L2ToL1Message(recipientAddress, content, 0).scope(contractAddress));
|
|
205
203
|
this.log.trace(`Tracing new l2 to l1 message (counter=${this.sideEffectCounter})`);
|
|
206
204
|
this.incrementSideEffectCounter();
|
|
207
205
|
}
|
|
@@ -211,10 +209,10 @@ export class SideEffectTrace implements PublicSideEffectTraceInterface {
|
|
|
211
209
|
throw new SideEffectLimitReachedError('public log', MAX_PUBLIC_LOGS_PER_TX);
|
|
212
210
|
}
|
|
213
211
|
|
|
214
|
-
if (log.length >
|
|
215
|
-
throw new Error(`Emitted public log is too large, max: ${
|
|
212
|
+
if (log.length > PUBLIC_LOG_SIZE_IN_FIELDS) {
|
|
213
|
+
throw new Error(`Emitted public log is too large, max: ${PUBLIC_LOG_SIZE_IN_FIELDS}, passed: ${log.length}`);
|
|
216
214
|
}
|
|
217
|
-
const publicLog = new PublicLog(contractAddress, padArrayEnd(log, Fr.ZERO,
|
|
215
|
+
const publicLog = new PublicLog(contractAddress, padArrayEnd(log, Fr.ZERO, PUBLIC_LOG_SIZE_IN_FIELDS), log.length);
|
|
218
216
|
this.publicLogs.push(publicLog);
|
|
219
217
|
this.log.trace(`Tracing new public log (counter=${this.sideEffectCounter})`);
|
|
220
218
|
this.incrementSideEffectCounter();
|
|
@@ -15,6 +15,7 @@ import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
|
15
15
|
import type { ContractClassPublicWithCommitment, ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
16
16
|
import { SerializableContractInstance } from '@aztec/stdlib/contract';
|
|
17
17
|
import { computeNoteHashNonce, computeUniqueNoteHash, siloNoteHash, siloNullifier } from '@aztec/stdlib/hash';
|
|
18
|
+
import { ScopedL2ToL1Message } from '@aztec/stdlib/messaging';
|
|
18
19
|
import { SharedMutableValues, SharedMutableValuesWithHash } from '@aztec/stdlib/shared-mutable';
|
|
19
20
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
20
21
|
import type { TreeSnapshots } from '@aztec/stdlib/tx';
|
|
@@ -301,6 +302,18 @@ export class PublicPersistableStateManager {
|
|
|
301
302
|
this.trace.traceNewL2ToL1Message(contractAddress, recipient, content);
|
|
302
303
|
}
|
|
303
304
|
|
|
305
|
+
/**
|
|
306
|
+
* Write a scoped L2 to L1 message.
|
|
307
|
+
* @param l2ToL1Message - The L2 to L1 message to write.
|
|
308
|
+
*/
|
|
309
|
+
public writeScopedL2ToL1Message(l2ToL1Message: ScopedL2ToL1Message) {
|
|
310
|
+
this.writeL2ToL1Message(
|
|
311
|
+
l2ToL1Message.contractAddress,
|
|
312
|
+
l2ToL1Message.message.recipient.toField(),
|
|
313
|
+
l2ToL1Message.message.content,
|
|
314
|
+
);
|
|
315
|
+
}
|
|
316
|
+
|
|
304
317
|
/**
|
|
305
318
|
* Write a public log
|
|
306
319
|
* @param contractAddress - address of the contract that emitted the log
|