Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
interaction_builder.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4#include <optional>
5#include <vector>
6
10
11namespace bb::avm2::tracegen {
12
13// Helper to generate a tuple type with N const FF& elements.
14namespace detail {
15template <size_t N, typename = std::make_index_sequence<N>> struct RefTupleHelper;
16template <size_t N, size_t... Is> struct RefTupleHelper<N, std::index_sequence<Is...>> {
17 template <size_t> using ConstFFRef = const FF&;
19};
20} // namespace detail
21template <size_t N> using RefTuple = typename detail::RefTupleHelper<N>::type;
22
24 public:
25 virtual ~InteractionBuilderInterface() = default;
26 virtual void process(TraceContainer& trace) = 0;
27 // Fingerprint of the destination columns.
28 // Used to identify jobs that share the same destination columns and prevent them
29 // from building the index at the same time.
30 virtual size_t get_destination_columns_fingerprint() const { return 0; }
31};
32
33// A concatenate that works with movable objects.
34template <typename T> std::vector<T> concatenate_jobs(std::vector<T>&& first, auto&&... rest)
35{
36 std::vector<T> result = std::move(first);
37 result.reserve(first.size() + (rest.size() + ...));
38 (std::move(rest.begin(), rest.end(), std::back_inserter(result)), ...);
39 return result;
40}
41
42// Orders jobs to minimize index building contention.
43// Jobs with first occurrences of each destination column key come first, followed by jobs that share
44// destination column keys with previously seen ones.
45// This ordering helps the SharedIndexCache by ensuring that when multiple jobs share
46// the same destination, only the first one builds the index while others wait.
48
49} // namespace bb::avm2::tracegen
virtual void process(TraceContainer &trace)=0
typename detail::RefTupleHelper< N >::type RefTuple
void order_jobs_by_destination_columns(std::vector< std::unique_ptr< InteractionBuilderInterface > > &jobs)
std::vector< T > concatenate_jobs(std::vector< T > &&first, auto &&... rest)
AvmFlavorSettings::FF FF
Definition field.hpp:10
STL namespace.
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13