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

feat: Goblin Translator (final part) #3022

Closed
wants to merge 47 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
c7372c4
Added flavor and permutation correctness test
Rumata888 Oct 22, 2023
e2daa84
Cleanup
Rumata888 Oct 22, 2023
178409c
Addressed Zac's comments
Rumata888 Oct 24, 2023
2ef2c25
Merge branch 'master' into is/goblin_translator_flavor_and_friends
Rumata888 Oct 24, 2023
8a5776e
Reverted incorrectly addressing comments
Rumata888 Oct 24, 2023
302327f
GenPermSort correctness test
Rumata888 Oct 22, 2023
9cd8811
Extra Relations and Opcode Constraint relation correctness tests
Rumata888 Oct 22, 2023
b0126c5
Minor Fix
Rumata888 Oct 24, 2023
ef48f70
Correctness tests for decomposition and non-native field relations
Rumata888 Oct 23, 2023
4d0e921
Comment fix
Rumata888 Oct 23, 2023
9cb5c7f
Minor fixes
Rumata888 Oct 24, 2023
aa88910
Zeromorph with concatenation
Rumata888 Oct 24, 2023
658d26e
WIP
Rumata888 Oct 24, 2023
98f9ce6
Updated in line with changes
Rumata888 Oct 25, 2023
c9379d4
Sumcheck failure
Rumata888 Oct 25, 2023
48ff608
FIx relation compilation
codygunton Oct 25, 2023
7302fd0
Merge remote-tracking branch 'origin/master' into is/goblin_translato…
codygunton Oct 25, 2023
634a935
Merge remote-tracking branch 'origin/master' into is/goblin_translato…
codygunton Oct 25, 2023
76da696
Merge remote-tracking branch 'origin/master' into is/goblin_translato…
codygunton Oct 26, 2023
9a5f3a6
WIP
codygunton Oct 27, 2023
6cc6fdb
Merge remote-tracking branch 'origin/master' into is/goblin_translato…
codygunton Oct 27, 2023
5bd3c5f
Checkout zeromorph from master.
codygunton Oct 29, 2023
625c89f
Make it work
codygunton Oct 31, 2023
f8ebd52
CI doesn't have format
codygunton Oct 31, 2023
7c68cce
Was using that implicitly.
codygunton Oct 31, 2023
c6ddf92
Handle case of no concatenations.
codygunton Oct 31, 2023
821ee62
Don't void
codygunton Oct 31, 2023
fc44c7b
Squash master merge
codygunton Nov 7, 2023
b1885ac
Merge remote-tracking branch 'origin/master' into is/goblin_translato…
codygunton Nov 7, 2023
e019b95
LInk issues
codygunton Nov 8, 2023
d485fa9
Bench ECCVM relations
codygunton Nov 8, 2023
83d2922
Full test builds; fails to fail?
codygunton Nov 8, 2023
22eacfb
High-prob failure with more gates.
codygunton Nov 8, 2023
788a9b2
Reduce test input sizes
codygunton Nov 9, 2023
bb0778d
Translator passes with small inputs.
codygunton Nov 9, 2023
e40fb34
Touch-up
codygunton Nov 10, 2023
4682156
Un-functionize
codygunton Nov 10, 2023
745cebd
Nix BN254 flavor; IOU benchmarks
codygunton Nov 10, 2023
669d210
Debugging
codygunton Nov 11, 2023
fb19414
Tmp workspace changes
codygunton Nov 13, 2023
27b0b0e
Plane WIP
codygunton Nov 14, 2023
9713e9a
Ratio is 2?
codygunton Nov 14, 2023
959f8cb
It's x not a power!
codygunton Nov 14, 2023
1f7be35
Debugging... transcripts match
codygunton Nov 15, 2023
3c80303
Debug just IPA
codygunton Nov 15, 2023
f636fed
dbg
codygunton Nov 15, 2023
7184a30
Hell yeah
codygunton Nov 15, 2023
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
5 changes: 3 additions & 2 deletions barretenberg/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
"typescript.enablePromptUseWorkspaceTsdk": true,
"[cpp]": {
// doesn't conflict with barratenberg.code-workspace settings.
"editor.defaultFormatter": "llvm-vs-code-extensions.vscode-clangd"
"editor.defaultFormatter": "xaver.clang-format"
},
"[terraform]": {
"editor.defaultFormatter": "hashicorp.terraform"
Expand All @@ -127,5 +127,6 @@
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"cmake.sourceDirectory": "${workspaceFolder}/cpp"
"cmake.sourceDirectory": "${workspaceFolder}/cpp",
"clangd.path": "/usr/bin/clangd-16"
}
2 changes: 1 addition & 1 deletion barretenberg/barretenberg.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
// Clangd. Note that this setting may be overridden by user settings
// to the default value "clangd".
//
"clangd.path": "clangd-16",
"clangd.path": "/usr/bin/clangd-16",
// We should disable automatic inclusion of headers unless we decide to follow "WhyIWYU".
"clangd.arguments": [
"-header-insertion=never"
Expand Down
23 changes: 23 additions & 0 deletions barretenberg/cpp/CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,19 @@
"TARGET_ARCH": "skylake"
}
},
{
"name": "default-dbg",
"displayName": "Debugging build with Clang",
"description": "Build with globally installed Clang in debug mode",
"inherits": "default",
"environment": {
"CMAKE_BUILD_TYPE": "Debug"
},
"cacheVariables": {
"ENABLE_ASAN": "OFF",
"DISABLE_ASM": "ON"
}
},
{
"name": "homebrew",
"displayName": "Homebrew + Clang",
Expand Down Expand Up @@ -250,6 +263,11 @@
"inheritConfigureEnvironment": true,
"jobs": 0
},
{
"name": "default-dbg",
"inherits": "default",
"configurePreset": "default-dbg"
},
{
"name": "homebrew",
"inherits": "default",
Expand Down Expand Up @@ -360,6 +378,11 @@
"configurePreset": "default",
"inheritConfigureEnvironment": true
},
{
"name": "default-dbg",
"inherits": "default",
"configurePreset": "default-dbg"
},
{
"name": "homebrew",
"inherits": "default",
Expand Down
1 change: 1 addition & 0 deletions barretenberg/cpp/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ add_subdirectory(barretenberg/srs)
add_subdirectory(barretenberg/stdlib)
add_subdirectory(barretenberg/sumcheck)
add_subdirectory(barretenberg/transcript)
add_subdirectory(barretenberg/translator_vm)
add_subdirectory(barretenberg/ultra_honk)
add_subdirectory(barretenberg/wasi)

Expand Down
3 changes: 2 additions & 1 deletion barretenberg/cpp/src/barretenberg/benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ add_subdirectory(decrypt_bench)
add_subdirectory(pippenger_bench)
add_subdirectory(plonk_bench)
add_subdirectory(honk_bench)
add_subdirectory(relations_bench)
add_subdirectory(relations_bench)
add_subdirectory(widgets_bench)
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@
set(BENCHMARK_SOURCES
barycentric.bench.cpp
relations.bench.cpp
widget.bench.cpp
)

# Required libraries for benchmark suites
set(LINKED_LIBRARIES
polynomials
proof_system
benchmark::benchmark
transcript
stdlib_primitives
)

# Add executable and custom target for each suite, e.g. ultra_honk_bench
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,26 @@
#include "barretenberg/flavor/ecc_vm.hpp"
#include "barretenberg/flavor/goblin_translator.hpp"
#include "barretenberg/flavor/goblin_ultra.hpp"
#include "barretenberg/flavor/ultra.hpp"
#include "barretenberg/relations/auxiliary_relation.hpp"
#include "barretenberg/relations/ecc_op_queue_relation.hpp"
#include "barretenberg/relations/elliptic_relation.hpp"
#include "barretenberg/relations/gen_perm_sort_relation.hpp"
#include "barretenberg/relations/lookup_relation.hpp"
#include "barretenberg/relations/permutation_relation.hpp"
#include "barretenberg/relations/relation_parameters.hpp"
#include "barretenberg/relations/ultra_arithmetic_relation.hpp"
#include <benchmark/benchmark.h>

namespace {
auto& engine = numeric::random::get_debug_engine();
}

using namespace proof_system::honk::sumcheck; // WORKTODO

namespace proof_system::benchmark::relations {

using FF = barretenberg::fr;
using Fr = barretenberg::fr;
using Fq = grumpkin::fr;

template <typename Flavor, typename Relation> void execute_relation(::benchmark::State& state)
{
using AllValues = typename Flavor::AllValues;
using SumcheckArrayOfValuesOverSubrelations = typename Relation::SumcheckArrayOfValuesOverSubrelations;

auto params = proof_system::RelationParameters<FF>::get_random();
auto params = proof_system::RelationParameters<Fr>::get_random();

// Extract an array containing all the polynomial evaluations at a given row i
AllValues new_value;
Expand All @@ -36,46 +33,118 @@ template <typename Flavor, typename Relation> void execute_relation(::benchmark:
}
}

void auxiliary_relation(::benchmark::State& state) noexcept
void ultra_auxiliary_relation(::benchmark::State& state) noexcept
{
execute_relation<honk::flavor::Ultra, AuxiliaryRelation<FF>>(state);
execute_relation<honk::flavor::Ultra, AuxiliaryRelation<Fr>>(state);
}
BENCHMARK(auxiliary_relation);
BENCHMARK(ultra_auxiliary_relation);

void elliptic_relation(::benchmark::State& state) noexcept
void ultra_elliptic_relation(::benchmark::State& state) noexcept
{
execute_relation<honk::flavor::Ultra, EllipticRelation<FF>>(state);
execute_relation<honk::flavor::Ultra, EllipticRelation<Fr>>(state);
}
BENCHMARK(elliptic_relation);
BENCHMARK(ultra_elliptic_relation);

void ecc_op_queue_relation(::benchmark::State& state) noexcept
void ultra_ecc_op_queue_relation(::benchmark::State& state) noexcept
{
execute_relation<honk::flavor::GoblinUltra, EccOpQueueRelation<FF>>(state);
execute_relation<honk::flavor::GoblinUltra, EccOpQueueRelation<Fr>>(state);
}
BENCHMARK(ecc_op_queue_relation);
BENCHMARK(ultra_ecc_op_queue_relation);

void gen_perm_sort_relation(::benchmark::State& state) noexcept
void ultra_gen_perm_sort_relation(::benchmark::State& state) noexcept
{
execute_relation<honk::flavor::Ultra, GenPermSortRelation<FF>>(state);
execute_relation<honk::flavor::Ultra, GenPermSortRelation<Fr>>(state);
}
BENCHMARK(gen_perm_sort_relation);
BENCHMARK(ultra_gen_perm_sort_relation);

void lookup_relation(::benchmark::State& state) noexcept
void ultralookup_relation(::benchmark::State& state) noexcept
{
execute_relation<honk::flavor::Ultra, LookupRelation<FF>>(state);
execute_relation<honk::flavor::Ultra, LookupRelation<Fr>>(state);
}
BENCHMARK(lookup_relation);
BENCHMARK(ultralookup_relation);

void ultra_permutation_relation(::benchmark::State& state) noexcept
{
execute_relation<honk::flavor::Ultra, UltraPermutationRelation<FF>>(state);
execute_relation<honk::flavor::Ultra, UltraPermutationRelation<Fr>>(state);
}
BENCHMARK(ultra_permutation_relation);

void ultra_arithmetic_relation(::benchmark::State& state) noexcept
{
execute_relation<honk::flavor::Ultra, UltraArithmeticRelation<FF>>(state);
execute_relation<honk::flavor::Ultra, UltraArithmeticRelation<Fr>>(state);
}
BENCHMARK(ultra_arithmetic_relation);

void translator_decomposition_relation(::benchmark::State& state) noexcept
{
execute_relation<honk::flavor::GoblinTranslator, GoblinTranslatorDecompositionRelation<Fr>>(state);
}
BENCHMARK(translator_decomposition_relation);

void translator_opcode_constraint_relation(::benchmark::State& state) noexcept
{
execute_relation<honk::flavor::GoblinTranslator, GoblinTranslatorOpcodeConstraintRelation<Fr>>(state);
}
BENCHMARK(translator_opcode_constraint_relation);

void translator_accumulator_transfer_relation(::benchmark::State& state) noexcept
{
execute_relation<honk::flavor::GoblinTranslator, GoblinTranslatorAccumulatorTransferRelation<Fr>>(state);
}
BENCHMARK(translator_accumulator_transfer_relation);

void translator_gen_perm_sort_relation(::benchmark::State& state) noexcept
{
execute_relation<honk::flavor::GoblinTranslator, GoblinTranslatorGenPermSortRelation<Fr>>(state);
}
BENCHMARK(translator_gen_perm_sort_relation);

void translator_non_native_field_relation(::benchmark::State& state) noexcept
{
execute_relation<honk::flavor::GoblinTranslator, GoblinTranslatorNonNativeFieldRelation<Fr>>(state);
}
BENCHMARK(translator_non_native_field_relation);

void translator_permutation_relation(::benchmark::State& state) noexcept
{
execute_relation<honk::flavor::GoblinTranslator, GoblinTranslatorPermutationRelation<Fr>>(state);
}
BENCHMARK(translator_permutation_relation);

// void eccvm_lookup_relation(::benchmark::State& state) noexcept
// {
// execute_relation<honk::flavor::ECCVM, ECCVMLookupRelation<Fq>>(state);
// }
// BENCHMARK(eccvm_lookup_relation);

// void eccvm_msm_relation(::benchmark::State& state) noexcept
// {
// execute_relation<honk::flavor::ECCVM, ECCVMMSMRelation<Fq>>(state);
// }
// BENCHMARK(eccvm_msm_relation);

// void eccvm_point_table_relation(::benchmark::State& state) noexcept
// {
// execute_relation<honk::flavor::ECCVM, ECCVMPointTableRelation<Fq>>(state);
// }
// BENCHMARK(eccvm_point_table_relation);

// void eccvm_set_relation(::benchmark::State& state) noexcept
// {
// execute_relation<honk::flavor::ECCVM, ECCVMSetRelation<Fq>>(state);
// }
// BENCHMARK(eccvm_set_relation);

// void eccvm_transcript_relation(::benchmark::State& state) noexcept
// {
// execute_relation<honk::flavor::ECCVM, ECCVMTranscriptRelation<Fq>>(state);
// }
// BENCHMARK(eccvm_transcript_relation);

// void eccvm_wnaf_relation(::benchmark::State& state) noexcept
// {
// execute_relation<honk::flavor::ECCVM, ECCVMWnafRelation<Fq>>(state);
// }
// BENCHMARK(eccvm_wnaf_relation);

} // namespace proof_system::benchmark::relations
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Each source represents a separate benchmark suite
set(BENCHMARK_SOURCES
widget.bench.cpp
)

# Required libraries for benchmark suites
set(LINKED_LIBRARIES
polynomials
proof_system
benchmark::benchmark
transcript
stdlib_primitives
)

# Add executable and custom target for each suite, e.g. ultra_honk_bench
foreach(BENCHMARK_SOURCE ${BENCHMARK_SOURCES})
get_filename_component(BENCHMARK_NAME ${BENCHMARK_SOURCE} NAME_WE) # extract name without extension
add_executable(${BENCHMARK_NAME}_bench main.bench.cpp ${BENCHMARK_SOURCE})
target_link_libraries(${BENCHMARK_NAME}_bench ${LINKED_LIBRARIES})
add_custom_target(run_${BENCHMARK_NAME} COMMAND ${BENCHMARK_NAME} WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
endforeach()
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include <benchmark/benchmark.h>

BENCHMARK_MAIN();
14 changes: 12 additions & 2 deletions barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ template <typename Curve> class IPA {
const Polynomial& polynomial,
BaseTranscript<Fr>& transcript)
{
ASSERT(opening_pair.challenge != 0 && "The challenge point should not be zero");
info("IPA challenge: ", opening_pair.challenge);
info("IPA eval : ", opening_pair.evaluation);
info("IPA comm : ", ck->commit(polynomial));

ASSERT(opening_pair.challenge != 0 && "The challenge point should not be zero"); // why?
auto poly_degree = static_cast<size_t>(polynomial.size());
transcript.send_to_verifier("IPA:poly_degree", static_cast<uint64_t>(poly_degree));
Fr generator_challenge = transcript.get_challenge("IPA:generator_challenge");
Expand Down Expand Up @@ -136,6 +140,10 @@ template <typename Curve> class IPA {
*/
static bool verify(std::shared_ptr<VK> vk, const OpeningClaim<Curve>& opening_claim, BaseTranscript<Fr>& transcript)
{
info("IPA challenge: ", opening_claim.opening_pair.challenge);
info("IPA eval : ", opening_claim.opening_pair.evaluation);
info("IPA comm : ", opening_claim.commitment);

auto poly_degree = static_cast<size_t>(transcript.template receive_from_prover<uint64_t>("IPA:poly_degree"));
Fr generator_challenge = transcript.get_challenge("IPA:generator_challenge");
auto aux_generator = Commitment::one() * generator_challenge;
Expand Down Expand Up @@ -202,7 +210,7 @@ template <typename Curve> class IPA {
// Copy the G_vector to local memory.
std::vector<Commitment> G_vec_local(poly_degree);
// The SRS stored in the commitment key is the result after applying the pippenger point table so the
// values at odd indices contain the point {srs[i-1].x * beta, srs[i-1].y}, where beta is the endomorphism
// values at odd indices contain the point {srs[i-1].x * g beta, srs[i-1].y}, where beta is the endomorphism
// G_vec_local should use only the original SRS thus we extract only the even indices.
for (size_t i = 0; i < poly_degree * 2; i += 2) {
G_vec_local[i >> 1] = srs_elements[i];
Expand All @@ -215,6 +223,8 @@ template <typename Curve> class IPA {

GroupElement right_hand_side = G_zero * a_zero + aux_generator * a_zero * b_zero;

info(C_zero.normalize());
info(right_hand_side.normalize());
return (C_zero.normalize() == right_hand_side.normalize());
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ template <typename Curve> class ShplonkProver_ {
const Fr& nu_challenge,
const Fr& z_challenge)
{

const size_t num_opening_pairs = opening_pairs.size();

// {ẑⱼ(r)}ⱼ , where ẑⱼ(r) = 1/zⱼ(r) = 1/(r - xⱼ)
Expand Down Expand Up @@ -163,16 +164,16 @@ template <typename Curve> class ShplonkVerifier_ {
*/
static OpeningClaim<Curve> reduce_verification(std::shared_ptr<VK> vk,
std::span<const OpeningClaim<Curve>> claims,
auto& transcript)
auto& transcript,
const std::string& suffix = "")
{

const size_t num_claims = claims.size();

const Fr nu = transcript.get_challenge("Shplonk:nu");

auto Q_commitment = transcript.template receive_from_prover<Commitment>("Shplonk:Q");
const Fr nu = transcript.get_challenge("Shplonk" + suffix + ":nu");
auto Q_commitment = transcript.template receive_from_prover<Commitment>("Shplonk" + suffix + ":Q");

const Fr z_challenge = transcript.get_challenge("Shplonk:z");
const Fr z_challenge = transcript.get_challenge("Shplonk" + suffix + ":z");

// [G] = [Q] - ∑ⱼ ρʲ / ( r − xⱼ )⋅[fⱼ] + G₀⋅[1]
// = [Q] - [∑ⱼ ρʲ ⋅ ( fⱼ(X) − vⱼ) / ( r − xⱼ )]
Expand Down
Loading