Skip to content

Commit

Permalink
review in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
martyall committed Dec 13, 2024
1 parent a6ad761 commit 1fe4676
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 34 deletions.
3 changes: 1 addition & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@

# Packages for the development environment that are not needed to build mina-dev.
# For instance dependencies for tests.
devShellPackages = with pkgs; [ rosetta-cli wasm-pack wasm-bindgen-cli nodejs binaryen ];
devShellPackages = with pkgs; [ rosetta-cli wasm-pack nodejs binaryen ];
in {
inherit ocamlPackages;

Expand Down Expand Up @@ -388,7 +388,6 @@
nativeBuildInputs = oa.nativeBuildInputs ++ [
pkgs.rustup
pkgs.libiconv # needed on macOS for one of the rust dep
pkgs.wasm-pack
];
});

Expand Down
59 changes: 27 additions & 32 deletions nix/rust.nix
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ let
allRefs = true;
}).narHash;
}) package;

in {
kimchi_bindings_stubs = let
toolchain = rustChannelFromToolchainFileOf
Expand Down Expand Up @@ -124,33 +123,6 @@ in {
doCheck = false;

};

wasm-bindgen-cli = final.rustPlatform.buildRustPackage rec {
pname = "wasm-bindgen-cli";
version = "0.2.87";
src = final.fetchCrate {
inherit pname version;
sha256 = "sha256-0u9bl+FkXEK2b54n7/l9JOCtKo+pb42GF9E1EnAUQa0=";
};

cargoSha256 = "sha256-AsZBtE2qHJqQtuCt/wCAgOoxYMfvDh8IzBPAOkYSYko=";

nativeBuildInputs = [ final.pkg-config ];

buildInputs = with final;
[ openssl ] ++ lib.optionals stdenv.isDarwin [
curl
darwin.apple_sdk.frameworks.Security
libiconv
];

checkInputs = [ final.nodejs ];

# other tests, like --test=wasm-bindgen, require it to be ran in the
# wasm-bindgen monorepo
cargoTestFlags = [ "--test=reference" ];
};

plonk_wasm = let
lock = ../src/lib/crypto/proof-systems/Cargo.lock;

Expand All @@ -161,6 +133,30 @@ in {

rustPlatform = rustPlatformFor final.kimchi-rust-wasm;

wasm-bindgen-cli = final.rustPlatform.buildRustPackage rec {
pname = "wasm-bindgen-cli";
version = "0.2.87";
src = final.fetchCrate {
inherit pname version;
sha256 = "sha256-0u9bl+FkXEK2b54n7/l9JOCtKo+pb42GF9E1EnAUQa0=";
};

cargoSha256 = "sha256-AsZBtE2qHJqQtuCt/wCAgOoxYMfvDh8IzBPAOkYSYko=";
nativeBuildInputs = [ final.pkg-config ];

buildInputs = with final;
[ openssl ] ++ lib.optionals stdenv.isDarwin [
curl
darwin.apple_sdk.frameworks.Security
libiconv
];

checkInputs = [ final.nodejs ];

# other tests, like --test=wasm-bindgen, require it to be ran in the
# wasm-bindgen monorepo
cargoTestFlags = [ "--test=reference" ];
};
in rustPlatform.buildRustPackage {
pname = "plonk_wasm";
version = "0.1.0";
Expand All @@ -169,7 +165,7 @@ in {
];
buildAndTestSubdir = "plonk-wasm";
sourceRoot = "source/lib/crypto/proof-systems";
nativeBuildInputs = [ final.wasm-pack final.wasm-bindgen-cli ];
nativeBuildInputs = [ final.wasm-pack wasm-bindgen-cli ];
buildInputs = with final; lib.optional stdenv.isDarwin libiconv;
cargoLock.lockFile = lock;
cargoLock.outputHashes = narHashesFromCargoLock lock;
Expand All @@ -194,10 +190,9 @@ in {
runHook preBuild
(
set -x
ls
export RUSTFLAGS="-C target-feature=+atomics,+bulk-memory,+mutable-globals -C link-arg=--no-check-features -C link-arg=--max-memory=4294967296"
wasm-pack build ./plonk-wasm --mode no-install --target nodejs --out-dir $out/nodejs -- --features nodejs
wasm-pack build ./plonk-wasm --mode no-install --target web --out-dir $out/web
wasm-pack build --mode no-install --target nodejs --out-dir $out/nodejs ./plonk-wasm -- --features nodejs
wasm-pack build --mode no-install --target web --out-dir $out/web ./plonk-wasm
)
runHook postBuild
'';
Expand Down
1 change: 1 addition & 0 deletions src/lib/crypto/kimchi_bindings/js/node_js/build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env bash
set -euo pipefail

# When using nix this is already cached
if [[ -z "${PLONK_WASM_NODEJS-}" ]]; then
export RUSTFLAGS="-C target-feature=+atomics,+bulk-memory,+mutable-globals -C link-arg=--no-check-features -C link-arg=--max-memory=4294967296"
# The version should stay in line with the one in kimchi_bindings/wasm/rust-toolchain.toml
Expand Down
1 change: 1 addition & 0 deletions src/lib/crypto/kimchi_bindings/js/web/build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env bash
set -euo pipefail

# When using nix this is already cached
if [[ -z "${PLONK_WASM_WEB-}" ]]; then
export RUSTFLAGS="-C target-feature=+atomics,+bulk-memory,+mutable-globals -C link-arg=--no-check-features -C link-arg=--max-memory=4294967296"
# The version should stay in line with the one in kimchi_bindings/wasm/rust-toolchain.toml
Expand Down

0 comments on commit 1fe4676

Please sign in to comment.