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..3c60f7a680 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,6 @@ o1js-reference _build/ src/config/ src/config.mlh +.direnv +.rustup +result diff --git a/README-dev.md b/README-dev.md index f00bd9c88b..7d8e1c8f59 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 +direnv with the `.envrc` provided. This devshell provides all the dependencies required for npm scripts including `npm run:update-bindings`. + ## 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. @@ -89,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**. @@ -202,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 diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000000..df34277a7d --- /dev/null +++ b/flake.lock @@ -0,0 +1,604 @@ +{ + "nodes": { + "describe-dune": { + "inputs": { + "flake-utils": [ + "flake-utils" + ], + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1724407960, + "narHash": "sha256-pUKTVMYEtsD1AGlHFTdPourowt+tJ3htKhRu7VALFzc=", + "owner": "o1-labs", + "repo": "describe-dune", + "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": { + "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" + } + }, + "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" + }, + "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_2", + "dune-nix": "dune-nix_2", + "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_2", + "nixpkgs-mozilla": "nixpkgs-mozilla", + "o1-opam-repository": "o1-opam-repository", + "opam-nix": "opam-nix", + "opam-repository": "opam-repository", + "utils": "utils" + }, + "locked": { + "lastModified": 1726508134, + "narHash": "sha256-rAyggDaasWFcgoYi1aNrGZxPK/wH5+cleIV453xuUYY=", + "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-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": 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=", + "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_3", + "nixpkgs-mozilla": "nixpkgs-mozilla_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..889fa51931 --- /dev/null +++ b/flake.nix @@ -0,0 +1,144 @@ +{ + description = "o1js - TypeScript framework for zk-SNARKs and zkApps"; + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11-small"; + mina.url = "path:src/mina"; + 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"; + dune-nix.url = "github:o1-labs/dune-nix"; + dune-nix.inputs.nixpkgs.follows = "nixpkgs"; + dune-nix.inputs.flake-utils.follows = "flake-utils"; + flake-utils.url = "github:numtide/flake-utils"; + }; + outputs = { self, nixpkgs, flake-utils, ... }@inputs: + flake-utils.lib.eachDefaultSystem (system: + let + 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 { + 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/jsoo_exports/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"; + }; + }; + }; + 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 = { + # This seems to work better for macos + mina-shell = inputs.mina.devShells."${system}".with-lsp; + default = pkgs.mkShell { + shellHook = + '' + RUSTUP_HOME=$(pwd)/.rustup + export RUSTUP_HOME + rustup toolchain link nix ${rust-channel} + ''; + packages = with pkgs; + [ nodejs + nodePackages.npm + typescript + nodePackages.typescript-language-server + + #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 + (writeShellApplication + { name = "rustup"; + text = + '' + if [ "$1" = run ] && [ "$2" = nightly-2023-09-01 ] + then + ${rustup}/bin/rustup run nix "''${@:3}" + else + ${rustup}/bin/rustup "$@" + fi + ''; + } + ) + rustup + wasm-pack + binaryen # provides wasm-opt + + dune_3 + ] ++ commonOverrides.buildInputs ; + }; + }; + # TODO build from ./ocaml root, not ./. (after fixing a bug in dune-nix) + packages = { + kim = pkgs.kimchi-rust-wasm; + inherit dune-description; + 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 + }; + }; + }); +} diff --git a/pin.sh b/pin.sh new file mode 100755 index 0000000000..6815dbac8e --- /dev/null +++ b/pin.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +# Set up flake registry to get o1js with all the submodules + +# Find the root of the o1js repo +ROOT=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +pushd "$ROOT" +# Update the submodules +git submodule sync && git submodule update --init --recursive +# Add the flake registry entry +nix registry add o1js "git+file://$ROOT?submodules=1" +# update mina input to local submodule +nix flake update mina --override-input mina 'path:src/mina' --flake '.?submodules=1' +popd diff --git a/run-jest-tests.sh b/run-jest-tests.sh index 54b84b73c5..545ffa1c9a 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/bindings b/src/bindings index 8e99acc94d..30106d23ff 160000 --- a/src/bindings +++ b/src/bindings @@ -1 +1 @@ -Subproject commit 8e99acc94da892eeb090367844f85d22ecf4f93b +Subproject commit 30106d23ffd707a7e6af4093b9af442cabef1d93 diff --git a/src/lib/proof-system/zkprogram.ts b/src/lib/proof-system/zkprogram.ts index 8c5f83da9b..9743f7f5a9 100644 --- a/src/lib/proof-system/zkprogram.ts +++ b/src/lib/proof-system/zkprogram.ts @@ -978,7 +978,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 b/src/mina index 24c8b2d723..203fbbcc7a 160000 --- a/src/mina +++ b/src/mina @@ -1 +1 @@ -Subproject commit 24c8b2d723fb09d0d7f996b6ac35373dc27084ef +Subproject commit 203fbbcc7a00494114066f67c20ac8c510691578 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,