-
Notifications
You must be signed in to change notification settings - Fork 270
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
refactor: Get rid of Honk UltraComposer #4875
Changes from all commits
ff7c876
9caf8ff
7274899
c6e85ea
0bfe8b9
b8177c1
8916fed
d64fe6e
1e4b4b3
3ca0909
c80894b
831fff5
12a8102
a9f2089
bd4e6e8
a37b9fb
303be77
b138a18
ca5fce2
8ea2cbc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ | |
#include "barretenberg/stdlib/primitives/field/field.hpp" | ||
#include "barretenberg/stdlib/primitives/packed_byte_array/packed_byte_array.hpp" | ||
#include "barretenberg/stdlib/primitives/witness/witness.hpp" | ||
#include "barretenberg/ultra_honk/ultra_composer.hpp" | ||
|
||
#include "barretenberg/ultra_honk/ultra_prover.hpp" | ||
|
||
namespace bb::mock_proofs { | ||
|
@@ -47,46 +47,27 @@ template <typename Builder> void generate_basic_arithmetic_circuit(Builder& buil | |
} | ||
} | ||
|
||
// ultrahonk | ||
inline UltraProver get_prover(UltraComposer& composer, | ||
void (*test_circuit_function)(UltraComposer::CircuitBuilder&, size_t), | ||
size_t num_iterations) | ||
template <typename Prover> | ||
Prover get_prover(void (*test_circuit_function)(typename Prover::Flavor::CircuitBuilder&, size_t), | ||
size_t num_iterations) | ||
{ | ||
UltraComposer::CircuitBuilder builder; | ||
test_circuit_function(builder, num_iterations); | ||
std::shared_ptr<UltraComposer::ProverInstance> instance = composer.create_prover_instance(builder); | ||
return composer.create_prover(instance); | ||
} | ||
|
||
inline GoblinUltraProver get_prover(GoblinUltraComposer& composer, | ||
void (*test_circuit_function)(GoblinUltraComposer::CircuitBuilder&, size_t), | ||
size_t num_iterations) | ||
{ | ||
GoblinUltraComposer::CircuitBuilder builder; | ||
test_circuit_function(builder, num_iterations); | ||
std::shared_ptr<GoblinUltraComposer::ProverInstance> instance = composer.create_prover_instance(builder); | ||
return composer.create_prover(instance); | ||
} | ||
using Flavor = typename Prover::Flavor; | ||
using Builder = typename Flavor::CircuitBuilder; | ||
|
||
// standard plonk | ||
inline plonk::Prover get_prover(plonk::StandardComposer& composer, | ||
void (*test_circuit_function)(StandardCircuitBuilder&, size_t), | ||
size_t num_iterations) | ||
{ | ||
StandardCircuitBuilder builder; | ||
Builder builder; | ||
test_circuit_function(builder, num_iterations); | ||
return composer.create_prover(builder); | ||
} | ||
// This is gross but it's going away soon. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. soon, from what? Plonk getting removed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Once we have a UH smart contract. Sean is working on this. |
||
if constexpr (IsPlonkFlavor<Flavor>) { | ||
// If Flavor is Ultra, alias UltraComposer, otherwise alias StandardComposer | ||
using Composer = std:: | ||
conditional_t<std::same_as<Flavor, plonk::flavor::Ultra>, plonk::UltraComposer, plonk::StandardComposer>; | ||
Composer composer; | ||
return composer.create_prover(builder); | ||
} else { | ||
return Prover(builder); | ||
} | ||
}; | ||
|
||
// ultraplonk | ||
inline plonk::UltraProver get_prover(plonk::UltraComposer& composer, | ||
void (*test_circuit_function)(UltraComposer::CircuitBuilder&, size_t), | ||
size_t num_iterations) | ||
{ | ||
plonk::UltraComposer::CircuitBuilder builder; | ||
test_circuit_function(builder, num_iterations); | ||
return composer.create_prover(builder); | ||
} | ||
/** | ||
* @brief Performs proof constuction for benchmarks based on a provided circuit function | ||
* | ||
|
@@ -97,20 +78,18 @@ inline plonk::UltraProver get_prover(plonk::UltraComposer& composer, | |
* @param state | ||
* @param test_circuit_function | ||
*/ | ||
template <typename Composer> | ||
void construct_proof_with_specified_num_iterations(benchmark::State& state, | ||
void (*test_circuit_function)(typename Composer::CircuitBuilder&, | ||
size_t), | ||
size_t num_iterations) | ||
template <typename Prover> | ||
void construct_proof_with_specified_num_iterations( | ||
benchmark::State& state, | ||
void (*test_circuit_function)(typename Prover::Flavor::CircuitBuilder&, size_t), | ||
size_t num_iterations) | ||
{ | ||
srs::init_crs_factory("../srs_db/ignition"); | ||
|
||
Composer composer; | ||
|
||
for (auto _ : state) { | ||
// Construct circuit and prover; don't include this part in measurement | ||
state.PauseTiming(); | ||
auto prover = get_prover(composer, test_circuit_function, num_iterations); | ||
Prover prover = get_prover<Prover>(test_circuit_function, num_iterations); | ||
state.ResumeTiming(); | ||
|
||
// Construct proof | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was the only real complication this PR. I had to add some type aliases in the Plonk settings code to make this work.