Skip to content

Commit

Permalink
Merge pull request #316 from o1-labs/brian/nix-pure-bindings
Browse files Browse the repository at this point in the history
Build bindings in a nix derivation
  • Loading branch information
Geometer1729 authored Dec 13, 2024
2 parents 46cf810 + a5a0883 commit f157000
Show file tree
Hide file tree
Showing 13 changed files with 91,068 additions and 91,054 deletions.
177,365 changes: 88,674 additions & 88,691 deletions compiled/node_bindings/o1js_node.bc.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion compiled/node_bindings/o1js_node.bc.map

Large diffs are not rendered by default.

1,588 changes: 794 additions & 794 deletions compiled/node_bindings/plonk_wasm.cjs

Large diffs are not rendered by default.

478 changes: 239 additions & 239 deletions compiled/node_bindings/plonk_wasm.d.cts

Large diffs are not rendered by default.

Binary file modified compiled/node_bindings/plonk_wasm_bg.wasm
Binary file not shown.
558 changes: 279 additions & 279 deletions compiled/node_bindings/plonk_wasm_bg.wasm.d.ts

Large diffs are not rendered by default.

40 changes: 20 additions & 20 deletions compiled/web_bindings/o1js_web.bc.js

Large diffs are not rendered by default.

852 changes: 426 additions & 426 deletions compiled/web_bindings/plonk_wasm.d.ts

Large diffs are not rendered by default.

656 changes: 328 additions & 328 deletions compiled/web_bindings/plonk_wasm.js

Large diffs are not rendered by default.

Binary file modified compiled/web_bindings/plonk_wasm_bg.wasm
Binary file not shown.
524 changes: 262 additions & 262 deletions compiled/web_bindings/plonk_wasm_bg.wasm.d.ts

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions crypto/test-vectors/dump-test-vectors.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

set -e

#Allows nix to provide the binary from a derivation
EXPORT_TEST_VECTORS=${EXPORT_TEST_VECTORS:="cargo run -p export_test_vectors --"}

pushd ../../../mina/src/lib/crypto/proof-systems/poseidon/export_test_vectors
cargo run -p export_test_vectors -- hex kimchi ../../../../../../../bindings/crypto/test-vectors/testVectors.json
cargo run -p export_test_vectors -- hex legacy ../../../../../../../bindings/crypto/test-vectors/testVectorsLegacy.json
$EXPORT_TEST_VECTORS hex kimchi ../../../../../../../bindings/crypto/test-vectors/testVectors.json
$EXPORT_TEST_VECTORS hex legacy ../../../../../../../bindings/crypto/test-vectors/testVectorsLegacy.json
popd

echo "// @gen this file is generated - don't edit it directly" > $1
Expand Down
52 changes: 40 additions & 12 deletions scripts/update-o1js-bindings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ WEB_BINDINGS="src/bindings/compiled/web_bindings"
# 1. node build

$DIR_PATH/build-o1js-node-artifacts.sh
cp src/bindings/compiled/_node_bindings/plonk_wasm.d.cts $NODE_BINDINGS/plonk_wasm.d.cts
node src/build/copy-to-dist.js

chmod -R 777 "$NODE_BINDINGS"
Expand All @@ -24,17 +25,40 @@ cp "$BINDINGS_PATH"/plonk_wasm* "$NODE_BINDINGS"/

sed -i 's/plonk_wasm.js/plonk_wasm.cjs/' "$NODE_BINDINGS"/o1js_node.bc.cjs

npm run build
if [ -z $JUST_BINDINGS ]
then
npm run build
fi

# 2. web build

cp "$BUILD_PATH/o1js_node.bc.map" "_build/o1js_node.bc.map"
dune b $DUNE_PATH/o1js_web.bc.js
cp "_build/o1js_node.bc.map" "$BUILD_PATH/o1js_node.bc.map"

cp _build/default/$KIMCHI_BINDINGS/js/web/plonk_wasm* $WEB_BINDINGS/
cp $BUILD_PATH/o1js_web*.js $WEB_BINDINGS/
chmod -R 666 "$WEB_BINDINGS"/*
# Normally these variables are not defined
# But the nix build uses them
if [ -z $PREBUILT_KIMCHI_BINDINGS_JS_WEB ] || [ -z $PREBUILT_KIMCHI_BINDINGS_JS_NODE_JS ]
then
cp "$BUILD_PATH/o1js_node.bc.map" "_build/o1js_node.bc.map"
dune b $DUNE_PATH/o1js_web.bc.js
cp "_build/o1js_node.bc.map" "$BUILD_PATH/o1js_node.bc.map"

cp _build/default/$KIMCHI_BINDINGS/js/web/plonk_wasm* $WEB_BINDINGS/
cp $BUILD_PATH/o1js_web*.js $WEB_BINDINGS/
chmod -R 666 "$WEB_BINDINGS"/*
else
mkdir -p $WEB_BINDINGS
cp $PREBUILT_KIMCHI_BINDINGS_JS_WEB/*.js \
$PREBUILT_KIMCHI_BINDINGS_JS_WEB/*.ts \
$PREBUILT_KIMCHI_BINDINGS_JS_WEB/*.wasm \
$WEB_BINDINGS
mkdir -p $NODE_BINDINGS
cp $PREBUILT_KIMCHI_BINDINGS_JS_NODE_JS/*.js \
$PREBUILT_KIMCHI_BINDINGS_JS_NODE_JS/*.ts \
$PREBUILT_KIMCHI_BINDINGS_JS_NODE_JS/*.wasm \
$NODE_BINDINGS
rm $NODE_BINDINGS/plonk_wasm.js \
$NODE_BINDINGS/plonk_wasm.d.ts
dune b $DUNE_PATH/o1js_web.bc.js
cp $BUILD_PATH/o1js_web*.js $WEB_BINDINGS/
fi

# better error messages
# `s` is the jsoo representation of the error message string, and `s.c` is the actual JS string
Expand All @@ -51,12 +75,16 @@ pushd $WEB_BINDINGS
mv o1js_web.bc.min.js o1js_web.bc.js
popd

npm run build:web
if [ -z $JUST_BINDINGS ]
then
npm run build:web
fi

# 3. update MINA_COMMIT file in o1js

pushd "$MINA_PATH"
MINA_COMMIT=$(git rev-parse HEAD)
popd
if [ -z $SKIP_MINA_COMMIT ]
then
MINA_COMMIT=$(git -C src/mina rev-parse HEAD)
echo "The mina commit used to generate the backends for node and web is" "$MINA_COMMIT" \
> src/bindings/MINA_COMMIT
fi

0 comments on commit f157000

Please sign in to comment.