@aztec/simulator 0.85.0 → 0.86.0
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/private/providers/acvm_native.d.ts +1 -1
- package/dest/private/providers/acvm_native.d.ts.map +1 -1
- package/dest/private/providers/acvm_native.js +4 -3
- package/dest/private/providers/acvm_wasm.d.ts +2 -1
- package/dest/private/providers/acvm_wasm.d.ts.map +1 -1
- package/dest/private/providers/acvm_wasm.js +6 -1
- package/dest/private/providers/acvm_wasm_with_blobs.d.ts +2 -1
- package/dest/private/providers/acvm_wasm_with_blobs.d.ts.map +1 -1
- package/dest/private/providers/acvm_wasm_with_blobs.js +6 -1
- package/dest/private/providers/circuit_recording/simulation_provider_recorder_wrapper.d.ts +2 -1
- package/dest/private/providers/circuit_recording/simulation_provider_recorder_wrapper.d.ts.map +1 -1
- package/dest/private/providers/simulation_provider.d.ts +2 -1
- package/dest/private/providers/simulation_provider.d.ts.map +1 -1
- package/dest/public/avm/avm_context.d.ts +2 -2
- package/dest/public/avm/avm_context.d.ts.map +1 -1
- package/dest/public/avm/avm_simulator.d.ts +2 -1
- package/dest/public/avm/avm_simulator.d.ts.map +1 -1
- package/dest/public/avm/avm_simulator.js +2 -1
- package/dest/public/avm/avm_simulator_interface.d.ts +11 -0
- package/dest/public/avm/avm_simulator_interface.d.ts.map +1 -0
- package/dest/public/avm/avm_simulator_interface.js +3 -0
- package/dest/public/avm/errors.d.ts +1 -16
- package/dest/public/avm/errors.d.ts.map +1 -1
- package/dest/public/avm/errors.js +0 -37
- 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 +1 -1
- package/dest/public/avm/fixtures/base_avm_simulation_tester.d.ts +1 -1
- package/dest/public/avm/fixtures/base_avm_simulation_tester.d.ts.map +1 -1
- package/dest/public/avm/fixtures/index.d.ts +2 -85
- package/dest/public/avm/fixtures/index.d.ts.map +1 -1
- package/dest/public/avm/fixtures/index.js +2 -174
- package/dest/public/avm/fixtures/initializers.d.ts +42 -0
- package/dest/public/avm/fixtures/initializers.d.ts.map +1 -0
- package/dest/public/avm/fixtures/initializers.js +42 -0
- package/dest/public/avm/fixtures/utils.d.ts +46 -0
- package/dest/public/avm/fixtures/utils.d.ts.map +1 -0
- package/dest/public/avm/fixtures/utils.js +136 -0
- package/dest/public/avm/index.d.ts +0 -1
- package/dest/public/avm/index.d.ts.map +1 -1
- package/dest/public/avm/index.js +0 -1
- package/dest/public/avm/opcodes/accrued_substate.d.ts.map +1 -1
- package/dest/public/avm/opcodes/accrued_substate.js +1 -1
- package/dest/public/avm/opcodes/external_calls.d.ts +3 -2
- package/dest/public/avm/opcodes/external_calls.d.ts.map +1 -1
- package/dest/public/avm/opcodes/external_calls.js +14 -9
- package/dest/public/avm/opcodes/instruction.d.ts +5 -5
- package/dest/public/avm/opcodes/instruction.d.ts.map +1 -1
- package/dest/public/avm/opcodes/instruction.js +6 -6
- package/dest/public/avm/revert_reason.d.ts +18 -0
- package/dest/public/avm/revert_reason.d.ts.map +1 -0
- package/dest/public/avm/revert_reason.js +38 -0
- package/dest/public/avm/serialization/bytecode_serialization.d.ts +2 -4
- package/dest/public/avm/serialization/bytecode_serialization.d.ts.map +1 -1
- package/dest/public/avm/serialization/bytecode_serialization.js +70 -69
- package/dest/{common → public}/debug_fn_name.d.ts +1 -1
- package/dest/{common → public}/debug_fn_name.d.ts.map +1 -1
- package/dest/public/fixtures/index.d.ts +1 -0
- package/dest/public/fixtures/index.d.ts.map +1 -1
- package/dest/public/fixtures/index.js +1 -0
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts +1 -1
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts.map +1 -1
- package/dest/public/fixtures/public_tx_simulation_tester.js +3 -4
- package/dest/public/fixtures/simple_contract_data_source.d.ts.map +1 -0
- package/dest/public/{avm/fixtures → fixtures}/simple_contract_data_source.js +1 -1
- package/dest/public/hinting_db_sources.d.ts +15 -5
- package/dest/public/hinting_db_sources.d.ts.map +1 -1
- package/dest/public/hinting_db_sources.js +65 -27
- package/dest/public/index.d.ts +2 -6
- package/dest/public/index.d.ts.map +1 -1
- package/dest/public/index.js +2 -6
- package/dest/public/public_db_sources.d.ts +19 -52
- package/dest/public/public_db_sources.d.ts.map +1 -1
- package/dest/public/public_db_sources.js +96 -107
- package/dest/public/public_processor/public_processor.d.ts +6 -6
- package/dest/public/public_processor/public_processor.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor.js +24 -26
- package/dest/public/public_tx_simulator/measured_public_tx_simulator.d.ts +3 -2
- package/dest/public/public_tx_simulator/measured_public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/measured_public_tx_simulator.js +2 -2
- package/dest/public/public_tx_simulator/public_tx_context.d.ts +3 -4
- package/dest/public/public_tx_simulator/public_tx_context.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_context.js +11 -21
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts +5 -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 +21 -10
- package/dest/public/public_tx_simulator/telemetry_public_tx_simulator.d.ts +3 -2
- 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 +1 -3
- package/dest/public/side_effect_trace.d.ts.map +1 -1
- package/dest/public/side_effect_trace.js +3 -2
- package/dest/public/state_manager/state_manager.d.ts +6 -4
- package/dest/public/state_manager/state_manager.d.ts.map +1 -1
- package/dest/public/state_manager/state_manager.js +20 -41
- package/package.json +14 -16
- package/src/private/providers/acvm_native.ts +5 -4
- package/src/private/providers/acvm_wasm.ts +5 -2
- package/src/private/providers/acvm_wasm_with_blobs.ts +5 -3
- package/src/private/providers/circuit_recording/simulation_provider_recorder_wrapper.ts +3 -2
- package/src/private/providers/simulation_provider.ts +2 -1
- package/src/public/avm/avm_context.ts +2 -2
- package/src/public/avm/avm_simulator.ts +4 -8
- package/src/public/avm/avm_simulator_interface.ts +8 -0
- package/src/public/avm/errors.ts +1 -53
- package/src/public/avm/fixtures/avm_simulation_tester.ts +1 -1
- package/src/public/avm/fixtures/base_avm_simulation_tester.ts +1 -1
- package/src/public/avm/fixtures/index.ts +2 -308
- package/src/public/avm/fixtures/initializers.ts +101 -0
- package/src/public/avm/fixtures/utils.ts +213 -0
- package/src/public/avm/index.ts +0 -1
- package/src/public/avm/opcodes/accrued_substate.ts +1 -5
- package/src/public/avm/opcodes/external_calls.ts +17 -11
- package/src/public/avm/opcodes/instruction.ts +9 -8
- package/src/public/avm/revert_reason.ts +55 -0
- package/src/public/avm/serialization/bytecode_serialization.ts +72 -74
- package/src/{common → public}/debug_fn_name.ts +1 -1
- package/src/public/fixtures/index.ts +1 -0
- package/src/public/fixtures/public_tx_simulation_tester.ts +3 -5
- package/src/public/{avm/fixtures → fixtures}/simple_contract_data_source.ts +1 -1
- package/src/public/hinting_db_sources.ts +104 -39
- package/src/public/index.ts +2 -6
- package/src/public/public_db_sources.ts +111 -164
- package/src/public/public_processor/public_processor.ts +27 -29
- package/src/public/public_tx_simulator/measured_public_tx_simulator.ts +4 -3
- package/src/public/public_tx_simulator/public_tx_context.ts +10 -47
- package/src/public/public_tx_simulator/public_tx_simulator.ts +25 -10
- package/src/public/public_tx_simulator/telemetry_public_tx_simulator.ts +4 -3
- package/src/public/side_effect_trace.ts +2 -4
- package/src/public/state_manager/state_manager.ts +24 -50
- package/dest/public/avm/fixtures/simple_contract_data_source.d.ts.map +0 -1
- /package/dest/{common → public}/debug_fn_name.js +0 -0
- /package/dest/public/{avm/fixtures → fixtures}/simple_contract_data_source.d.ts +0 -0
|
@@ -7,7 +7,8 @@ import { ContractInstanceDeployedEvent } from '@aztec/protocol-contracts/instanc
|
|
|
7
7
|
import { PublicDataWrite } from '@aztec/stdlib/avm';
|
|
8
8
|
import { computePublicBytecodeCommitment } from '@aztec/stdlib/contract';
|
|
9
9
|
import { computePublicDataTreeLeafSlot } from '@aztec/stdlib/hash';
|
|
10
|
-
import { MerkleTreeId, NullifierLeaf, PublicDataTreeLeaf } from '@aztec/stdlib/trees';
|
|
10
|
+
import { MerkleTreeId, NullifierLeaf, PublicDataTreeLeaf, getTreeName } from '@aztec/stdlib/trees';
|
|
11
|
+
import { TreeSnapshots } from '@aztec/stdlib/tx';
|
|
11
12
|
import { TxContractCache } from './tx_contract_cache.js';
|
|
12
13
|
/**
|
|
13
14
|
* Implements the PublicContractsDBInterface using a ContractDataSource.
|
|
@@ -182,114 +183,61 @@ import { TxContractCache } from './tx_contract_cache.js';
|
|
|
182
183
|
}
|
|
183
184
|
}
|
|
184
185
|
/**
|
|
185
|
-
*
|
|
186
|
+
* A high-level class that provides access to the merkle trees.
|
|
186
187
|
*
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
getStateReference() {
|
|
199
|
-
return this.operations.getStateReference();
|
|
200
|
-
}
|
|
201
|
-
getInitialHeader() {
|
|
202
|
-
return this.operations.getInitialHeader();
|
|
203
|
-
}
|
|
204
|
-
getSiblingPath(treeId, index) {
|
|
205
|
-
return this.operations.getSiblingPath(treeId, index);
|
|
206
|
-
}
|
|
207
|
-
getPreviousValueIndex(treeId, value) {
|
|
208
|
-
return this.operations.getPreviousValueIndex(treeId, value);
|
|
209
|
-
}
|
|
210
|
-
getLeafPreimage(treeId, index) {
|
|
211
|
-
return this.operations.getLeafPreimage(treeId, index);
|
|
212
|
-
}
|
|
213
|
-
findLeafIndices(treeId, values) {
|
|
214
|
-
return this.operations.findLeafIndices(treeId, values);
|
|
215
|
-
}
|
|
216
|
-
findLeafIndicesAfter(treeId, values, startIndex) {
|
|
217
|
-
return this.operations.findLeafIndicesAfter(treeId, values, startIndex);
|
|
218
|
-
}
|
|
219
|
-
getLeafValue(treeId, index) {
|
|
220
|
-
return this.operations.getLeafValue(treeId, index);
|
|
221
|
-
}
|
|
222
|
-
getBlockNumbersForLeafIndices(treeId, leafIndices) {
|
|
223
|
-
return this.operations.getBlockNumbersForLeafIndices(treeId, leafIndices);
|
|
224
|
-
}
|
|
225
|
-
createCheckpoint() {
|
|
226
|
-
return this.operations.createCheckpoint();
|
|
227
|
-
}
|
|
228
|
-
commitCheckpoint() {
|
|
229
|
-
return this.operations.commitCheckpoint();
|
|
230
|
-
}
|
|
231
|
-
revertCheckpoint() {
|
|
232
|
-
return this.operations.revertCheckpoint();
|
|
233
|
-
}
|
|
234
|
-
appendLeaves(treeId, leaves) {
|
|
235
|
-
return this.operations.appendLeaves(treeId, leaves);
|
|
236
|
-
}
|
|
237
|
-
updateArchive(header) {
|
|
238
|
-
return this.operations.updateArchive(header);
|
|
239
|
-
}
|
|
240
|
-
batchInsert(treeId, leaves, subtreeHeight) {
|
|
241
|
-
return this.operations.batchInsert(treeId, leaves, subtreeHeight);
|
|
242
|
-
}
|
|
243
|
-
sequentialInsert(treeId, leaves) {
|
|
244
|
-
return this.operations.sequentialInsert(treeId, leaves);
|
|
245
|
-
}
|
|
246
|
-
close() {
|
|
247
|
-
return this.operations.close();
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
/**
|
|
251
|
-
* A class that provides access to the merkle trees, and other helper methods.
|
|
252
|
-
*/ export class PublicTreesDB extends ForwardMerkleTree {
|
|
253
|
-
logger = createLogger('simulator:public-trees-db');
|
|
188
|
+
* This class is just a helper wrapper around a merkle db. Anything that you can do with it
|
|
189
|
+
* can also be done directly with the merkle db. This class should NOT be exposed or used
|
|
190
|
+
* outside of `simulator/src/public`.
|
|
191
|
+
*
|
|
192
|
+
* NOTE: This class is currently written in such a way that it would generate the
|
|
193
|
+
* necessary hints if used with a hinting merkle db. This is a bit of a leak of concepts.
|
|
194
|
+
* Eventually we can have everything depend on a config/factory at the TxSimulator level
|
|
195
|
+
* to decide whether to use hints or not (same with tracing, etc).
|
|
196
|
+
*/ export class PublicTreesDB {
|
|
197
|
+
db;
|
|
198
|
+
logger;
|
|
254
199
|
constructor(db){
|
|
255
|
-
|
|
200
|
+
this.db = db;
|
|
201
|
+
this.logger = createLogger('simulator:public-trees-db');
|
|
256
202
|
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
* @param contract - Owner of the storage.
|
|
260
|
-
* @param slot - Slot to read in the contract storage.
|
|
261
|
-
* @returns The current value in the storage slot.
|
|
262
|
-
*/ async storageRead(contract, slot) {
|
|
203
|
+
async storageRead(contract, slot) {
|
|
204
|
+
const timer = new Timer();
|
|
263
205
|
const leafSlot = (await computePublicDataTreeLeafSlot(contract, slot)).toBigInt();
|
|
264
|
-
const lowLeafResult = await this.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot);
|
|
206
|
+
const lowLeafResult = await this.db.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot);
|
|
265
207
|
if (!lowLeafResult) {
|
|
266
208
|
throw new Error('Low leaf not found');
|
|
267
209
|
}
|
|
268
|
-
// TODO
|
|
269
|
-
await this.getSiblingPath(MerkleTreeId.PUBLIC_DATA_TREE, lowLeafResult.index);
|
|
210
|
+
// TODO: We need this for the hints. See class comment for more details.
|
|
211
|
+
await this.db.getSiblingPath(MerkleTreeId.PUBLIC_DATA_TREE, lowLeafResult.index);
|
|
270
212
|
// Unconditionally fetching the preimage for the hints. Move it to the hinting layer?
|
|
271
|
-
const preimage = await this.getLeafPreimage(MerkleTreeId.PUBLIC_DATA_TREE, lowLeafResult.index);
|
|
272
|
-
|
|
213
|
+
const preimage = await this.db.getLeafPreimage(MerkleTreeId.PUBLIC_DATA_TREE, lowLeafResult.index);
|
|
214
|
+
const result = lowLeafResult.alreadyPresent ? preimage.leaf.value : Fr.ZERO;
|
|
215
|
+
this.logger.debug(`Storage read (contract=${contract}, slot=${slot}, value=${result})`, {
|
|
216
|
+
eventName: 'public-db-access',
|
|
217
|
+
duration: timer.ms(),
|
|
218
|
+
operation: 'storage-read'
|
|
219
|
+
});
|
|
220
|
+
return result;
|
|
273
221
|
}
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
* @param contract - Owner of the storage.
|
|
277
|
-
* @param slot - Slot to read in the contract storage.
|
|
278
|
-
* @param newValue - The new value to store.
|
|
279
|
-
* @returns The slot of the written leaf in the public data tree.
|
|
280
|
-
*/ async storageWrite(contract, slot, newValue) {
|
|
222
|
+
async storageWrite(contract, slot, newValue) {
|
|
223
|
+
const timer = new Timer();
|
|
281
224
|
const leafSlot = await computePublicDataTreeLeafSlot(contract, slot);
|
|
282
225
|
const publicDataWrite = new PublicDataWrite(leafSlot, newValue);
|
|
283
|
-
await this.sequentialInsert(MerkleTreeId.PUBLIC_DATA_TREE, [
|
|
226
|
+
await this.db.sequentialInsert(MerkleTreeId.PUBLIC_DATA_TREE, [
|
|
284
227
|
publicDataWrite.toBuffer()
|
|
285
228
|
]);
|
|
229
|
+
this.logger.debug(`Storage write (contract=${contract}, slot=${slot}, value=${newValue})`, {
|
|
230
|
+
eventName: 'public-db-access',
|
|
231
|
+
duration: timer.ms(),
|
|
232
|
+
operation: 'storage-write'
|
|
233
|
+
});
|
|
286
234
|
}
|
|
287
235
|
async getL1ToL2LeafValue(leafIndex) {
|
|
288
236
|
const timer = new Timer();
|
|
289
|
-
const leafValue = await this.getLeafValue(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, leafIndex);
|
|
290
|
-
// TODO
|
|
291
|
-
await this.getSiblingPath(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, leafIndex);
|
|
292
|
-
this.logger.debug(`
|
|
237
|
+
const leafValue = await this.db.getLeafValue(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, leafIndex);
|
|
238
|
+
// TODO: We need this for the hints. See class comment for more details.
|
|
239
|
+
await this.db.getSiblingPath(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, leafIndex);
|
|
240
|
+
this.logger.debug(`Fetched L1 to L2 message leaf value (leafIndex=${leafIndex}, value=${leafValue})`, {
|
|
293
241
|
eventName: 'public-db-access',
|
|
294
242
|
duration: timer.ms(),
|
|
295
243
|
operation: 'get-l1-to-l2-message-leaf-value'
|
|
@@ -298,50 +246,91 @@ import { TxContractCache } from './tx_contract_cache.js';
|
|
|
298
246
|
}
|
|
299
247
|
async getNoteHash(leafIndex) {
|
|
300
248
|
const timer = new Timer();
|
|
301
|
-
const leafValue = await this.getLeafValue(MerkleTreeId.NOTE_HASH_TREE, leafIndex);
|
|
302
|
-
// TODO
|
|
303
|
-
await this.getSiblingPath(MerkleTreeId.NOTE_HASH_TREE, leafIndex);
|
|
304
|
-
this.logger.debug(`
|
|
249
|
+
const leafValue = await this.db.getLeafValue(MerkleTreeId.NOTE_HASH_TREE, leafIndex);
|
|
250
|
+
// TODO: We need this for the hints. See class comment for more details.
|
|
251
|
+
await this.db.getSiblingPath(MerkleTreeId.NOTE_HASH_TREE, leafIndex);
|
|
252
|
+
this.logger.debug(`Fetched note hash leaf value (leafIndex=${leafIndex}, value=${leafValue})`, {
|
|
305
253
|
eventName: 'public-db-access',
|
|
306
254
|
duration: timer.ms(),
|
|
307
255
|
operation: 'get-note-hash'
|
|
308
256
|
});
|
|
309
257
|
return leafValue;
|
|
310
258
|
}
|
|
259
|
+
async writeNoteHash(noteHash) {
|
|
260
|
+
const timer = new Timer();
|
|
261
|
+
await this.db.appendLeaves(MerkleTreeId.NOTE_HASH_TREE, [
|
|
262
|
+
noteHash
|
|
263
|
+
]);
|
|
264
|
+
this.logger.debug(`Wrote note hash (noteHash=${noteHash})`, {
|
|
265
|
+
eventName: 'public-db-access',
|
|
266
|
+
duration: timer.ms(),
|
|
267
|
+
operation: 'write-note-hash'
|
|
268
|
+
});
|
|
269
|
+
}
|
|
311
270
|
async checkNullifierExists(nullifier) {
|
|
312
271
|
const timer = new Timer();
|
|
313
|
-
const lowLeafResult = await this.getPreviousValueIndex(MerkleTreeId.NULLIFIER_TREE, nullifier.toBigInt());
|
|
272
|
+
const lowLeafResult = await this.db.getPreviousValueIndex(MerkleTreeId.NULLIFIER_TREE, nullifier.toBigInt());
|
|
314
273
|
if (!lowLeafResult) {
|
|
315
274
|
throw new Error('Low leaf not found');
|
|
316
275
|
}
|
|
317
|
-
// TODO
|
|
318
|
-
await this.getSiblingPath(MerkleTreeId.NULLIFIER_TREE, lowLeafResult.index);
|
|
319
|
-
// TODO
|
|
320
|
-
await this.getLeafPreimage(MerkleTreeId.NULLIFIER_TREE, lowLeafResult.index);
|
|
276
|
+
// TODO: We need this for the hints. See class comment for more details.
|
|
277
|
+
await this.db.getSiblingPath(MerkleTreeId.NULLIFIER_TREE, lowLeafResult.index);
|
|
278
|
+
// TODO: We need this for the hints. See class comment for more details.
|
|
279
|
+
await this.db.getLeafPreimage(MerkleTreeId.NULLIFIER_TREE, lowLeafResult.index);
|
|
321
280
|
const exists = lowLeafResult.alreadyPresent;
|
|
322
|
-
this.logger.debug(`
|
|
281
|
+
this.logger.debug(`Checked nullifier exists (nullifier=${nullifier}, exists=${exists})`, {
|
|
323
282
|
eventName: 'public-db-access',
|
|
324
283
|
duration: timer.ms(),
|
|
325
284
|
operation: 'check-nullifier-exists'
|
|
326
285
|
});
|
|
327
286
|
return exists;
|
|
328
287
|
}
|
|
288
|
+
async writeNullifier(siloedNullifier) {
|
|
289
|
+
const timer = new Timer();
|
|
290
|
+
await this.db.sequentialInsert(MerkleTreeId.NULLIFIER_TREE, [
|
|
291
|
+
siloedNullifier.toBuffer()
|
|
292
|
+
]);
|
|
293
|
+
this.logger.debug(`Wrote nullifier (nullifier=${siloedNullifier})`, {
|
|
294
|
+
eventName: 'public-db-access',
|
|
295
|
+
duration: timer.ms(),
|
|
296
|
+
operation: 'write-nullifier'
|
|
297
|
+
});
|
|
298
|
+
}
|
|
329
299
|
async padTree(treeId, leavesToInsert) {
|
|
300
|
+
const timer = new Timer();
|
|
330
301
|
switch(treeId){
|
|
331
302
|
// Indexed trees.
|
|
332
303
|
case MerkleTreeId.NULLIFIER_TREE:
|
|
333
|
-
await this.batchInsert(treeId, Array(leavesToInsert).fill(NullifierLeaf.empty().toBuffer()), NULLIFIER_SUBTREE_HEIGHT);
|
|
304
|
+
await this.db.batchInsert(treeId, Array(leavesToInsert).fill(NullifierLeaf.empty().toBuffer()), NULLIFIER_SUBTREE_HEIGHT);
|
|
334
305
|
break;
|
|
335
306
|
case MerkleTreeId.PUBLIC_DATA_TREE:
|
|
336
|
-
await this.batchInsert(treeId, Array(leavesToInsert).fill(PublicDataTreeLeaf.empty().toBuffer()), PUBLIC_DATA_SUBTREE_HEIGHT);
|
|
307
|
+
await this.db.batchInsert(treeId, Array(leavesToInsert).fill(PublicDataTreeLeaf.empty().toBuffer()), PUBLIC_DATA_SUBTREE_HEIGHT);
|
|
337
308
|
break;
|
|
338
|
-
//
|
|
309
|
+
// Append-only trees.
|
|
339
310
|
case MerkleTreeId.L1_TO_L2_MESSAGE_TREE:
|
|
340
311
|
case MerkleTreeId.NOTE_HASH_TREE:
|
|
341
|
-
await this.appendLeaves(treeId, Array(leavesToInsert).fill(Fr.ZERO));
|
|
312
|
+
await this.db.appendLeaves(treeId, Array(leavesToInsert).fill(Fr.ZERO));
|
|
342
313
|
break;
|
|
343
314
|
default:
|
|
344
315
|
throw new Error(`Padding not supported for tree ${treeId}`);
|
|
345
316
|
}
|
|
317
|
+
this.logger.debug(`Padded tree (tree=${getTreeName(treeId)}, leavesToInsert=${leavesToInsert})`, {
|
|
318
|
+
eventName: 'public-db-access',
|
|
319
|
+
duration: timer.ms(),
|
|
320
|
+
operation: 'pad-tree'
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
async createCheckpoint() {
|
|
324
|
+
await this.db.createCheckpoint();
|
|
325
|
+
}
|
|
326
|
+
async commitCheckpoint() {
|
|
327
|
+
await this.db.commitCheckpoint();
|
|
328
|
+
}
|
|
329
|
+
async revertCheckpoint() {
|
|
330
|
+
await this.db.revertCheckpoint();
|
|
331
|
+
}
|
|
332
|
+
async getTreeSnapshots() {
|
|
333
|
+
const stateReference = await this.db.getStateReference();
|
|
334
|
+
return new TreeSnapshots(stateReference.l1ToL2MessageTree, stateReference.partial.noteHashTree, stateReference.partial.nullifierTree, stateReference.partial.publicDataTree);
|
|
346
335
|
}
|
|
347
336
|
}
|
|
@@ -6,7 +6,7 @@ import { Gas } from '@aztec/stdlib/gas';
|
|
|
6
6
|
import type { MerkleTreeWriteOperations } from '@aztec/stdlib/interfaces/server';
|
|
7
7
|
import { type FailedTx, GlobalVariables, NestedProcessReturnValues, type ProcessedTx, Tx, type TxValidator } from '@aztec/stdlib/tx';
|
|
8
8
|
import { type TelemetryClient, type Traceable, type Tracer } from '@aztec/telemetry-client';
|
|
9
|
-
import { PublicContractsDB
|
|
9
|
+
import { PublicContractsDB } from '../public_db_sources.js';
|
|
10
10
|
import { type PublicTxSimulator } from '../public_tx_simulator/index.js';
|
|
11
11
|
/**
|
|
12
12
|
* Creates new instances of PublicProcessor given the provided merkle tree db and contract data source.
|
|
@@ -14,7 +14,7 @@ import { type PublicTxSimulator } from '../public_tx_simulator/index.js';
|
|
|
14
14
|
export declare class PublicProcessorFactory {
|
|
15
15
|
private contractDataSource;
|
|
16
16
|
private dateProvider;
|
|
17
|
-
|
|
17
|
+
protected telemetryClient: TelemetryClient;
|
|
18
18
|
constructor(contractDataSource: ContractDataSource, dateProvider: DateProvider, telemetryClient?: TelemetryClient);
|
|
19
19
|
/**
|
|
20
20
|
* Creates a new instance of a PublicProcessor.
|
|
@@ -24,7 +24,7 @@ export declare class PublicProcessorFactory {
|
|
|
24
24
|
* @returns A new instance of a PublicProcessor.
|
|
25
25
|
*/
|
|
26
26
|
create(merkleTree: MerkleTreeWriteOperations, globalVariables: GlobalVariables, skipFeeEnforcement: boolean): PublicProcessor;
|
|
27
|
-
protected createPublicTxSimulator(
|
|
27
|
+
protected createPublicTxSimulator(merkleTree: MerkleTreeWriteOperations, contractsDB: PublicContractsDB, globalVariables: GlobalVariables, doMerkleOperations: boolean, skipFeeEnforcement: boolean): PublicTxSimulator;
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
30
|
* Converts Txs lifted from the P2P module into ProcessedTx objects by executing
|
|
@@ -32,13 +32,13 @@ export declare class PublicProcessorFactory {
|
|
|
32
32
|
*/
|
|
33
33
|
export declare class PublicProcessor implements Traceable {
|
|
34
34
|
protected globalVariables: GlobalVariables;
|
|
35
|
-
|
|
35
|
+
private merkleTree;
|
|
36
36
|
protected contractsDB: PublicContractsDB;
|
|
37
37
|
protected publicTxSimulator: PublicTxSimulator;
|
|
38
38
|
private dateProvider;
|
|
39
39
|
private log;
|
|
40
40
|
private metrics;
|
|
41
|
-
constructor(globalVariables: GlobalVariables,
|
|
41
|
+
constructor(globalVariables: GlobalVariables, merkleTree: MerkleTreeWriteOperations, contractsDB: PublicContractsDB, publicTxSimulator: PublicTxSimulator, dateProvider: DateProvider, telemetryClient?: TelemetryClient, log?: import("@aztec/foundation/log").Logger);
|
|
42
42
|
get tracer(): Tracer;
|
|
43
43
|
/**
|
|
44
44
|
* Run each tx through the public circuit and the public kernel circuit if needed.
|
|
@@ -67,7 +67,7 @@ export declare class PublicProcessor implements Traceable {
|
|
|
67
67
|
* This is used in private only txs, since for txs with public calls
|
|
68
68
|
* the avm handles the fee payment itself.
|
|
69
69
|
*/
|
|
70
|
-
private
|
|
70
|
+
private performFeePaymentPublicDataWrite;
|
|
71
71
|
private processPrivateOnlyTx;
|
|
72
72
|
private processTxWithPublicCalls;
|
|
73
73
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public_processor.d.ts","sourceRoot":"","sources":["../../../src/public/public_processor/public_processor.ts"],"names":[],"mappings":";;AAIA,OAAO,EAAE,KAAK,YAAY,EAAkC,MAAM,yBAAyB,CAAC;AAM5F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACxC,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAEjF,OAAO,EACL,KAAK,QAAQ,EACb,eAAe,EACf,yBAAyB,EACzB,KAAK,WAAW,EAChB,EAAE,EAEF,KAAK,WAAW,EAGjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,KAAK,MAAM,EAGZ,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"public_processor.d.ts","sourceRoot":"","sources":["../../../src/public/public_processor/public_processor.ts"],"names":[],"mappings":";;AAIA,OAAO,EAAE,KAAK,YAAY,EAAkC,MAAM,yBAAyB,CAAC;AAM5F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACxC,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAEjF,OAAO,EACL,KAAK,QAAQ,EACb,eAAe,EACf,yBAAyB,EACzB,KAAK,WAAW,EAChB,EAAE,EAEF,KAAK,WAAW,EAGjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,KAAK,MAAM,EAGZ,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,iBAAiB,EAAiB,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,KAAK,iBAAiB,EAA8B,MAAM,iCAAiC,CAAC;AAGrG;;GAEG;AACH,qBAAa,sBAAsB;IAE/B,OAAO,CAAC,kBAAkB;IAC1B,OAAO,CAAC,YAAY;IACpB,SAAS,CAAC,eAAe,EAAE,eAAe;gBAFlC,kBAAkB,EAAE,kBAAkB,EACtC,YA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,MAAM,EAAE,KAAK,IAAI,CAAA;SAAE,CAAC;KAC/D,GACL,OAAO,CAAC,CAAC,WAAW,EAAE,EAAE,QAAQ,EAAE,EAAE,yBAAyB,EAAE,CAAC,CAAC;YA4ItD,SAAS;YA2BT,gCAAgC;IAoC9C,kFAAkF;YACpE,uBAAuB;IA+BrC;;;;OAIG;YACW,gCAAgC;YA0BhC,oBAAoB;YAsCpB,wBAAwB;CA8CvC"}
|
|
@@ -39,13 +39,12 @@ import { PublicProcessorMetrics } from './public_processor_metrics.js';
|
|
|
39
39
|
* @param skipFeeEnforcement - Allows disabling balance checks for fee estimations.
|
|
40
40
|
* @returns A new instance of a PublicProcessor.
|
|
41
41
|
*/ create(merkleTree, globalVariables, skipFeeEnforcement) {
|
|
42
|
-
const treesDB = new PublicTreesDB(merkleTree);
|
|
43
42
|
const contractsDB = new PublicContractsDB(this.contractDataSource);
|
|
44
|
-
const publicTxSimulator = this.createPublicTxSimulator(
|
|
45
|
-
return new PublicProcessor(globalVariables,
|
|
43
|
+
const publicTxSimulator = this.createPublicTxSimulator(merkleTree, contractsDB, globalVariables, /*doMerkleOperations=*/ true, skipFeeEnforcement);
|
|
44
|
+
return new PublicProcessor(globalVariables, merkleTree, contractsDB, publicTxSimulator, this.dateProvider, this.telemetryClient);
|
|
46
45
|
}
|
|
47
|
-
createPublicTxSimulator(
|
|
48
|
-
return new TelemetryPublicTxSimulator(
|
|
46
|
+
createPublicTxSimulator(merkleTree, contractsDB, globalVariables, doMerkleOperations, skipFeeEnforcement) {
|
|
47
|
+
return new TelemetryPublicTxSimulator(merkleTree, contractsDB, globalVariables, doMerkleOperations, skipFeeEnforcement, this.telemetryClient);
|
|
49
48
|
}
|
|
50
49
|
}
|
|
51
50
|
class PublicProcessorTimeoutError extends Error {
|
|
@@ -59,15 +58,15 @@ class PublicProcessorTimeoutError extends Error {
|
|
|
59
58
|
* any public function calls in them. Txs with private calls only are unaffected.
|
|
60
59
|
*/ export class PublicProcessor {
|
|
61
60
|
globalVariables;
|
|
62
|
-
|
|
61
|
+
merkleTree;
|
|
63
62
|
contractsDB;
|
|
64
63
|
publicTxSimulator;
|
|
65
64
|
dateProvider;
|
|
66
65
|
log;
|
|
67
66
|
metrics;
|
|
68
|
-
constructor(globalVariables,
|
|
67
|
+
constructor(globalVariables, merkleTree, contractsDB, publicTxSimulator, dateProvider, telemetryClient = getTelemetryClient(), log = createLogger('simulator:public-processor')){
|
|
69
68
|
this.globalVariables = globalVariables;
|
|
70
|
-
this.
|
|
69
|
+
this.merkleTree = merkleTree;
|
|
71
70
|
this.contractsDB = contractsDB;
|
|
72
71
|
this.publicTxSimulator = publicTxSimulator;
|
|
73
72
|
this.dateProvider = dateProvider;
|
|
@@ -154,7 +153,7 @@ class PublicProcessorTimeoutError extends Error {
|
|
|
154
153
|
// We checkpoint the transaction here, then within the try/catch we
|
|
155
154
|
// 1. Revert the checkpoint if the tx fails or needs to be discarded for any reason
|
|
156
155
|
// 2. Commit the transaction in the finally block. Note that by using the ForkCheckpoint lifecycle only the first commit/revert takes effect
|
|
157
|
-
const checkpoint = await ForkCheckpoint.new(this.
|
|
156
|
+
const checkpoint = await ForkCheckpoint.new(this.merkleTree);
|
|
158
157
|
try {
|
|
159
158
|
const [processedTx, returnValues] = await this.processTx(tx, deadline);
|
|
160
159
|
// If the actual size of this tx would exceed block size, skip it
|
|
@@ -170,15 +169,8 @@ class PublicProcessorTimeoutError extends Error {
|
|
|
170
169
|
await checkpoint.revert();
|
|
171
170
|
continue;
|
|
172
171
|
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
// When there are public calls, the PublicTxSimulator & AVM handle tree insertions.
|
|
176
|
-
await this.doTreeInsertionsForPrivateOnlyTx(processedTx);
|
|
177
|
-
// Add any contracts registered/deployed in this private-only tx to the block-level cache
|
|
178
|
-
// (add to tx-level cache and then commit to block-level cache)
|
|
179
|
-
await this.contractsDB.addNewContracts(tx);
|
|
180
|
-
this.contractsDB.commitContractsForTx();
|
|
181
|
-
}
|
|
172
|
+
// FIXME(fcarreiro): it's ugly to have to notify the validator of nullifiers.
|
|
173
|
+
// I'd rather pass the validators the processedTx as well and let them deal with it.
|
|
182
174
|
nullifierCache?.addNullifiers(processedTx.txEffect.nullifiers.map((n)=>n.toBuffer()));
|
|
183
175
|
result.push(processedTx);
|
|
184
176
|
returns = returns.concat(returnValues);
|
|
@@ -252,9 +244,9 @@ class PublicProcessorTimeoutError extends Error {
|
|
|
252
244
|
// b) always had a txHandler with the same db passed to it as this.db, which updated the db in buildBaseRollupHints in this loop
|
|
253
245
|
// To see how this ^ happens, move back to one shared db in test_context and run orchestrator_multi_public_functions.test.ts
|
|
254
246
|
// The below is taken from buildBaseRollupHints:
|
|
255
|
-
await this.
|
|
247
|
+
await this.merkleTree.appendLeaves(MerkleTreeId.NOTE_HASH_TREE, padArrayEnd(processedTx.txEffect.noteHashes, Fr.ZERO, MAX_NOTE_HASHES_PER_TX));
|
|
256
248
|
try {
|
|
257
|
-
await this.
|
|
249
|
+
await this.merkleTree.batchInsert(MerkleTreeId.NULLIFIER_TREE, padArrayEnd(processedTx.txEffect.nullifiers, Fr.ZERO, MAX_NULLIFIERS_PER_TX).map((n)=>n.toBuffer()), NULLIFIER_SUBTREE_HEIGHT);
|
|
258
250
|
} catch (error) {
|
|
259
251
|
if (txValidator) {
|
|
260
252
|
// Ideally the validator has already caught this above, but just in case:
|
|
@@ -264,8 +256,6 @@ class PublicProcessorTimeoutError extends Error {
|
|
|
264
256
|
this.log.warn(`Detected duplicate nullifier after public processing for: ${processedTx.hash}.`);
|
|
265
257
|
}
|
|
266
258
|
}
|
|
267
|
-
// The only public data write should be for fee payment
|
|
268
|
-
await this.treesDB.sequentialInsert(MerkleTreeId.PUBLIC_DATA_TREE, processedTx.txEffect.publicDataWrites.map((x)=>x.toBuffer()));
|
|
269
259
|
const treeInsertionEnd = process.hrtime.bigint();
|
|
270
260
|
this.metrics.recordTreeInsertions(Number(treeInsertionEnd - treeInsertionStart) / 1_000);
|
|
271
261
|
}
|
|
@@ -290,26 +280,34 @@ class PublicProcessorTimeoutError extends Error {
|
|
|
290
280
|
* Creates the public data write for paying the tx fee.
|
|
291
281
|
* This is used in private only txs, since for txs with public calls
|
|
292
282
|
* the avm handles the fee payment itself.
|
|
293
|
-
*/ async
|
|
283
|
+
*/ async performFeePaymentPublicDataWrite(txFee, feePayer) {
|
|
294
284
|
const feeJuiceAddress = ProtocolContractAddress.FeeJuice;
|
|
295
285
|
const balanceSlot = await computeFeePayerBalanceStorageSlot(feePayer);
|
|
296
286
|
const leafSlot = await computeFeePayerBalanceLeafSlot(feePayer);
|
|
287
|
+
// This high-level db is used as a convenient helper. It could be done with the merkleTree directly.
|
|
288
|
+
const treesDB = new PublicTreesDB(this.merkleTree);
|
|
297
289
|
this.log.debug(`Deducting ${txFee.toBigInt()} balance in Fee Juice for ${feePayer}`);
|
|
298
|
-
const balance = await
|
|
290
|
+
const balance = await treesDB.storageRead(feeJuiceAddress, balanceSlot);
|
|
299
291
|
if (balance.lt(txFee)) {
|
|
300
292
|
throw new Error(`Not enough balance for fee payer to pay for transaction (got ${balance.toBigInt()} needs ${txFee.toBigInt()})`);
|
|
301
293
|
}
|
|
302
294
|
const updatedBalance = balance.sub(txFee);
|
|
303
|
-
await
|
|
295
|
+
await treesDB.storageWrite(feeJuiceAddress, balanceSlot, updatedBalance);
|
|
304
296
|
return new PublicDataWrite(leafSlot, updatedBalance);
|
|
305
297
|
}
|
|
306
298
|
async processPrivateOnlyTx(tx) {
|
|
307
299
|
const gasFees = this.globalVariables.gasFees;
|
|
308
300
|
const transactionFee = tx.data.gasUsed.computeFee(gasFees);
|
|
309
|
-
const feePaymentPublicDataWrite = await this.
|
|
301
|
+
const feePaymentPublicDataWrite = await this.performFeePaymentPublicDataWrite(transactionFee, tx.data.feePayer);
|
|
310
302
|
const processedTx = await makeProcessedTxFromPrivateOnlyTx(tx, transactionFee, feePaymentPublicDataWrite, this.globalVariables);
|
|
311
303
|
const siloedContractClassLogs = await tx.filterContractClassLogs(tx.data.getNonEmptyContractClassLogsHashes(), true);
|
|
312
304
|
this.metrics.recordClassRegistration(...siloedContractClassLogs.filter((log)=>ContractClassRegisteredEvent.isContractClassRegisteredEvent(log)).map((log)=>ContractClassRegisteredEvent.fromLog(log)));
|
|
305
|
+
// Fee payment insertion has already been done. Do the rest.
|
|
306
|
+
await this.doTreeInsertionsForPrivateOnlyTx(processedTx);
|
|
307
|
+
// Add any contracts registered/deployed in this private-only tx to the block-level cache
|
|
308
|
+
// (add to tx-level cache and then commit to block-level cache)
|
|
309
|
+
await this.contractsDB.addNewContracts(tx);
|
|
310
|
+
this.contractsDB.commitContractsForTx();
|
|
313
311
|
return [
|
|
314
312
|
processedTx,
|
|
315
313
|
undefined
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { Fr } from '@aztec/foundation/fields';
|
|
2
2
|
import type { Gas } from '@aztec/stdlib/gas';
|
|
3
|
+
import type { MerkleTreeWriteOperations } from '@aztec/stdlib/trees';
|
|
3
4
|
import { type GlobalVariables, PublicCallRequestWithCalldata, Tx, TxExecutionPhase } from '@aztec/stdlib/tx';
|
|
4
5
|
import type { AvmFinalizedCallResult } from '../avm/avm_contract_call_result.js';
|
|
5
6
|
import type { ExecutorMetricsInterface } from '../executor_metrics_interface.js';
|
|
6
|
-
import type { PublicContractsDB
|
|
7
|
+
import type { PublicContractsDB } from '../public_db_sources.js';
|
|
7
8
|
import type { PublicPersistableStateManager } from '../state_manager/state_manager.js';
|
|
8
9
|
import { PublicTxContext } from './public_tx_context.js';
|
|
9
10
|
import { type ProcessedPhase, type PublicTxResult, PublicTxSimulator } from './public_tx_simulator.js';
|
|
@@ -12,7 +13,7 @@ import { type ProcessedPhase, type PublicTxResult, PublicTxSimulator } from './p
|
|
|
12
13
|
*/
|
|
13
14
|
export declare class MeasuredPublicTxSimulator extends PublicTxSimulator {
|
|
14
15
|
protected readonly metrics: ExecutorMetricsInterface;
|
|
15
|
-
constructor(
|
|
16
|
+
constructor(merkleTree: MerkleTreeWriteOperations, contractsDB: PublicContractsDB, globalVariables: GlobalVariables, doMerkleOperations: boolean | undefined, skipFeeEnforcement: boolean | undefined, metrics: ExecutorMetricsInterface);
|
|
16
17
|
simulate(tx: Tx, txLabel?: string): Promise<PublicTxResult>;
|
|
17
18
|
protected computeTxHash(tx: Tx): Promise<import("@aztec/stdlib/tx").TxHash>;
|
|
18
19
|
protected insertNonRevertiblesFromPrivate(context: PublicTxContext, tx: Tx): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"measured_public_tx_simulator.d.ts","sourceRoot":"","sources":["../../../src/public/public_tx_simulator/measured_public_tx_simulator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAEnD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,EAAE,KAAK,eAAe,EAAE,6BAA6B,EAAE,EAAE,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAE7G,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AACjF,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AACjF,OAAO,KAAK,EAAE,iBAAiB,EAAE,
|
|
1
|
+
{"version":3,"file":"measured_public_tx_simulator.d.ts","sourceRoot":"","sources":["../../../src/public/public_tx_simulator/measured_public_tx_simulator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAEnD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EAAE,KAAK,eAAe,EAAE,6BAA6B,EAAE,EAAE,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAE7G,OAAO,KAAK,EAAE,sBAAsB,EAAE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A public tx simulator that tracks miscellaneous simulation metrics without telemetry.
|
|
5
5
|
*/ export class MeasuredPublicTxSimulator extends PublicTxSimulator {
|
|
6
6
|
metrics;
|
|
7
|
-
constructor(
|
|
8
|
-
super(
|
|
7
|
+
constructor(merkleTree, contractsDB, globalVariables, doMerkleOperations = false, skipFeeEnforcement = false, metrics){
|
|
8
|
+
super(merkleTree, contractsDB, globalVariables, doMerkleOperations, skipFeeEnforcement), this.metrics = metrics;
|
|
9
9
|
}
|
|
10
10
|
async simulate(tx, txLabel = 'unlabeledTx') {
|
|
11
11
|
this.metrics.startRecordingTxSimulation(txLabel);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
-
import { type AvmCircuitPublicInputs,
|
|
2
|
+
import { type AvmCircuitPublicInputs, RevertCode } from '@aztec/stdlib/avm';
|
|
3
3
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
4
|
import type { SimulationError } from '@aztec/stdlib/errors';
|
|
5
5
|
import { Gas } from '@aztec/stdlib/gas';
|
|
6
6
|
import { type PrivateToPublicAccumulatedData } from '@aztec/stdlib/kernel';
|
|
7
7
|
import { type GlobalVariables, PublicCallRequestWithCalldata, type Tx, TxExecutionPhase, type TxHash } from '@aztec/stdlib/tx';
|
|
8
|
-
import type { PublicContractsDBInterface } from '
|
|
8
|
+
import type { PublicContractsDBInterface } from '../db_interfaces.js';
|
|
9
9
|
import type { PublicTreesDB } from '../public_db_sources.js';
|
|
10
10
|
import { PublicPersistableStateManager } from '../state_manager/state_manager.js';
|
|
11
11
|
/**
|
|
@@ -14,8 +14,8 @@ import { PublicPersistableStateManager } from '../state_manager/state_manager.js
|
|
|
14
14
|
export declare class PublicTxContext {
|
|
15
15
|
readonly txHash: TxHash;
|
|
16
16
|
readonly state: PhaseStateManager;
|
|
17
|
+
private readonly startTreeSnapshots;
|
|
17
18
|
private readonly globalVariables;
|
|
18
|
-
private readonly startStateReference;
|
|
19
19
|
private readonly gasSettings;
|
|
20
20
|
private readonly gasUsedByPrivate;
|
|
21
21
|
private readonly gasAllocatedToPublic;
|
|
@@ -26,7 +26,6 @@ export declare class PublicTxContext {
|
|
|
26
26
|
readonly revertibleAccumulatedDataFromPrivate: PrivateToPublicAccumulatedData;
|
|
27
27
|
readonly feePayer: AztecAddress;
|
|
28
28
|
private readonly trace;
|
|
29
|
-
readonly hints: AvmExecutionHints;
|
|
30
29
|
private log;
|
|
31
30
|
private gasUsedByPublic;
|
|
32
31
|
teardownGasUsed: Gas;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public_tx_context.d.ts","sourceRoot":"","sources":["../../../src/public/public_tx_simulator/public_tx_context.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAG9C,OAAO,
|
|
1
|
+
{"version":3,"file":"public_tx_context.d.ts","sourceRoot":"","sources":["../../../src/public/public_tx_simulator/public_tx_context.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAG9C,OAAO,EAAE,KAAK,sBAAsB,EAAmB,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC7F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,OAAO,EAAE,GAAG,EAAe,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAGL,KAAK,8BAA8B,EAIpC,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,KAAK,eAAe,EACpB,6BAA6B,EAE7B,KAAK,EAAE,EACP,gBAAgB,EAChB,KAAK,MAAM,EACZ,MAAM,kBAAkB,CAAC;AAK1B,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAE7D,OAAO,EAAE,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