Skip to content
This repository has been archived by the owner on Feb 17, 2025. It is now read-only.

Add a nix-based build environment #48

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
26 changes: 26 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

83 changes: 83 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
{
description = "Solana state proof";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs";
};

outputs = { self, nixpkgs }:
let
revCount = self.revCount or 1;
package_version = "0.1.0-${toString revCount}";

# Systems supported
allSystems = [
"x86_64-linux" # 64-bit Intel/AMD Linux
"aarch64-linux" # 64-bit ARM Linux
"x86_64-darwin" # 64-bit Intel macOS
"aarch64-darwin" # 64-bit ARM macOS
];

forAllSystems = f: nixpkgs.lib.genAttrs allSystems (system: f {
pkgs = import nixpkgs { inherit system; };
});


make_package = pkgs: with pkgs;
let
stdenv = pkgs.llvmPackages_15.stdenv;

pythonEnv = python3.withPackages (ps: with ps; [ sphinx pydata-sphinx-theme ]);
in
stdenv.mkDerivation {
name = "solana_state_proof";
src = self;
dontFixCmake = true;
env.CXXFLAGS = toString([
"-fPIC"
]);
env.NIX_CFLAGS_COMPILE = toString([
"-Wno-unused-but-set-variable"
]);
nativeBuildInputs = [
cmake
(pkgs.callPackage ./fmt.nix {}).fmt_6
protobuf
c-ares
boost177
ragel
gnutls
lz4
pkg-config
yaml-cpp
lksctp-tools
hwloc
numactl
libxfs
libsystemtap
linuxPackages.perf
gdb
];
cmakeFlags = [
"-DCMAKE_BUILD_TYPE=Debug"
"-DBUILD_SHARED_LIBS=FALSE"
"-DBUILD_TESTS=TRUE"
"-DBUILD_WITH_NUMA=FALSE"
"-DBUILD_WITH_CUDA=FALSE"
"-DBUILD_WITH_OPENCL=FALSE"
"-DBUILD_WITH_SANITIZE=FALSE"
"-DBUILD_WITH_DPDK=FALSE"
"-DCRYPTO3_HASH_POSEIDON=FALSE"
"-DBUILD_EXAMPLES=TRUE"
"-DZK_PLACEHOLDER_PROFILING=TRUE"
"-DBLUEPRINT_PLACEHOLDER_PROOF_GEN=True"
];
};
in
{
packages = forAllSystems({ pkgs }: {
solana_state_proof = make_package pkgs;
default = make_package pkgs;
});
};
}
39 changes: 39 additions & 0 deletions fmt.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5f0fff01..07ed8faa 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -226,16 +226,6 @@ if (FMT_SAFE_DURATION_CAST)
target_compile_definitions(fmt PUBLIC FMT_SAFE_DURATION_CAST)
endif()

-add_library(fmt-header-only INTERFACE)
-add_library(fmt::fmt-header-only ALIAS fmt-header-only)
-
-target_compile_definitions(fmt-header-only INTERFACE FMT_HEADER_ONLY=1)
-target_compile_features(fmt-header-only INTERFACE ${FMT_REQUIRED_FEATURES})
-
-target_include_directories(fmt-header-only INTERFACE
- $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
- $<INSTALL_INTERFACE:${FMT_INC_DIR}>)
-
# Install targets.
if (FMT_INSTALL)
include(CMakePackageConfigHelpers)
@@ -273,7 +263,7 @@ if (FMT_INSTALL)
${project_config}
INSTALL_DESTINATION ${FMT_CMAKE_DIR})

- set(INSTALL_TARGETS fmt fmt-header-only)
+ set(INSTALL_TARGETS fmt)
# Use a namespace because CMake provides better diagnostics for namespaced
# imported targets.
export(TARGETS ${INSTALL_TARGETS} NAMESPACE fmt::
@@ -292,8 +282,6 @@ if (FMT_INSTALL)
ARCHIVE DESTINATION ${FMT_LIB_DIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

- install(FILES $<TARGET_PDB_FILE:${INSTALL_TARGETS}>
- DESTINATION ${FMT_LIB_DIR} OPTIONAL)
install(FILES ${FMT_HEADERS} DESTINATION "${FMT_INC_DIR}/fmt")
install(FILES "${pkgconfig}" DESTINATION "${FMT_PKGCONFIG_DIR}")
endif ()
98 changes: 98 additions & 0 deletions fmt.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
{ lib
, stdenv
, fetchFromGitHub, fetchpatch
, cmake
, enableShared ? !stdenv.hostPlatform.isStatic
# tests
, mpd
, openimageio
, fcitx5
, spdlog
}:

let
generic = { version, sha256, patches ? [ ] }:
stdenv.mkDerivation {
pname = "fmt";
inherit version;

outputs = [ "out" "dev" ];

src = fetchFromGitHub {
owner = "fmtlib";
repo = "fmt";
rev = version;
inherit sha256;
};
patches = [
# Fix BC break breaking Kodi
# https://github.com/xbmc/xbmc/issues/17629
# https://github.com/fmtlib/fmt/issues/1620
(fetchpatch {
url = "https://github.com/fmtlib/fmt/commit/7d01859ef16e6b65bc023ad8bebfedecb088bf81.patch";
sha256 = "0v8hm5958ih1bmnjr16fsbcmdnq4ykyf6b0hg6dxd5hxd126vnxx";
})

# Fix paths in pkg-config file
# https://github.com/fmtlib/fmt/pull/1657
(fetchpatch {
url = "https://github.com/fmtlib/fmt/commit/78f041ab5b40a1145ba686aeb8013e8788b08cd2.patch";
sha256 = "1hqp96zl9l3qyvsm7pxl6ah8c26z035q2mz2pqhqa0wvzd1klcc6";
})

# Fix cmake config paths.
(fetchpatch {
url = "https://github.com/fmtlib/fmt/pull/1702.patch";
sha256 = "18cadqi7nac37ymaz3ykxjqs46rvki396g6qkqwp4k00cmic23y3";
})
./fmt.diff
];


nativeBuildInputs = [ cmake ];

cmakeFlags = [
"-DBUILD_SHARED_LIBS=${if enableShared then "ON" else "OFF"}"
];

doCheck = true;

passthru.tests = {
inherit mpd openimageio fcitx5 spdlog;
};

meta = with lib; {
description = "Small, safe and fast formatting library";
longDescription = ''
fmt (formerly cppformat) is an open-source formatting library. It can be
used as a fast and safe alternative to printf and IOStreams.
'';
homepage = "https://fmt.dev/";
changelog = "https://github.com/fmtlib/fmt/blob/${version}/ChangeLog.rst";
downloadPage = "https://github.com/fmtlib/fmt/";
maintainers = [ maintainers.jdehaas ];
license = licenses.mit;
platforms = platforms.all;
};
};
in
{
fmt_6 = generic {
version = "6.2.1";
sha256 = "sha256-LGKMl65YGbOdMuGmvVpG+mA8efyD+a5HLqAR/FV31sQ=";
};
fmt_8 = generic {
version = "8.1.1";
sha256 = "sha256-leb2800CwdZMJRWF5b1Y9ocK0jXpOX/nwo95icDf308=";
};

fmt_9 = generic {
version = "9.1.0";
sha256 = "sha256-rP6ymyRc7LnKxUXwPpzhHOQvpJkpnRFOt2ctvUNlYI0=";
};

fmt_10 = generic {
version = "10.1.1";
sha256 = "sha256-H9+1lEaHM12nzXSmo9m8S6527t+97e6necayyjCPm1A=";
};
}
2 changes: 1 addition & 1 deletion libs/actor/zk
Submodule zk updated 128 files
2 changes: 1 addition & 1 deletion libs/algebra
Submodule algebra updated 43 files
+26 −0 include/nil/crypto3/algebra/curves/detail/bls12/g1.hpp
+28 −2 include/nil/crypto3/algebra/curves/detail/curve25519/g1.hpp
+12 −4 include/nil/crypto3/algebra/curves/detail/curve25519/params.hpp
+56 −6 include/nil/crypto3/algebra/curves/detail/edwards/element_g2.hpp
+51 −5 include/nil/crypto3/algebra/curves/detail/forms/edwards/inverted/element_g1.hpp
+40 −0 include/nil/crypto3/algebra/curves/detail/forms/montgomery/element_g1_affine.hpp
+53 −5 include/nil/crypto3/algebra/curves/detail/forms/short_weierstrass/element_g1_affine.hpp
+38 −5 include/nil/crypto3/algebra/curves/detail/forms/short_weierstrass/jacobian/element_g1.hpp
+45 −7 include/nil/crypto3/algebra/curves/detail/forms/short_weierstrass/jacobian_with_a4_0/element_g1.hpp
+44 −6 include/nil/crypto3/algebra/curves/detail/forms/short_weierstrass/jacobian_with_a4_minus_3/element_g1.hpp
+53 −7 include/nil/crypto3/algebra/curves/detail/forms/short_weierstrass/projective/element_g1.hpp
+45 −5 include/nil/crypto3/algebra/curves/detail/forms/twisted_edwards/element_g1_affine.hpp
+44 −10 include/nil/crypto3/algebra/curves/detail/forms/twisted_edwards/extended_with_a_minus_1/element_g1.hpp
+44 −6 include/nil/crypto3/algebra/curves/detail/forms/twisted_edwards/inverted/element_g1.hpp
+1 −1 include/nil/crypto3/algebra/curves/detail/marshalling.hpp
+21 −0 include/nil/crypto3/algebra/curves/detail/pallas/g1.hpp
+9 −1 include/nil/crypto3/algebra/curves/detail/pallas/params.hpp
+3 −2 include/nil/crypto3/algebra/curves/detail/pallas/types.hpp
+21 −0 include/nil/crypto3/algebra/curves/detail/vesta/g1.hpp
+9 −2 include/nil/crypto3/algebra/curves/detail/vesta/params.hpp
+3 −2 include/nil/crypto3/algebra/curves/detail/vesta/types.hpp
+6 −3 include/nil/crypto3/algebra/fields/arithmetic_params/pallas.hpp
+5 −2 include/nil/crypto3/algebra/fields/arithmetic_params/vesta.hpp
+19 −13 include/nil/crypto3/algebra/fields/bls12/base_field.hpp
+19 −13 include/nil/crypto3/algebra/fields/bls12/scalar_field.hpp
+12 −8 include/nil/crypto3/algebra/fields/curve25519/base_field.hpp
+12 −7 include/nil/crypto3/algebra/fields/curve25519/scalar_field.hpp
+23 −2 include/nil/crypto3/algebra/fields/detail/element/fp.hpp
+10 −0 include/nil/crypto3/algebra/fields/detail/element/fp12_2over3over2.hpp
+1 −0 include/nil/crypto3/algebra/fields/detail/element/fp2.hpp
+5 −3 include/nil/crypto3/algebra/fields/detail/element/fp3.hpp
+2 −0 include/nil/crypto3/algebra/fields/detail/element/fp4.hpp
+4 −0 include/nil/crypto3/algebra/fields/detail/element/fp6_2over3.hpp
+2 −0 include/nil/crypto3/algebra/fields/detail/element/fp6_3over2.hpp
+7 −1 include/nil/crypto3/algebra/fields/field.hpp
+16 −8 include/nil/crypto3/algebra/fields/pallas/base_field.hpp
+6 −0 include/nil/crypto3/algebra/fields/pallas/scalar_field.hpp
+16 −9 include/nil/crypto3/algebra/fields/vesta/base_field.hpp
+6 −0 include/nil/crypto3/algebra/fields/vesta/scalar_field.hpp
+77 −0 include/nil/crypto3/algebra/totient.hpp
+217 −70 include/nil/crypto3/detail/type_traits.hpp
+10 −0 include/nil/crypto3/detail/unbounded_shift.hpp
+36 −0 test/curves.cpp
2 changes: 1 addition & 1 deletion libs/block
Submodule block updated 1 files
+1 −3 CMakeLists.txt
2 changes: 1 addition & 1 deletion libs/container
2 changes: 1 addition & 1 deletion libs/hash
Submodule hash updated 33 files
+10 −1 CMakeLists.txt
+2 −1 README.md
+16 −25 cmake/CheckAVX.cmake
+5 −4 include/nil/crypto3/detail/type_traits.hpp
+25 −6 include/nil/crypto3/hash/algorithm/hash.hpp
+265 −0 include/nil/crypto3/hash/crc.hpp
+153 −0 include/nil/crypto3/hash/detail/crc/accumulator.hpp
+1 −0 include/nil/crypto3/hash/detail/keccak/keccak_finalizer.hpp
+1 −1 include/nil/crypto3/hash/detail/pedersen/basic_functions.hpp
+656 −0 include/nil/crypto3/hash/detail/poseidon/kimchi_constants.hpp
+1,822 −0 include/nil/crypto3/hash/detail/poseidon/original_constants.hpp
+81 −0 include/nil/crypto3/hash/detail/poseidon/poseidon_constants.hpp
+200 −0 include/nil/crypto3/hash/detail/poseidon/poseidon_constants_generator.hpp
+0 −204 include/nil/crypto3/hash/detail/poseidon/poseidon_constants_operator.hpp
+0 −124 include/nil/crypto3/hash/detail/poseidon/poseidon_functions.hpp
+0 −123 include/nil/crypto3/hash/detail/poseidon/poseidon_lfsr.hpp
+0 −155 include/nil/crypto3/hash/detail/poseidon/poseidon_mds_matrix.hpp
+79 −0 include/nil/crypto3/hash/detail/poseidon/poseidon_permutation.hpp
+64 −110 include/nil/crypto3/hash/detail/poseidon/poseidon_policy.hpp
+141 −0 include/nil/crypto3/hash/detail/poseidon/poseidon_round_operator.hpp
+98 −0 include/nil/crypto3/hash/detail/poseidon/poseidon_sponge.hpp
+25 −0 include/nil/crypto3/hash/detail/reinforced_concrete/reinforced_concrete_functions.hpp
+29 −4 include/nil/crypto3/hash/detail/reinforced_concrete/reinforced_concrete_lfsr.hpp
+50 −23 include/nil/crypto3/hash/detail/reinforced_concrete/reinforced_concrete_operators.hpp
+51 −19 include/nil/crypto3/hash/detail/reinforced_concrete/reinforced_concrete_policy.hpp
+41 −8 include/nil/crypto3/hash/hash_value.hpp
+1 −1 include/nil/crypto3/hash/pedersen.hpp
+25 −7 include/nil/crypto3/hash/poseidon.hpp
+19 −0 include/nil/crypto3/hash/sha2.hpp
+3 −0 test/CMakeLists.txt
+133 −0 test/crc.cpp
+0 −56 test/data/poseidon.json
+181 −114 test/poseidon.cpp
2 changes: 1 addition & 1 deletion libs/marshalling/zk
Submodule zk updated 45 files
+113 −0 .github/workflows/run_tests.yml
+0 −1 CMakeLists.txt
+0 −1 example/CMakeLists.txt
+264 −0 include/nil/crypto3/marshalling/math/types/expression.hpp
+171 −0 include/nil/crypto3/marshalling/math/types/flat_expression.hpp
+0 −100 include/nil/crypto3/marshalling/math/types/non_linear_combination.hpp
+27 −23 include/nil/crypto3/marshalling/math/types/term.hpp
+0 −50 include/nil/crypto3/marshalling/math/types/variable.hpp
+175 −0 include/nil/crypto3/marshalling/zk/types/commitments/eval_storage.hpp
+356 −218 include/nil/crypto3/marshalling/zk/types/commitments/fri.hpp
+74 −75 include/nil/crypto3/marshalling/zk/types/commitments/lpc.hpp
+1 −0 include/nil/crypto3/marshalling/zk/types/commitments/powers_of_tau/accumulator.hpp
+1 −0 include/nil/crypto3/marshalling/zk/types/commitments/powers_of_tau/result.hpp
+21 −22 include/nil/crypto3/marshalling/zk/types/commitments/r1cs_gg_ppzksnark_mpc/public_key.hpp
+116 −54 include/nil/crypto3/marshalling/zk/types/placeholder/common_data.hpp
+64 −254 include/nil/crypto3/marshalling/zk/types/placeholder/proof.hpp
+145 −0 include/nil/crypto3/marshalling/zk/types/plonk/assignment_table.hpp
+50 −12 include/nil/crypto3/marshalling/zk/types/plonk/constraint.hpp
+96 −0 include/nil/crypto3/marshalling/zk/types/plonk/constraint_system.hpp
+101 −0 include/nil/crypto3/marshalling/zk/types/plonk/copy_constraint.hpp
+32 −26 include/nil/crypto3/marshalling/zk/types/plonk/gate.hpp
+113 −0 include/nil/crypto3/marshalling/zk/types/plonk/lookup_constraint.hpp
+139 −0 include/nil/crypto3/marshalling/zk/types/plonk/lookup_gate.hpp
+152 −0 include/nil/crypto3/marshalling/zk/types/plonk/lookup_table.hpp
+47 −10 include/nil/crypto3/marshalling/zk/types/plonk/variable.hpp
+1 −0 include/nil/crypto3/marshalling/zk/types/r1cs_gg_ppzksnark/fast_proving_key.hpp
+1 −0 include/nil/crypto3/marshalling/zk/types/r1cs_gg_ppzksnark/proving_key.hpp
+1 −0 include/nil/crypto3/marshalling/zk/types/r1cs_gg_ppzksnark/r1cs.hpp
+32 −30 test/CMakeLists.txt
+24 −20 test/accumulation_vector.cpp
+864 −141 test/detail/circuits.hpp
+52 −51 test/eddsa.cpp
+312 −895 test/fri_commitment.cpp
+402 −710 test/lpc_commitment.cpp
+21 −20 test/merkle_proof.cpp
+652 −0 test/placeholder_common_data.cpp
+624 −131 test/placeholder_proof.cpp
+596 −0 test/plonk_assignment_table.cpp
+531 −0 test/plonk_constraint_system.cpp
+480 −164 test/plonk_gates.cpp
+28 −28 test/r1cs_gg_ppzksnark.cpp
+21 −19 test/r1cs_gg_ppzksnark_primary_input.cpp
+15 −15 test/r1cs_gg_ppzksnark_proof.cpp
+109 −108 test/r1cs_gg_ppzksnark_verification_key.cpp
+14 −14 test/sparse_vector.cpp
2 changes: 1 addition & 1 deletion libs/random
2 changes: 1 addition & 1 deletion libs/zk
Submodule zk updated 104 files