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

Use tachyon to speed up witness and proofgen #75 #102

Merged
merged 5 commits into from
Aug 21, 2024

Conversation

whoisgautxm
Copy link
Collaborator

Fixes #75

This PR integrates Tachyon to speed up the witness and proof generation process. The following changes were made:

Changed libs/rapidSnark.Dockerfile to libs/tachyon.Dockerfile
Changed the packages/prover/circom_proofgen.sh to accommodate proofgen by tachyon
Changes the packages/prover/Dockerfile to accommodate tachyon prover
Changes the packages/prover/core.py to accommodate tachyon prover
The benchmark results of circom circuits are in this github repo: https://github.com/whoisgautxm/circom-benchmark, which show ~30% speedup due to nmap/mmap usage primarily.

@SoraSuegami
Copy link
Collaborator

Thank you for your PR!
I am sorry for the delay in reviewing it.
When I ran modal deploy modal_server.py, I got the following error when building a docker image.

=> Step 24: RUN git fetch origin && git checkout build/support-building-tachyon-based-on-python-3.10-docker-image
error: pathspec 'build/support-building-tachyon-based-on-python-3.10-docker-image' did not match any file(s) known to git
Terminating task due to error: failed to run builder command "git fetch origin && git checkout build/support-building-tachyon-based-on-python-3.10-docker-image"

I think the Dockerfile should specify main branch of tachyon, right?

@SoraSuegami
Copy link
Collaborator

I changed the branch to main, and got the following error.

ERROR: /tachyon/tachyon/zk/air/plonky3/challenger/BUILD.bazel:53:20: Compiling tachyon/zk/air/plonky3/challenger/duplex_challenger_unittest.cc failed: (Exit 1): gcc failed: error executing command (from target //tachyon/zk/air/plonky3/challenger:challenger_unittests) /usr/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG -ffunction-sections ... (remaining 97 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
In file included from external/com_google_absl/absl/container/inlined_vector.h:53,
                 from ./tachyon/zk/air/plonky3/challenger/duplex_challenger.h:11,
                 from tachyon/zk/air/plonky3/challenger/duplex_challenger_unittest.cc:6:
In member function 'void absl::lts_20230125::inlined_vector_internal::Storage<T, N, A>::MemcpyFrom(const absl::lts_20230125::inlined_vector_internal::Storage<T, N, A>&) [with T = tachyon::math::PrimeField<tachyon::math::BabyBearConfig>; long unsigned int N = 4; A = std::allocator<tachyon::math::PrimeField<tachyon::math::BabyBearConfig> >]',
    inlined from 'void absl::lts_20230125::InlinedVector<T, N, A>::MoveAssignment(MemcpyPolicy, absl::lts_20230125::InlinedVector<T, N, A>&&) [with T = tachyon::math::PrimeField<tachyon::math::BabyBearConfig>; long unsigned int N = 4; A = std::allocator<tachyon::math::PrimeField<tachyon::math::BabyBearConfig> >]' at external/com_google_absl/absl/container/inlined_vector.h:790:24,
    inlined from 'absl::lts_20230125::InlinedVector<T, N, A>& absl::lts_20230125::InlinedVector<T, N, A>::operator=(absl::lts_20230125::InlinedVector<T, N, A>&&) [with T = tachyon::math::PrimeField<tachyon::math::BabyBearConfig>; long unsigned int N = 4; A = std::allocator<tachyon::math::PrimeField<tachyon::math::BabyBearConfig> >]' at external/com_google_absl/absl/container/inlined_vector.h:498:21,
    inlined from 'tachyon::zk::air::plonky3::DuplexChallenger<tachyon::crypto::Poseidon2Sponge<tachyon::crypto::Poseidon2ExternalMatrix<tachyon::crypto::Poseidon2Plonky3ExternalMatrix<tachyon::math::PrimeField<tachyon::math::BabyBearConfig> > > >, 16, 4>& tachyon::zk::air::plonky3::DuplexChallenger<tachyon::crypto::Poseidon2Sponge<tachyon::crypto::Poseidon2ExternalMatrix<tachyon::crypto::Poseidon2Plonky3ExternalMatrix<tachyon::math::PrimeField<tachyon::math::BabyBearConfig> > > >, 16, 4>::operator=(tachyon::zk::air::plonky3::DuplexChallenger<tachyon::crypto::Poseidon2Sponge<tachyon::crypto::Poseidon2ExternalMatrix<tachyon::crypto::Poseidon2Plonky3ExternalMatrix<tachyon::math::PrimeField<tachyon::math::BabyBearConfig> > > >, 16, 4>&&)' at ./tachyon/zk/air/plonky3/challenger/duplex_challenger.h:19:7,
    inlined from 'virtual void tachyon::zk::air::plonky3::{anonymous}::DuplexChallengerTest::SetUp()' at tachyon/zk/air/plonky3/challenger/duplex_challenger_unittest.cc:34:79:
external/com_google_absl/absl/container/internal/inlined_vector.h:468:5: error: '<unnamed>.tachyon::zk::air::plonky3::DuplexChallenger<tachyon::crypto::Poseidon2Sponge<tachyon::crypto::Poseidon2ExternalMatrix<tachyon::crypto::Poseidon2Plonky3ExternalMatrix<tachyon::math::PrimeField<tachyon::math::BabyBearConfig, void> > > >, 16, 4>::input_buffer_.absl::lts_20230125::InlinedVector<tachyon::math::PrimeField<tachyon::math::BabyBearConfig, void>, 4, std::allocator<tachyon::math::PrimeField<tachyon::math::BabyBearConfig, void> > >::storage_.absl::lts_20230125::inlined_vector_internal::Storage<tachyon::math::PrimeField<tachyon::math::BabyBearConfig>, 4, std::allocator<tachyon::math::PrimeField<tachyon::math::BabyBearConfig> > >::data_' may be used uninitialized [-Werror=maybe-uninitialized]
  468 |     data_ = other_storage.data_;
      |     ^~~~~
tachyon/zk/air/plonky3/challenger/duplex_challenger_unittest.cc: In member function 'virtual void tachyon::zk::air::plonky3::{anonymous}::DuplexChallengerTest::SetUp()':
tachyon/zk/air/plonky3/challenger/duplex_challenger_unittest.cc:34:79: note: '<anonymous>' declared here
   34 |     challenger_ = DuplexChallenger<Poseidon2, kWidth, kRate>(std::move(sponge));
      |                                                                               ^
In member function 'void absl::lts_20230125::inlined_vector_internal::Storage<T, N, A>::MemcpyFrom(const absl::lts_20230125::inlined_vector_internal::Storage<T, N, A>&) [with T = tachyon::math::PrimeField<tachyon::math::BabyBearConfig>; long unsigned int N = 16; A = std::allocator<tachyon::math::PrimeField<tachyon::math::BabyBearConfig> >]',
    inlined from 'void absl::lts_20230125::InlinedVector<T, N, A>::MoveAssignment(MemcpyPolicy, absl::lts_20230125::InlinedVector<T, N, A>&&) [with T = tachyon::math::PrimeField<tachyon::math::BabyBearConfig>; long unsigned int N = 16; A = std::allocator<tachyon::math::PrimeField<tachyon::math::BabyBearConfig> >]' at external/com_google_absl/absl/container/inlined_vector.h:790:24,
    inlined from 'absl::lts_20230125::InlinedVector<T, N, A>& absl::lts_20230125::InlinedVector<T, N, A>::operator=(absl::lts_20230125::InlinedVector<T, N, A>&&) [with T = tachyon::math::PrimeField<tachyon::math::BabyBearConfig>; long unsigned int N = 16; A = std::allocator<tachyon::math::PrimeField<tachyon::math::BabyBearConfig> >]' at external/com_google_absl/absl/container/inlined_vector.h:498:21,
    inlined from 'tachyon::zk::air::plonky3::DuplexChallenger<tachyon::crypto::Poseidon2Sponge<tachyon::crypto::Poseidon2ExternalMatrix<tachyon::crypto::Poseidon2Plonky3ExternalMatrix<tachyon::math::PrimeField<tachyon::math::BabyBearConfig> > > >, 16, 4>& tachyon::zk::air::plonky3::DuplexChallenger<tachyon::crypto::Poseidon2Sponge<tachyon::crypto::Poseidon2ExternalMatrix<tachyon::crypto::Poseidon2Plonky3ExternalMatrix<tachyon::math::PrimeField<tachyon::math::BabyBearConfig> > > >, 16, 4>::operator=(tachyon::zk::air::plonky3::DuplexChallenger<tachyon::crypto::Poseidon2Sponge<tachyon::crypto::Poseidon2ExternalMatrix<tachyon::crypto::Poseidon2Plonky3ExternalMatrix<tachyon::math::PrimeField<tachyon::math::BabyBearConfig> > > >, 16, 4>&&)' at ./tachyon/zk/air/plonky3/challenger/duplex_challenger.h:19:7,
    inlined from 'virtual void tachyon::zk::air::plonky3::{anonymous}::DuplexChallengerTest::SetUp()' at tachyon/zk/air/plonky3/challenger/duplex_challenger_unittest.cc:34:79:
external/com_google_absl/absl/container/internal/inlined_vector.h:468:5: error: '<unnamed>.tachyon::zk::air::plonky3::DuplexChallenger<tachyon::crypto::Poseidon2Sponge<tachyon::crypto::Poseidon2ExternalMatrix<tachyon::crypto::Poseidon2Plonky3ExternalMatrix<tachyon::math::PrimeField<tachyon::math::BabyBearConfig, void> > > >, 16, 4>::output_buffer_.absl::lts_20230125::InlinedVector<tachyon::math::PrimeField<tachyon::math::BabyBearConfig, void>, 16, std::allocator<tachyon::math::PrimeField<tachyon::math::BabyBearConfig, void> > >::storage_.absl::lts_20230125::inlined_vector_internal::Storage<tachyon::math::PrimeField<tachyon::math::BabyBearConfig>, 16, std::allocator<tachyon::math::PrimeField<tachyon::math::BabyBearConfig> > >::data_' may be used uninitialized [-Werror=maybe-uninitialized]
  468 |     data_ = other_storage.data_;
      |     ^~~~~
tachyon/zk/air/plonky3/challenger/duplex_challenger_unittest.cc: In member function 'virtual void tachyon::zk::air::plonky3::{anonymous}::DuplexChallengerTest::SetUp()':
tachyon/zk/air/plonky3/challenger/duplex_challenger_unittest.cc:34:79: note: '<anonymous>' declared here
   34 |     challenger_ = DuplexChallenger<Poseidon2, kWidth, kRate>(std::move(sponge));
      |                                                                               ^
cc1plus: all warnings being treated as errors
INFO: Elapsed time: 502.849s, Critical Path: 147.82s
INFO: 4948 processes: 1687 internal, 396 local, 2865 processwrapper-sandbox.
FAILED: Build did NOT complete successfully
Terminating task due to error: failed to run builder command "bazel build //..."

Comment on lines 25 to 26
WORKDIR /tachyon
RUN bazel --batch build --config linux //...

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you only need the prover_main binary, please build just that. Refer to the details in the Tachyon Circom README (assuming you're not using CUDA):

Suggested change
WORKDIR /tachyon
RUN bazel --batch build --config linux //...
WORKDIR /tachyon/vendors/circom
RUN CARGO_BAZEL_REPIN=1 bazel sync --only=crate_index && bazel build --@kroma_network_tachyon//:has_openmp -c opt --config linux //:prover_main

RUN ln -s /usr/bin/python3 /usr/bin/python

# Clone and build Tachyon
RUN git clone https://github.com/kroma-network/tachyon /tachyon

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even with our best efforts, the main branch doesn't always ensure build stability. To mitigate this, I recommend cloning the repository with a specific tag, such as v0.3.0, and upgrade the version gradually.

Suggested change
RUN git clone https://github.com/kroma-network/tachyon /tachyon
RUN git clone --branch v0.3.0 https://github.com/kroma-network/tachyon /tachyon

Comment on lines 65 to 72
# NOTE(whoisgautxm): Should remove after this is merged to main branch
RUN git fetch origin && git checkout main

RUN echo build --config linux > .bazelrc.user && \
echo "build --action_env=CARGO=$HOME/.cargo/bin/cargo" >> .bazelrc.user && \
echo "build --@rules_rust//rust/toolchain/channel=nightly" >> .bazelrc.user
RUN bazel build //...

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
WORKDIR /tachyon
# NOTE(whoisgautxm): Should remove after this is merged to main branch
RUN git fetch origin && git checkout main
RUN echo build --config linux > .bazelrc.user && \
echo "build --action_env=CARGO=$HOME/.cargo/bin/cargo" >> .bazelrc.user && \
echo "build --@rules_rust//rust/toolchain/channel=nightly" >> .bazelrc.user
RUN bazel build //...
WORKDIR /tachyon/vendors/circom
RUN CARGO_BAZEL_REPIN=1 bazel sync --only=crate_index && bazel build --@kroma_network_tachyon//:has_openmp -c opt --config linux //:prover_main


# Clone and build Tachyon
RUN git clone https://github.com/kroma-network/tachyon /tachyon

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
RUN git clone https://github.com/kroma-network/tachyon /tachyon
RUN git clone --branch v0.3.0 https://github.com/kroma-network/tachyon /tachyon

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SoraSuegami I think perhaps you are missing this!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SoraSuegami I think perhaps you are missing this!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much!
I could build the docker image on modal!

@SoraSuegami
Copy link
Collaborator

Thank you for your additional comments!
I reflected changes you suggested, and I next got the following error.

=> Step 24: RUN CARGO_BAZEL_REPIN=1 bazel sync --only=crate_index && bazel build --@kroma_network_tachyon//:has_openmp -c opt --config linux //:prover_main
Extracting Bazel installation...
Starting local Bazel server and connecting to it...
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
WARNING: Download from https://storage.googleapis.com/mirror.tensorflow.org/github.com/kroma-network/ffiasm/archive/7db5a442b12dba825ec35361441aa116dc3bff8b.tar.gz failed: class java.io.FileNotFoundException GET returned 404 Not Found
 checking cached actions
 checking cached actions
 checking cached actions
Loading: 
Loading: 
Loading: 
Loading: 1 packages loaded
Analyzing: target //:prover_main (2 packages loaded, 0 targets configured)
Analyzing: target //:prover_main (88 packages loaded, 223 targets configured)
WARNING: Download from https://storage.googleapis.com/mirror.tensorflow.org/github.com/ingonyama-zk/icicle/archive/4fef5423462a72a37fe66cee89e24eae083cc112.tar.gz failed: class java.io.FileNotFoundException GET returned 404 Not Found
Analyzing: target //:prover_main (151 packages loaded, 668 targets configured)
WARNING: Download from https://storage.googleapis.com/mirror.tensorflow.org/github.com/orlp/pdqsort/archive/b1ef26a55cdb60d236a5cb199c4234c704f46726.tar.gz failed: class java.io.FileNotFoundException GET returned 404 Not Found
DEBUG: Rule 'com_github_gflags_gflags' indicated that a canonical reproducible form can be obtained by modifying arguments sha256 = "34af2f15cf7367513b352bdcd2493ab14ce43692d2dcd9dfc499492966c64dcf"
DEBUG: Repository com_github_gflags_gflags instantiated at:
  /tachyon/vendors/circom/WORKSPACE:56:13: in <toplevel>
  /root/.cache/bazel/_bazel_root/0f899c535a62c364a7f75378d7f046ec/external/kroma_network_tachyon/bazel/tachyon_deps.bzl:65:21: in tachyon_deps
Repository rule http_archive defined at:
  /root/.cache/bazel/_bazel_root/0f899c535a62c364a7f75378d7f046ec/external/bazel_tools/tools/build_defs/repo/http.bzl:372:31: in <toplevel>
WARNING: Download from https://mirror.bazel.build/github.com/gflags/gflags/archive/v2.2.2.tar.gz failed: class java.io.FileNotFoundException GET returned 404 Not Found
WARNING: Download from https://storage.googleapis.com/mirror.tensorflow.org/github.com/sebawild/powersort/archive/48e31e909280ca43bb2c33dd3df9922b0a0f3f84.tar.gz failed: class java.io.FileNotFoundException GET returned 404 Not Found
Analyzing: target //:prover_main (165 packages loaded, 1430 targets configured)
Analyzing: target //:prover_main (171 packages loaded, 1845 targets configured)
Analyzing: target //:prover_main (179 packages loaded, 7332 targets configured)
Analyzing: target //:prover_main (349 packages loaded, 8572 targets configured)
Analyzing: target //:prover_main (350 packages loaded, 8647 targets configured)
Analyzing: target //:prover_main (350 packages loaded, 8647 targets configured)
INFO: Analyzed target //:prover_main (351 packages loaded, 8673 targets configured).
INFO: Found 1 target...
[0 / 308] [Prepa] BazelWorkspaceStatusAction stable-status.txt
[492 / 1,043] Compiling absl/base/internal/throw_delegate.cc; 0s processwrapper-sandbox ... (51 actions, 48 running)
[645 / 1,114] Compiling absl/numeric/int128.cc; 1s processwrapper-sandbox ... (53 actions, 51 running)
[824 / 1,208] Compiling absl/strings/internal/cord_rep_btree_navigator.cc; 2s processwrapper-sandbox ... (52 actions, 50 running)
[932 / 1,259] Compiling absl/strings/internal/cord_internal.cc; 3s processwrapper-sandbox ... (51 actions, 49 running)
[1,017 / 1,328] Compiling absl/strings/internal/cordz_info.cc; 4s processwrapper-sandbox ... (51 actions, 50 running)
[1,039 / 1,330] Compiling absl/strings/cord.cc; 5s processwrapper-sandbox ... (58 actions, 57 running)
[1,056 / 1,330] Compiling absl/strings/cord.cc; 6s processwrapper-sandbox ... (58 actions, 57 running)
[1,075 / 1,330] Compiling absl/strings/cord.cc; 7s processwrapper-sandbox ... (58 actions, 57 running)
[1,086 / 1,330] Creating runfiles tree bazel-out/k8-opt-exec-2B5CBBC6/bin/external/aspect_rules_js/npm/private/lifecycle/lifecycle-hooks.sh.runfiles [for tool]; 8s local ... (58 actions, 57 running)
[1,101 / 1,330] Creating runfiles tree bazel-out/k8-opt-exec-2B5CBBC6/bin/external/aspect_rules_js/npm/private/lifecycle/lifecycle-hooks.sh.runfiles [for tool]; 9s local ... (57 actions, 56 running)
[1,106 / 1,330] Creating runfiles tree bazel-out/k8-opt-exec-2B5CBBC6/bin/external/aspect_rules_js/npm/private/lifecycle/lifecycle-hooks.sh.runfiles [for tool]; 11s local ... (57 actions running)
[1,124 / 1,330] Creating runfiles tree bazel-out/k8-opt-exec-2B5CBBC6/bin/external/aspect_rules_js/npm/private/lifecycle/lifecycle-hooks.sh.runfiles [for tool]; 12s local ... (58 actions, 57 running)
[1,146 / 1,330] Creating runfiles tree bazel-out/k8-opt-exec-2B5CBBC6/bin/external/aspect_rules_js/npm/private/lifecycle/lifecycle-hooks.sh.runfiles [for tool]; 13s local ... (58 actions, 57 running)
[1,175 / 1,330] Creating runfiles tree bazel-out/k8-opt-exec-2B5CBBC6/bin/external/aspect_rules_js/npm/private/lifecycle/lifecycle-hooks.sh.runfiles [for tool]; 14s local ... (58 actions, 57 running)
[1,208 / 1,330] Creating runfiles tree bazel-out/k8-opt-exec-2B5CBBC6/bin/external/aspect_rules_js/npm/private/lifecycle/lifecycle-hooks.sh.runfiles [for tool]; 15s local ... (53 actions running)
[1,250 / 1,330] Creating runfiles tree bazel-out/k8-opt-exec-2B5CBBC6/bin/external/aspect_rules_js/npm/private/lifecycle/lifecycle-hooks.sh.runfiles [for tool]; 16s local ... (12 actions running)
[1,253 / 1,330] Creating runfiles tree bazel-out/k8-opt-exec-2B5CBBC6/bin/external/aspect_rules_js/npm/private/lifecycle/lifecycle-hooks.sh.runfiles [for tool]; 17s local ... (11 actions running)
[1,262 / 1,330] Creating runfiles tree bazel-out/k8-opt-exec-2B5CBBC6/bin/external/aspect_rules_js/npm/private/lifecycle/lifecycle-hooks.sh.runfiles [for tool]; 18s local ... (6 actions running)
[1,281 / 1,330] Compiling sdk/perfetto.cc; 12s processwrapper-sandbox ... (12 actions, 5 running)
[1,312 / 1,330] Compiling sdk/perfetto.cc; 14s processwrapper-sandbox ... (13 actions running)
[1,317 / 1,330] Compiling sdk/perfetto.cc; 16s processwrapper-sandbox ... (8 actions running)
[1,318 / 1,330] Compiling sdk/perfetto.cc; 19s processwrapper-sandbox ... (7 actions running)
[1,319 / 1,330] Compiling sdk/perfetto.cc; 23s processwrapper-sandbox ... (6 actions running)
[1,323 / 1,330] Compiling sdk/perfetto.cc; 24s processwrapper-sandbox ... (6 actions, 5 running)
[1,327 / 1,330] Compiling sdk/perfetto.cc; 26s processwrapper-sandbox ... (2 actions running)
ERROR: /tachyon/vendors/circom/BUILD.bazel:3:18: Compiling prover_main.cc failed: (Exit 1): gcc failed: error executing command (from target //:prover_main) /usr/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG -ffunction-sections ... (remaining 123 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
In file included from external/kroma_network_tachyon/tachyon/math/polynomials/univariate/univariate_evaluation_domain_factory.h:11,
                 from prover_main.cc:16:
In static member function 'static constexpr std::unique_ptr<tachyon::math::MixedRadixEvaluationDomain<F, MaxDegree> > tachyon::math::MixedRadixEvaluationDomain<F, MaxDegree>::Create(size_t) [with F = tachyon::math::PrimeField<tachyon::math::bls12_381::FrConfig>; long unsigned int MaxDegree = 18446744073709551615]',
    inlined from 'static constexpr std::unique_ptr<tachyon::math::UnivariateEvaluationDomain<F, MaxDegree> > tachyon::math::UnivariateEvaluationDomainFactory<F, MaxDegree>::Create(size_t) [with F = tachyon::math::PrimeField<tachyon::math::bls12_381::FrConfig>; long unsigned int MaxDegree = 18446744073709551615]' at external/kroma_network_tachyon/tachyon/math/polynomials/univariate/univariate_evaluation_domain_factory.h:39:73,
    inlined from 'static constexpr std::unique_ptr<tachyon::math::UnivariateEvaluationDomain<F, MaxDegree> > tachyon::math::UnivariateEvaluationDomain<F, MaxDegree>::Create(size_t) [with F = tachyon::math::PrimeField<tachyon::math::bls12_381::FrConfig>; long unsigned int MaxDegree = 18446744073709551615]' at external/kroma_network_tachyon/tachyon/math/polynomials/univariate/univariate_evaluation_domain.h:75:78,
    inlined from 'void tachyon::circom::CreateProof(const tachyon::base::FilePath&, const tachyon::base::FilePath&, const tachyon::base::FilePath&, const tachyon::base::FilePath&, const CreateProofOptions&) [with Curve = tachyon::math::BLS12Curve<tachyon::math::bls12_381::BLS12_381Config<tachyon::math::PrimeField<tachyon::math::bls12_381::FqConfig>, tachyon::math::Fp2<tachyon::math::bls12_381::Fq2Config<tachyon::math::PrimeField<tachyon::math::bls12_381::FqConfig> > >, tachyon::math::Fp6<tachyon::math::bls12_381::Fq6Config<tachyon::math::Fp2<tachyon::math::bls12_381::Fq2Config<tachyon::math::PrimeField<tachyon::math::bls12_381::FqConfig> > > > >, tachyon::math::Fp12<tachyon::math::bls12_381::Fq12Config<tachyon::math::Fp6<tachyon::math::bls12_381::Fq6Config<tachyon::math::Fp2<tachyon::math::bls12_381::Fq2Config<tachyon::math::PrimeField<tachyon::math::bls12_381::FqConfig> > > > > > >, tachyon::math::SWCurve<tachyon::math::bls12_381::G1CurveConfig<tachyon::math::PrimeField<tachyon::math::bls12_381::FqConfig>, tachyon::math::PrimeField<tachyon::math::bls12_381::FrConfig> > >, tachyon::math::SWCurve<tachyon::math::bls12_381::G2CurveConfig<tachyon::math::Fp2<tachyon::math::bls12_381::Fq2Config<tachyon::math::PrimeField<tachyon::math::bls12_381::FqConfig> > >, tachyon::math::PrimeField<tachyon::math::bls12_381::FrConfig> > > > >]' at prover_main.cc:116:27:
external/kroma_network_tachyon/tachyon/math/polynomials/univariate/mixed_radix_evaluation_domain.h:70:9: error: 'factors.tachyon::math::PrimeFieldFactors::two_adicity' may be used uninitialized [-Werror=maybe-uninitialized]
   70 |         new MixedRadixEvaluationDomain(size, factors.two_adicity));
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
external/kroma_network_tachyon/tachyon/math/polynomials/univariate/mixed_radix_evaluation_domain.h: In function 'void tachyon::circom::CreateProof(const tachyon::base::FilePath&, const tachyon::base::FilePath&, const tachyon::base::FilePath&, const tachyon::base::FilePath&, const CreateProofOptions&) [with Curve = tachyon::math::BLS12Curve<tachyon::math::bls12_381::BLS12_381Config<tachyon::math::PrimeField<tachyon::math::bls12_381::FqConfig>, tachyon::math::Fp2<tachyon::math::bls12_381::Fq2Config<tachyon::math::PrimeField<tachyon::math::bls12_381::FqConfig> > >, tachyon::math::Fp6<tachyon::math::bls12_381::Fq6Config<tachyon::math::Fp2<tachyon::math::bls12_381::Fq2Config<tachyon::math::PrimeField<tachyon::math::bls12_381::FqConfig> > > > >, tachyon::math::Fp12<tachyon::math::bls12_381::Fq12Config<tachyon::math::Fp6<tachyon::math::bls12_381::Fq6Config<tachyon::math::Fp2<tachyon::math::bls12_381::Fq2Config<tachyon::math::PrimeField<tachyon::math::bls12_381::FqConfig> > > > > > >, tachyon::math::SWCurve<tachyon::math::bls12_381::G1CurveConfig<tachyon::math::PrimeField<tachyon::math::bls12_381::FqConfig>, tachyon::math::PrimeField<tachyon::math::bls12_381::FrConfig> > >, tachyon::math::SWCurve<tachyon::math::bls12_381::G2CurveConfig<tachyon::math::Fp2<tachyon::math::bls12_381::Fq2Config<tachyon::math::PrimeField<tachyon::math::bls12_381::FqConfig> > >, tachyon::math::PrimeField<tachyon::math::bls12_381::FrConfig> > > > >]':
external/kroma_network_tachyon/tachyon/math/polynomials/univariate/mixed_radix_evaluation_domain.h:67:23: note: 'factors' declared here
   67 |     PrimeFieldFactors factors;
      |                       ^~~~~~~
cc1plus: all warnings being treated as errors
Target //:prover_main failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 56.433s, Critical Path: 38.74s
INFO: 1277 processes: 564 internal, 396 local, 317 processwrapper-sandbox.
FAILED: Build did NOT complete successfully
Terminating task due to error: failed to run builder command "CARGO_BAZEL_REPIN=1 bazel sync --only=crate_index && bazel build --@kroma_network_tachyon//:has_openmp -c opt --config linux //:prover_main"

Caused by:
    container exit status: 1

@SoraSuegami SoraSuegami merged commit 906c0c9 into main Aug 21, 2024
4 checks passed
@SoraSuegami
Copy link
Collaborator

@chokobole Is the following format correct for the output of the tachyon prover?
https://github.com/zkemail/email-wallet/blob/main/packages/relayer/src/utils/utils.rs#L44-L49

@chokobole
Copy link

We don't store points in a vector of strings, as demonstrated in the code here. However, the output of prover_main is identical to that of a proof generated by rapidsnark. You can see more details in this file.

@Divide-By-0
Copy link
Member

If our parsing is wrong, are we confident that a new modal deployment will still be able to generate the correct format of proof? Was this end-to-end tested at all

@SoraSuegami
Copy link
Collaborator

@chokobole
I got the following json from a prover.

"proof": [
    "2018721414038404820327",
    "0",
    "0",
    "0",
    "0",
    "0",
    "0",
    "0",
    "0",
    "6632353713085157925504008443078919716322386156160602218536961028046468237192",
    "19894320019016719114298695954688611116822060474192999674641264748344728553214",
    "1724342615",
    "12424312113957298897351547719054010854075115739442060206737756826328039462065",
    "4294223308299735140139693782429412250667096998968531391722386702932610034429",
    "10287587543879982271389500964794028174629429687291862342493089880334707793270"
  ]

I am not sure why it is different from the expected format in the code.
Could you tell me how to fix that, or how can the relayer decompose it into pi_a, pi_b, and pi_c parts?

@SoraSuegami
Copy link
Collaborator

If our parsing is wrong, are we confident that a new modal deployment will still be able to generate the correct format of proof? Was this end-to-end tested at all

Sorry, I merged this PR because the modal sever pulls this repo from main branch when building a Dockerfile, and I expected that the prover worked once a docker image is built.

SoraSuegami added a commit that referenced this pull request Aug 22, 2024
SoraSuegami added a commit that referenced this pull request Aug 22, 2024
@chokobole
Copy link

@SoraSuegami Could you tell me how to run the tests?

@SoraSuegami
Copy link
Collaborator

SoraSuegami commented Aug 27, 2024

@chokobole
Sorry for the late reply.
Could you pass the following json data to "/prove/account_creation" POST endpoint of the prover server?

"input": {
    "in_padded": [
        "116",
        "111",
        "58",
        "101",
        "109",
        "97",
        "105",
        "119",
        "97",
        "108",
        "108",
        "101",
        "116",
        "46",
        "97",
        "108",
        "105",
        "99",
        "101",
        "64",
        "103",
        "109",
        "97",
        "105",
        "108",
        "46",
        "99",
        "111",
        "109",
        "13",
        "10",
        "115",
        "117",
        "98",
        "106",
        "101",
        "99",
        "116",
        "58",
        "69",
        "109",
        "97",
        "105",
        "108",
        "32",
        "87",
        "97",
        "108",
        "108",
        "101",
        "116",
        "32",
        "65",
        "99",
        "99",
        "111",
        "117",
        "110",
        "116",
        "32",
        "67",
        "114",
        "101",
        "97",
        "116",
        "105",
        "111",
        "110",
        "46",
        "32",
        "67",
        "111",
        "100",
        "101",
        "32",
        "48",
        "53",
        "98",
        "98",
        "97",
        "53",
        "98",
        "48",
        "99",
        "56",
        "55",
        "50",
        "100",
        "56",
        "49",
        "99",
        "100",
        "54",
        "98",
        "97",
        "48",
        "53",
        "100",
        "56",
        "56",
        "49",
        "56",
        "52",
        "98",
        "52",
        "98",
        "50",
        "97",
        "57",
        "57",
        "101",
        "56",
        "102",
        "55",
        "97",
        "99",
        "98",
        "53",
        "50",
        "54",
        "99",
        "50",
        "49",
        "48",
        "52",
        "48",
        "98",
        "57",
        "101",
        "49",
        "97",
        "99",
        "48",
        "50",
        "56",
        "102",
        "51",
        "53",
        "49",
        "13",
        "10",
        "109",
        "101",
        "115",
        "115",
        "97",
        "103",
        "101",
        "45",
        "105",
        "100",
        "58",
        "60",
        "67",
        "65",
        "74",
        "55",
        "89",
        "54",
        "106",
        "101",
        "51",
        "70",
        "86",
        "120",
        "69",
        "117",
        "118",
        "66",
        "72",
        "71",
        "114",
        "68",
        "76",
        "61",
        "98",
        "120",
        "50",
        "113",
        "77",
        "115",
        "76",
        "101",
        "53",
        "119",
        "98",
        "85",
        "50",
        "113",
        "115",
        "100",
        "69",
        "98",
        "112",
        "70",
        "109",
        "112",
        "50",
        "48",
        "49",
        "86",
        "111",
        "69",
        "119",
        "64",
        "109",
        "97",
        "105",
        "108",
        "46",
        "103",
        "109",
        "97",
        "105",
        "108",
        "46",
        "99",
        "111",
        "109",
        "62",
        "13",
        "10",
        "100",
        "97",
        "116",
        "101",
        "58",
        "84",
        "117",
        "101",
        "44",
        "32",
        "50",
        "55",
        "32",
        "65",
        "117",
        "103",
        "32",
        "50",
        "48",
        "50",
        "52",
        "32",
        "49",
        "55",
        "58",
        "51",
        "53",
        "58",
        "49",
        "56",
        "32",
        "43",
        "48",
        "57",
        "48",
        "48",
        "13",
        "10",
        "102",
        "114",
        "111",
        "109",
        "58",
        "83",
        "111",
        "114",
        "97",
        "32",
        "83",
        "117",
        "101",
        "103",
        "97",
        "109",
        "105",
        "32",
        "60",
        "115",
        "117",
        "101",
        "103",
        "97",
        "109",
        "105",
        "115",
        "111",
        "114",
        "97",
        "64",
        "103",
        "109",
        "97",
        "105",
        "108",
        "46",
        "99",
        "111",
        "109",
        "62",
        "13",
        "10",
        "109",
        "105",
        "109",
        "101",
        "45",
        "118",
        "101",
        "114",
        "115",
        "105",
        "111",
        "110",
        "58",
        "49",
        "46",
        "48",
        "13",
        "10",
        "100",
        "107",
        "105",
        "109",
        "45",
        "115",
        "105",
        "103",
        "110",
        "97",
        "116",
        "117",
        "114",
        "101",
        "58",
        "118",
        "61",
        "49",
        "59",
        "32",
        "97",
        "61",
        "114",
        "115",
        "97",
        "45",
        "115",
        "104",
        "97",
        "50",
        "53",
        "54",
        "59",
        "32",
        "99",
        "61",
        "114",
        "101",
        "108",
        "97",
        "120",
        "101",
        "100",
        "47",
        "114",
        "101",
        "108",
        "97",
        "120",
        "101",
        "100",
        "59",
        "32",
        "100",
        "61",
        "103",
        "109",
        "97",
        "105",
        "108",
        "46",
        "99",
        "111",
        "109",
        "59",
        "32",
        "115",
        "61",
        "50",
        "48",
        "50",
        "51",
        "48",
        "54",
        "48",
        "49",
        "59",
        "32",
        "116",
        "61",
        "49",
        "55",
        "50",
        "52",
        "55",
        "52",
        "55",
        "55",
        "51",
        "48",
        "59",
        "32",
        "120",
        "61",
        "49",
        "55",
        "50",
        "53",
        "51",
        "53",
        "50",
        "53",
        "51",
        "48",
        "59",
        "32",
        "100",
        "97",
        "114",
        "97",
        "61",
        "103",
        "111",
        "111",
        "103",
        "108",
        "101",
        "46",
        "99",
        "111",
        "109",
        "59",
        "32",
        "104",
        "61",
        "116",
        "111",
        "58",
        "115",
        "117",
        "98",
        "106",
        "101",
        "99",
        "116",
        "58",
        "109",
        "101",
        "115",
        "115",
        "97",
        "103",
        "101",
        "45",
        "105",
        "100",
        "58",
        "100",
        "97",
        "116",
        "101",
        "58",
        "102",
        "114",
        "111",
        "109",
        "58",
        "109",
        "105",
        "109",
        "101",
        "45",
        "118",
        "101",
        "114",
        "115",
        "105",
        "111",
        "110",
        "58",
        "102",
        "114",
        "111",
        "109",
        "58",
        "116",
        "111",
        "58",
        "99",
        "99",
        "58",
        "115",
        "117",
        "98",
        "106",
        "101",
        "99",
        "116",
        "32",
        "58",
        "100",
        "97",
        "116",
        "101",
        "58",
        "109",
        "101",
        "115",
        "115",
        "97",
        "103",
        "101",
        "45",
        "105",
        "100",
        "58",
        "114",
        "101",
        "112",
        "108",
        "121",
        "45",
        "116",
        "111",
        "59",
        "32",
        "98",
        "104",
        "61",
        "82",
        "98",
        "68",
        "88",
        "114",
        "107",
        "105",
        "73",
        "109",
        "82",
        "71",
        "116",
        "117",
        "70",
        "52",
        "109",
        "116",
        "98",
        "98",
        "51",
        "97",
        "113",
        "69",
        "82",
        "110",
        "77",
        "109",
        "88",
        "106",
        "82",
        "57",
        "104",
        "120",
        "114",
        "114",
        "82",
        "113",
        "78",
        "104",
        "110",
        "107",
        "72",
        "56",
        "61",
        "59",
        "32",
        "98",
        "61",
        "128",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "18",
        "96",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0"
    ],
    "pubkey": [
        "2107195391459410975264579855291297887",
        "2562632063603354817278035230349645235",
        "1868388447387859563289339873373526818",
        "2159353473203648408714805618210333973",
        "351789365378952303483249084740952389",
        "659717315519250910761248850885776286",
        "1321773785542335225811636767147612036",
        "258646249156909342262859240016844424",
        "644872192691135519287736182201377504",
        "174898460680981733302111356557122107",
        "1068744134187917319695255728151595132",
        "1870792114609696396265442109963534232",
        "8288818605536063568933922407756344",
        "1446710439657393605686016190803199177",
        "2256068140678002554491951090436701670",
        "518946826903468667178458656376730744",
        "3222036726675473160989497427257757"
    ],
    "signature": [
        "335992625265003713003703271366365205",
        "1871237777855547144812801917223343780",
        "106508606336782023744762985070058216",
        "2400892623382387620510255985725237396",
        "292408932416815817990429002759293251",
        "2523918905778795080925262380089314320",
        "1504660408070810519669523369299272602",
        "1587280029638103745273914317700813376",
        "2405623573622273293005431363269025521",
        "311482349457442701574871559785229354",
        "1391191727965739419049927871210659789",
        "1040116797814855458022472948986674472",
        "2053604244847407191285520093795491462",
        "2045330438179675033739572210411131444",
        "1601014344972070387007602004959338906",
        "805988531404043665032095407960793970",
        "2793795832846907023830455030728570"
    ],
    "in_padded_len": "640",
    "relayer_rand": "0x0db75d2cfc53917134303eb685eef53b44f5ae3c69de7f4e6791c4273ad2833b",
    "sender_email_idx": 279,
    "code_idx": 75,
    "domain_idx": 12,
    "timestamp_idx": 401
}

@Bisht13
Copy link
Member

Bisht13 commented Sep 13, 2024

@chokobole the tests still seems to be slower than rapidsnark, maybe we can see some sort of acceleration by using gpu?

@batzor
Copy link

batzor commented Sep 13, 2024

@Bisht13 I think I can inspect this. Could you tell me your specs and how you tested the performance?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use tachyon to speed up witness and proofgen
6 participants