Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(avm): tweak check-circuit settings #7872

Merged
merged 1 commit into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions barretenberg/cpp/src/barretenberg/vm/avm/trace/execution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
#include "barretenberg/vm/stats.hpp"

#include <cassert>
#include <cmath>
#include <cstddef>
#include <cstdint>
#include <cstdlib>
#include <filesystem>
#include <string>
#include <tuple>
Expand Down Expand Up @@ -124,13 +126,19 @@ std::tuple<AvmFlavor::VerificationKey, HonkProof> Execution::prove(std::vector<u
}
auto circuit_builder = bb::AvmCircuitBuilder();
circuit_builder.set_trace(std::move(trace));
vinfo("Trace size after padding: 2^",
// this calculates the integer log2
std::bit_width(circuit_builder.get_circuit_subgroup_size()) - 1);

if (circuit_builder.get_circuit_subgroup_size() > SRS_SIZE) {
throw_or_abort("Circuit subgroup size (" + std::to_string(circuit_builder.get_circuit_subgroup_size()) +
") exceeds SRS_SIZE (" + std::to_string(SRS_SIZE) + ")");
}

AVM_TRACK_TIME("prove/check_circuit", circuit_builder.check_circuit());
// We only run check_circuit if we are not proving, or if forced to.
if (!ENABLE_PROVING || std::getenv("AVM_FORCE_CHECK_CIRCUIT") != nullptr) {
AVM_TRACK_TIME("prove/check_circuit", circuit_builder.check_circuit());
}

auto composer = AVM_TRACK_TIME_V("prove/create_composer", AvmComposer());
auto prover = AVM_TRACK_TIME_V("prove/create_prover", composer.create_prover(circuit_builder));
Expand Down Expand Up @@ -814,7 +822,7 @@ std::vector<Row> Execution::gen_trace(std::vector<Instruction> const& instructio
}

auto trace = trace_builder.finalize();
vinfo("Final trace size: ", trace.size());
vinfo("Built trace size: ", trace.size());
vinfo("Number of columns: ", trace.front().SIZE);
const size_t total_elements = trace.front().SIZE * trace.size();
const size_t nonzero_elements = [&]() {
Expand Down
13 changes: 6 additions & 7 deletions barretenberg/cpp/src/barretenberg/vm/avm/trace/trace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3439,7 +3439,7 @@ void AvmTraceBuilder::op_keccakf1600(uint8_t indirect,
*
* @return The main trace
*/
std::vector<Row> AvmTraceBuilder::finalize(uint32_t min_trace_size, bool range_check_required)
std::vector<Row> AvmTraceBuilder::finalize(bool range_check_required)
{
auto mem_trace = mem_trace_builder.finalize();
auto alu_trace = alu_trace_builder.finalize();
Expand Down Expand Up @@ -3476,12 +3476,11 @@ std::vector<Row> AvmTraceBuilder::finalize(uint32_t min_trace_size, bool range_c
// Range check size is 1 less than it needs to be since we insert a "first row" at the top of the trace at the
// end, with clk 0 (this doubles as our range check)
size_t const range_check_size = range_check_required ? UINT16_MAX : 0;
std::vector<size_t> trace_sizes = { mem_trace_size, main_trace_size, alu_trace_size,
range_check_size, conv_trace_size, lookup_table_size,
sha256_trace_size, poseidon2_trace_size, pedersen_trace_size,
gas_trace_size + 1, KERNEL_INPUTS_LENGTH, KERNEL_OUTPUTS_LENGTH,
min_trace_size, fixed_gas_table.size(), slice_trace_size,
calldata.size() };
std::vector<size_t> trace_sizes = { mem_trace_size, main_trace_size, alu_trace_size,
range_check_size, conv_trace_size, lookup_table_size,
sha256_trace_size, poseidon2_trace_size, pedersen_trace_size,
gas_trace_size + 1, KERNEL_INPUTS_LENGTH, KERNEL_OUTPUTS_LENGTH,
fixed_gas_table.size(), slice_trace_size, calldata.size() };
vinfo("Trace sizes before padding:",
"\n\tmain_trace_size: ",
main_trace_size,
Expand Down
2 changes: 1 addition & 1 deletion barretenberg/cpp/src/barretenberg/vm/avm/trace/trace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class AvmTraceBuilder {
void op_sha256_compression(uint8_t indirect, uint32_t output_offset, uint32_t h_init_offset, uint32_t input_offset);
void op_keccakf1600(uint8_t indirect, uint32_t output_offset, uint32_t input_offset, uint32_t input_size_offset);

std::vector<Row> finalize(uint32_t min_trace_size = 0, bool range_check_required = ENABLE_PROVING);
std::vector<Row> finalize(bool range_check_required = ENABLE_PROVING);
void reset();

// (not an opcode) Halt -> stop program execution.
Expand Down
Loading