Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
update_check_trace.cpp
Go to the documentation of this file.
2
3#include <memory>
4
8
9namespace bb::avm2::tracegen {
10
13{
14 using C = Column;
15
16 uint32_t row = 0;
17
18 for (const auto& event : events) {
19 uint256_t update_metadata = static_cast<uint256_t>(event.update_preimage_metadata);
20 uint256_t update_metadata_hi = update_metadata >> 32;
21
22 // Note that the code below no longer works after 2106 as by that time the timestamp will overflow u32. The 64
23 // bit timestamp being packed in 32 bits is a tech debt that is not worth tackling.
24 uint64_t timestamp_of_change = static_cast<uint64_t>(static_cast<uint32_t>(update_metadata & 0xffffffff));
25
26 bool timestamp_is_lt_timestamp_of_change = event.current_timestamp < timestamp_of_change;
27
28 FF update_hash_inv = event.update_hash == 0 ? 0 : event.update_hash.invert();
29
30 FF timestamp_of_change_subtraction = timestamp_is_lt_timestamp_of_change
31 ? (timestamp_of_change - 1 - event.current_timestamp)
32 : (event.current_timestamp - timestamp_of_change);
33
34 bool update_pre_class_id_is_zero = event.update_preimage_pre_class_id == 0;
35 FF update_pre_class_inv = update_pre_class_id_is_zero ? 0 : event.update_preimage_pre_class_id.invert();
36
37 bool update_post_class_id_is_zero = event.update_preimage_post_class_id == 0;
38 FF update_post_class_inv = update_post_class_id_is_zero ? 0 : event.update_preimage_post_class_id.invert();
39
40 trace.set(
41 row,
42 { { { C::update_check_sel, 1 },
43 { C::update_check_address, event.address },
44 { C::update_check_current_class_id, event.current_class_id },
45 { C::update_check_original_class_id, event.original_class_id },
46 { C::update_check_public_data_tree_root, event.public_data_tree_root },
47 { C::update_check_timestamp, event.current_timestamp },
48 { C::update_check_timestamp_pi_offset, AVM_PUBLIC_INPUTS_GLOBAL_VARIABLES_TIMESTAMP_ROW_IDX },
49 { C::update_check_update_hash, event.update_hash },
50 { C::update_check_update_hash_inv, update_hash_inv },
51 { C::update_check_hash_not_zero, event.update_hash != 0 },
52 { C::update_check_update_preimage_metadata, event.update_preimage_metadata },
53 { C::update_check_update_preimage_pre_class_id, event.update_preimage_pre_class_id },
54 { C::update_check_update_preimage_post_class_id, event.update_preimage_post_class_id },
55 { C::update_check_updated_class_ids_slot, UPDATED_CLASS_IDS_SLOT },
56 { C::update_check_delayed_public_mutable_slot, event.delayed_public_mutable_slot },
57 { C::update_check_delayed_public_mutable_hash_slot,
58 event.delayed_public_mutable_slot + UPDATES_DELAYED_PUBLIC_MUTABLE_VALUES_LEN },
59 { C::update_check_public_leaf_index_domain_separator, GENERATOR_INDEX__PUBLIC_LEAF_INDEX },
60 { C::update_check_deployer_protocol_contract_address, CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS },
61 { C::update_check_timestamp_of_change, timestamp_of_change },
62 { C::update_check_update_hi_metadata, update_metadata_hi },
63 { C::update_check_update_hi_metadata_bit_size,
65 { C::update_check_timestamp_of_change_bit_size, TIMESTAMP_OF_CHANGE_BIT_SIZE },
66 { C::update_check_timestamp_is_lt_timestamp_of_change, timestamp_is_lt_timestamp_of_change },
67 { C::update_check_timestamp_of_change_subtraction, timestamp_of_change_subtraction },
68 { C::update_check_update_pre_class_id_is_zero, update_pre_class_id_is_zero },
69 { C::update_check_update_pre_class_inv, update_pre_class_inv },
70 { C::update_check_update_post_class_id_is_zero, update_post_class_id_is_zero },
71 { C::update_check_update_post_class_inv, update_post_class_inv } } });
72 row++;
73 }
74}
75
79 .add<lookup_update_check_update_hash_poseidon2_settings, InteractionType::LookupSequential>()
81 .add<lookup_update_check_update_hash_public_data_read_settings, InteractionType::LookupGeneric>()
83 .add<lookup_update_check_update_lo_metadata_range_settings, InteractionType::LookupGeneric>()
85
86} // namespace bb::avm2::tracegen
#define GENERATOR_INDEX__PUBLIC_LEAF_INDEX
#define UPDATES_DELAYED_PUBLIC_MUTABLE_METADATA_BIT_SIZE
#define UPDATES_DELAYED_PUBLIC_MUTABLE_VALUES_LEN
#define UPDATED_CLASS_IDS_SLOT
#define TIMESTAMP_OF_CHANGE_BIT_SIZE
#define AVM_PUBLIC_INPUTS_GLOBAL_VARIABLES_TIMESTAMP_ROW_IDX
#define CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS
InteractionDefinition & add(auto &&... args)
void process(const simulation::EventEmitterInterface< simulation::UpdateCheckEvent >::Container &events, TraceContainer &trace)
static const InteractionDefinition interactions
TestTraceContainer trace
lookup_settings< lookup_update_check_timestamp_of_change_cmp_range_settings_ > lookup_update_check_timestamp_of_change_cmp_range_settings
lookup_settings< lookup_update_check_delayed_public_mutable_slot_poseidon2_settings_ > lookup_update_check_delayed_public_mutable_slot_poseidon2_settings
lookup_settings< lookup_update_check_timestamp_from_public_inputs_settings_ > lookup_update_check_timestamp_from_public_inputs_settings
lookup_settings< lookup_update_check_update_hi_metadata_range_settings_ > lookup_update_check_update_hi_metadata_range_settings
AvmFlavorSettings::FF FF
Definition field.hpp:10
simulation::PublicDataTreeReadWriteEvent event