19 return a->context_id <
b->context_id;
22 sorted_events.reserve(events.size());
23 for (
const auto&
event : events) {
24 sorted_events.push_back(&
event);
26 std::ranges::sort(sorted_events.begin(), sorted_events.end(), cmp);
30 for (uint32_t j = 0; j < events.size(); j++) {
31 const auto&
event = sorted_events[j];
32 const auto&
calldata =
event->calldata;
34 bool is_last = j == events.size() - 1;
36 for (
size_t i = 0; i <
calldata.size(); i++) {
37 bool is_latch = i ==
calldata.size() - 1;
40 { C::calldata_sel, 1 },
43 { C::calldata_index, i + 1 },
44 { C::calldata_latch, is_latch ? 1 : 0 },
46 { C::calldata_diff_context_id,
60 { C::calldata_sel, 1 },
62 { C::calldata_value, 0 },
63 { C::calldata_index, 0 },
64 { C::calldata_latch, 1 },
66 { C::calldata_diff_context_id, !is_last ? sorted_events[j + 1]->context_id -
context_id - 1 : 0 },
79 for (
const auto&
event : events) {
81 size_t input_size =
event.calldata.size() + 1;
82 calldata_with_sep.reserve(input_size);
83 calldata_with_sep.insert(calldata_with_sep.end(),
event.calldata.begin(),
event.calldata.end());
84 auto calldata_field_at = [&calldata_with_sep](
size_t i) ->
FF {
85 return i < calldata_with_sep.size() ? calldata_with_sep[i] : 0;
93 auto padding_amount = (2 * calldata_with_sep.size()) % 3;
94 auto num_rounds_rem = (calldata_with_sep.size() + padding_amount) / 3;
96 while (num_rounds_rem > 0) {
100 { C::calldata_hashing_sel, 1 },
101 { C::calldata_hashing_start, index == 0 ? 1 : 0 },
102 { C::calldata_hashing_sel_not_start, index == 0 ? 0 : 1 },
103 { C::calldata_hashing_context_id,
event.context_id },
104 { C::calldata_hashing_calldata_size,
event.calldata.size() },
105 { C::calldata_hashing_input_len, calldata_with_sep.size() },
106 { C::calldata_hashing_rounds_rem, num_rounds_rem },
107 { C::calldata_hashing_index_0_, index },
108 { C::calldata_hashing_index_1_, index + 1 },
109 { C::calldata_hashing_index_2_, index + 2 },
110 { C::calldata_hashing_input_0_, calldata_field_at(index) },
111 { C::calldata_hashing_input_1_, calldata_field_at(index + 1) },
112 { C::calldata_hashing_input_2_, calldata_field_at(index + 2) },
113 { C::calldata_hashing_output_hash, output_hash },
114 { C::calldata_hashing_sel_not_padding_1, (num_rounds_rem == 1) && (padding_amount == 2) ? 0 : 1 },
115 { C::calldata_hashing_sel_not_padding_2, (num_rounds_rem == 1) && (padding_amount > 0) ? 0 : 1 },
116 { C::calldata_hashing_latch, num_rounds_rem == 1 ? 1 : 0 },
Implements a parallelized batch insertion indexed tree Accepts template argument of the type of store...