Skip to content

Commit

Permalink
merge main and rebuild bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
hattyhattington17 committed Dec 16, 2024
2 parents 317c732 + f157000 commit 0c908a2
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 14 deletions.
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 0c908a2

Please sign in to comment.