7#include <gtest/gtest.h>
19class ChonkPinnedIvcInputsTest :
public ::testing::Test {
23 static std::filesystem::path find_repo_root()
25 if (
const char* env =
std::getenv(
"AZTEC_REPO_ROOT"); env !=
nullptr && *env !=
'\0') {
26 return std::filesystem::path{ env };
28 return std::filesystem::weakly_canonical(std::filesystem::current_path() /
"../../..");
31 static std::filesystem::path pinned_inputs_root()
33 if (
const char* env =
std::getenv(
"CHONK_PINNED_IVC_INPUTS_DIR"); env !=
nullptr && *env !=
'\0') {
34 return std::filesystem::path{ env };
36 return find_repo_root() /
"barretenberg/cpp/chonk-pinned-flows";
42 if (!std::filesystem::is_directory(inputs_root)) {
45 for (
const auto& entry :
std::filesystem::directory_iterator(inputs_root)) {
46 if (entry.is_directory() && std::filesystem::exists(entry.path() /
"ivc-inputs.msgpack")) {
47 flows.push_back(entry.path());
59 [filter](
const auto& flow) {
60 return flow.filename().string().find(filter) == std::string::npos;
65 const char* limit_env =
std::getenv(
"CHONK_PINNED_IVC_FLOW_LIMIT");
66 if (limit_env ==
nullptr || *limit_env ==
'\0') {
70 const long limit =
std::strtol(limit_env, &end, 10);
71 if (end != limit_env && *end ==
'\0' && limit > 0 &&
static_cast<size_t>(limit) < flows.size()) {
72 flows.resize(
static_cast<size_t>(limit));
76 static void run_flow(
const std::filesystem::path& flow_dir)
78 const std::filesystem::path inputs_path = flow_dir /
"ivc-inputs.msgpack";
79 info(
"ChonkPinnedIvcInputs: loading ", inputs_path.string());
82 ASSERT_FALSE(raw_steps.empty()) <<
"no execution steps in " << inputs_path;
84 const auto hiding_vk = raw_steps.back().vk;
90 bb::bbapi::wire::ChonkStart{
91 .num_circuits =
static_cast<uint32_t
>(raw_steps.size()),
94 for (
auto& step : raw_steps) {
96 bb::bbapi::wire::ChonkLoad{
97 .circuit = { .name =
std::move(step.function_name),
102 bb::bbapi::wire::ChonkAccumulate{
110 request, bb::bbapi::wire::ChonkVerify{ .proof =
std::move(prove_response.proof), .vk = hiding_vk });
111 EXPECT_TRUE(verify_response.valid) <<
"ChonkVerify rejected " << flow_dir.filename();
115TEST_F(ChonkPinnedIvcInputsTest, AllPinnedFlows)
117 const auto inputs_root = pinned_inputs_root();
118 auto flows = find_flow_dirs(inputs_root);
119 ASSERT_FALSE(flows.empty()) <<
"no pinned Chonk flows under " << inputs_root
120 <<
". Run `barretenberg/cpp/scripts/chonk_inputs.sh download` first.";
122 apply_flow_selection(flows);
123 const char* flow_filter =
std::getenv(
"CHONK_PINNED_IVC_FLOW");
124 ASSERT_FALSE(flows.empty() && flow_filter !=
nullptr && *flow_filter !=
'\0')
125 <<
"CHONK_PINNED_IVC_FLOW='" << flow_filter <<
"' matched no pinned flows under " << inputs_root;
126 ASSERT_FALSE(flows.empty()) <<
"no pinned Chonk flows found under " << inputs_root;
128 for (
const auto& flow : flows) {
129 SCOPED_TRACE(
"flow: " + flow.filename().string());
Non-template handler declarations for the bb service.
Shared type definitions for the Barretenberg RPC API.
TEST_F(BoomerangIPARecursiveTests, FullRecursiveVerifierMediumRandom)
wire::ChonkVerifyResponse handle_chonk_verify(BBApiRequest &, wire::ChonkVerify &&cmd)
wire::ChonkProveResponse handle_chonk_prove(BBApiRequest &request, wire::ChonkProve &&)
wire::ChonkAccumulateResponse handle_chonk_accumulate(BBApiRequest &request, wire::ChonkAccumulate &&cmd)
wire::ChonkLoadResponse handle_chonk_load(BBApiRequest &request, wire::ChonkLoad &&cmd)
wire::ChonkStartResponse handle_chonk_start(BBApiRequest &request, wire::ChonkStart &&cmd)
std::filesystem::path bb_crs_path()
void init_file_crs_factory(const std::filesystem::path &path)
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
static std::vector< PrivateExecutionStepRaw > load_and_decompress(const std::filesystem::path &input_path)