Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
ultra_execution_trace.hpp
Go to the documentation of this file.
1// === AUDIT STATUS ===
2// internal: { status: not started, auditors: [], date: YYYY-MM-DD }
3// external_1: { status: not started, auditors: [], date: YYYY-MM-DD }
4// external_2: { status: not started, auditors: [], date: YYYY-MM-DD }
5// =====================
6
7#pragma once
8
14
15namespace bb {
16
17class UltraTraceBlock : public ExecutionTraceBlock<fr, 4> {
18 public:
19 virtual Selector<fr>& q_lookup_type() { return zero_selectors[0]; };
20 virtual Selector<fr>& q_arith() { return zero_selectors[1]; }
21 virtual Selector<fr>& q_delta_range() { return zero_selectors[2]; }
22 virtual Selector<fr>& q_elliptic() { return zero_selectors[3]; }
23 virtual Selector<fr>& q_memory() { return zero_selectors[4]; }
24 virtual Selector<fr>& q_nnf() { return zero_selectors[5]; }
27
29 {
30 return RefVector{ q_m(),
31 q_c(),
32 q_1(),
33 q_2(),
34 q_3(),
35 q_4(),
37 q_arith(),
39 q_elliptic(),
40 q_memory(),
41 q_nnf(),
44 }
45
49 virtual void set_gate_selector([[maybe_unused]] const fr& value) {}
50
51 private:
53};
54
56
76
96
116
136
156
176
196
216
218 public:
219 SelectorType& q_lookup_type() override { return gate_selectors[0]; };
220 SelectorType& q_arith() override { return gate_selectors[1]; }
221 SelectorType& q_delta_range() override { return gate_selectors[2]; }
222 SelectorType& q_elliptic() override { return gate_selectors[3]; }
223 SelectorType& q_memory() override { return gate_selectors[4]; }
224 SelectorType& q_nnf() override { return gate_selectors[5]; }
227
228 private:
230};
231
291
293
294 public:
295 static constexpr size_t NUM_WIRES = UltraTraceBlock::NUM_WIRES;
296 using FF = fr;
297
298 bool has_overflow = false;
299
301
302 void compute_offsets(bool is_structured)
303 {
304 if (is_structured) {
305 throw_or_abort("Trace is structuring not implemented for UltraHonk");
306 }
307 uint32_t offset = 1; // start at 1 because the 0th row is unused for selectors for Honk
308 for (auto& block : this->get()) {
309 block.trace_offset_ = offset;
310 offset += block.get_fixed_size(is_structured);
311 }
312 }
313
314 void summarize() const
315 {
316 info("Gate blocks summary:");
317 info("pub inputs :\t", this->pub_inputs.size());
318 info("lookups :\t", this->lookup.size());
319 info("arithmetic :\t", this->arithmetic.size());
320 info("delta range:\t", this->delta_range.size());
321 info("elliptic :\t", this->elliptic.size());
322 info("memory :\t", this->memory.size());
323 info("nnf :\t", this->nnf.size());
324 info("poseidon ext :\t", this->poseidon2_external.size());
325 info("poseidon int :\t", this->poseidon2_internal.size());
326 info("overflow :\t", this->overflow.size());
327 }
328
329 // Get cumulative size of all blocks
331 {
332 size_t total_size(0);
333 for (const auto& block : this->get()) {
334 total_size += block.size();
335 }
336 return total_size;
337 }
338
340 {
341 size_t total_size = 1; // start at 1 because the 0th row is unused for selectors for Honk
342 for (auto& block : this->get()) {
343 total_size += block.get_fixed_size();
344 }
345
346 auto log2_n = static_cast<size_t>(numeric::get_msb(total_size));
347 if ((1UL << log2_n) != (total_size)) {
348 ++log2_n;
349 }
350 return 1UL << log2_n;
351 }
352
353 bool operator==(const UltraExecutionTraceBlocks& other) const = default;
354};
355
356} // namespace bb
Basic structure for storing gate data in a builder.
A template class for a reference array. Behaves as if std::array<T&, N> was possible.
Definition ref_array.hpp:22
A template class for a reference vector. Behaves as if std::vector<T&> was possible.
Abstract interface for a generic selector.
void emplace_back(const FF &value)
Append a field element to the selector.
Selector backed by a slab allocator vector.
void emplace_back(int i) override
Append an integer value to the selector.
bool operator==(const UltraExecutionTraceBlocks &other) const =default
void compute_offsets(bool is_structured)
SlabVectorSelector< fr > gate_selector
void set_gate_selector(const fr &value) override
Default implementation does nothing.
SelectorType & q_arith() override
virtual Selector< fr > & q_poseidon2_internal()
virtual Selector< fr > & q_elliptic()
RefVector< Selector< fr > > get_selectors() override
virtual void set_gate_selector(const fr &value)
Default implementation does nothing.
virtual Selector< fr > & q_arith()
virtual Selector< fr > & q_poseidon2_external()
virtual Selector< fr > & q_lookup_type()
virtual Selector< fr > & q_nnf()
virtual Selector< fr > & q_delta_range()
std::array< ZeroSelector< fr >, 8 > zero_selectors
virtual Selector< fr > & q_memory()
SlabVectorSelector< fr > gate_selector
SelectorType & q_delta_range() override
void set_gate_selector(const fr &value) override
Default implementation does nothing.
void set_gate_selector(const fr &value) override
Default implementation does nothing.
SlabVectorSelector< fr > gate_selector
SelectorType & q_elliptic() override
void set_gate_selector(const fr &value) override
Default implementation does nothing.
SlabVectorSelector< fr > gate_selector
SelectorType & q_lookup_type() override
void set_gate_selector(const fr &value) override
Default implementation does nothing.
SelectorType & q_memory() override
SlabVectorSelector< fr > gate_selector
void set_gate_selector(const fr &value) override
Default implementation does nothing.
SelectorType & q_lookup_type() override
SelectorType & q_arith() override
SelectorType & q_nnf() override
SelectorType & q_elliptic() override
SelectorType & q_delta_range() override
SelectorType & q_poseidon2_external() override
std::array< SlabVectorSelector< fr >, 8 > gate_selectors
SelectorType & q_memory() override
SelectorType & q_poseidon2_internal() override
void set_gate_selector(const fr &value) override
Default implementation does nothing.
void set_gate_selector(const fr &value) override
Default implementation does nothing.
void info(Args... args)
Definition log.hpp:74
ssize_t offset
Definition engine.cpp:36
constexpr T get_msb(const T in)
Definition get_msb.hpp:47
Entry point for Barretenberg command-line interface.
field< Bn254FrParams > fr
Definition fr.hpp:174
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
Defines the circuit block types for the Ultra arithmetization.
UltraTracePublicInputBlock pub_inputs
UltraTraceDeltaRangeBlock delta_range
UltraTraceArithmeticBlock arithmetic
UltraTraceNonNativeFieldBlock nnf
UltraTraceOverflowBlock overflow
UltraTraceEllipticBlock elliptic
UltraTracePoseidon2ExternalBlock poseidon2_external
bool operator==(const UltraTraceBlockData &other) const =default
UltraTracePoseidon2InternalBlock poseidon2_internal
void throw_or_abort(std::string const &err)