Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
retrieved_bytecodes_tree_check.cpp
Go to the documentation of this file.
2
3#include <memory>
4
8
9namespace bb::avm2::tracegen {
10
14{
15 using C = Column;
16
17 uint32_t row = 0;
18 for (const auto& event : events) {
19 FF class_id = event.class_id;
20
21 bool exists = event.low_leaf_preimage.leaf.class_id == class_id;
22 FF class_id_low_leaf_class_id_diff = class_id - event.low_leaf_preimage.leaf.class_id;
23
24 bool next_class_id_is_nonzero = false;
25 FF next_class_id = 0;
26 if (!exists) {
27 next_class_id_is_nonzero = event.low_leaf_preimage.nextKey != 0;
28 next_class_id = event.low_leaf_preimage.nextKey;
29 }
30
31 uint64_t updated_low_leaf_next_index = 0;
32 FF updated_low_leaf_next_key = 0;
33 FF updated_low_leaf_hash = 0;
34 FF new_leaf_hash = 0;
35 FF intermediate_root = 0;
36
37 bool append = event.append_data.has_value();
38 if (append) {
39 updated_low_leaf_next_key = class_id;
40 updated_low_leaf_next_index = event.prev_snapshot.nextAvailableLeafIndex;
41 updated_low_leaf_hash = event.append_data->updated_low_leaf_hash;
42 new_leaf_hash = event.append_data->new_leaf_hash;
43 intermediate_root = event.append_data->intermediate_root;
44 }
45
46 trace.set(
47 row,
48 { {
49 { C::retrieved_bytecodes_tree_check_sel, 1 },
50 { C::retrieved_bytecodes_tree_check_write, event.write },
51 { C::retrieved_bytecodes_tree_check_class_id, class_id },
52 { C::retrieved_bytecodes_tree_check_root, event.prev_snapshot.root },
53 { C::retrieved_bytecodes_tree_check_write_root, event.next_snapshot.root },
54 { C::retrieved_bytecodes_tree_check_tree_size_before_write,
55 event.prev_snapshot.nextAvailableLeafIndex },
56 { C::retrieved_bytecodes_tree_check_tree_size_after_write, event.next_snapshot.nextAvailableLeafIndex },
57 { C::retrieved_bytecodes_tree_check_low_leaf_class_id, event.low_leaf_preimage.leaf.class_id },
58 { C::retrieved_bytecodes_tree_check_low_leaf_next_index, event.low_leaf_preimage.nextIndex },
59 { C::retrieved_bytecodes_tree_check_low_leaf_next_class_id, event.low_leaf_preimage.nextKey },
60 { C::retrieved_bytecodes_tree_check_updated_low_leaf_next_index, updated_low_leaf_next_index },
61 { C::retrieved_bytecodes_tree_check_updated_low_leaf_next_class_id, updated_low_leaf_next_key },
62 { C::retrieved_bytecodes_tree_check_low_leaf_index, event.low_leaf_index },
63 { C::retrieved_bytecodes_tree_check_should_insert, append },
64 { C::retrieved_bytecodes_tree_check_low_leaf_hash, event.low_leaf_hash },
65 { C::retrieved_bytecodes_tree_check_intermediate_root, intermediate_root },
66 { C::retrieved_bytecodes_tree_check_updated_low_leaf_hash, updated_low_leaf_hash },
67 { C::retrieved_bytecodes_tree_check_tree_height, AVM_RETRIEVED_BYTECODES_TREE_HEIGHT },
68 { C::retrieved_bytecodes_tree_check_leaf_not_exists, !exists },
69 { C::retrieved_bytecodes_tree_check_class_id_low_leaf_class_id_diff_inv,
70 class_id_low_leaf_class_id_diff }, // Will be inverted in batch later
71 { C::retrieved_bytecodes_tree_check_next_class_id_is_nonzero, next_class_id_is_nonzero },
72 { C::retrieved_bytecodes_tree_check_next_class_id_inv,
73 next_class_id }, // Will be inverted in batch later
74 { C::retrieved_bytecodes_tree_check_new_leaf_hash, new_leaf_hash },
75 } });
76 row++;
77 }
78
79 // Batch invert the columns.
80 trace.invert_columns({ { C::retrieved_bytecodes_tree_check_class_id_low_leaf_class_id_diff_inv,
81 C::retrieved_bytecodes_tree_check_next_class_id_inv } });
82}
83
94 .add<lookup_retrieved_bytecodes_tree_check_new_leaf_poseidon2_settings, InteractionType::LookupGeneric>()
96;
97
98} // namespace bb::avm2::tracegen
#define AVM_RETRIEVED_BYTECODES_TREE_HEIGHT
InteractionDefinition & add(auto &&... args)
void process(const simulation::EventEmitterInterface< simulation::RetrievedBytecodesTreeCheckEvent >::Container &events, TraceContainer &trace)
TestTraceContainer trace
lookup_settings< lookup_retrieved_bytecodes_tree_check_new_leaf_merkle_check_settings_ > lookup_retrieved_bytecodes_tree_check_new_leaf_merkle_check_settings
lookup_settings< lookup_retrieved_bytecodes_tree_check_low_leaf_poseidon2_settings_ > lookup_retrieved_bytecodes_tree_check_low_leaf_poseidon2_settings
lookup_settings< lookup_retrieved_bytecodes_tree_check_low_leaf_merkle_check_settings_ > lookup_retrieved_bytecodes_tree_check_low_leaf_merkle_check_settings
lookup_settings< lookup_retrieved_bytecodes_tree_check_low_leaf_next_class_id_validation_settings_ > lookup_retrieved_bytecodes_tree_check_low_leaf_next_class_id_validation_settings
AvmFlavorSettings::FF FF
Definition field.hpp:10
simulation::PublicDataTreeReadWriteEvent event