Skip to content

Commit

Permalink
chore: Remove work queue from honk (#2814)
Browse files Browse the repository at this point in the history
Charlie has confirmed that the new method of multithreading in wasm is
here to stay and there is no longer need for the work_queue. This PR
removes the `work_queue` from Honk only.
  • Loading branch information
ledwards2225 authored Oct 12, 2023
1 parent b36fdc4 commit bca7d12
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 187 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "barretenberg/proof_system/circuit_builder/eccvm/eccvm_circuit_builder.hpp"
#include "barretenberg/proof_system/composer/composer_lib.hpp"
#include "barretenberg/srs/factories/file_crs_factory.hpp"
#include "barretenberg/srs/global_crs.hpp"

namespace proof_system::honk {
template <ECCVMFlavor Flavor> class ECCVMComposer_ {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ template <ECCVMFlavor Flavor>
ECCVMProver_<Flavor>::ECCVMProver_(std::shared_ptr<typename Flavor::ProvingKey> input_key,
std::shared_ptr<PCSCommitmentKey> commitment_key)
: key(input_key)
, queue(commitment_key, transcript)
, pcs_commitment_key(commitment_key)
, commitment_key(commitment_key)
{

// TODO(@zac-williamson) Future work; is there a cleaner way of doing this? #2213
Expand Down Expand Up @@ -147,19 +146,6 @@ ECCVMProver_<Flavor>::ECCVMProver_(std::shared_ptr<typename Flavor::ProvingKey>
prover_polynomials.z_perm_shift = key->z_perm; // this will be initialized properly later
}

/**
* @brief Commit to the first three wires only
*
*/
template <ECCVMFlavor Flavor> void ECCVMProver_<Flavor>::compute_wire_commitments()
{
auto wire_polys = key->get_wires();
auto labels = commitment_labels.get_wires();
for (size_t idx = 0; idx < wire_polys.size(); ++idx) {
queue.add_commitment(wire_polys[idx], labels[idx]);
}
}

/**
* @brief Add circuit size, public input size, and public inputs to transcript
*
Expand All @@ -180,7 +166,7 @@ template <ECCVMFlavor Flavor> void ECCVMProver_<Flavor>::execute_wire_commitment
auto wire_polys = key->get_wires();
auto labels = commitment_labels.get_wires();
for (size_t idx = 0; idx < wire_polys.size(); ++idx) {
queue.add_commitment(wire_polys[idx], labels[idx]);
transcript.send_to_verifier(labels[idx], commitment_key->commit(wire_polys[idx]));
}
}

Expand All @@ -204,7 +190,7 @@ template <ECCVMFlavor Flavor> void ECCVMProver_<Flavor>::execute_log_derivative_
// Compute inverse polynomial for our logarithmic-derivative lookup method
lookup_library::compute_logderivative_inverse<Flavor, typename Flavor::LookupRelation>(
prover_polynomials, relation_parameters, key->circuit_size);
queue.add_commitment(key->lookup_inverses, commitment_labels.lookup_inverses);
transcript.send_to_verifier(commitment_labels.lookup_inverses, commitment_key->commit(key->lookup_inverses));
prover_polynomials.lookup_inverses = key->lookup_inverses;
}

Expand All @@ -217,7 +203,7 @@ template <ECCVMFlavor Flavor> void ECCVMProver_<Flavor>::execute_grand_product_c
// Compute permutation grand product and their commitments
permutation_library::compute_permutation_grand_products<Flavor>(key, prover_polynomials, relation_parameters);

queue.add_commitment(key->z_perm, commitment_labels.z_perm);
transcript.send_to_verifier(commitment_labels.z_perm, commitment_key->commit(key->z_perm));
}

/**
Expand Down Expand Up @@ -266,7 +252,8 @@ template <ECCVMFlavor Flavor> void ECCVMProver_<Flavor>::execute_univariatizatio

// Compute and add to trasnscript the commitments [Fold^(i)], i = 1, ..., d-1
for (size_t l = 0; l < key->log_circuit_size - 1; ++l) {
queue.add_commitment(gemini_polynomials[l + 2], "Gemini:FOLD_" + std::to_string(l + 1));
transcript.send_to_verifier("Gemini:FOLD_" + std::to_string(l + 1),
commitment_key->commit(gemini_polynomials[l + 2]));
}
}

Expand Down Expand Up @@ -301,7 +288,7 @@ template <ECCVMFlavor Flavor> void ECCVMProver_<Flavor>::execute_shplonk_batched
Shplonk::compute_batched_quotient(gemini_output.opening_pairs, gemini_output.witnesses, nu_challenge);

// commit to Q(X) and add [Q] to the transcript
queue.add_commitment(batched_quotient_Q, "Shplonk:Q");
transcript.send_to_verifier("Shplonk:Q", commitment_key->commit(batched_quotient_Q));
}

/**
Expand All @@ -322,8 +309,7 @@ template <ECCVMFlavor Flavor> void ECCVMProver_<Flavor>::execute_shplonk_partial
* */
template <ECCVMFlavor Flavor> void ECCVMProver_<Flavor>::execute_final_pcs_round()
{
PCS::compute_opening_proof(pcs_commitment_key, shplonk_output.opening_pair, shplonk_output.witness, transcript);
// queue.add_commitment(quotient_W, "KZG:W");
PCS::compute_opening_proof(commitment_key, shplonk_output.opening_pair, shplonk_output.witness, transcript);
}

template <ECCVMFlavor Flavor> plonk::proof& ECCVMProver_<Flavor>::export_proof()
Expand All @@ -339,16 +325,13 @@ template <ECCVMFlavor Flavor> plonk::proof& ECCVMProver_<Flavor>::construct_proo

// Compute first three wire commitments
execute_wire_commitments_round();
queue.process_queue();

// Compute sorted list accumulator and commitment
execute_log_derivative_commitments_round();
queue.process_queue();

// Fiat-Shamir: bbeta & gamma
// Compute grand product(s) and commitments.
execute_grand_product_computation_round();
queue.process_queue();

// Fiat-Shamir: alpha
// Run sumcheck subprotocol.
Expand All @@ -357,7 +340,6 @@ template <ECCVMFlavor Flavor> plonk::proof& ECCVMProver_<Flavor>::construct_proo
// Fiat-Shamir: rho
// Compute Fold polynomials and their commitments.
execute_univariatization_round();
queue.process_queue();

// Fiat-Shamir: r
// Compute Fold evaluations
Expand All @@ -366,7 +348,6 @@ template <ECCVMFlavor Flavor> plonk::proof& ECCVMProver_<Flavor>::construct_proo
// Fiat-Shamir: nu
// Compute Shplonk batched quotient commitment Q
execute_shplonk_batched_quotient_round();
queue.process_queue();

// Fiat-Shamir: z
// Compute partial evaluation Q_z
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#include "barretenberg/honk/flavor/ecc_vm.hpp"
#include "barretenberg/honk/pcs/gemini/gemini.hpp"
#include "barretenberg/honk/pcs/shplonk/shplonk.hpp"
#include "barretenberg/honk/proof_system/work_queue.hpp"
#include "barretenberg/honk/sumcheck/sumcheck_output.hpp"
#include "barretenberg/honk/transcript/transcript.hpp"
#include "barretenberg/plonk/proof_system/types/proof.hpp"
Expand Down Expand Up @@ -37,8 +36,6 @@ template <ECCVMFlavor Flavor> class ECCVMProver_ {
void execute_shplonk_partial_evaluation_round();
void execute_final_pcs_round();

void compute_wire_commitments();

plonk::proof& export_proof();
plonk::proof& construct_proof();

Expand All @@ -63,12 +60,10 @@ template <ECCVMFlavor Flavor> class ECCVMProver_ {

Polynomial quotient_W;

work_queue<Curve> queue;

sumcheck::SumcheckOutput<Flavor> sumcheck_output;
pcs::gemini::ProverOutput<Curve> gemini_output;
pcs::shplonk::ProverOutput<Curve> shplonk_output;
std::shared_ptr<PCSCommitmentKey> pcs_commitment_key;
std::shared_ptr<PCSCommitmentKey> commitment_key;

using Gemini = pcs::gemini::GeminiProver_<Curve>;
using Shplonk = pcs::shplonk::ShplonkProver_<Curve>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ namespace proof_system::honk {
* */
template <UltraFlavor Flavor>
UltraProver_<Flavor>::UltraProver_(std::shared_ptr<Instance> inst)
: queue(inst->commitment_key, transcript)
, instance(std::move(inst))
, pcs_commitment_key(instance->commitment_key)
: instance(std::move(inst))
, commitment_key(instance->commitment_key)
{
instance->initialise_prover_polynomials();
}
Expand Down Expand Up @@ -51,14 +50,14 @@ template <UltraFlavor Flavor> void UltraProver_<Flavor>::execute_wire_commitment
auto wire_polys = instance->proving_key->get_wires();
auto labels = commitment_labels.get_wires();
for (size_t idx = 0; idx < 3; ++idx) {
queue.add_commitment(wire_polys[idx], labels[idx]);
transcript.send_to_verifier(labels[idx], commitment_key->commit(wire_polys[idx]));
}

if constexpr (IsGoblinFlavor<Flavor>) {
auto op_wire_polys = instance->proving_key->get_ecc_op_wires();
auto labels = commitment_labels.get_ecc_op_wires();
for (size_t idx = 0; idx < Flavor::NUM_WIRES; ++idx) {
queue.add_commitment(op_wire_polys[idx], labels[idx]);
transcript.send_to_verifier(labels[idx], commitment_key->commit(op_wire_polys[idx]));
}
}
}
Expand All @@ -75,8 +74,10 @@ template <UltraFlavor Flavor> void UltraProver_<Flavor>::execute_sorted_list_acc

// Commit to the sorted withness-table accumulator and the finalised (i.e. with memory records) fourth wire
// polynomial
queue.add_commitment(instance->proving_key->sorted_accum, commitment_labels.sorted_accum);
queue.add_commitment(instance->proving_key->w_4, commitment_labels.w_4);
auto sorted_accum_commitment = commitment_key->commit(instance->proving_key->sorted_accum);
auto w_4_commitment = commitment_key->commit(instance->proving_key->w_4);
transcript.send_to_verifier(commitment_labels.sorted_accum, sorted_accum_commitment);
transcript.send_to_verifier(commitment_labels.w_4, w_4_commitment);
}

/**
Expand All @@ -90,8 +91,10 @@ template <UltraFlavor Flavor> void UltraProver_<Flavor>::execute_grand_product_c

instance->compute_grand_product_polynomials(beta, gamma);

queue.add_commitment(instance->proving_key->z_perm, commitment_labels.z_perm);
queue.add_commitment(instance->proving_key->z_lookup, commitment_labels.z_lookup);
auto z_perm_commitment = commitment_key->commit(instance->proving_key->z_perm);
auto z_lookup_commitment = commitment_key->commit(instance->proving_key->z_lookup);
transcript.send_to_verifier(commitment_labels.z_perm, z_perm_commitment);
transcript.send_to_verifier(commitment_labels.z_lookup, z_lookup_commitment);
}

/**
Expand All @@ -118,7 +121,7 @@ template <UltraFlavor Flavor> void UltraProver_<Flavor>::execute_zeromorph_round
instance->prover_polynomials.get_to_be_shifted(),
sumcheck_output.claimed_evaluations,
sumcheck_output.challenge,
pcs_commitment_key,
commitment_key,
transcript);
}

Expand All @@ -135,16 +138,13 @@ template <UltraFlavor Flavor> plonk::proof& UltraProver_<Flavor>::construct_proo

// Compute first three wire commitments
execute_wire_commitments_round();
queue.process_queue();

// Compute sorted list accumulator and commitment
execute_sorted_list_accumulator_round();
queue.process_queue();

// Fiat-Shamir: beta & gamma
// Compute grand product(s) and commitments.
execute_grand_product_computation_round();
queue.process_queue();

// Fiat-Shamir: alpha
// Run sumcheck subprotocol.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "barretenberg/honk/flavor/ultra_grumpkin.hpp"
#include "barretenberg/honk/instance/prover_instance.hpp"
#include "barretenberg/honk/pcs/zeromorph/zeromorph.hpp"
#include "barretenberg/honk/proof_system/work_queue.hpp"
#include "barretenberg/honk/sumcheck/sumcheck_output.hpp"
#include "barretenberg/honk/transcript/transcript.hpp"
#include "barretenberg/plonk/proof_system/types/proof.hpp"
Expand Down Expand Up @@ -44,12 +43,11 @@ template <UltraFlavor Flavor> class UltraProver_ {

Polynomial quotient_W;

work_queue<Curve> queue;

std::shared_ptr<Instance> instance;

sumcheck::SumcheckOutput<Flavor> sumcheck_output;
std::shared_ptr<CommitmentKey> pcs_commitment_key;

std::shared_ptr<CommitmentKey> commitment_key;

using ZeroMorph = pcs::zeromorph::ZeroMorphProver_<Curve>;

Expand Down
Loading

0 comments on commit bca7d12

Please sign in to comment.