Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
bb::ChonkBatchVerifier Class Reference

Asynchronous batch verifier for Chonk IVC proofs. More...

#include <chonk_batch_verifier.hpp>

Classes

struct  ReduceResult
 Per-proof result from the reduce phase. More...
 

Public Types

using ResultCallback = std::function< void(VerifyResult)>
 

Public Member Functions

 ChonkBatchVerifier ()=default
 
 ~ChonkBatchVerifier ()
 
 ChonkBatchVerifier (const ChonkBatchVerifier &)=delete
 
ChonkBatchVerifieroperator= (const ChonkBatchVerifier &)=delete
 
void start (std::vector< std::shared_ptr< MegaZKFlavor::VKAndHash > > vks, uint32_t num_cores, uint32_t batch_size, ResultCallback on_result)
 Start the coordinator thread.
 
void enqueue (VerifyRequest request)
 Enqueue a proof for verification.
 
void stop ()
 Stop the processor, flushing remaining proofs.
 

Private Member Functions

void coordinator_loop ()
 
std::vector< ReduceResultparallel_reduce (const std::vector< VerifyRequest > &batch)
 
bool batch_check (const std::vector< ReduceResult > &results, const std::vector< size_t > &indices)
 
void bisect (std::vector< ReduceResult > &results, std::vector< size_t > indices, uint32_t depth, std::chrono::steady_clock::time_point reduce_start)
 
void emit_ok (const std::vector< ReduceResult > &results, const std::vector< size_t > &indices, std::chrono::steady_clock::time_point reduce_start, double ipa_ms, uint32_t depth)
 

Static Private Member Functions

static double ms_since (std::chrono::steady_clock::time_point t)
 
static double ms_between (std::chrono::steady_clock::time_point from, std::chrono::steady_clock::time_point to)
 

Private Attributes

std::vector< std::shared_ptr< MegaZKFlavor::VKAndHash > > vks_
 
uint32_t num_cores_ = 1
 
uint32_t batch_size_ = 8
 
ResultCallback on_result_
 
std::mutex mutex_
 
std::condition_variable cv_
 
std::deque< VerifyRequestqueue_
 
bool shutdown_ = false
 
std::thread coordinator_thread_
 

Detailed Description

Asynchronous batch verifier for Chonk IVC proofs.

Pipeline: Phase 1 (parallel reduce): Work-stealing threads each run full non-IPA verification (MegaZK sumcheck, databus, Goblin merge/eccvm/translator). Phase 2 (batch check): Batch IPA verification via IPA::batch_reduce_verify on all passed proofs. Phase 3 (emit/bisect): On success, emit OK for all. On failure, binary-search to isolate bad proofs.

Definition at line 27 of file chonk_batch_verifier.hpp.

Member Typedef Documentation

◆ ResultCallback

Definition at line 29 of file chonk_batch_verifier.hpp.

Constructor & Destructor Documentation

◆ ChonkBatchVerifier() [1/2]

bb::ChonkBatchVerifier::ChonkBatchVerifier ( )
default

◆ ~ChonkBatchVerifier()

bb::ChonkBatchVerifier::~ChonkBatchVerifier ( )

Definition at line 50 of file chonk_batch_verifier.cpp.

◆ ChonkBatchVerifier() [2/2]

bb::ChonkBatchVerifier::ChonkBatchVerifier ( const ChonkBatchVerifier )
delete

Member Function Documentation

◆ batch_check()

bool bb::ChonkBatchVerifier::batch_check ( const std::vector< ReduceResult > &  results,
const std::vector< size_t > &  indices 
)
private

Definition at line 211 of file chonk_batch_verifier.cpp.

◆ bisect()

void bb::ChonkBatchVerifier::bisect ( std::vector< ReduceResult > &  results,
std::vector< size_t >  indices,
uint32_t  depth,
std::chrono::steady_clock::time_point  reduce_start 
)
private

Definition at line 238 of file chonk_batch_verifier.cpp.

◆ coordinator_loop()

void bb::ChonkBatchVerifier::coordinator_loop ( )
private

Definition at line 57 of file chonk_batch_verifier.cpp.

◆ emit_ok()

void bb::ChonkBatchVerifier::emit_ok ( const std::vector< ReduceResult > &  results,
const std::vector< size_t > &  indices,
std::chrono::steady_clock::time_point  reduce_start,
double  ipa_ms,
uint32_t  depth 
)
private

Definition at line 285 of file chonk_batch_verifier.cpp.

◆ enqueue()

void bb::ChonkBatchVerifier::enqueue ( VerifyRequest  request)

Enqueue a proof for verification.

Definition at line 27 of file chonk_batch_verifier.cpp.

◆ ms_between()

static double bb::ChonkBatchVerifier::ms_between ( std::chrono::steady_clock::time_point  from,
std::chrono::steady_clock::time_point  to 
)
inlinestaticprivate

Definition at line 90 of file chonk_batch_verifier.hpp.

◆ ms_since()

static double bb::ChonkBatchVerifier::ms_since ( std::chrono::steady_clock::time_point  t)
inlinestaticprivate

Definition at line 86 of file chonk_batch_verifier.hpp.

◆ operator=()

ChonkBatchVerifier & bb::ChonkBatchVerifier::operator= ( const ChonkBatchVerifier )
delete

◆ parallel_reduce()

std::vector< ChonkBatchVerifier::ReduceResult > bb::ChonkBatchVerifier::parallel_reduce ( const std::vector< VerifyRequest > &  batch)
private

Definition at line 148 of file chonk_batch_verifier.cpp.

◆ start()

void bb::ChonkBatchVerifier::start ( std::vector< std::shared_ptr< MegaZKFlavor::VKAndHash > >  vks,
uint32_t  num_cores,
uint32_t  batch_size,
ResultCallback  on_result 
)

Start the coordinator thread.

Parameters
vksVerification keys indexed by VerifyRequest::vk_index
num_coresNumber of cores for parallel reduce
batch_sizeNumber of proofs to accumulate before batch-checking
on_resultCallback invoked for each completed verification

Definition at line 12 of file chonk_batch_verifier.cpp.

◆ stop()

void bb::ChonkBatchVerifier::stop ( )

Stop the processor, flushing remaining proofs.

Definition at line 37 of file chonk_batch_verifier.cpp.

Member Data Documentation

◆ batch_size_

uint32_t bb::ChonkBatchVerifier::batch_size_ = 8
private

Definition at line 97 of file chonk_batch_verifier.hpp.

◆ coordinator_thread_

std::thread bb::ChonkBatchVerifier::coordinator_thread_
private

Definition at line 104 of file chonk_batch_verifier.hpp.

◆ cv_

std::condition_variable bb::ChonkBatchVerifier::cv_
private

Definition at line 101 of file chonk_batch_verifier.hpp.

◆ mutex_

std::mutex bb::ChonkBatchVerifier::mutex_
private

Definition at line 100 of file chonk_batch_verifier.hpp.

◆ num_cores_

uint32_t bb::ChonkBatchVerifier::num_cores_ = 1
private

Definition at line 96 of file chonk_batch_verifier.hpp.

◆ on_result_

ResultCallback bb::ChonkBatchVerifier::on_result_
private

Definition at line 98 of file chonk_batch_verifier.hpp.

◆ queue_

std::deque<VerifyRequest> bb::ChonkBatchVerifier::queue_
private

Definition at line 102 of file chonk_batch_verifier.hpp.

◆ shutdown_

bool bb::ChonkBatchVerifier::shutdown_ = false
private

Definition at line 103 of file chonk_batch_verifier.hpp.

◆ vks_

std::vector<std::shared_ptr<MegaZKFlavor::VKAndHash> > bb::ChonkBatchVerifier::vks_
private

Definition at line 95 of file chonk_batch_verifier.hpp.


The documentation for this class was generated from the following files: