Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
simulation_helper.cpp
Go to the documentation of this file.
2
3#include <cstdint>
4
10
23
24// Events.
48
49// Gadgets.
77
78// Standalone.
94
95namespace bb::avm2 {
96
97using namespace bb::avm2::simulation;
98
99namespace {
100
101PublicTxEffect extract_public_tx_effect(const TxExecutionResult& tx_execution_result,
103{
104 PublicTxEffect public_tx_effect;
105 const auto& side_effects = side_effect_tracker.get_side_effects();
106 public_tx_effect.transaction_fee = tx_execution_result.transaction_fee;
107 public_tx_effect.note_hashes = side_effects.note_hashes;
108 public_tx_effect.nullifiers = side_effects.nullifiers;
109 public_tx_effect.l2_to_l1_msgs = side_effects.l2_to_l1_messages;
110 public_tx_effect.public_logs = side_effects.public_logs.to_logs();
111
112 // We need to copy the storage writes slot to value in the order of the slots by insertion.
113 for (uint32_t i = 0; i < side_effects.storage_writes_slots_by_insertion.size(); i++) {
114 const auto& slot = side_effects.storage_writes_slots_by_insertion.at(i);
115 const auto& value = side_effects.storage_writes_slot_to_value.at(slot);
116 public_tx_effect.public_data_writes.push_back(PublicDataWrite{ .leaf_slot = slot, .value = value });
117 }
118
119 return public_tx_effect;
120}
121
122} // namespace
123
124// Internal helper function for event-generating simulation (with full gadgets).
125// NOTE: Some of the config parameters are ignored in this function.
126template <template <typename> class DefaultEventEmitter, template <typename> class DefaultDeduplicatingEventEmitter>
128 ContractDBInterface& raw_contract_db,
129 LowLevelMerkleDBInterface& raw_merkle_db,
130 const PublicSimulatorConfig& config,
131 const Tx& tx,
132 const GlobalVariables& global_variables,
133 const ProtocolContracts& protocol_contracts)
134{
135 BB_BENCH_NAME("AvmSimulationHelper::simulate_for_witgen_internal");
136
137 DefaultEventEmitter<ExecutionEvent> execution_emitter;
138 DefaultDeduplicatingEventEmitter<AluEvent> alu_emitter;
139 DefaultDeduplicatingEventEmitter<BitwiseEvent> bitwise_emitter;
140 DefaultEventEmitter<DataCopyEvent> data_copy_emitter;
141 DefaultEventEmitter<MemoryEvent> memory_emitter;
142 DefaultEventEmitter<BytecodeRetrievalEvent> bytecode_retrieval_emitter;
143 DefaultEventEmitter<BytecodeHashingEvent> bytecode_hashing_emitter;
144 DefaultEventEmitter<BytecodeDecompositionEvent> bytecode_decomposition_emitter;
145 DefaultDeduplicatingEventEmitter<InstructionFetchingEvent> instruction_fetching_emitter;
146 DefaultEventEmitter<AddressDerivationEvent> address_derivation_emitter;
147 DefaultEventEmitter<ClassIdDerivationEvent> class_id_derivation_emitter;
148 DefaultEventEmitter<SiloingEvent> siloing_emitter;
149 DefaultEventEmitter<Sha256CompressionEvent> sha256_compression_emitter;
150 DefaultEventEmitter<EccAddEvent> ecc_add_emitter;
151 DefaultEventEmitter<ScalarMulEvent> scalar_mul_emitter;
152 DefaultEventEmitter<EccAddMemoryEvent> ecc_add_memory_emitter;
153 DefaultEventEmitter<Poseidon2HashEvent> poseidon2_hash_emitter;
154 DefaultEventEmitter<Poseidon2PermutationEvent> poseidon2_perm_emitter;
155 DefaultEventEmitter<Poseidon2PermutationMemoryEvent> poseidon2_perm_mem_emitter;
156 DefaultEventEmitter<KeccakF1600Event> keccakf1600_emitter;
157 DefaultEventEmitter<ToRadixEvent> to_radix_emitter;
158 DefaultEventEmitter<ToRadixMemoryEvent> to_radix_memory_emitter;
159 DefaultDeduplicatingEventEmitter<FieldGreaterThanEvent> field_gt_emitter;
160 DefaultEventEmitter<MerkleCheckEvent> merkle_check_emitter;
161 DefaultDeduplicatingEventEmitter<RangeCheckEvent> range_check_emitter;
162 DefaultEventEmitter<ContextStackEvent> context_stack_emitter;
163 DefaultEventEmitter<PublicDataTreeCheckEvent> public_data_tree_check_emitter;
164 DefaultEventEmitter<UpdateCheckEvent> update_check_emitter;
165 DefaultEventEmitter<NullifierTreeCheckEvent> nullifier_tree_check_emitter;
166 DefaultEventEmitter<TxEvent> tx_event_emitter;
167 DefaultEventEmitter<CalldataEvent> calldata_emitter;
168 DefaultEventEmitter<InternalCallStackEvent> internal_call_stack_emitter;
169 DefaultEventEmitter<NoteHashTreeCheckEvent> note_hash_tree_check_emitter;
170 DefaultEventEmitter<WrittenPublicDataSlotsTreeCheckEvent> written_public_data_slots_tree_check_emitter;
171 DefaultDeduplicatingEventEmitter<GreaterThanEvent> greater_than_emitter;
172 DefaultEventEmitter<ContractInstanceRetrievalEvent> contract_instance_retrieval_emitter;
173 DefaultEventEmitter<GetContractInstanceEvent> get_contract_instance_emitter;
174 DefaultEventEmitter<L1ToL2MessageTreeCheckEvent> l1_to_l2_msg_tree_check_emitter;
175 DefaultEventEmitter<EmitUnencryptedLogEvent> emit_unencrypted_log_emitter;
176 DefaultEventEmitter<RetrievedBytecodesTreeCheckEvent> retrieved_bytecodes_tree_check_emitter;
177
181 GreaterThan greater_than(field_gt, range_check, greater_than_emitter);
182 ToRadix to_radix(execution_id_manager, greater_than, to_radix_emitter, to_radix_memory_emitter);
184 execution_id_manager, greater_than, poseidon2_hash_emitter, poseidon2_perm_emitter, poseidon2_perm_mem_emitter);
185 MerkleCheck merkle_check(poseidon2, merkle_check_emitter);
186 PublicDataTreeCheck public_data_tree_check(
187 poseidon2, merkle_check, field_gt, execution_id_manager, public_data_tree_check_emitter);
190 field_gt,
192 written_public_data_slots_tree_check_emitter);
194 poseidon2, merkle_check, field_gt, build_retrieved_bytecodes_tree(), retrieved_bytecodes_tree_check_emitter);
195 NullifierTreeCheck nullifier_tree_check(poseidon2, merkle_check, field_gt, nullifier_tree_check_emitter);
196
197 // The protocol requires at least one non-revertible nullifier in the transaction (used for uniqueness of note
198 // hashes).
199 if (tx.non_revertible_accumulated_data.nullifiers.empty()) {
200 throw std::runtime_error("Non-revertible nullifiers are empty in the transaction.");
201 }
202
204 tx.non_revertible_accumulated_data.nullifiers.at(0), poseidon2, merkle_check, note_hash_tree_check_emitter);
205 L1ToL2MessageTreeCheck l1_to_l2_msg_tree_check(merkle_check, l1_to_l2_msg_tree_check_emitter);
206 EmitUnencryptedLog emit_unencrypted_log_component(execution_id_manager, greater_than, emit_unencrypted_log_emitter);
208 Bitwise bitwise(bitwise_emitter);
209 Sha256 sha256(execution_id_manager, bitwise, greater_than, sha256_compression_emitter);
211
212 Ecc ecc(execution_id_manager, greater_than, to_radix, ecc_add_emitter, scalar_mul_emitter, ecc_add_memory_emitter);
213 AddressDerivation address_derivation(poseidon2, ecc, address_derivation_emitter);
214 ClassIdDerivation class_id_derivation(poseidon2, class_id_derivation_emitter);
215
216 ContractDB contract_db(raw_contract_db, address_derivation, class_id_derivation, protocol_contracts);
217
218 MerkleDB base_merkle_db(raw_merkle_db,
219 public_data_tree_check,
220 nullifier_tree_check,
223 l1_to_l2_msg_tree_check);
224 base_merkle_db.add_checkpoint_listener(note_hash_tree_check);
225 base_merkle_db.add_checkpoint_listener(nullifier_tree_check);
226 base_merkle_db.add_checkpoint_listener(public_data_tree_check);
227 // This one is only needed for events.
228 base_merkle_db.add_checkpoint_listener(emit_unencrypted_log_component);
229
230 // Side effect tracking is only strictly needed for logs and L2-to-L1 messages.
232
234 tx.non_revertible_accumulated_data.nullifiers.at(0), base_merkle_db, side_effect_tracker);
235
236 UpdateCheck update_check(poseidon2, range_check, greater_than, merkle_db, update_check_emitter, global_variables);
237
238 BytecodeHasher bytecode_hasher(poseidon2, bytecode_hashing_emitter);
239 Siloing siloing(siloing_emitter);
241
243 contract_db, merkle_db, update_check, field_gt, protocol_contracts, contract_instance_retrieval_emitter);
244
245 TxBytecodeManager bytecode_manager(contract_db,
246 merkle_db,
251 bytecode_retrieval_emitter,
252 bytecode_decomposition_emitter,
253 instruction_fetching_emitter);
255
256 MemoryProvider memory_provider(range_check, execution_id_manager, memory_emitter);
257 CalldataHashingProvider calldata_hashing_provider(poseidon2, calldata_emitter);
258 InternalCallStackManagerProvider internal_call_stack_manager_provider(internal_call_stack_emitter);
259 ContextProvider context_provider(bytecode_manager,
260 memory_provider,
261 calldata_hashing_provider,
262 internal_call_stack_manager_provider,
263 merkle_db,
267 global_variables);
269
270 // Create GetContractInstance opcode component
272 execution_id_manager, merkle_db, get_contract_instance_emitter, contract_instance_manager);
273
274 NoopDebugLogger debug_log_component;
280
282 bitwise,
283 data_copy,
284 poseidon2,
285 ecc,
286 to_radix,
287 sha256,
288 execution_components,
292 execution_emitter,
293 context_stack_emitter,
297 emit_unencrypted_log_component,
298 debug_log_component,
299 merkle_db,
301
305 merkle_db,
309 field_gt,
310 poseidon2,
313
315 public_inputs_builder.extract_inputs(tx, global_variables, protocol_contracts, config.prover_id, raw_merkle_db);
316
317 TxExecutionResult tx_execution_result = tx_execution.simulate(tx);
318
319 public_inputs_builder.extract_outputs(raw_merkle_db,
320 // TODO(MW): Use of billed_gas is a bit misleading - we want public + private
321 // - teardown, which is stored as billed gas here/in ts:
322 tx_execution_result.gas_used.billed_gas,
323 tx_execution_result.transaction_fee,
324 tx_execution_result.revert_code != RevertCode::OK,
325 side_effect_tracker.get_side_effects());
326
327 public_data_tree_check.generate_ff_gt_events_for_squashing(
328 side_effect_tracker.get_side_effects().storage_writes_slots_by_insertion);
329
330 EventsContainer events = {
331 tx_event_emitter.dump_events(),
332 execution_emitter.dump_events(),
333 alu_emitter.dump_events(),
334 bitwise_emitter.dump_events(),
335 memory_emitter.dump_events(),
336 bytecode_retrieval_emitter.dump_events(),
337 bytecode_hashing_emitter.dump_events(),
338 bytecode_decomposition_emitter.dump_events(),
339 instruction_fetching_emitter.dump_events(),
340 address_derivation_emitter.dump_events(),
341 class_id_derivation_emitter.dump_events(),
342 siloing_emitter.dump_events(),
343 sha256_compression_emitter.dump_events(),
344 ecc_add_emitter.dump_events(),
345 scalar_mul_emitter.dump_events(),
346 ecc_add_memory_emitter.dump_events(),
347 poseidon2_hash_emitter.dump_events(),
348 poseidon2_perm_emitter.dump_events(),
349 poseidon2_perm_mem_emitter.dump_events(),
350 keccakf1600_emitter.dump_events(),
351 to_radix_emitter.dump_events(),
352 to_radix_memory_emitter.dump_events(),
353 field_gt_emitter.dump_events(),
354 greater_than_emitter.dump_events(),
355 merkle_check_emitter.dump_events(),
356 range_check_emitter.dump_events(),
357 context_stack_emitter.dump_events(),
358 public_data_tree_check_emitter.dump_events(),
359 update_check_emitter.dump_events(),
360 nullifier_tree_check_emitter.dump_events(),
361 data_copy_emitter.dump_events(),
362 calldata_emitter.dump_events(),
363 internal_call_stack_emitter.dump_events(),
364 note_hash_tree_check_emitter.dump_events(),
365 written_public_data_slots_tree_check_emitter.dump_events(),
366 contract_instance_retrieval_emitter.dump_events(),
367 get_contract_instance_emitter.dump_events(),
368 l1_to_l2_msg_tree_check_emitter.dump_events(),
369 emit_unencrypted_log_emitter.dump_events(),
370 retrieved_bytecodes_tree_check_emitter.dump_events(),
371 };
372
373 TxSimulationResult tx_simulation_result = {
374 .gas_used = tx_execution_result.gas_used,
375 .revert_code = tx_execution_result.revert_code,
376 .public_tx_effect = extract_public_tx_effect(tx_execution_result, side_effect_tracker),
377 .call_stack_metadata = call_stack_metadata_collector->dump_call_stack_metadata(),
378 .logs = debug_log_component.dump_logs(),
379 .public_inputs =
381 };
382
383 return { std::move(events), std::move(tx_simulation_result) };
384}
385
386// Internal helper function for fast simulation.
388 LowLevelMerkleDBInterface& raw_merkle_db,
389 const PublicSimulatorConfig& config,
390 const Tx& tx,
391 const GlobalVariables& global_variables,
392 const ProtocolContracts& protocol_contracts,
393 CancellationTokenPtr cancellation_token)
394{
395 BB_BENCH_NAME("AvmSimulationHelper::simulate_fast_internal");
396
397 NoopEventEmitter<ExecutionEvent> execution_emitter;
398 NoopEventEmitter<DataCopyEvent> data_copy_emitter;
399 NoopEventEmitter<EccAddEvent> ecc_add_emitter;
400 NoopEventEmitter<ScalarMulEvent> scalar_mul_emitter;
401 NoopEventEmitter<EccAddMemoryEvent> ecc_add_memory_emitter;
403 NoopEventEmitter<MerkleCheckEvent> merkle_check_emitter;
405 NoopEventEmitter<ContextStackEvent> context_stack_emitter;
407 NoopEventEmitter<CalldataEvent> calldata_emitter;
408 NoopEventEmitter<InternalCallStackEvent> internal_call_stack_emitter;
409 NoopEventEmitter<ContractInstanceRetrievalEvent> contract_instance_retrieval_emitter;
410 NoopEventEmitter<GetContractInstanceEvent> get_contract_instance_emitter;
411 NoopEventEmitter<EmitUnencryptedLogEvent> emit_unencrypted_log_emitter;
412 NoopEventEmitter<RetrievedBytecodesTreeCheckEvent> retrieved_bytecodes_tree_check_emitter;
413 NoopEventEmitter<UpdateCheckEvent> update_check_emitter;
414
421 MerkleCheck merkle_check(poseidon2, merkle_check_emitter);
424 poseidon2, merkle_check, field_gt, build_retrieved_bytecodes_tree(), retrieved_bytecodes_tree_check_emitter);
425 EmitUnencryptedLog emit_unencrypted_log_component(execution_id_manager, greater_than, emit_unencrypted_log_emitter);
426 PureAlu alu;
430
431 Ecc ecc(execution_id_manager, greater_than, to_radix, ecc_add_emitter, scalar_mul_emitter, ecc_add_memory_emitter);
432
434 PureContractDB contract_db(raw_contract_db);
435
436 // The protocol requires at least one non-revertible nullifier in the transaction (used for uniqueness of note
437 // hashes).
438 if (tx.non_revertible_accumulated_data.nullifiers.empty()) {
439 throw std::runtime_error("Non-revertible nullifiers are empty in the transaction.");
440 }
441
443 tx.non_revertible_accumulated_data.nullifiers.at(0), raw_merkle_db, written_public_data_slots_tree_check);
445
446 tx.non_revertible_accumulated_data.nullifiers.at(0), base_merkle_db, side_effect_tracker);
447
450
452 contract_db, merkle_db, update_check, field_gt, protocol_contracts, contract_instance_retrieval_emitter);
454
456
457 PureMemoryProvider memory_provider;
458 CalldataHashingProvider calldata_hashing_provider(poseidon2, calldata_emitter);
459 InternalCallStackManagerProvider internal_call_stack_manager_provider(internal_call_stack_emitter);
460 ContextProvider context_provider(tx_bytecode_manager,
461 memory_provider,
462 calldata_hashing_provider,
463 internal_call_stack_manager_provider,
464 merkle_db,
468 global_variables);
470
471 // Create GetContractInstance opcode component
473 execution_id_manager, merkle_db, get_contract_instance_emitter, contract_instance_manager);
474
476 if (config.collect_debug_logs) {
477 // TODO(fcarreiro): add debug log level?
478 const DebugLogLevel debug_log_level = DebugLogLevel::INFO;
479 return std::make_unique<DebugLogger>(debug_log_level,
481 [](const std::string& message) { vinfo(message); });
482 } else {
484 }
485 }();
491
493 bitwise,
494 data_copy,
495 poseidon2,
496 ecc,
497 to_radix,
498 sha256,
499 execution_components,
503 execution_emitter,
504 context_stack_emitter,
508 emit_unencrypted_log_component,
509 *debug_log_component,
510 merkle_db,
512 std::move(cancellation_token));
516 merkle_db,
520 field_gt,
521 poseidon2,
524 config.skip_fee_enforcement);
525
527 public_inputs_builder.extract_inputs(tx, global_variables, protocol_contracts, config.prover_id, raw_merkle_db);
528
529 // This triggers all the work.
530 TxExecutionResult tx_execution_result = tx_execution.simulate(tx);
531
532 public_inputs_builder.extract_outputs(raw_merkle_db,
533 // TODO(MW): Use of billed_gas is a bit misleading - we want public + private
534 // - teardown, which is stored as billed gas here/in ts:
535 tx_execution_result.gas_used.billed_gas,
536 tx_execution_result.transaction_fee,
537 tx_execution_result.revert_code != RevertCode::OK,
538 side_effect_tracker.get_side_effects());
539
540 return {
541 // Simulation.
542 .gas_used = tx_execution_result.gas_used,
543 .revert_code = tx_execution_result.revert_code,
544 .public_tx_effect = extract_public_tx_effect(tx_execution_result, side_effect_tracker),
545 .call_stack_metadata = call_stack_metadata_collector->dump_call_stack_metadata(),
546 .logs = debug_log_component->dump_logs(),
547 // Proving request data.
548 .public_inputs =
550 .hints = std::nullopt, // NOTE: hints are injected by the caller.
551 };
552}
553
554/************************************
555 * Entry points
556 ************************************/
557
559 simulation::ContractDBInterface& raw_contract_db,
560 const world_state::WorldStateRevision& world_state_revision,
562 const PublicSimulatorConfig& config,
563 const Tx& tx,
564 const GlobalVariables& global_variables,
565 const ProtocolContracts& protocol_contracts,
566 CancellationTokenPtr cancellation_token)
567{
568 // For collecting hints, use the other method.
569 BB_ASSERT(!config.collect_hints && "Use simulate_for_hint_collection instead");
570
571 // Create PureRawMerkleDB with the provided WorldState instance and cancellation token
572 PureRawMerkleDB raw_merkle_db(world_state_revision, ws, /*cache_tree_roots=*/true, cancellation_token);
573
575 raw_contract_db, raw_merkle_db, config, tx, global_variables, protocol_contracts, cancellation_token);
576}
577
579 simulation::ContractDBInterface& raw_contract_db,
580 const world_state::WorldStateRevision& world_state_revision,
582 const PublicSimulatorConfig& config,
583 const Tx& tx,
584 const GlobalVariables& global_variables,
585 const ProtocolContracts& protocol_contracts,
586 CancellationTokenPtr cancellation_token)
587{
588 // If you are not collecting hints, don't use this method.
589 BB_ASSERT(config.collect_hints && "Use simulate_fast_with_existing_ws instead");
590
591 // Create PureRawMerkleDB with the provided WorldState instance and cancellation token
592 PureRawMerkleDB raw_merkle_db(world_state_revision, ws, /*cache_tree_roots=*/true, cancellation_token);
593
594 auto starting_tree_roots = raw_merkle_db.get_tree_roots();
596 HintingRawDB hinting_merkle_db(raw_merkle_db);
597
598 // We use NoopEventEmitters here because we don't want to collect events.
599 auto [/* unused */ events_, tx_result] = simulate_for_witgen_internal<NoopEventEmitter, NoopEventEmitter>(
600 hinting_contract_db, hinting_merkle_db, config, tx, global_variables, protocol_contracts);
601
602 ExecutionHints collected_hints = ExecutionHints{ .global_variables = global_variables,
603 .tx = tx,
604 .protocol_contracts = protocol_contracts,
605 .starting_tree_roots = starting_tree_roots };
606 hinting_contract_db.dump_hints(collected_hints);
607 hinting_merkle_db.dump_hints(collected_hints);
608
609 tx_result.hints = std::move(collected_hints);
610
611 // Need to std::move to avoid copying (due to structured bindings).
612 // This was fixed in C++23 via http://wg21.link/P2266R3.
613 return std::move(tx_result);
614}
615
617{
618 // TODO(fcarreiro): decide if we want to pass a config here.
619 const PublicSimulatorConfig config{};
620
621 HintedRawContractDB raw_contract_db(hints);
622 HintedRawMerkleDB raw_merkle_db(hints);
623
624 // We use EventEmitters and DeduplicatingEventEmitters here because we want to collect events.
625 auto [events, /* unused */ tx_result_] = simulate_for_witgen_internal<EventEmitter, DeduplicatingEventEmitter>(
626 raw_contract_db, raw_merkle_db, config, hints.tx, hints.global_variables, hints.protocol_contracts);
627
628 // Need to std::move to avoid copying (due to structured bindings).
629 // This was fixed in C++23 via http://wg21.link/P2266R3.
630 return std::move(events);
631}
632
634 const PublicSimulatorConfig& config)
635{
636 HintedRawContractDB raw_contract_db(hints);
637 HintedRawMerkleDB raw_merkle_db(hints);
639 raw_contract_db, raw_merkle_db, config, hints.tx, hints.global_variables, hints.protocol_contracts);
640}
641
642} // namespace bb::avm2
DeduplicatingEventEmitter< FieldGreaterThanEvent > field_gt_emitter
GreaterThan greater_than
FieldGreaterThan field_gt
DeduplicatingEventEmitter< RangeCheckEvent > range_check_emitter
EventEmitter< AluEvent > alu_emitter
#define BB_ASSERT(expression,...)
Definition assert.hpp:80
#define BB_BENCH_NAME(name)
Definition bb_bench.hpp:219
BytecodeHasher bytecode_hasher
StrictMock< MockHighLevelMerkleDB > merkle_db
StrictMock< MockContractDB > contract_db
StrictMock< MockContractInstanceManager > contract_instance_manager
TxSimulationResult simulate_fast_internal(simulation::ContractDBInterface &raw_contract_db, simulation::LowLevelMerkleDBInterface &raw_merkle_db, const PublicSimulatorConfig &config, const Tx &tx, const GlobalVariables &global_variables, const ProtocolContracts &protocol_contracts, simulation::CancellationTokenPtr cancellation_token=nullptr)
std::tuple< simulation::EventsContainer, TxSimulationResult > simulate_for_witgen_internal(simulation::ContractDBInterface &raw_contract_db, simulation::LowLevelMerkleDBInterface &raw_merkle_db, const PublicSimulatorConfig &config, const Tx &tx, const GlobalVariables &global_variables, const ProtocolContracts &protocol_contracts)
TxSimulationResult simulate_for_hint_collection(simulation::ContractDBInterface &raw_contract_db, const world_state::WorldStateRevision &world_state_revision, world_state::WorldState &ws, const PublicSimulatorConfig &config, const Tx &tx, const GlobalVariables &global_variables, const ProtocolContracts &protocol_contracts, simulation::CancellationTokenPtr cancellation_token=nullptr)
TxSimulationResult simulate_fast_with_hinted_dbs(const ExecutionHints &hints, const PublicSimulatorConfig &config)
TxSimulationResult simulate_fast_with_existing_ws(simulation::ContractDBInterface &raw_contract_db, const world_state::WorldStateRevision &world_state_revision, world_state::WorldState &ws, const PublicSimulatorConfig &config, const Tx &tx, const GlobalVariables &global_variables, const ProtocolContracts &protocol_contracts, simulation::CancellationTokenPtr cancellation_token=nullptr)
simulation::EventsContainer simulate_for_witgen(const ExecutionHints &hints)
std::vector< DebugLog > dump_logs() override
Definition debug_log.hpp:19
void generate_ff_gt_events_for_squashing(const std::vector< FF > &written_leaf_slots)
Generates ff_gt events for squashing.
PublicInputsBuilder & extract_inputs(const Tx &tx, const GlobalVariables &global_variables, const ProtocolContracts &protocol_contracts, const FF &prover_id, const LowLevelMerkleDBInterface &merkle_db)
TreeSnapshots get_tree_roots() const override
const TrackedSideEffects & get_side_effects() const override
A high-level merkle db that tracks side effects.
Holds the Merkle trees responsible for storing the state of the Aztec protocol.
ExecutionIdManager execution_id_manager
InstructionInfoDB instruction_info_db
HintingContractsDB hinting_contract_db
HintedRawMerkleDB base_merkle_db
HintingRawDB hinting_merkle_db
crypto::Poseidon2< crypto::Poseidon2Bn254ScalarFieldParams > poseidon2
RetrievedBytecodesTree build_retrieved_bytecodes_tree()
std::shared_ptr< CancellationToken > CancellationTokenPtr
WrittenPublicDataSlotsTree build_public_data_slots_tree()
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
GlobalVariables global_variables
Definition avm_io.hpp:359
ProtocolContracts protocol_contracts
Definition avm_io.hpp:362
CollectionLimitsConfig collection_limits
Definition avm_io.hpp:451
std::vector< FF > note_hashes
Definition avm_io.hpp:537
std::vector< PublicLog > public_logs
Definition avm_io.hpp:540
std::vector< FF > nullifiers
Definition avm_io.hpp:538
std::vector< PublicDataWrite > public_data_writes
Definition avm_io.hpp:541
std::vector< ScopedL2ToL1Message > l2_to_l1_msgs
Definition avm_io.hpp:539
tracegen::PublicInputsTraceBuilder public_inputs_builder
Definition tx.test.cpp:81
SideEffectTracker side_effect_tracker
TxExecution tx_execution
NiceMock< MockContextProvider > context_provider
NoopCallStackMetadataCollector call_stack_metadata_collector
EventEmitter< TxEvent > tx_event_emitter