35 FF update_preimage_pre_class_id = 0;
36 FF update_preimage_post_class_id = 0;
44 throw std::runtime_error(
"Current class id does not match expected class id");
50 std::vector<FF> update_preimage(3);
52 for (
size_t i = 0; i < update_preimage.size(); ++i) {
54 delayed_public_mutable_slot + i);
55 update_preimage[i] = unconstrained_read(unconstrained_merkle_db, leaf_slot);
61 if (
hash != reconstructed_hash) {
62 throw std::runtime_error(
"Stored hash does not match preimage hash");
65 update_preimage_metadata =
static_cast<uint256_t>(update_preimage[0]);
66 update_preimage_pre_class_id = update_preimage[1];
67 update_preimage_post_class_id = update_preimage[2];
73 uint64_t timestamp_of_change =
74 static_cast<uint64_t
>(
static_cast<uint32_t
>(update_preimage_metadata & 0xffffffff));
80 FF pre_class = update_preimage_pre_class_id == 0 ? instance.
original_class_id : update_preimage_pre_class_id;
81 FF post_class = update_preimage_post_class_id == 0 ? instance.
original_class_id : update_preimage_post_class_id;
83 FF expected_current_class_id = current_timestamp < timestamp_of_change ? pre_class : post_class;
84 uint64_t timestamp_of_change_subtraction = current_timestamp < timestamp_of_change
85 ? timestamp_of_change - 1 - current_timestamp
86 : current_timestamp - timestamp_of_change;
91 throw std::runtime_error(
93 " does not match expected class id: " +
field_to_string(expected_current_class_id));
102 .current_timestamp = current_timestamp,
104 .update_preimage_metadata = update_preimage_metadata,
105 .update_preimage_pre_class_id = update_preimage_pre_class_id,
106 .update_preimage_post_class_id = update_preimage_post_class_id,
107 .delayed_public_mutable_slot = delayed_public_mutable_slot,