Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
tx_trace.cpp
Go to the documentation of this file.
2
3#include <array>
4#include <cstdint>
5#include <optional>
6#include <utility>
7#include <variant>
8#include <vector>
9
20
21namespace bb::avm2::tracegen {
22
23namespace {
24
25using C = Column;
26
27using simulation::CollectGasFeeEvent;
28using simulation::EnqueuedCallEvent;
29using simulation::PhaseLengths;
30using simulation::PrivateAppendTreeEvent;
31using simulation::PrivateEmitL2L1MessageEvent;
32using simulation::TxContextEvent;
33
34// Helper type for the visitor (See https://en.cppreference.com/w/cpp/utility/variant/visit)
35template <class... Ts> struct overloaded : Ts... {
36 using Ts::operator()...;
37};
38// Explicit deduction guide (not needed as of C++20)
39template <class... Ts> overloaded(Ts...) -> overloaded<Ts...>;
40
41// Helper to get the phase length from PhaseLengths struct
42uint32_t get_phase_length(const PhaseLengths& phase_lengths, TransactionPhase phase)
43{
44 switch (phase) {
46 return phase_lengths.nr_nullifier_insertion;
48 return phase_lengths.nr_note_insertion;
50 return phase_lengths.nr_l2_to_l1_message;
52 return phase_lengths.setup;
54 return phase_lengths.r_nullifier_insertion;
56 return phase_lengths.r_note_insertion;
58 return phase_lengths.r_l2_to_l1_message;
60 return phase_lengths.app_logic;
62 return phase_lengths.teardown;
63 default:
64 return 1; // One-shot phases (COLLECT_GAS_FEES, TREE_PADDING, CLEANUP).
65 }
66}
67
68constexpr size_t NUM_PHASES = static_cast<size_t>(TransactionPhase::LAST) + 1;
69
76bool is_revertible(TransactionPhase phase)
77{
78 return get_tx_phase_spec_map().at(phase).is_revertible;
79}
80
87bool is_note_hash_insert_phase(TransactionPhase phase)
88{
89 return get_tx_phase_spec_map().at(phase).non_revertible_append_note_hash ||
90 get_tx_phase_spec_map().at(phase).revertible_append_note_hash;
91}
92
99bool is_nullifier_insert_phase(TransactionPhase phase)
100{
101 return get_tx_phase_spec_map().at(phase).non_revertible_append_nullifier ||
102 get_tx_phase_spec_map().at(phase).revertible_append_nullifier;
103}
104
112bool is_one_shot_phase(TransactionPhase phase)
113{
114 return get_tx_phase_spec_map().at(phase).is_collect_fee || get_tx_phase_spec_map().at(phase).is_tree_padding ||
115 get_tx_phase_spec_map().at(phase).is_cleanup;
116}
117
124bool is_teardown(TransactionPhase phase)
125{
126 return get_tx_phase_spec_map().at(phase).is_teardown;
127}
128
136std::vector<std::pair<C, FF>> insert_tree_state(const TxContextEvent& prev_state, const TxContextEvent& next_state)
137{
138 return {
139 // Previous Tree State
140 // Note Hash
141 { C::tx_prev_note_hash_tree_root, prev_state.tree_states.note_hash_tree.tree.root },
142 { C::tx_prev_note_hash_tree_size, prev_state.tree_states.note_hash_tree.tree.next_available_leaf_index },
143 { C::tx_prev_num_note_hashes_emitted, prev_state.tree_states.note_hash_tree.counter },
144 // Nullifier Tree Roots
145 { C::tx_prev_nullifier_tree_root, prev_state.tree_states.nullifier_tree.tree.root },
146 { C::tx_prev_nullifier_tree_size, prev_state.tree_states.nullifier_tree.tree.next_available_leaf_index },
147 { C::tx_prev_num_nullifiers_emitted, prev_state.tree_states.nullifier_tree.counter },
148 // Public Data Tree Roots
149 { C::tx_prev_public_data_tree_root, prev_state.tree_states.public_data_tree.tree.root },
150 { C::tx_prev_public_data_tree_size, prev_state.tree_states.public_data_tree.tree.next_available_leaf_index },
151 // Written Public Data Slots Tree Roots
152 { C::tx_prev_written_public_data_slots_tree_root, prev_state.written_public_data_slots_tree_snapshot.root },
153 { C::tx_prev_written_public_data_slots_tree_size,
154 prev_state.written_public_data_slots_tree_snapshot.next_available_leaf_index },
155 // L1 to L2 Message Tree Roots
156 { C::tx_l1_l2_tree_root, prev_state.tree_states.l1_to_l2_message_tree.tree.root },
157 { C::tx_l1_l2_tree_size, prev_state.tree_states.l1_to_l2_message_tree.tree.next_available_leaf_index },
158 // Retrieved bytecodes Tree Roots
159 { C::tx_prev_retrieved_bytecodes_tree_root, prev_state.retrieved_bytecodes_tree_snapshot.root },
160 { C::tx_prev_retrieved_bytecodes_tree_size,
161 prev_state.retrieved_bytecodes_tree_snapshot.next_available_leaf_index },
162
163 // Next Tree State
164 { C::tx_next_note_hash_tree_root, next_state.tree_states.note_hash_tree.tree.root },
165 { C::tx_next_note_hash_tree_size, next_state.tree_states.note_hash_tree.tree.next_available_leaf_index },
166 { C::tx_next_num_note_hashes_emitted, next_state.tree_states.note_hash_tree.counter },
167 // Nullifier Tree Roots
168 { C::tx_next_nullifier_tree_root, next_state.tree_states.nullifier_tree.tree.root },
169 { C::tx_next_nullifier_tree_size, next_state.tree_states.nullifier_tree.tree.next_available_leaf_index },
170 { C::tx_next_num_nullifiers_emitted, next_state.tree_states.nullifier_tree.counter },
171 // Public Data Tree Roots
172 { C::tx_next_public_data_tree_root, next_state.tree_states.public_data_tree.tree.root },
173 { C::tx_next_public_data_tree_size, next_state.tree_states.public_data_tree.tree.next_available_leaf_index },
174 // Written Public Data Slots Tree Roots
175 { C::tx_next_written_public_data_slots_tree_root, next_state.written_public_data_slots_tree_snapshot.root },
176 { C::tx_next_written_public_data_slots_tree_size,
177 next_state.written_public_data_slots_tree_snapshot.next_available_leaf_index },
178 // Retrieved bytecodes Tree Roots
179 { C::tx_next_retrieved_bytecodes_tree_root, next_state.retrieved_bytecodes_tree_snapshot.root },
180 { C::tx_next_retrieved_bytecodes_tree_size,
181 next_state.retrieved_bytecodes_tree_snapshot.next_available_leaf_index },
182
183 // Execution context
184 { C::tx_next_context_id, prev_state.next_context_id },
185 };
186}
187
196std::vector<std::pair<C, FF>> insert_side_effect_states(const TxContextEvent& prev_state,
197 const TxContextEvent& next_state)
198{
199 return {
200 { C::tx_prev_num_unencrypted_log_fields, prev_state.numUnencryptedLogFields },
201 { C::tx_prev_num_l2_to_l1_messages, prev_state.numL2ToL1Messages },
202 { C::tx_next_num_unencrypted_log_fields, next_state.numUnencryptedLogFields },
203 { C::tx_next_num_l2_to_l1_messages, next_state.numL2ToL1Messages },
204 };
205}
206
216std::vector<std::pair<C, FF>> handle_pi_read(TransactionPhase phase, uint32_t phase_length, uint32_t read_counter)
217{
218 const auto& phase_spec = get_tx_phase_spec_map().at(phase);
219
220 const auto remaining_length = phase_length - read_counter;
221
222 return {
223 { C::tx_read_pi_offset, phase_spec.read_pi_start_offset + read_counter },
224 { C::tx_remaining_phase_counter, remaining_length },
225 { C::tx_remaining_phase_inv, remaining_length }, // Will be inverted in batch later
226 { C::tx_remaining_phase_minus_one_inv, remaining_length - 1 }, // Will be inverted in batch later
227 };
228}
229
238std::vector<std::pair<C, FF>> handle_phase_spec(TransactionPhase phase)
239{
240 const auto& phase_spec = get_tx_phase_spec_map().at(phase);
241 return {
242 { C::tx_phase_value, static_cast<uint8_t>(phase) },
243 { C::tx_is_public_call_request, phase_spec.is_public_call_request ? 1 : 0 },
244 { C::tx_is_teardown, phase_spec.is_teardown ? 1 : 0 },
245 { C::tx_is_collect_fee, phase_spec.is_collect_fee ? 1 : 0 },
246 { C::tx_is_tree_padding, phase_spec.is_tree_padding ? 1 : 0 },
247 { C::tx_is_cleanup, phase_spec.is_cleanup ? 1 : 0 },
248 { C::tx_is_revertible, phase_spec.is_revertible ? 1 : 0 },
249 { C::tx_read_pi_start_offset, phase_spec.read_pi_start_offset },
250 { C::tx_read_pi_length_offset, phase_spec.read_pi_length_offset },
251 { C::tx_sel_non_revertible_append_note_hash, phase_spec.non_revertible_append_note_hash ? 1 : 0 },
252 { C::tx_sel_non_revertible_append_nullifier, phase_spec.non_revertible_append_nullifier ? 1 : 0 },
253 { C::tx_sel_non_revertible_append_l2_l1_msg, phase_spec.non_revertible_append_l2_l1_msg ? 1 : 0 },
254 { C::tx_sel_revertible_append_note_hash, phase_spec.revertible_append_note_hash ? 1 : 0 },
255 { C::tx_sel_revertible_append_nullifier, phase_spec.revertible_append_nullifier ? 1 : 0 },
256 { C::tx_sel_revertible_append_l2_l1_msg, phase_spec.revertible_append_l2_l1_msg ? 1 : 0 },
257 { C::tx_next_phase_on_revert, phase_spec.next_phase_on_revert },
258
259 // Directly derived from the phase spec but not part of the phase spec struct.
260 { C::tx_is_tree_insert_phase, (is_note_hash_insert_phase(phase) || is_nullifier_insert_phase(phase)) ? 1 : 0 },
261 };
262}
263
270std::vector<std::pair<C, FF>> handle_prev_gas_used(const Gas& prev_gas_used)
271{
272 return {
273 { C::tx_prev_da_gas_used, prev_gas_used.da_gas },
274 { C::tx_prev_l2_gas_used, prev_gas_used.l2_gas },
275 };
276}
277
284std::vector<std::pair<C, FF>> handle_next_gas_used(const Gas& next_gas_used)
285{
286 return {
287 { C::tx_next_da_gas_used, next_gas_used.da_gas },
288 { C::tx_next_l2_gas_used, next_gas_used.l2_gas },
289 };
290}
291
298std::vector<std::pair<C, FF>> handle_gas_limit(TransactionPhase phase, const Gas& gas_limit, bool is_first_active_row)
299{
300 const bool is_phase_teardown = is_teardown(phase);
301
302 uint32_t gas_limit_pi_offset = 0;
303 if (is_phase_teardown) {
305 } else if (is_first_active_row) {
307 }
308
309 return {
310 { C::tx_gas_limit_pi_offset, gas_limit_pi_offset },
311 { C::tx_should_read_gas_limit, (is_phase_teardown || is_first_active_row) ? 1 : 0 },
312 { C::tx_da_gas_limit, gas_limit.da_gas },
313 { C::tx_l2_gas_limit, gas_limit.l2_gas },
314 };
315}
316
324std::vector<std::pair<C, FF>> handle_enqueued_call_event(const EnqueuedCallEvent& event)
325{
326 return { { C::tx_should_process_call_request, 1 },
327 { C::tx_msg_sender, event.msg_sender },
328 { C::tx_contract_addr, event.contract_address },
329 { C::tx_fee, event.transaction_fee },
330 { C::tx_is_static, event.is_static ? 1 : 0 },
331 { C::tx_calldata_size, event.calldata_size },
332 { C::tx_calldata_hash, event.calldata_hash },
333 { C::tx_prev_da_gas_used_sent_to_enqueued_call, event.start_gas.da_gas },
334 { C::tx_prev_l2_gas_used_sent_to_enqueued_call, event.start_gas.l2_gas },
335 { C::tx_next_da_gas_used_sent_to_enqueued_call, event.end_gas.da_gas },
336 { C::tx_next_l2_gas_used_sent_to_enqueued_call, event.end_gas.l2_gas } };
337}
338
347std::vector<std::pair<C, FF>> handle_note_hash_append(const PrivateAppendTreeEvent& event,
348 const TxContextEvent& state_before)
349{
350 uint32_t remaining_note_hashes = MAX_NOTE_HASHES_PER_TX - state_before.tree_states.note_hash_tree.counter;
351
352 return {
353 { C::tx_leaf_value, event.leaf_value },
354 { C::tx_remaining_side_effects_inv, remaining_note_hashes }, // Will be inverted in batch later
355 { C::tx_should_try_note_hash_append, 1 },
356 { C::tx_should_note_hash_append, remaining_note_hashes > 0 ? 1 : 0 },
357 };
358}
359
368std::vector<std::pair<C, FF>> handle_nullifier_append(const PrivateAppendTreeEvent& event,
369 const TxContextEvent& state_before)
370{
371 uint32_t remaining_nullifiers = MAX_NULLIFIERS_PER_TX - state_before.tree_states.nullifier_tree.counter;
372
373 return {
374 { C::tx_leaf_value, event.leaf_value },
375 { C::tx_nullifier_limit_error, remaining_nullifiers > 0 ? 0 : 1 },
376 { C::tx_remaining_side_effects_inv, remaining_nullifiers }, // Will be inverted in batch later
377 { C::tx_should_try_nullifier_append, 1 },
378 { C::tx_should_nullifier_append, remaining_nullifiers > 0 ? 1 : 0 },
379 };
380}
381
390std::vector<std::pair<C, FF>> handle_append_tree_event(const PrivateAppendTreeEvent& event,
391 TransactionPhase phase,
392 const TxContextEvent& state_before)
393{
394 if (is_note_hash_insert_phase(phase)) {
395 return handle_note_hash_append(event, state_before);
396 }
397 if (is_nullifier_insert_phase(phase)) {
398 return handle_nullifier_append(event, state_before);
399 }
400
401 BB_ASSERT(false, format("Invalid phase for append tree event: ", static_cast<uint8_t>(phase)));
402 return {};
403}
404
413std::vector<std::pair<C, FF>> handle_l2_l1_msg_event(const PrivateEmitL2L1MessageEvent& event,
414 const TxContextEvent& state_before,
415 bool discard)
416{
417 uint32_t remaining_l2_to_l1_msgs = MAX_L2_TO_L1_MSGS_PER_TX - state_before.numL2ToL1Messages;
418 return {
419 { C::tx_should_try_l2_l1_msg_append, 1 },
420 { C::tx_remaining_side_effects_inv, remaining_l2_to_l1_msgs }, // Will be inverted in batch later
421 { C::tx_should_l2_l1_msg_append, (remaining_l2_to_l1_msgs > 0 && !discard) ? 1 : 0 },
422 { C::tx_l2_l1_msg_contract_address, event.scoped_msg.contract_address },
423 { C::tx_l2_l1_msg_recipient, event.scoped_msg.message.recipient },
424 { C::tx_l2_l1_msg_content, event.scoped_msg.message.content },
425 { C::tx_write_pi_offset,
426 AVM_PUBLIC_INPUTS_AVM_ACCUMULATED_DATA_L2_TO_L1_MSGS_ROW_IDX + state_before.numL2ToL1Messages },
427 };
428}
429
436std::vector<std::pair<C, FF>> handle_collect_gas_fee_event(const CollectGasFeeEvent& event)
437{
438 return {
439 { C::tx_effective_fee_per_da_gas, FF(event.effective_fee_per_da_gas) },
440 { C::tx_effective_fee_per_l2_gas, FF(event.effective_fee_per_l2_gas) },
441 { C::tx_fee_payer, event.fee_payer },
442 { C::tx_fee_payer_pi_offset, AVM_PUBLIC_INPUTS_FEE_PAYER_ROW_IDX },
443 { C::tx_fee, event.fee },
444 { C::tx_fee_juice_contract_address, FEE_JUICE_ADDRESS },
445 { C::tx_fee_juice_balances_slot_constant, FEE_JUICE_BALANCES_SLOT },
446 { C::tx_fee_juice_balance_slot, event.fee_juice_balance_slot },
447 { C::tx_fee_payer_balance, event.fee_payer_balance },
448 { C::tx_fee_payer_new_balance, event.fee_payer_balance - event.fee },
449 { C::tx_uint32_max, UINT32_MAX },
450 { C::tx_write_pi_offset, AVM_PUBLIC_INPUTS_TRANSACTION_FEE_ROW_IDX },
451 };
452}
453
459std::vector<std::pair<C, FF>> handle_cleanup()
460{
461 return {
462 // End state
463 { C::tx_sel_read_trees_and_gas_used, 1 },
468 { C::tx_gas_used_pi_offset, AVM_PUBLIC_INPUTS_END_GAS_USED_ROW_IDX },
469 { C::tx_reverted_pi_offset, AVM_PUBLIC_INPUTS_REVERTED_ROW_IDX },
470 { C::tx_array_length_note_hashes_pi_offset,
472 { C::tx_array_length_nullifiers_pi_offset,
474 // Public data write counter is handled by the public data check trace due to squashing.
475 { C::tx_array_length_l2_to_l1_messages_pi_offset,
477 { C::tx_fields_length_unencrypted_logs_pi_offset, AVM_PUBLIC_INPUTS_AVM_ACCUMULATED_DATA_PUBLIC_LOGS_ROW_IDX },
478 };
479}
480
486std::vector<std::pair<C, FF>> handle_first_active_row()
487{
489 { C::tx_start_tx, 1 },
490 { C::tx_sel_read_trees_and_gas_used, 1 },
495 { C::tx_gas_used_pi_offset, AVM_PUBLIC_INPUTS_START_GAS_USED_ROW_IDX },
496 };
497
498 return columns;
499}
500
501} // namespace
502
547 TraceContainer& trace)
548{
554
555 uint32_t row = 1; // Shifts
556
557 // We bucket the events by phase to make it easier to detect phases with no events.
558 std::array<std::vector<const TxPhaseEvent*>, NUM_PHASES> phase_buckets = {};
559 // We have the phases in iterable form so that, in the main loop, when we encounter an empty phase,
560 // we can map back to this enum.
561
562 std::optional<TxStartupEvent> startup_event;
563 PhaseLengths phase_lengths{}; // Will be populated from startup event
564
565 // Some flags used to populate the discard column.
566 bool r_insertion_or_app_logic_failure = false;
567 bool teardown_failure = false;
568
569 // Pre-processing pass:
570 // - Extract the startup event and phase lengths.
571 // - Set the flags defined above.
572 // - Bucket the events by phase.
573 for (const auto& tx_event : events) {
575 startup_event = std::get<TxStartupEvent>(tx_event);
576 phase_lengths = startup_event.value().phase_lengths;
577 } else {
578 const TxPhaseEvent& tx_phase_event = std::get<TxPhaseEvent>(tx_event);
579 phase_buckets[static_cast<uint8_t>(tx_phase_event.phase)].push_back(&tx_phase_event);
580
581 // Set some flags for use when populating the discard column.
582 if (tx_phase_event.reverted) {
583 // Simulation must have been aborted if we reverted in a non-revertible phase.
584 BB_ASSERT(is_revertible(tx_phase_event.phase),
585 format("Reverted in non-revertible phase: ", static_cast<uint8_t>(tx_phase_event.phase)));
586
587 if (is_teardown(tx_phase_event.phase)) {
588 teardown_failure = true;
589 } else {
590 r_insertion_or_app_logic_failure = true;
591 }
592 }
593 }
594 }
595
596 // Our simulation always emits a startup event.
597 BB_ASSERT(startup_event.has_value(), "Transaction startup event is missing");
598
599 const auto& startup_event_data = startup_event.value();
600
601 Gas current_gas_limit = startup_event_data.gas_limit;
602 const Gas& teardown_gas_limit = startup_event_data.teardown_gas_limit;
603 // Track the gas used over the course of the transaction.
604 Gas gas_used = startup_event_data.gas_used;
605 // Track whether this tx reverted.
606 bool tx_reverted = false;
607
608 // From here we start populating the trace.
609
610 trace.set(row, handle_first_active_row());
611
612 // Go through each phase except startup and process the events in the phase.
613 for (uint32_t i = 0; i < NUM_PHASES; i++) {
614 const auto& phase_events = phase_buckets[i];
615 if (phase_events.empty()) {
616 // There will be no events for a phase if it is skipped (jumped over) due to a revert.
617 // This is different from a phase that has an EmptyPhaseEvent, which is a phase that has no contents to
618 // process, like when app logic starts but has no enqueued calls.
619 continue;
620 }
621
622 const TransactionPhase phase = static_cast<TransactionPhase>(i);
623
624 bool discard = false;
625 if (is_revertible(phase)) {
626 if (is_teardown(phase)) {
628 } else {
629 // Even if we don't fail until later in teardown, all revertible phases discard.
630 discard = teardown_failure || r_insertion_or_app_logic_failure;
631 }
632 }
633
634 if (is_teardown(phase)) {
635 current_gas_limit = teardown_gas_limit;
636 }
637
638 // Count the number of steps in this phase.
639 uint32_t phase_counter = 0;
640 // Get the phase length from the startup event's phase_lengths.
641 // This represents how many items were specified for this phase in the transaction itself.
642 // In case of a revert, we may process fewer items in a phase as we'll stop at the revert.
643 const uint32_t phase_length = get_phase_length(phase_lengths, phase);
644
645 // We have events to process in this phase.
646 for (const auto* tx_phase_event : phase_events) {
647 // If this phase is the first revert, set tx_reverted:
648 tx_reverted = tx_reverted || tx_phase_event->reverted;
649
650 // Generic selectors and values common to all phase events.
651 trace.set(row,
652 { {
653 { C::tx_sel, 1 },
654 { C::tx_discard, discard ? 1 : 0 },
655 { C::tx_reverted, tx_phase_event->reverted ? 1 : 0 },
656 { C::tx_tx_reverted, tx_reverted ? 1 : 0 },
657 { C::tx_setup_phase_value, static_cast<uint8_t>(TransactionPhase::SETUP) },
658 { C::tx_start_phase, phase_counter == 0 ? 1 : 0 },
659 { C::tx_sel_read_phase_length, (phase_counter == 0 && !is_one_shot_phase(phase)) ? 1 : 0 },
660 { C::tx_end_phase, phase_counter == phase_events.size() - 1 ? 1 : 0 },
661 } });
662
663 // Populate all phase_spec related columns.
664 trace.set(row, handle_phase_spec(phase));
665
666 // Read PI offset and remaining phase counter related columns.
667 trace.set(row, handle_pi_read(phase, phase_length, phase_counter));
668
669 // We always set the tree state and side effect states.
670 trace.set(row, insert_tree_state(tx_phase_event->state_before, tx_phase_event->state_after));
671 trace.set(row, insert_side_effect_states(tx_phase_event->state_before, tx_phase_event->state_after));
672 trace.set(row, handle_prev_gas_used(gas_used));
673
674 // Pattern match on the variant event type and call the appropriate handler.
675 std::visit(
676 overloaded{
677 [&](const EnqueuedCallEvent& event) {
678 trace.set(row, handle_enqueued_call_event(event));
679 gas_used = tx_phase_event->state_after.gas_used;
680 },
681 [&](const PrivateAppendTreeEvent& event) {
682 trace.set(row, handle_append_tree_event(event, phase, tx_phase_event->state_before));
683 },
685 trace.set(row, handle_l2_l1_msg_event(event, tx_phase_event->state_before, discard));
686 },
687 [&](const CollectGasFeeEvent& event) { trace.set(row, handle_collect_gas_fee_event(event)); },
688 [&](const PadTreesEvent&) {},
689 [&](const CleanupEvent&) { trace.set(row, handle_cleanup()); },
690 [&](const EmptyPhaseEvent&) {
691 // EmptyPhaseEvent represents a phase that is not explicitly skipped because of a
692 // revert, but just has no contents to process, like when app logic starts but
693 // has no enqueued calls.
694 trace.set(C::tx_is_padded, row, 1);
695 } },
696 tx_phase_event->event);
697
698 trace.set(row, handle_next_gas_used(gas_used));
699 trace.set(row, handle_gas_limit(phase, current_gas_limit, row == 1));
700
701 phase_counter++; // Inner loop counter.
702 row++;
703 }
704 }
705
706 // Batch invert the columns.
707 trace.invert_columns(
708 { { C::tx_remaining_phase_inv, C::tx_remaining_phase_minus_one_inv, C::tx_remaining_side_effects_inv } });
709}
710
711const InteractionDefinition TxTraceBuilder::interactions =
713 .add<lookup_tx_read_phase_spec_settings, InteractionType::LookupIntoIndexedByClk>()
714 .add<lookup_tx_read_phase_length_settings, InteractionType::LookupIntoIndexedByClk>()
715 .add<perm_tx_read_calldata_hash_settings, InteractionType::Permutation>()
716 .add<lookup_tx_read_public_call_request_phase_settings, InteractionType::LookupIntoIndexedByClk>()
717 .add<perm_tx_dispatch_exec_start_settings, InteractionType::Permutation>()
718 .add<perm_tx_dispatch_exec_end_settings, InteractionType::Permutation>()
719 .add<lookup_tx_read_tree_insert_value_settings, InteractionType::LookupIntoIndexedByClk>()
720 .add<lookup_tx_read_l2_l1_msg_settings, InteractionType::LookupIntoIndexedByClk>()
721 .add<lookup_tx_write_l2_l1_msg_settings, InteractionType::LookupIntoIndexedByClk>()
722 .add<lookup_tx_read_effective_fee_public_inputs_settings, InteractionType::LookupIntoIndexedByClk>()
723 .add<lookup_tx_read_fee_payer_public_inputs_settings, InteractionType::LookupIntoIndexedByClk>()
724 .add<lookup_tx_balance_validation_settings, InteractionType::LookupGeneric>() // ff_gt deduplicates
725 .add<lookup_tx_note_hash_append_settings, InteractionType::LookupSequential>()
726 .add<lookup_tx_nullifier_append_settings, InteractionType::LookupSequential>()
727 // Cannot be sequential (sorting happens in public data tree trace)
728 .add<lookup_tx_balance_read_settings, InteractionType::LookupGeneric>()
729 .add<lookup_tx_write_fee_public_inputs_settings, InteractionType::LookupIntoIndexedByClk>()
730 .add<lookup_tx_balance_slot_poseidon2_settings, InteractionType::LookupSequential>()
731 // Lookups from tx_context.pil
732 .add<lookup_tx_context_public_inputs_note_hash_tree_settings, InteractionType::LookupIntoIndexedByClk>()
733 .add<lookup_tx_context_public_inputs_nullifier_tree_settings, InteractionType::LookupIntoIndexedByClk>()
734 .add<lookup_tx_context_public_inputs_public_data_tree_settings, InteractionType::LookupIntoIndexedByClk>()
735 .add<lookup_tx_context_public_inputs_l1_l2_tree_settings, InteractionType::LookupIntoIndexedByClk>()
736 .add<lookup_tx_context_public_inputs_gas_used_settings, InteractionType::LookupIntoIndexedByClk>()
737 .add<lookup_tx_context_public_inputs_read_gas_limit_settings, InteractionType::LookupIntoIndexedByClk>()
738 .add<lookup_tx_context_public_inputs_read_reverted_settings, InteractionType::LookupIntoIndexedByClk>()
739 .add<lookup_tx_context_public_inputs_write_note_hash_count_settings, InteractionType::LookupIntoIndexedByClk>()
740 .add<lookup_tx_context_public_inputs_write_nullifier_count_settings, InteractionType::LookupIntoIndexedByClk>()
742 InteractionType::LookupIntoIndexedByClk>()
744 InteractionType::LookupIntoIndexedByClk>()
745 .add<lookup_tx_context_restore_state_on_revert_settings, InteractionType::LookupGeneric>();
746
747} // namespace bb::avm2::tracegen
#define BB_ASSERT(expression,...)
Definition assert.hpp:67
#define AVM_PUBLIC_INPUTS_AVM_ACCUMULATED_DATA_ARRAY_LENGTHS_NOTE_HASHES_ROW_IDX
#define AVM_PUBLIC_INPUTS_END_TREE_SNAPSHOTS_L1_TO_L2_MESSAGE_TREE_ROW_IDX
#define AVM_PUBLIC_INPUTS_FEE_PAYER_ROW_IDX
#define AVM_PUBLIC_INPUTS_AVM_ACCUMULATED_DATA_L2_TO_L1_MSGS_ROW_IDX
#define AVM_PUBLIC_INPUTS_GAS_SETTINGS_TEARDOWN_GAS_LIMITS_ROW_IDX
#define AVM_PUBLIC_INPUTS_TRANSACTION_FEE_ROW_IDX
#define AVM_PUBLIC_INPUTS_AVM_ACCUMULATED_DATA_ARRAY_LENGTHS_L2_TO_L1_MSGS_ROW_IDX
#define AVM_PUBLIC_INPUTS_END_GAS_USED_ROW_IDX
#define AVM_PUBLIC_INPUTS_AVM_ACCUMULATED_DATA_ARRAY_LENGTHS_NULLIFIERS_ROW_IDX
#define AVM_PUBLIC_INPUTS_START_TREE_SNAPSHOTS_L1_TO_L2_MESSAGE_TREE_ROW_IDX
#define AVM_PUBLIC_INPUTS_END_TREE_SNAPSHOTS_NULLIFIER_TREE_ROW_IDX
#define FEE_JUICE_ADDRESS
#define AVM_PUBLIC_INPUTS_START_TREE_SNAPSHOTS_NOTE_HASH_TREE_ROW_IDX
#define AVM_PUBLIC_INPUTS_END_TREE_SNAPSHOTS_NOTE_HASH_TREE_ROW_IDX
#define MAX_L2_TO_L1_MSGS_PER_TX
#define MAX_NOTE_HASHES_PER_TX
#define AVM_PUBLIC_INPUTS_START_TREE_SNAPSHOTS_PUBLIC_DATA_TREE_ROW_IDX
#define AVM_PUBLIC_INPUTS_REVERTED_ROW_IDX
#define FEE_JUICE_BALANCES_SLOT
#define AVM_PUBLIC_INPUTS_START_TREE_SNAPSHOTS_NULLIFIER_TREE_ROW_IDX
#define MAX_NULLIFIERS_PER_TX
#define AVM_PUBLIC_INPUTS_START_GAS_USED_ROW_IDX
#define AVM_PUBLIC_INPUTS_AVM_ACCUMULATED_DATA_PUBLIC_LOGS_ROW_IDX
#define AVM_PUBLIC_INPUTS_GAS_SETTINGS_GAS_LIMITS_ROW_IDX
#define AVM_PUBLIC_INPUTS_END_TREE_SNAPSHOTS_PUBLIC_DATA_TREE_ROW_IDX
InteractionDefinition & add(auto &&... args)
std::string format(Args... args)
Definition log.hpp:22
TestTraceContainer trace
bool teardown_failure
const std::unordered_map< TransactionPhase, TxPhaseSpec > & get_tx_phase_spec_map()
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
simulation::PublicDataTreeReadWriteEvent event