From 3b83954ee26ecf417406b1d5d57186468c1acc50 Mon Sep 17 00:00:00 2001 From: Geometer1729 <16kuhnb@gmail.com> Date: Thu, 22 Aug 2024 11:21:37 -0400 Subject: [PATCH 01/22] mostly move george's nix from o1js-bindings --- .envrc | 2 + .gitignore | 1 + flake.lock | 527 +++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 110 +++++++++++ pin.sh | 9 + src/bindings | 2 +- src/mina | 2 +- 7 files changed, 651 insertions(+), 2 deletions(-) create mode 100644 .envrc create mode 100644 flake.lock create mode 100644 flake.nix create mode 100755 pin.sh diff --git a/.envrc b/.envrc new file mode 100644 index 0000000000..d00f1b6996 --- /dev/null +++ b/.envrc @@ -0,0 +1,2 @@ +./pin.sh +use flake o1js#default diff --git a/.gitignore b/.gitignore index 78d26c7d8a..06e288a0dd 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ o1js-reference _build/ src/config/ src/config.mlh +.direnv diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000000..cbb582fe6e --- /dev/null +++ b/flake.lock @@ -0,0 +1,527 @@ +{ + "nodes": { + "describe-dune": { + "inputs": { + "flake-utils": [ + "flake-utils" + ], + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1722457451, + "narHash": "sha256-0liAC5hWgbyR1+0UCgE/qOQkQ62LDvvXmCcz6EnTMzw=", + "owner": "o1-labs", + "repo": "describe-dune", + "rev": "2bf2a178809b7707b1d898e4a804b1a9b521ff8e", + "type": "github" + }, + "original": { + "owner": "o1-labs", + "repo": "describe-dune", + "type": "github" + } + }, + "dune-nix": { + "inputs": { + "flake-utils": [ + "flake-utils" + ], + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1723653683, + "narHash": "sha256-n7h3X1PCp+pPOu/bwUQ0Gwv0yXrdjA+h3Zp6CQSS4jQ=", + "owner": "o1-labs", + "repo": "dune-nix", + "rev": "303e4cea2e035c84d4067754a9275a053dac1564", + "type": "github" + }, + "original": { + "owner": "o1-labs", + "repo": "dune-nix", + "type": "github" + } + }, + "flake-buildkite-pipeline": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1665561509, + "narHash": "sha256-+9KQw0ftpNjezYwbUIcLAvDWekuGSBAs8I2XulcUkT4=", + "owner": "tweag", + "repo": "flake-buildkite-pipeline", + "rev": "c836a5a449973dd04a80f6741863ceb43ec414c9", + "type": "github" + }, + "original": { + "owner": "tweag", + "repo": "flake-buildkite-pipeline", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1668681692, + "narHash": "sha256-Ht91NGdewz8IQLtWZ9LCeNXMSXHUss+9COoqu6JLmXU=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "009399224d5e398d03b22badca40a37ac85412a1", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-compat_2": { + "flake": false, + "locked": { + "lastModified": 1627913399, + "narHash": "sha256-hY8g6H2KFL8ownSiFeMOjwPC8P0ueXpCVEbxgda3pko=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "12c64ca55c1014cdc1b16ed5a804aa8576601ff2", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "locked": { + "lastModified": 1623875721, + "narHash": "sha256-A8BU7bjS5GirpAUv4QA+QnJ4CceLHkcXdRp4xITDB0s=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "f7e004a55b120c02ecb6219596820fcd32ca8772", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_3": { + "locked": { + "lastModified": 1638122382, + "narHash": "sha256-sQzZzAbvKEqN9s0bzWuYmRaA03v40gaJ4+iL1LXjaeI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "74f7e4319258e287b0f9cb95426c9853b282730b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_4": { + "locked": { + "lastModified": 1644229661, + "narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flockenzeit": { + "locked": { + "lastModified": 1671184471, + "narHash": "sha256-oTsIo40BxHG8ZcMNwJybV68F8CLNdfY9HKFzEBzeJ6A=", + "owner": "balsoft", + "repo": "Flockenzeit", + "rev": "0409dcd0cc87feebd211c529171d61b89f10d9b3", + "type": "github" + }, + "original": { + "owner": "balsoft", + "repo": "Flockenzeit", + "type": "github" + } + }, + "gitignore-nix": { + "inputs": { + "nixpkgs": [ + "mina", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1660459072, + "narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "a20de23b925fd8264fd7fad6454652e142fd7f73", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "mina": { + "inputs": { + "describe-dune": [ + "describe-dune" + ], + "dune-nix": [ + "dune-nix" + ], + "flake-buildkite-pipeline": "flake-buildkite-pipeline", + "flake-compat": "flake-compat", + "flockenzeit": "flockenzeit", + "gitignore-nix": "gitignore-nix", + "mix-to-nix": "mix-to-nix", + "nix-filter": "nix-filter", + "nix-npm-buildPackage": "nix-npm-buildPackage", + "nix-utils": "nix-utils", + "nixpkgs": [ + "nixpkgs" + ], + "nixpkgs-mozilla": "nixpkgs-mozilla", + "o1-opam-repository": "o1-opam-repository", + "opam-nix": "opam-nix", + "opam-repository": "opam-repository", + "utils": "utils" + }, + "locked": { + "lastModified": 1, + "narHash": "sha256-9mtY3wevSrAimyB9inP1CwIQPAKuU51ImjRbFoCLM00=", + "path": "src/mina", + "type": "path" + }, + "original": { + "path": "src/mina", + "type": "path" + } + }, + "mirage-opam-overlays": { + "flake": false, + "locked": { + "lastModified": 1661959605, + "narHash": "sha256-CPTuhYML3F4J58flfp3ZbMNhkRkVFKmBEYBZY5tnQwA=", + "owner": "dune-universe", + "repo": "mirage-opam-overlays", + "rev": "05f1c1823d891ce4d8adab91f5db3ac51d86dc0b", + "type": "github" + }, + "original": { + "owner": "dune-universe", + "repo": "mirage-opam-overlays", + "type": "github" + } + }, + "mix-to-nix": { + "locked": { + "lastModified": 1643291492, + "narHash": "sha256-B+VIFF8qDJhF5hVMc8PbY/WPzUtbGgjsV1eAxTt5GuQ=", + "owner": "serokell", + "repo": "mix-to-nix", + "rev": "f6f0172b3ac4d32c0e6050a7d805734de0b7adef", + "type": "github" + }, + "original": { + "owner": "serokell", + "repo": "mix-to-nix", + "type": "github" + } + }, + "nix-filter": { + "locked": { + "lastModified": 1666547822, + "narHash": "sha256-razwnAybPHyoAyhkKCwXdxihIqJi1G6e1XP4FQOJTEs=", + "owner": "numtide", + "repo": "nix-filter", + "rev": "1a3b735e13e90a8d2fd5629f2f8363bd7ffbbec7", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "nix-filter", + "type": "github" + } + }, + "nix-npm-buildPackage": { + "inputs": { + "nixpkgs": [ + "mina", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1670813451, + "narHash": "sha256-v0IvQ35CMKtPreGlxWb1FvFUraJNZd144+MbiDwGoAA=", + "owner": "serokell", + "repo": "nix-npm-buildpackage", + "rev": "ec0365cd14a3359a23b80a9e2531a09afc3488fc", + "type": "github" + }, + "original": { + "owner": "serokell", + "repo": "nix-npm-buildpackage", + "type": "github" + } + }, + "nix-utils": { + "inputs": { + "flake-utils": "flake-utils_2", + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1632973430, + "narHash": "sha256-9G8zo+0nfYAALV5umCyQR/2hVUFNH10JropBkyxZGGw=", + "owner": "juliosueiras-nix", + "repo": "nix-utils", + "rev": "b44e1ffd726aa03056db9df469efb497d8b9871b", + "type": "github" + }, + "original": { + "owner": "juliosueiras-nix", + "repo": "nix-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1629252929, + "narHash": "sha256-Aj20gmGBs8TG7pyaQqgbsqAQ6cB+TVuL18Pk3DPBxcQ=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "3788c68def67ca7949e0864c27638d484389363d", + "type": "github" + }, + "original": { + "owner": "nixos", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1649551420, + "narHash": "sha256-J/Pn38rBZTszdtTHhhxroQaHADhd5TgbJ53F9j1WTIE=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "3a16841c57b0d3025b21b869cc921a119ce73033", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "nixpkgs-mozilla": { + "flake": false, + "locked": { + "lastModified": 1704373101, + "narHash": "sha256-+gi59LRWRQmwROrmE1E2b3mtocwueCQqZ60CwLG+gbg=", + "owner": "mozilla", + "repo": "nixpkgs-mozilla", + "rev": "9b11a87c0cc54e308fa83aac5b4ee1816d5418a2", + "type": "github" + }, + "original": { + "owner": "mozilla", + "repo": "nixpkgs-mozilla", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1720535198, + "narHash": "sha256-zwVvxrdIzralnSbcpghA92tWu2DV2lwv89xZc8MTrbg=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "205fd4226592cc83fd4c0885a3e4c9c400efabb5", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-23.11-small", + "repo": "nixpkgs", + "type": "github" + } + }, + "o1-opam-repository": { + "flake": false, + "locked": { + "lastModified": 1715294616, + "narHash": "sha256-W2p9Vs8PqpKGvMByxVqpxAljjpEMqNcuNnjMBAAKicI=", + "owner": "o1-labs", + "repo": "opam-repository", + "rev": "38d6995e307c82b3c0b3bc86a867213db724d1c5", + "type": "github" + }, + "original": { + "owner": "o1-labs", + "repo": "opam-repository", + "type": "github" + } + }, + "opam-nix": { + "inputs": { + "flake-compat": "flake-compat_2", + "flake-utils": "flake-utils_3", + "mirage-opam-overlays": "mirage-opam-overlays", + "nixpkgs": [ + "mina", + "nixpkgs" + ], + "opam-overlays": "opam-overlays", + "opam-repository": [ + "mina", + "opam-repository" + ], + "opam2json": "opam2json" + }, + "locked": { + "lastModified": 1712645768, + "narHash": "sha256-9dUh8nElGtC74Q4gIDV6DM0FKgF1oXh0PUkCxdbp+sg=", + "owner": "tweag", + "repo": "opam-nix", + "rev": "464863fba44c7ecc50bd1a2967274482a2c33daf", + "type": "github" + }, + "original": { + "owner": "tweag", + "repo": "opam-nix", + "type": "github" + } + }, + "opam-overlays": { + "flake": false, + "locked": { + "lastModified": 1654162756, + "narHash": "sha256-RV68fUK+O3zTx61iiHIoS0LvIk0E4voMp+0SwRg6G6c=", + "owner": "dune-universe", + "repo": "opam-overlays", + "rev": "c8f6ef0fc5272f254df4a971a47de7848cc1c8a4", + "type": "github" + }, + "original": { + "owner": "dune-universe", + "repo": "opam-overlays", + "type": "github" + } + }, + "opam-repository": { + "flake": false, + "locked": { + "lastModified": 1708601497, + "narHash": "sha256-mDYINTjOiYLN4wT5fGlWTvHFQdWkzY46XUuZWKgmJxY=", + "owner": "ocaml", + "repo": "opam-repository", + "rev": "90d8c520a4f0b035ac51e267a8b33739c5a78b5a", + "type": "github" + }, + "original": { + "owner": "ocaml", + "repo": "opam-repository", + "type": "github" + } + }, + "opam2json": { + "inputs": { + "nixpkgs": [ + "mina", + "opam-nix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1671540003, + "narHash": "sha256-5pXfbUfpVABtKbii6aaI2EdAZTjHJ2QntEf0QD2O5AM=", + "owner": "tweag", + "repo": "opam2json", + "rev": "819d291ea95e271b0e6027679de6abb4d4f7f680", + "type": "github" + }, + "original": { + "owner": "tweag", + "repo": "opam2json", + "type": "github" + } + }, + "root": { + "inputs": { + "describe-dune": "describe-dune", + "dune-nix": "dune-nix", + "flake-utils": "flake-utils", + "mina": "mina", + "nixpkgs": "nixpkgs_2" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "utils": { + "inputs": { + "flake-utils": "flake-utils_4" + }, + "locked": { + "lastModified": 1657226504, + "narHash": "sha256-GIYNjuq4mJlFgqKsZ+YrgzWm0IpA4axA3MCrdKYj7gs=", + "owner": "gytis-ivaskevicius", + "repo": "flake-utils-plus", + "rev": "2bf0f91643c2e5ae38c1b26893ac2927ac9bd82a", + "type": "github" + }, + "original": { + "owner": "gytis-ivaskevicius", + "repo": "flake-utils-plus", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000000..0d84b7a679 --- /dev/null +++ b/flake.nix @@ -0,0 +1,110 @@ +{ + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11-small"; + mina.url = "path:src/mina"; + mina.inputs.nixpkgs.follows = "nixpkgs"; + describe-dune.url = "github:o1-labs/describe-dune"; + describe-dune.inputs.nixpkgs.follows = "nixpkgs"; + describe-dune.inputs.flake-utils.follows = "flake-utils"; + dune-nix.url = "github:o1-labs/dune-nix"; + dune-nix.inputs.nixpkgs.follows = "nixpkgs"; + dune-nix.inputs.flake-utils.follows = "flake-utils"; + mina.inputs.dune-nix.follows = "dune-nix"; + mina.inputs.describe-dune.follows = "describe-dune"; + flake-utils.url = "github:numtide/flake-utils"; + }; + outputs = { self, nixpkgs, flake-utils, ... }@inputs: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + dune-nix = inputs.dune-nix.lib.${system}; + describe-dune = inputs.describe-dune.defaultPackage.${system}; + dune-description = pkgs.stdenv.mkDerivation { + pname = "dune-description"; + version = "dev"; + src = with pkgs.lib.fileset; + (toSource { + root = ./src/bindings; + fileset = unions [ + ./src/bindings/ocaml/dune + ./src/bindings/ocaml/lib/dune + ./src/bindings/ocaml/dune-project + ./src/bindings/ocaml/js/dune + ]; + }); + phases = [ "unpackPhase" "buildPhase" ]; + buildPhase = '' + ${describe-dune}/bin/describe-dune > $out + ''; + }; + desc = builtins.fromJSON (builtins.readFile dune-description); + allOcamlDeps_ = pkgs.lib.concatMap (duneSpec: + pkgs.lib.concatMap (unitSpec: unitSpec.deps or [ ]) + (duneSpec.units or [ ])) desc; + allOcamlDeps = + builtins.map (d: builtins.head (pkgs.lib.splitString "." d)) + allOcamlDeps_; + mina = inputs.mina.packages."${system}"; + minaDeps_ = + builtins.intersectAttrs (pkgs.lib.genAttrs allOcamlDeps (_: { })) + mina.info.raw.deps.units; + minaDeps = builtins.attrNames (builtins.foldl' + (acc: pkg: acc // dune-nix.deps.packageDeps minaDeps_ "pkgs" pkg) + minaDeps_ (builtins.attrNames minaDeps_)); + commonOverrides = { + DUNE_PROFILE = "dev"; + buildInputs = [ mina.base-libs ] ++ mina.external-libs + ++ pkgs.lib.attrVals minaDeps mina.pkgs; + }; + info = dune-nix.info desc; + allDeps = dune-nix.allDeps info; + noTestSkipping = _: false; + prj_ = dune-nix.outputs' commonOverrides (pkgs.lib.fileset.toSource { + root = ./src/bindings; + fileset = ./src/bindings/ocaml; + }) allDeps info noTestSkipping prj; + prj = prj_ // { + pkgs = prj_.pkgs // { + __ocaml-js__ = prj_.pkgs.__ocaml-js__.overrideAttrs { + PREBUILT_KIMCHI_BINDINGS_JS_WEB = + "${mina.files.src-lib-crypto-kimchi_bindings-js-web}/src/lib/crypto/kimchi_bindings/js/web"; + PREBUILT_KIMCHI_BINDINGS_JS_NODE_JS = + "${mina.files.src-lib-crypto-kimchi_bindings-js-node_js}/src/lib/crypto/kimchi_bindings/js/node_js"; + }; + }; + }; + in { + formatter = pkgs.nixfmt; + inherit mina; + devShells = { + default = pkgs.mkShell { + inputsFrom = [ prj.pkgs.o1js_bindings prj.pkgs.__ocaml-js__ ]; + shellHook = + '' + rustup update nightly-2023-09-01-x86_64-unknown-linux-gnu + rustup component add rust-src --toolchain nightly-2023-09-01-x86_64-unknown-linux-gnu + ''; + packages = with pkgs; + [ nodejs + nodePackages.npm + typescript + nodePackages.typescript-language-server + + rustup + wasm-pack + binaryen # provides wasm-opt + + dune_3 + ocamlPackages.js_of_ocaml-ppx + ocamlPackages.base + ] ++ commonOverrides.buildInputs ; + }; + }; + # TODO build from ./ocaml root, not ./. (after fixing a bug in dune-nix) + packages = { + inherit dune-description; + default = prj.pkgs.o1js_bindings; + js = prj.pkgs.__ocaml-js__; + }; + }); +} diff --git a/pin.sh b/pin.sh new file mode 100755 index 0000000000..641acc9a6f --- /dev/null +++ b/pin.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +# Set up flake registry to get Mina with all the submodules + +# Find the root of the Mina repo +ROOT=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +# Update the submodules +pushd "$ROOT" && git submodule sync && git submodule update --init --recursive && popd +# Add the flake registry entry +nix registry add o1js "git+file://$ROOT?submodules=1" diff --git a/src/bindings b/src/bindings index 35b2a6135c..9767adf1bb 160000 --- a/src/bindings +++ b/src/bindings @@ -1 +1 @@ -Subproject commit 35b2a6135cdc0ed1fda6fc0262eedea9034fa948 +Subproject commit 9767adf1bbd71f1d20df6f30f84b455d728aff5c diff --git a/src/mina b/src/mina index 02accb5bc5..7ef7f98f8c 160000 --- a/src/mina +++ b/src/mina @@ -1 +1 @@ -Subproject commit 02accb5bc5bd152b5b849d864b3339ada56ef891 +Subproject commit 7ef7f98f8cc251ffbfb988894f359a60a4cf1334 From 58cba23259c3c2faca750e2aa7a79c96e3c13eba Mon Sep 17 00:00:00 2001 From: Geometer1729 <16kuhnb@gmail.com> Date: Thu, 22 Aug 2024 12:12:07 -0400 Subject: [PATCH 02/22] update bindings add to README-dev --- README-dev.md | 6 ++++++ pin.sh | 4 ++-- src/bindings | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/README-dev.md b/README-dev.md index f00bd9c88b..bab9cbe2dc 100644 --- a/README-dev.md +++ b/README-dev.md @@ -35,6 +35,12 @@ npm run build This command compiles the TypeScript source files, making them ready for use. The compiled OCaml and WebAssembly artifacts are version-controlled to simplify the build process for end users. These artifacts are stored under `src/bindings/compiled` and contain the artifacts needed for both node and web builds. These files only have to be regenerated if there are changes to the OCaml or Rust source files. +## Building with nix + +Much like the mina repo, we use the nix registry to conveniently handle git submodules. +You can enter the devshell with `./pin.sh` and `nix develop o1js#default` or by using +the direnv with the `.envrc` provided. + ## Building Bindings To regenerate the OCaml and WebAssembly artifacts, you can do so within the o1js repo. The [bindings](https://github.com/o1-labs/o1js-bindings) and [Mina](https://github.com/MinaProtocol/mina) repos are both submodules of o1js so you can build them from within the o1js repo. diff --git a/pin.sh b/pin.sh index 641acc9a6f..7d2cdf47df 100755 --- a/pin.sh +++ b/pin.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash -# Set up flake registry to get Mina with all the submodules +# Set up flake registry to get o1js with all the submodules -# Find the root of the Mina repo +# Find the root of the o1js repo ROOT=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) # Update the submodules pushd "$ROOT" && git submodule sync && git submodule update --init --recursive && popd diff --git a/src/bindings b/src/bindings index 9767adf1bb..6148d0ecb7 160000 --- a/src/bindings +++ b/src/bindings @@ -1 +1 @@ -Subproject commit 9767adf1bbd71f1d20df6f30f84b455d728aff5c +Subproject commit 6148d0ecb71caf63dcb8c38c924d046863e0cff5 From 71f1a4a7599fa3006870d53884cd6dbcd478f984 Mon Sep 17 00:00:00 2001 From: Geometer1729 <16kuhnb@gmail.com> Date: Thu, 22 Aug 2024 12:23:37 -0400 Subject: [PATCH 03/22] typo --- README-dev.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README-dev.md b/README-dev.md index bab9cbe2dc..0f94f6f151 100644 --- a/README-dev.md +++ b/README-dev.md @@ -39,7 +39,7 @@ This command compiles the TypeScript source files, making them ready for use. Th Much like the mina repo, we use the nix registry to conveniently handle git submodules. You can enter the devshell with `./pin.sh` and `nix develop o1js#default` or by using -the direnv with the `.envrc` provided. +direnv with the `.envrc` provided. ## Building Bindings @@ -95,8 +95,8 @@ o1js uses these types to ensure that the constants used in the protocol are cons | main | **Yes** | | develop | No | -When you start your work on o1js, please create the feature branch off of one of the above base branches. -It's encouraged to submit your work-in-progress as a draft PR to raise visibility! +When you start your work on o1js, please create the feature branch off of one of the above base branches. +It's encouraged to submit your work-in-progress as a draft PR to raise visibility! When working with submodules and various interconnected parts of the stack, ensure you are on the correct branches that are compatible with each other. **Default to `main` as the base branch**. @@ -208,8 +208,8 @@ docker run --rm --pull=missing -it \ See the [Docker Hub repository](https://hub.docker.com/r/o1labs/mina-local-network) for more information. -Next up, get the Mina blockchain accounts information to be used in your zkApp. -After the local network is up and running, you can use the [Lightnet](https://github.com/o1-labs/o1js/blob/ec789794b2067addef6b6f9c9a91c6511e07e37c/src/lib/fetch.ts#L1012) `o1js API namespace` to get the accounts information. +Next up, get the Mina blockchain accounts information to be used in your zkApp. +After the local network is up and running, you can use the [Lightnet](https://github.com/o1-labs/o1js/blob/ec789794b2067addef6b6f9c9a91c6511e07e37c/src/lib/fetch.ts#L1012) `o1js API namespace` to get the accounts information. See the corresponding example in [src/examples/zkapps/hello-world/run-live.ts](https://github.com/o1-labs/o1js/blob/ec789794b2067addef6b6f9c9a91c6511e07e37c/src/examples/zkapps/hello-world/run-live.ts). ### Profiling o1js From c51adc4f7475268976e1ad936e37da190d74916d Mon Sep 17 00:00:00 2001 From: Geometer1729 <16kuhnb@gmail.com> Date: Thu, 22 Aug 2024 13:42:36 -0400 Subject: [PATCH 04/22] add output for npm package --- flake.nix | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index 0d84b7a679..5d46d40b61 100644 --- a/flake.nix +++ b/flake.nix @@ -103,8 +103,14 @@ # TODO build from ./ocaml root, not ./. (after fixing a bug in dune-nix) packages = { inherit dune-description; - default = prj.pkgs.o1js_bindings; - js = prj.pkgs.__ocaml-js__; + bindings = prj.pkgs.o1js_bindings; + ocaml-js = prj.pkgs.__ocaml-js__; + default = pkgs.buildNpmPackage + { name = "o1js"; + src = ./.; + npmDepsHash = "sha256-++MTGDUVBccYN8LA2Xb0FkbrZ14ZyVCrDPESXa52AwQ="; + # TODO ideally re-build bindings here + }; }; }); } From 69d689cce978f392435e3dd4811fc60a7561f66d Mon Sep 17 00:00:00 2001 From: Geometer1729 <16kuhnb@gmail.com> Date: Thu, 22 Aug 2024 14:07:18 -0400 Subject: [PATCH 05/22] update bindings add to README-dev --- README-dev.md | 2 +- src/bindings | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README-dev.md b/README-dev.md index 0f94f6f151..7d8e1c8f59 100644 --- a/README-dev.md +++ b/README-dev.md @@ -39,7 +39,7 @@ This command compiles the TypeScript source files, making them ready for use. Th Much like the mina repo, we use the nix registry to conveniently handle git submodules. You can enter the devshell with `./pin.sh` and `nix develop o1js#default` or by using -direnv with the `.envrc` provided. +direnv with the `.envrc` provided. This devshell provides all the dependencies required for npm scripts including `npm run:update-bindings`. ## Building Bindings diff --git a/src/bindings b/src/bindings index 6148d0ecb7..cafa3e34d5 160000 --- a/src/bindings +++ b/src/bindings @@ -1 +1 @@ -Subproject commit 6148d0ecb71caf63dcb8c38c924d046863e0cff5 +Subproject commit cafa3e34d512a2a925e5b05d03fd43ebca078dc2 From a250f777cf29b19049f4bdbcf7b0c02ff8868319 Mon Sep 17 00:00:00 2001 From: Geometer1729 <16kuhnb@gmail.com> Date: Fri, 23 Aug 2024 11:33:08 -0400 Subject: [PATCH 06/22] update mina --- src/mina | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mina b/src/mina index 7ef7f98f8c..b929a827a3 160000 --- a/src/mina +++ b/src/mina @@ -1 +1 @@ -Subproject commit 7ef7f98f8cc251ffbfb988894f359a60a4cf1334 +Subproject commit b929a827a366a783a47be173fae2a83b7163b330 From c0881c050e4f5635e070a6f1a975685615222100 Mon Sep 17 00:00:00 2001 From: Geometer1729 <16kuhnb@gmail.com> Date: Fri, 23 Aug 2024 13:23:37 -0400 Subject: [PATCH 07/22] update bindings fix tests --- src/bindings | 2 +- src/lib/proof-system/prover-keys.ts | 2 +- src/lib/proof-system/zkprogram.ts | 2 +- src/mina-signer/tests/client.test.ts | 2 +- src/mina-signer/tests/keypair.test.ts | 2 +- src/mina-signer/tests/message.test.ts | 4 ++-- src/mina-signer/tests/payment.test.ts | 4 ++-- src/mina-signer/tests/rosetta.test.ts | 8 ++++---- src/mina-signer/tests/stake-delegation.test.ts | 4 ++-- 9 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/bindings b/src/bindings index cafa3e34d5..9f3b1ba1ca 160000 --- a/src/bindings +++ b/src/bindings @@ -1 +1 @@ -Subproject commit cafa3e34d512a2a925e5b05d03fd43ebca078dc2 +Subproject commit 9f3b1ba1cacb3ab8a5d4fa61c7bc0c83c0398311 diff --git a/src/lib/proof-system/prover-keys.ts b/src/lib/proof-system/prover-keys.ts index 8568eb78d6..758c1e1bc0 100644 --- a/src/lib/proof-system/prover-keys.ts +++ b/src/lib/proof-system/prover-keys.ts @@ -53,7 +53,7 @@ function parseHeader( methods: MethodInterface[], header: SnarkKeyHeader ): CacheHeader { - let hash = Pickles.util.fromMlString(header[1][2][7]); + let hash = Pickles.util.fromMlString(header[1][2][6]); switch (header[0]) { case KeyType.StepProvingKey: case KeyType.StepVerificationKey: { diff --git a/src/lib/proof-system/zkprogram.ts b/src/lib/proof-system/zkprogram.ts index fe497a7a65..2d4dbe33fc 100644 --- a/src/lib/proof-system/zkprogram.ts +++ b/src/lib/proof-system/zkprogram.ts @@ -928,7 +928,7 @@ async function compileProgram({ }) { await initializeBindings(); if (methodIntfs.length === 0) - throw Error(`The Program you are trying to compile has no methods. + throw Error(`The Program you are trying to compile has no methods. Try adding a method to your ZkProgram or SmartContract. If you are using a SmartContract, make sure you are using the @method decorator.`); diff --git a/src/mina-signer/tests/client.test.ts b/src/mina-signer/tests/client.test.ts index 4ca384a2d2..00a63282c3 100644 --- a/src/mina-signer/tests/client.test.ts +++ b/src/mina-signer/tests/client.test.ts @@ -1,4 +1,4 @@ -import Client from '../dist/node/mina-signer/mina-signer.js'; +import Client from '../../../dist/node/mina-signer/mina-signer.js'; describe('Client Class Initialization', () => { let client; diff --git a/src/mina-signer/tests/keypair.test.ts b/src/mina-signer/tests/keypair.test.ts index 2c19c95caa..ae2deb3b5e 100644 --- a/src/mina-signer/tests/keypair.test.ts +++ b/src/mina-signer/tests/keypair.test.ts @@ -1,4 +1,4 @@ -import Client from '../dist/node/mina-signer/mina-signer.js'; +import Client from '../../../dist/node/mina-signer/mina-signer.js'; describe('Keypair', () => { let client: Client; diff --git a/src/mina-signer/tests/message.test.ts b/src/mina-signer/tests/message.test.ts index bd9586fb19..90f718d450 100644 --- a/src/mina-signer/tests/message.test.ts +++ b/src/mina-signer/tests/message.test.ts @@ -1,5 +1,5 @@ -import Client from '../dist/node/mina-signer/mina-signer.js'; -import type { PrivateKey } from '../dist/node/mina-signer/src/types.js'; +import Client from '../../../dist/node/mina-signer/mina-signer.js'; +import type { PrivateKey } from '.../.././dist/node/mina-signer/src/types.js'; describe('Message', () => { describe('Mainnet network', () => { diff --git a/src/mina-signer/tests/payment.test.ts b/src/mina-signer/tests/payment.test.ts index de84939d67..9c434e3721 100644 --- a/src/mina-signer/tests/payment.test.ts +++ b/src/mina-signer/tests/payment.test.ts @@ -1,5 +1,5 @@ -import Client from '../dist/node/mina-signer/mina-signer.js'; -import type { Keypair } from '../dist/node/mina-signer/src/types.js'; +import Client from '../../../dist/node/mina-signer/mina-signer.js'; +import type { Keypair } from '../../../dist/node/mina-signer/src/types.js'; describe('Payment', () => { describe('Mainnet network', () => { diff --git a/src/mina-signer/tests/rosetta.test.ts b/src/mina-signer/tests/rosetta.test.ts index 8b8d691822..67efdc6671 100644 --- a/src/mina-signer/tests/rosetta.test.ts +++ b/src/mina-signer/tests/rosetta.test.ts @@ -1,7 +1,7 @@ -import Client from '../dist/node/mina-signer/mina-signer.js'; -import { fieldFromHex, fieldToHex, signatureJsonToHex, signatureJsonFromHex, UnsignedTransaction, publicKeyToHex, signTransaction } from '../dist/node/mina-signer/src/rosetta.js'; -import { PublicKey } from '../dist/node/mina-signer/src/curve-bigint.js'; -import { Field } from '../dist/node/mina-signer/src/field-bigint.js'; +import Client from '../../../dist/node/mina-signer/mina-signer.js'; +import { fieldFromHex, fieldToHex, signatureJsonToHex, signatureJsonFromHex, UnsignedTransaction, publicKeyToHex, signTransaction } from '../../../dist/node/mina-signer/src/rosetta.js'; +import { PublicKey } from '../../../dist/node/mina-signer/src/curve-bigint.js'; +import { Field } from '../../../dist/node/mina-signer/src/field-bigint.js'; describe('Rosetta', () => { let client: Client; diff --git a/src/mina-signer/tests/stake-delegation.test.ts b/src/mina-signer/tests/stake-delegation.test.ts index 16cdf0d8f6..a298157734 100644 --- a/src/mina-signer/tests/stake-delegation.test.ts +++ b/src/mina-signer/tests/stake-delegation.test.ts @@ -1,5 +1,5 @@ -import Client from '../dist/node/mina-signer/mina-signer.js'; -import type { Keypair } from '../dist/node/mina-signer/src/types.js'; +import Client from '../../../dist/node/mina-signer/mina-signer.js'; +import type { Keypair } from '../../../dist/node/mina-signer/src/types.js'; describe('Stake Delegation', () => { describe('Mainnet network', () => { From e485171bb023c1276a7e25e404194d88bc6106ef Mon Sep 17 00:00:00 2001 From: Geometer1729 <16kuhnb@gmail.com> Date: Tue, 27 Aug 2024 10:54:24 -0400 Subject: [PATCH 08/22] build rustup toolchain with nix --- .gitignore | 1 + flake.lock | 7 +++++-- flake.nix | 51 +++++++++++++++++++++++++++++++++++++++++++-------- src/bindings | 2 +- 4 files changed, 50 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 06e288a0dd..8d945cda45 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ _build/ src/config/ src/config.mlh .direnv +.rustup diff --git a/flake.lock b/flake.lock index cbb582fe6e..9b65c60186 100644 --- a/flake.lock +++ b/flake.lock @@ -214,7 +214,9 @@ "nixpkgs": [ "nixpkgs" ], - "nixpkgs-mozilla": "nixpkgs-mozilla", + "nixpkgs-mozilla": [ + "nixpkgs-mozilla" + ], "o1-opam-repository": "o1-opam-repository", "opam-nix": "opam-nix", "opam-repository": "opam-repository", @@ -485,7 +487,8 @@ "dune-nix": "dune-nix", "flake-utils": "flake-utils", "mina": "mina", - "nixpkgs": "nixpkgs_2" + "nixpkgs": "nixpkgs_2", + "nixpkgs-mozilla": "nixpkgs-mozilla" } }, "systems": { diff --git a/flake.nix b/flake.nix index 5d46d40b61..1c7c5a17cd 100644 --- a/flake.nix +++ b/flake.nix @@ -3,6 +3,9 @@ nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11-small"; mina.url = "path:src/mina"; mina.inputs.nixpkgs.follows = "nixpkgs"; + mina.inputs.nixpkgs-mozilla.follows = "nixpkgs-mozilla"; + nixpkgs-mozilla.url = "github:mozilla/nixpkgs-mozilla"; + nixpkgs-mozilla.flake = false; describe-dune.url = "github:o1-labs/describe-dune"; describe-dune.inputs.nixpkgs.follows = "nixpkgs"; describe-dune.inputs.flake-utils.follows = "flake-utils"; @@ -16,7 +19,9 @@ outputs = { self, nixpkgs, flake-utils, ... }@inputs: flake-utils.lib.eachDefaultSystem (system: let - pkgs = nixpkgs.legacyPackages.${system}; + pkgs= (nixpkgs.legacyPackages."${system}".extend + (import inputs.nixpkgs-mozilla) + ).extend inputs.mina.overlays.rust; dune-nix = inputs.dune-nix.lib.${system}; describe-dune = inputs.describe-dune.defaultPackage.${system}; dune-description = pkgs.stdenv.mkDerivation { @@ -73,26 +78,55 @@ }; }; }; + rust-channel = + ((pkgs.rustChannelOf + { channel = "nightly"; + date = "2023-09-01"; + sha256 = "sha256-zek9JAnRaoX8V0U2Y5ssXVe9tvoQ0ERGXfUCUGYdrMA="; + }).rust.override + { targets = ["wasm32-unknown-unknown" "x86_64-unknown-linux-gnu" ]; + extensions = [ "rust-src" ]; + }); in { formatter = pkgs.nixfmt; inherit mina; devShells = { default = pkgs.mkShell { - inputsFrom = [ prj.pkgs.o1js_bindings prj.pkgs.__ocaml-js__ ]; - shellHook = - '' - rustup update nightly-2023-09-01-x86_64-unknown-linux-gnu - rustup component add rust-src --toolchain nightly-2023-09-01-x86_64-unknown-linux-gnu + shellHook = '' + export RUSTUP_HOME=$(pwd)/.rustup + rustup toolchain link nix ${rust-channel} ''; + inputsFrom = + [ prj.pkgs.o1js_bindings + prj.pkgs.__ocaml-js__ + ]; packages = with pkgs; [ nodejs nodePackages.npm typescript nodePackages.typescript-language-server - rustup + #Rustup doesn't allow local toolchains to contain 'nightly' in the name + #so the toolchain is linked with the name nix and rustup is wrapped in a shellscript + #which calls the nix toolchain instead of the nightly one + (pkgs.writeShellApplication + { name = "rustup"; + text = + '' + if [ $1 = run ] && [ $2 = nightly-2023-09-01 ] + then + ${pkgs.rustup}/bin/rustup run nix ''${@:2} + else + ${pkgs.rustup}/bin/rustup "$@" + fi + ''; + } + ) wasm-pack binaryen # provides wasm-opt + rustc + cargo + #rust-channel.rust dune_3 ocamlPackages.js_of_ocaml-ppx @@ -102,7 +136,8 @@ }; # TODO build from ./ocaml root, not ./. (after fixing a bug in dune-nix) packages = { - inherit dune-description; + inherit dune-description pkgs rust-channel; + kim = pkgs.kimchi-rust-wasm; bindings = prj.pkgs.o1js_bindings; ocaml-js = prj.pkgs.__ocaml-js__; default = pkgs.buildNpmPackage diff --git a/src/bindings b/src/bindings index 9f3b1ba1ca..c80139e85d 160000 --- a/src/bindings +++ b/src/bindings @@ -1 +1 @@ -Subproject commit 9f3b1ba1cacb3ab8a5d4fa61c7bc0c83c0398311 +Subproject commit c80139e85dc692ab11a3caf40de14adfa13983ec From 7edd1990159f5920c42a93b0c64721c22b2d5f6b Mon Sep 17 00:00:00 2001 From: Geometer1729 <16kuhnb@gmail.com> Date: Wed, 28 Aug 2024 15:02:52 -0400 Subject: [PATCH 09/22] fix dependency on existing build artifacts --- .gitignore | 1 + flake.lock | 22 ++++++++++++++++++---- flake.nix | 27 ++++++++++++--------------- src/bindings | 2 +- 4 files changed, 32 insertions(+), 20 deletions(-) diff --git a/.gitignore b/.gitignore index 8d945cda45..3c60f7a680 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ src/config/ src/config.mlh .direnv .rustup +result diff --git a/flake.lock b/flake.lock index 9b65c60186..9f0c7a2db7 100644 --- a/flake.lock +++ b/flake.lock @@ -214,9 +214,7 @@ "nixpkgs": [ "nixpkgs" ], - "nixpkgs-mozilla": [ - "nixpkgs-mozilla" - ], + "nixpkgs-mozilla": "nixpkgs-mozilla", "o1-opam-repository": "o1-opam-repository", "opam-nix": "opam-nix", "opam-repository": "opam-repository", @@ -365,6 +363,22 @@ "type": "github" } }, + "nixpkgs-mozilla_2": { + "flake": false, + "locked": { + "lastModified": 1704373101, + "narHash": "sha256-+gi59LRWRQmwROrmE1E2b3mtocwueCQqZ60CwLG+gbg=", + "owner": "mozilla", + "repo": "nixpkgs-mozilla", + "rev": "9b11a87c0cc54e308fa83aac5b4ee1816d5418a2", + "type": "github" + }, + "original": { + "owner": "mozilla", + "repo": "nixpkgs-mozilla", + "type": "github" + } + }, "nixpkgs_2": { "locked": { "lastModified": 1720535198, @@ -488,7 +502,7 @@ "flake-utils": "flake-utils", "mina": "mina", "nixpkgs": "nixpkgs_2", - "nixpkgs-mozilla": "nixpkgs-mozilla" + "nixpkgs-mozilla": "nixpkgs-mozilla_2" } }, "systems": { diff --git a/flake.nix b/flake.nix index 1c7c5a17cd..ab7ce8d42c 100644 --- a/flake.nix +++ b/flake.nix @@ -92,14 +92,13 @@ inherit mina; devShells = { default = pkgs.mkShell { - shellHook = '' - export RUSTUP_HOME=$(pwd)/.rustup - rustup toolchain link nix ${rust-channel} + inputsFrom = [ prj.pkgs.o1js_bindings prj.pkgs.__ocaml-js__ ]; + shellHook = + '' + RUSTUP_HOME=$(pwd)/.rustup + export RUSTUP_HOME + rustup toolchain link nix ${rust-channel} ''; - inputsFrom = - [ prj.pkgs.o1js_bindings - prj.pkgs.__ocaml-js__ - ]; packages = with pkgs; [ nodejs nodePackages.npm @@ -109,24 +108,22 @@ #Rustup doesn't allow local toolchains to contain 'nightly' in the name #so the toolchain is linked with the name nix and rustup is wrapped in a shellscript #which calls the nix toolchain instead of the nightly one - (pkgs.writeShellApplication + (writeShellApplication { name = "rustup"; text = '' - if [ $1 = run ] && [ $2 = nightly-2023-09-01 ] + if [ "$1" = run ] && [ "$2" = nightly-2023-09-01 ] then - ${pkgs.rustup}/bin/rustup run nix ''${@:2} + ${rustup}/bin/rustup run nix "''${@:3}" else - ${pkgs.rustup}/bin/rustup "$@" + ${rustup}/bin/rustup "$@" fi ''; } ) + rustup wasm-pack binaryen # provides wasm-opt - rustc - cargo - #rust-channel.rust dune_3 ocamlPackages.js_of_ocaml-ppx @@ -136,8 +133,8 @@ }; # TODO build from ./ocaml root, not ./. (after fixing a bug in dune-nix) packages = { - inherit dune-description pkgs rust-channel; kim = pkgs.kimchi-rust-wasm; + inherit dune-description; bindings = prj.pkgs.o1js_bindings; ocaml-js = prj.pkgs.__ocaml-js__; default = pkgs.buildNpmPackage diff --git a/src/bindings b/src/bindings index c80139e85d..4f15b3152a 160000 --- a/src/bindings +++ b/src/bindings @@ -1 +1 @@ -Subproject commit c80139e85dc692ab11a3caf40de14adfa13983ec +Subproject commit 4f15b3152adf9db9eb1e7e9b71bdf432c8400a05 From 446ea62a247cfc17bf0ad59bfd2df0e86cf353e1 Mon Sep 17 00:00:00 2001 From: Geometer1729 <16kuhnb@gmail.com> Date: Thu, 29 Aug 2024 10:27:05 -0400 Subject: [PATCH 10/22] fix relative path issue with nix --- flake.lock | 88 +++++++++++++++++++++++++++++++++++++++++++--------- flake.nix | 4 --- pin.sh | 1 + src/bindings | 2 +- 4 files changed, 76 insertions(+), 19 deletions(-) diff --git a/flake.lock b/flake.lock index 9f0c7a2db7..ca26e7b09b 100644 --- a/flake.lock +++ b/flake.lock @@ -10,11 +10,36 @@ ] }, "locked": { - "lastModified": 1722457451, - "narHash": "sha256-0liAC5hWgbyR1+0UCgE/qOQkQ62LDvvXmCcz6EnTMzw=", + "lastModified": 1724407960, + "narHash": "sha256-pUKTVMYEtsD1AGlHFTdPourowt+tJ3htKhRu7VALFzc=", "owner": "o1-labs", "repo": "describe-dune", - "rev": "2bf2a178809b7707b1d898e4a804b1a9b521ff8e", + "rev": "be828239c05671209e979f9d5c2e3094e3be7a46", + "type": "github" + }, + "original": { + "owner": "o1-labs", + "repo": "describe-dune", + "type": "github" + } + }, + "describe-dune_2": { + "inputs": { + "flake-utils": [ + "mina", + "utils" + ], + "nixpkgs": [ + "mina", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1724407960, + "narHash": "sha256-pUKTVMYEtsD1AGlHFTdPourowt+tJ3htKhRu7VALFzc=", + "owner": "o1-labs", + "repo": "describe-dune", + "rev": "be828239c05671209e979f9d5c2e3094e3be7a46", "type": "github" }, "original": { @@ -46,6 +71,31 @@ "type": "github" } }, + "dune-nix_2": { + "inputs": { + "flake-utils": [ + "mina", + "utils" + ], + "nixpkgs": [ + "mina", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1724418497, + "narHash": "sha256-HjTh7o02QhGXmbxmpE5HRWei3H/pyh/NKCMCnucDaYs=", + "owner": "o1-labs", + "repo": "dune-nix", + "rev": "26dc164a4c3976888e13eabd73a210b78505820f", + "type": "github" + }, + "original": { + "owner": "o1-labs", + "repo": "dune-nix", + "type": "github" + } + }, "flake-buildkite-pipeline": { "inputs": { "nixpkgs-lib": "nixpkgs-lib" @@ -197,12 +247,8 @@ }, "mina": { "inputs": { - "describe-dune": [ - "describe-dune" - ], - "dune-nix": [ - "dune-nix" - ], + "describe-dune": "describe-dune_2", + "dune-nix": "dune-nix_2", "flake-buildkite-pipeline": "flake-buildkite-pipeline", "flake-compat": "flake-compat", "flockenzeit": "flockenzeit", @@ -211,9 +257,7 @@ "nix-filter": "nix-filter", "nix-npm-buildPackage": "nix-npm-buildPackage", "nix-utils": "nix-utils", - "nixpkgs": [ - "nixpkgs" - ], + "nixpkgs": "nixpkgs_2", "nixpkgs-mozilla": "nixpkgs-mozilla", "o1-opam-repository": "o1-opam-repository", "opam-nix": "opam-nix", @@ -222,7 +266,7 @@ }, "locked": { "lastModified": 1, - "narHash": "sha256-9mtY3wevSrAimyB9inP1CwIQPAKuU51ImjRbFoCLM00=", + "narHash": "sha256-So/hGZ1uqgIGYKRlRcVhxHqi26tg2ogMO55SrvARb1g=", "path": "src/mina", "type": "path" }, @@ -380,6 +424,22 @@ } }, "nixpkgs_2": { + "locked": { + "lastModified": 1713180868, + "narHash": "sha256-5CSnPSCEWeUmrFiLuYIQIPQzPrpCB8x3VhE+oXLRO3k=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "140546acf30a8212a03a88ded8506413fa3b5d21", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-23.11-small", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { "locked": { "lastModified": 1720535198, "narHash": "sha256-zwVvxrdIzralnSbcpghA92tWu2DV2lwv89xZc8MTrbg=", @@ -501,7 +561,7 @@ "dune-nix": "dune-nix", "flake-utils": "flake-utils", "mina": "mina", - "nixpkgs": "nixpkgs_2", + "nixpkgs": "nixpkgs_3", "nixpkgs-mozilla": "nixpkgs-mozilla_2" } }, diff --git a/flake.nix b/flake.nix index ab7ce8d42c..a3c8988d29 100644 --- a/flake.nix +++ b/flake.nix @@ -2,8 +2,6 @@ inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11-small"; mina.url = "path:src/mina"; - mina.inputs.nixpkgs.follows = "nixpkgs"; - mina.inputs.nixpkgs-mozilla.follows = "nixpkgs-mozilla"; nixpkgs-mozilla.url = "github:mozilla/nixpkgs-mozilla"; nixpkgs-mozilla.flake = false; describe-dune.url = "github:o1-labs/describe-dune"; @@ -12,8 +10,6 @@ dune-nix.url = "github:o1-labs/dune-nix"; dune-nix.inputs.nixpkgs.follows = "nixpkgs"; dune-nix.inputs.flake-utils.follows = "flake-utils"; - mina.inputs.dune-nix.follows = "dune-nix"; - mina.inputs.describe-dune.follows = "describe-dune"; flake-utils.url = "github:numtide/flake-utils"; }; outputs = { self, nixpkgs, flake-utils, ... }@inputs: diff --git a/pin.sh b/pin.sh index 7d2cdf47df..9350e1b6af 100755 --- a/pin.sh +++ b/pin.sh @@ -7,3 +7,4 @@ ROOT=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) pushd "$ROOT" && git submodule sync && git submodule update --init --recursive && popd # Add the flake registry entry nix registry add o1js "git+file://$ROOT?submodules=1" +nix flake lock '.?submodules=1' --update-input mina diff --git a/src/bindings b/src/bindings index 4f15b3152a..a31eecbfe1 160000 --- a/src/bindings +++ b/src/bindings @@ -1 +1 @@ -Subproject commit 4f15b3152adf9db9eb1e7e9b71bdf432c8400a05 +Subproject commit a31eecbfe17aaab8d09236bdefdab8ecaa10f9f3 From 21c4bb519ae0a087cd3e816e67133550517ef540 Mon Sep 17 00:00:00 2001 From: Geometer1729 <16kuhnb@gmail.com> Date: Tue, 3 Sep 2024 15:27:14 -0400 Subject: [PATCH 11/22] add mina-shell for macos --- flake.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index a3c8988d29..0ff946b354 100644 --- a/flake.nix +++ b/flake.nix @@ -87,8 +87,9 @@ formatter = pkgs.nixfmt; inherit mina; devShells = { + # This seems to work better for macos + mina-shell = inputs.mina.devShells."${system}".with-lsp; default = pkgs.mkShell { - inputsFrom = [ prj.pkgs.o1js_bindings prj.pkgs.__ocaml-js__ ]; shellHook = '' RUSTUP_HOME=$(pwd)/.rustup From 9a44799fa2f685fcdc9fdcc231a367c11b7c50b3 Mon Sep 17 00:00:00 2001 From: Geometer1729 <16kuhnb@gmail.com> Date: Tue, 3 Sep 2024 16:12:02 -0400 Subject: [PATCH 12/22] work with nix 2.24 --- flake.lock | 4 ++-- flake.nix | 1 + pin.sh | 7 +++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/flake.lock b/flake.lock index ca26e7b09b..5e7f546be7 100644 --- a/flake.lock +++ b/flake.lock @@ -265,8 +265,8 @@ "utils": "utils" }, "locked": { - "lastModified": 1, - "narHash": "sha256-So/hGZ1uqgIGYKRlRcVhxHqi26tg2ogMO55SrvARb1g=", + "lastModified": 1724963391, + "narHash": "sha256-59BiFfMZKblxVwW7tTzqR4ui5rH8B25WJIbpfzW05pg=", "path": "src/mina", "type": "path" }, diff --git a/flake.nix b/flake.nix index 0ff946b354..f683659fff 100644 --- a/flake.nix +++ b/flake.nix @@ -1,4 +1,5 @@ { + description = "o1js - TypeScript framework for zk-SNARKs and zkApps"; inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11-small"; mina.url = "path:src/mina"; diff --git a/pin.sh b/pin.sh index 9350e1b6af..6815dbac8e 100755 --- a/pin.sh +++ b/pin.sh @@ -3,8 +3,11 @@ # Find the root of the o1js repo ROOT=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +pushd "$ROOT" # Update the submodules -pushd "$ROOT" && git submodule sync && git submodule update --init --recursive && popd +git submodule sync && git submodule update --init --recursive # Add the flake registry entry nix registry add o1js "git+file://$ROOT?submodules=1" -nix flake lock '.?submodules=1' --update-input mina +# update mina input to local submodule +nix flake update mina --override-input mina 'path:src/mina' --flake '.?submodules=1' +popd From 9ae5c4c9c7ad678432e7b9c06e6494cdf0875d4b Mon Sep 17 00:00:00 2001 From: Geometer1729 <16kuhnb@gmail.com> Date: Fri, 6 Sep 2024 09:27:53 -0400 Subject: [PATCH 13/22] restore dune files remove unused pkgs --- flake.nix | 2 -- src/bindings | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/flake.nix b/flake.nix index f683659fff..8ccf9da626 100644 --- a/flake.nix +++ b/flake.nix @@ -124,8 +124,6 @@ binaryen # provides wasm-opt dune_3 - ocamlPackages.js_of_ocaml-ppx - ocamlPackages.base ] ++ commonOverrides.buildInputs ; }; }; diff --git a/src/bindings b/src/bindings index a31eecbfe1..2d79600d5a 160000 --- a/src/bindings +++ b/src/bindings @@ -1 +1 @@ -Subproject commit a31eecbfe17aaab8d09236bdefdab8ecaa10f9f3 +Subproject commit 2d79600d5a830feb6838a5476169e4fbf0eb9bde From a3ea6b2d6f75aeabdc1356d9342e9237d4718edf Mon Sep 17 00:00:00 2001 From: Geometer1729 <16kuhnb@gmail.com> Date: Fri, 6 Sep 2024 11:33:26 -0400 Subject: [PATCH 14/22] update bindings and flake.lock --- flake.lock | 2 +- src/bindings | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/flake.lock b/flake.lock index 3adb0e1787..f97b2ab557 100644 --- a/flake.lock +++ b/flake.lock @@ -265,7 +265,7 @@ "utils": "utils" }, "locked": { - "lastModified": 1725630088, + "lastModified": 1725634290, "narHash": "sha256-N/tNdKgaTjZ6Sq+HO2Z6rnE+9kwdYmnmIGU96sDmn3o=", "path": "src/mina", "type": "path" diff --git a/src/bindings b/src/bindings index 2d79600d5a..8580e52bd5 160000 --- a/src/bindings +++ b/src/bindings @@ -1 +1 @@ -Subproject commit 2d79600d5a830feb6838a5476169e4fbf0eb9bde +Subproject commit 8580e52bd5d344a53277b284b130f206c35b919d From 876182a8394b0b37576fbd0b735803ad931986df Mon Sep 17 00:00:00 2001 From: Geometer1729 <16kuhnb@gmail.com> Date: Mon, 9 Sep 2024 10:50:32 -0400 Subject: [PATCH 15/22] Fix paths add script to build mina-signer --- run-jest-tests.sh | 7 +++++++ src/mina-signer/tests/client.test.ts | 2 +- src/mina-signer/tests/keypair.test.ts | 2 +- src/mina-signer/tests/message.test.ts | 4 ++-- src/mina-signer/tests/payment.test.ts | 4 ++-- src/mina-signer/tests/rosetta.test.ts | 8 ++++---- src/mina-signer/tests/stake-delegation.test.ts | 4 ++-- 7 files changed, 19 insertions(+), 12 deletions(-) diff --git a/run-jest-tests.sh b/run-jest-tests.sh index 54b84b73c5..b0bc4ee06f 100755 --- a/run-jest-tests.sh +++ b/run-jest-tests.sh @@ -2,6 +2,13 @@ set -e shopt -s globstar # to expand '**' into nested directories +if ! [ -f /mina-signer/dist ] +then + pushd src/mina-signer + npm run build + popd +fi + for f in ./src/**/*.test.ts; do NODE_OPTIONS=--experimental-vm-modules npx jest $f; done diff --git a/src/mina-signer/tests/client.test.ts b/src/mina-signer/tests/client.test.ts index 00a63282c3..4ca384a2d2 100644 --- a/src/mina-signer/tests/client.test.ts +++ b/src/mina-signer/tests/client.test.ts @@ -1,4 +1,4 @@ -import Client from '../../../dist/node/mina-signer/mina-signer.js'; +import Client from '../dist/node/mina-signer/mina-signer.js'; describe('Client Class Initialization', () => { let client; diff --git a/src/mina-signer/tests/keypair.test.ts b/src/mina-signer/tests/keypair.test.ts index ae2deb3b5e..eb7e3b2cc4 100644 --- a/src/mina-signer/tests/keypair.test.ts +++ b/src/mina-signer/tests/keypair.test.ts @@ -1,4 +1,4 @@ -import Client from '../../../dist/node/mina-signer/mina-signer.js'; +import Client from '..//dist/node/mina-signer/mina-signer.js'; describe('Keypair', () => { let client: Client; diff --git a/src/mina-signer/tests/message.test.ts b/src/mina-signer/tests/message.test.ts index 90f718d450..bd9586fb19 100644 --- a/src/mina-signer/tests/message.test.ts +++ b/src/mina-signer/tests/message.test.ts @@ -1,5 +1,5 @@ -import Client from '../../../dist/node/mina-signer/mina-signer.js'; -import type { PrivateKey } from '.../.././dist/node/mina-signer/src/types.js'; +import Client from '../dist/node/mina-signer/mina-signer.js'; +import type { PrivateKey } from '../dist/node/mina-signer/src/types.js'; describe('Message', () => { describe('Mainnet network', () => { diff --git a/src/mina-signer/tests/payment.test.ts b/src/mina-signer/tests/payment.test.ts index 9c434e3721..de84939d67 100644 --- a/src/mina-signer/tests/payment.test.ts +++ b/src/mina-signer/tests/payment.test.ts @@ -1,5 +1,5 @@ -import Client from '../../../dist/node/mina-signer/mina-signer.js'; -import type { Keypair } from '../../../dist/node/mina-signer/src/types.js'; +import Client from '../dist/node/mina-signer/mina-signer.js'; +import type { Keypair } from '../dist/node/mina-signer/src/types.js'; describe('Payment', () => { describe('Mainnet network', () => { diff --git a/src/mina-signer/tests/rosetta.test.ts b/src/mina-signer/tests/rosetta.test.ts index 67efdc6671..8b8d691822 100644 --- a/src/mina-signer/tests/rosetta.test.ts +++ b/src/mina-signer/tests/rosetta.test.ts @@ -1,7 +1,7 @@ -import Client from '../../../dist/node/mina-signer/mina-signer.js'; -import { fieldFromHex, fieldToHex, signatureJsonToHex, signatureJsonFromHex, UnsignedTransaction, publicKeyToHex, signTransaction } from '../../../dist/node/mina-signer/src/rosetta.js'; -import { PublicKey } from '../../../dist/node/mina-signer/src/curve-bigint.js'; -import { Field } from '../../../dist/node/mina-signer/src/field-bigint.js'; +import Client from '../dist/node/mina-signer/mina-signer.js'; +import { fieldFromHex, fieldToHex, signatureJsonToHex, signatureJsonFromHex, UnsignedTransaction, publicKeyToHex, signTransaction } from '../dist/node/mina-signer/src/rosetta.js'; +import { PublicKey } from '../dist/node/mina-signer/src/curve-bigint.js'; +import { Field } from '../dist/node/mina-signer/src/field-bigint.js'; describe('Rosetta', () => { let client: Client; diff --git a/src/mina-signer/tests/stake-delegation.test.ts b/src/mina-signer/tests/stake-delegation.test.ts index a298157734..16cdf0d8f6 100644 --- a/src/mina-signer/tests/stake-delegation.test.ts +++ b/src/mina-signer/tests/stake-delegation.test.ts @@ -1,5 +1,5 @@ -import Client from '../../../dist/node/mina-signer/mina-signer.js'; -import type { Keypair } from '../../../dist/node/mina-signer/src/types.js'; +import Client from '../dist/node/mina-signer/mina-signer.js'; +import type { Keypair } from '../dist/node/mina-signer/src/types.js'; describe('Stake Delegation', () => { describe('Mainnet network', () => { From ca47389c8da74edc0352f7a2e1d82e20b0ae626a Mon Sep 17 00:00:00 2001 From: Geometer1729 <16kuhnb@gmail.com> Date: Mon, 9 Sep 2024 11:10:59 -0400 Subject: [PATCH 16/22] typo --- run-jest-tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run-jest-tests.sh b/run-jest-tests.sh index b0bc4ee06f..545ffa1c9a 100755 --- a/run-jest-tests.sh +++ b/run-jest-tests.sh @@ -2,7 +2,7 @@ set -e shopt -s globstar # to expand '**' into nested directories -if ! [ -f /mina-signer/dist ] +if ! [ -f ./mina-signer/dist ] then pushd src/mina-signer npm run build From 3eb237fcdfaa212c48d5ce138677a3d0305a0714 Mon Sep 17 00:00:00 2001 From: Geometer1729 <16kuhnb@gmail.com> Date: Mon, 9 Sep 2024 11:27:15 -0400 Subject: [PATCH 17/22] another typo --- src/mina-signer/tests/keypair.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mina-signer/tests/keypair.test.ts b/src/mina-signer/tests/keypair.test.ts index eb7e3b2cc4..2c19c95caa 100644 --- a/src/mina-signer/tests/keypair.test.ts +++ b/src/mina-signer/tests/keypair.test.ts @@ -1,4 +1,4 @@ -import Client from '..//dist/node/mina-signer/mina-signer.js'; +import Client from '../dist/node/mina-signer/mina-signer.js'; describe('Keypair', () => { let client: Client; From 0761b9a740acdd8fd71aa472f7fabd2e44ec9633 Mon Sep 17 00:00:00 2001 From: Geometer1729 <16kuhnb@gmail.com> Date: Mon, 9 Sep 2024 15:22:07 -0400 Subject: [PATCH 18/22] update bindings --- src/bindings | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bindings b/src/bindings index 8580e52bd5..f15768d43e 160000 --- a/src/bindings +++ b/src/bindings @@ -1 +1 @@ -Subproject commit 8580e52bd5d344a53277b284b130f206c35b919d +Subproject commit f15768d43eeb6cd3eadeb1df6bac18c6a7bdbb40 From d3ba14da7cb94f50177ce1ba01885c22cf8d39ef Mon Sep 17 00:00:00 2001 From: Geometer1729 <16kuhnb@gmail.com> Date: Mon, 9 Sep 2024 15:53:21 -0400 Subject: [PATCH 19/22] fix path in flake.nix --- flake.lock | 2 +- flake.nix | 2 +- src/bindings | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.lock b/flake.lock index f97b2ab557..f07708ca9e 100644 --- a/flake.lock +++ b/flake.lock @@ -265,7 +265,7 @@ "utils": "utils" }, "locked": { - "lastModified": 1725634290, + "lastModified": 1725910775, "narHash": "sha256-N/tNdKgaTjZ6Sq+HO2Z6rnE+9kwdYmnmIGU96sDmn3o=", "path": "src/mina", "type": "path" diff --git a/flake.nix b/flake.nix index 8ccf9da626..889fa51931 100644 --- a/flake.nix +++ b/flake.nix @@ -31,7 +31,7 @@ ./src/bindings/ocaml/dune ./src/bindings/ocaml/lib/dune ./src/bindings/ocaml/dune-project - ./src/bindings/ocaml/js/dune + ./src/bindings/ocaml/jsoo_exports/dune ]; }); phases = [ "unpackPhase" "buildPhase" ]; diff --git a/src/bindings b/src/bindings index f15768d43e..4b8f11b2ae 160000 --- a/src/bindings +++ b/src/bindings @@ -1 +1 @@ -Subproject commit f15768d43eeb6cd3eadeb1df6bac18c6a7bdbb40 +Subproject commit 4b8f11b2aea5c9f6a895b66912963e635a819dd2 From fa0323573590e902a16359b25859cfed98e56d05 Mon Sep 17 00:00:00 2001 From: Geometer1729 <16kuhnb@gmail.com> Date: Mon, 16 Sep 2024 10:24:25 -0400 Subject: [PATCH 20/22] update mina to compatible --- flake.lock | 2 +- src/bindings | 2 +- src/mina | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.lock b/flake.lock index f07708ca9e..05dec10714 100644 --- a/flake.lock +++ b/flake.lock @@ -265,7 +265,7 @@ "utils": "utils" }, "locked": { - "lastModified": 1725910775, + "lastModified": 1726495955, "narHash": "sha256-N/tNdKgaTjZ6Sq+HO2Z6rnE+9kwdYmnmIGU96sDmn3o=", "path": "src/mina", "type": "path" diff --git a/src/bindings b/src/bindings index 4b8f11b2ae..aa03b03ef8 160000 --- a/src/bindings +++ b/src/bindings @@ -1 +1 @@ -Subproject commit 4b8f11b2aea5c9f6a895b66912963e635a819dd2 +Subproject commit aa03b03ef8843c99d70f1ed1a92510b566f028c6 diff --git a/src/mina b/src/mina index 97f63d093a..4dff45dc6d 160000 --- a/src/mina +++ b/src/mina @@ -1 +1 @@ -Subproject commit 97f63d093af135d2b30d8fdbec28119dc6e70728 +Subproject commit 4dff45dc6dddfea81e3ebbb2a1136527d2fe430a From f9944db8fa662e86876cb4a928b001487005a6b9 Mon Sep 17 00:00:00 2001 From: Geometer1729 <16kuhnb@gmail.com> Date: Mon, 16 Sep 2024 14:20:56 -0400 Subject: [PATCH 21/22] update mina again --- flake.lock | 4 ++-- src/bindings | 2 +- src/mina | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/flake.lock b/flake.lock index 05dec10714..df34277a7d 100644 --- a/flake.lock +++ b/flake.lock @@ -265,8 +265,8 @@ "utils": "utils" }, "locked": { - "lastModified": 1726495955, - "narHash": "sha256-N/tNdKgaTjZ6Sq+HO2Z6rnE+9kwdYmnmIGU96sDmn3o=", + "lastModified": 1726508134, + "narHash": "sha256-rAyggDaasWFcgoYi1aNrGZxPK/wH5+cleIV453xuUYY=", "path": "src/mina", "type": "path" }, diff --git a/src/bindings b/src/bindings index aa03b03ef8..30106d23ff 160000 --- a/src/bindings +++ b/src/bindings @@ -1 +1 @@ -Subproject commit aa03b03ef8843c99d70f1ed1a92510b566f028c6 +Subproject commit 30106d23ffd707a7e6af4093b9af442cabef1d93 diff --git a/src/mina b/src/mina index 4dff45dc6d..203fbbcc7a 160000 --- a/src/mina +++ b/src/mina @@ -1 +1 @@ -Subproject commit 4dff45dc6dddfea81e3ebbb2a1136527d2fe430a +Subproject commit 203fbbcc7a00494114066f67c20ac8c510691578 From cf58f8cfb1fc8fc28ccf7cec4a6dbc69357bc39f Mon Sep 17 00:00:00 2001 From: Florian Date: Tue, 17 Sep 2024 17:19:44 +0200 Subject: [PATCH 22/22] move heavier circuits --- tests/vk-regression/vk-regression.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/vk-regression/vk-regression.ts b/tests/vk-regression/vk-regression.ts index 3298b9725f..dcee2f5b2a 100644 --- a/tests/vk-regression/vk-regression.ts +++ b/tests/vk-regression/vk-regression.ts @@ -50,6 +50,8 @@ type MinimumConstraintSystem = { }; const ConstraintSystems: MinimumConstraintSystem[] = [ + ecdsa, + keccakAndEcdsa, Voting_, Membership_, HelloWorld, @@ -60,8 +62,6 @@ const ConstraintSystems: MinimumConstraintSystem[] = [ HashCS, BasicCS, CryptoCS, - ecdsa, - keccakAndEcdsa, ecdsaEthers, SHA256Program, diverse,