From 0a823ec40443faca6a95c5abfea7a9b247ce39a6 Mon Sep 17 00:00:00 2001 From: Martin Minkov Date: Thu, 28 Sep 2023 13:48:08 -0300 Subject: [PATCH 01/23] feat: add ocaml build directory to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index fcb737b159..4571a23f08 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ tests/test-artifacts/ profiling.md snarkyjs-reference *.tmp.js +_build/ From 0fe99ff294f9e5cee4f8e92c16497a913287a735 Mon Sep 17 00:00:00 2001 From: Martin Minkov Date: Thu, 28 Sep 2023 13:48:36 -0300 Subject: [PATCH 02/23] feat: add dune-project file to build bindings from o1js root directory --- dune-project | 1 + 1 file changed, 1 insertion(+) create mode 100644 dune-project diff --git a/dune-project b/dune-project new file mode 100644 index 0000000000..7b17fb2d30 --- /dev/null +++ b/dune-project @@ -0,0 +1 @@ +(lang dune 3.3) From 9864ffb257836f53bcdfd48061b5a3ef50efc047 Mon Sep 17 00:00:00 2001 From: Martin Minkov Date: Thu, 5 Oct 2023 14:32:07 -0700 Subject: [PATCH 03/23] chore(bindings): update subproject commit --- src/bindings | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bindings b/src/bindings index d40dd6c6a5..285d40ffe3 160000 --- a/src/bindings +++ b/src/bindings @@ -1 +1 @@ -Subproject commit d40dd6c6a5517bbebd3c77abd54c2f9813724d7f +Subproject commit 285d40ffe37f8e4f73199080ba113d515b83861e From 3fcaa6565c0432a72f990f09f8ec1269c598e8f7 Mon Sep 17 00:00:00 2001 From: Martin Minkov Date: Fri, 27 Oct 2023 12:36:26 -0700 Subject: [PATCH 04/23] fix(package.json): update 'make' script to use local script --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f82d5a5afe..c295598c12 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "scripts": { "type-check": "tsc --noEmit", "dev": "npx tsc -p tsconfig.node.json && node src/build/copy-to-dist.js", - "make": "make -C ../../.. snarkyjs", + "make": "./src/bindings/scripts/update-snarkyjs-bindings.sh", "make:no-types": "npm run clean && make -C ../../.. snarkyjs_no_types", "bindings": "cd ../../.. && ./scripts/update-snarkyjs-bindings.sh && cd src/lib/snarkyjs", "build": "node src/build/copy-artifacts.js && rimraf ./dist/node && npm run dev && node src/build/buildNode.js", From b278770916ae7cee6076b7361354e6949ab4f5f3 Mon Sep 17 00:00:00 2001 From: Martin Minkov Date: Fri, 27 Oct 2023 12:36:57 -0700 Subject: [PATCH 05/23] fix(tsconfig.json): add './src/mina' to exclude list to prevent unnecessary compilation of mina directory --- tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index 268b0f8b3a..367f1cc41d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,6 @@ { "include": ["./src/**/*.ts"], - "exclude": ["./src/**/*.bc.js", "./src/build", "./src/examples"], + "exclude": ["./src/**/*.bc.js", "./src/build", "./src/examples", "./src/mina"], "compilerOptions": { "rootDir": "./src", "outDir": "dist", From 750451fce1a79aae24d4361c91e1fcc4516aac60 Mon Sep 17 00:00:00 2001 From: Martin Minkov Date: Fri, 27 Oct 2023 16:47:05 -0700 Subject: [PATCH 06/23] feat(jest.config.js): add 'src/mina/' to modulePathIgnorePatterns to prevent Jest from running tests in this directory --- jest.config.js | 1 + 1 file changed, 1 insertion(+) diff --git a/jest.config.js b/jest.config.js index b24c895d96..7f6d944074 100644 --- a/jest.config.js +++ b/jest.config.js @@ -3,6 +3,7 @@ export default { testEnvironment: 'node', extensionsToTreatAsEsm: ['.ts'], transformIgnorePatterns: ['node_modules/', 'dist/node/'], + modulePathIgnorePatterns: ['src/mina/'], globals: { 'ts-jest': { useESM: true, From 0c242033d8793ab8bf06e07d1fea45aeea1a3eaa Mon Sep 17 00:00:00 2001 From: Martin Minkov Date: Sun, 29 Oct 2023 10:42:24 -0700 Subject: [PATCH 07/23] feat(run-jest-tests.sh): add condition to exclude 'src/mina' from jest tests This change is temporary until 'snarkyjs' is removed from the mina repo. --- run-jest-tests.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/run-jest-tests.sh b/run-jest-tests.sh index d103274798..f034d80158 100755 --- a/run-jest-tests.sh +++ b/run-jest-tests.sh @@ -3,5 +3,8 @@ set -e shopt -s globstar # to expand '**' into nested directories for f in ./src/**/*.test.ts; do - NODE_OPTIONS=--experimental-vm-modules npx jest $f; -done + # TODO: Remove this once we remove the `snarkyjs` inside the mina repo + if [[ $f != *"src/mina"* ]]; then + NODE_OPTIONS=--experimental-vm-modules npx jest $f; + fi +done \ No newline at end of file From db7ccba2b0b22a189751eb004ef2fd6236fea1f4 Mon Sep 17 00:00:00 2001 From: Martin Minkov Date: Sun, 29 Oct 2023 20:22:32 -0700 Subject: [PATCH 08/23] feat(README-dev): first draft --- README-dev.md | 127 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 93 insertions(+), 34 deletions(-) diff --git a/README-dev.md b/README-dev.md index 2276795050..602e24e0e2 100644 --- a/README-dev.md +++ b/README-dev.md @@ -1,74 +1,133 @@ +<<<<<<< HEAD # How to contribute to the SnarkyJS codebase This README includes information that is helpful for SnarkyJS core contributors. +======= +# o1js README-dev -## Run examples using Node.js +o1js is a TypeScript framework designed for zk-SNARKs and zkApps on the Mina blockchain. +>>>>>>> e3c20452a... feat(README-dev): first draft + +- [zkApps Overview](https://docs.minaprotocol.com/zkapps) +- [Mina README](/src/mina/README.md) + +For more information on our development process and how to contribute, see [CONTRIBUTING.md](https://github.com/o1-labs/o1js/blob/main/CONTRIBUTING.md). This document is meant to guide you through building o1js from source and understanding the development workflow. + +## Prerequisites + +Before starting, ensure you have the following tools installed: + +- [Git](https://git-scm.com/) +- [Node.js and npm](https://nodejs.org/) +- [opam](https://opam.ocaml.org/) +- [Cargo](https://www.rust-lang.org/learn/get-started) + +After cloning the repository, you need to fetch the submodules: + +```sh +git submodule update --init --recursive +``` + +## Building o1js + +For most users, building o1js is as simple as running: ```sh npm install npm run build - -./run src/examples/api_exploration.ts ``` -## Build and run the web version +This will compile the TypeScript source files, making it 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 do not have to be regenerated unless there are changes to the OCaml or Rust source files. + +## Building Bindings + +If you need 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. + +o1js depends on OCaml code that is transplied to JavaScript using [Js_of_ocaml](https://github.com/ocsigen/js_of_ocaml), and Rust code that is transpiled to WebAssembly using [wasm-pack](https://github.com/rustwasm/wasm-pack). These artifacts allow o1js to call into [snarky](https://github.com/o1-labs/snarky) and [Kimchi](https://github.com/o1-labs/proof-systems) to write zk-SNARKs and zkApps. + +The compiled artifacts are stored under `src/bindings/compiled`, and are version-controlled to simplify the build process for end-users. + +If you wish to rebuild the OCaml and Rust artifacts, you must be able to build the Mina repo before building the bindings. See the [Mina Dev Readme](https://github.com/MinaProtocol/mina/blob/develop/README-dev.md) for more information. Once you have configured your environment to build Mina, you can build the bindings: ```sh -npm install -npm run build:web -npm run serve:web +npm run make ``` -To see the test running in a web browser, go to `http://localhost:8000/`. +This will build the OCaml and Rust artifacts, and copy them to the `src/bindings/compiled` directory. + +### OCaml Bindings -## Run tests +The OCaml bindings are located under `src/bindings`, and they specify all of the low-level OCaml code that is exposed to o1js. See the [OCaml Bindings README](https://github.com/o1-labs/o1js-bindings/blob/main/README.md) for more information. -- Unit tests +### WebAssembly Bindings - ```sh - npm run test - npm run test:unit - ``` +The WebAssembly bindings are built using Rust's `wasm-pack`. Ensure you have it installed and configured correctly. -- Integration tests +## Development - ```sh - npm run test:integration - ``` +### Branch Compatibility -- E2E tests +When working with submodules and various interconnected parts of the stack, ensure you are on the correct branches that are compatible with each other. - ```sh - npm install - npm run e2e:install - npm run build:web +#### How to Use the Branches - npm run e2e:prepare-server - npm run test:e2e - npm run e2e:show-report - ``` +| Repository | mina -> o1js -> o1js-bindings | +| ---------- | -------------------------------- | +| Branches | o1js-main -> main -> main | +| | berkeley -> berkeley -> berkeley | +| | develop -> develop -> develop | -## Branch Compatibility +- `o1js-main`: The o1js-main branch in the Mina repository corresponds to the main branch in both o1js and o1js-bindings repositories. This is where stable releases and ramp-up features are maintained. +- `berkeley`: The berkeley branch is maintained across all three repositories. This branch is used for features and updates specific to the Berkeley release of the project. + +<<<<<<< HEAD SnarkyJS is mostly used to write Mina Smart Contracts and must be compatible with the latest Berkeley Testnet (or soon Mainnet). The OCaml code is in the snarkyjs-bindings repository, not directly in SnarkyJS. To maintain compatibility between the repositories and build SnarkyJS from the [Mina repository](https://github.com/MinaProtocol/mina), make changes to its core, such as the OCaml-bindings in the [snarkyjs-bindings repository](https://github.com/o1-labs/snarkyjs-bindings), you must follow a certain branch compatibility pattern: +======= +- `develop`: The develop branch is also maintained across all three repositories. It is used for ongoing development, testing new features, and integration work. + +### Running Tests -The following branches are compatible: +To ensure your changes don't break existing functionality, run the test suite: +>>>>>>> e3c20452a... feat(README-dev): first draft +```sh +npm run test +npm run test:unit +``` + +<<<<<<< HEAD | repository | mina -> snarkyjs -> snarkyjs-bindings | | ---------- | ------------------------------------- | | branches | rampup -> main -> main | | | berkeley -> berkeley -> berkeley | | | develop -> develop -> develop | +======= +This will run all the unit tests and provide you with a summary of the test results. +>>>>>>> e3c20452a... feat(README-dev): first draft -## Run the GitHub actions locally +You can additionally run integration tests by running: - -You can execute the CI locally by using [act](https://github.com/nektos/act). First generate a GitHub token and use: +```sh +npm run test:integration ``` -act -j Build-And-Test-Server --matrix test_type:"Simple integration tests" -s $GITHUB_TOKEN + +Finally, we have a set of end-to-end tests that run against the browser. These tests are not run by default, but you can run them by running: + +```sh +npm install +npm run e2e:install +npm run build:web + +npm run e2e:prepare-server +npm run test:e2e +npm run e2e:show-report ``` -to execute the job "Build-And-Test-Server for the test type `Simple integration tests`. + +### Releasing + +To release a new version of o1js, you must first update the version number in `package.json`. Then, you can create a new pull request to merge your changes into the main branch. Once the pull request is merged, a CI job will automatically publish the new version to npm. From 96d07348300639ed599db7fd5afd402950cd55fb Mon Sep 17 00:00:00 2001 From: Martin Minkov Date: Mon, 13 Nov 2023 15:36:27 -0800 Subject: [PATCH 09/23] docs(README-dev.md): clarify bindings --- README-dev.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README-dev.md b/README-dev.md index 602e24e0e2..51d6cf75e5 100644 --- a/README-dev.md +++ b/README-dev.md @@ -43,7 +43,7 @@ This will compile the TypeScript source files, making it ready for use. The comp If you need 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. -o1js depends on OCaml code that is transplied to JavaScript using [Js_of_ocaml](https://github.com/ocsigen/js_of_ocaml), and Rust code that is transpiled to WebAssembly using [wasm-pack](https://github.com/rustwasm/wasm-pack). These artifacts allow o1js to call into [snarky](https://github.com/o1-labs/snarky) and [Kimchi](https://github.com/o1-labs/proof-systems) to write zk-SNARKs and zkApps. +o1js depends on OCaml code that is transplied to JavaScript using [Js_of_ocaml](https://github.com/ocsigen/js_of_ocaml), and Rust code that is transpiled to WebAssembly using [wasm-pack](https://github.com/rustwasm/wasm-pack). These artifacts allow o1js to call into [Pickles](https://github.com/o1-labs/snarkyhttps://github.com/MinaProtocol/mina/blob/develop/src/lib/pickles/README.md), [snarky](https://github.com/o1-labs/snarky), and [Kimchi](https://github.com/o1-labs/proof-systems) to write zk-SNARKs and zkApps. The compiled artifacts are stored under `src/bindings/compiled`, and are version-controlled to simplify the build process for end-users. @@ -57,11 +57,11 @@ This will build the OCaml and Rust artifacts, and copy them to the `src/bindings ### OCaml Bindings -The OCaml bindings are located under `src/bindings`, and they specify all of the low-level OCaml code that is exposed to o1js. See the [OCaml Bindings README](https://github.com/o1-labs/o1js-bindings/blob/main/README.md) for more information. +o1js depends on Pickles, snarky, and parts of the Mina transaction logic, all of which are compiled to JavaScript and stored as artifacts to be used by o1js natively. The OCaml bindings are located under `src/bindings`. See the [OCaml Bindings README](https://github.com/o1-labs/o1js-bindings/blob/main/README.md) for more information. ### WebAssembly Bindings -The WebAssembly bindings are built using Rust's `wasm-pack`. Ensure you have it installed and configured correctly. +o1js additionally depends on Kimchi, which is compiled to WebAssembly. Kimchi is located in the Mina repo, under `src/mina`. See the [Kimchi README](https://github.com/o1-labs/proof-systems/blob/master/README.md) for more information. ## Development From 7e9529c0685098347ee0f51233cda205b4e8e3c4 Mon Sep 17 00:00:00 2001 From: Martin Minkov Date: Tue, 14 Nov 2023 12:55:13 -0800 Subject: [PATCH 10/23] refactor(run-jest-tests.sh): remove condition excluding 'src/mina' from jest tests This change was made because the 'snarkyjs' inside the mina repo has been removed, making the condition unnecessary. --- run-jest-tests.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/run-jest-tests.sh b/run-jest-tests.sh index f034d80158..b15b30d311 100755 --- a/run-jest-tests.sh +++ b/run-jest-tests.sh @@ -3,8 +3,5 @@ set -e shopt -s globstar # to expand '**' into nested directories for f in ./src/**/*.test.ts; do - # TODO: Remove this once we remove the `snarkyjs` inside the mina repo - if [[ $f != *"src/mina"* ]]; then - NODE_OPTIONS=--experimental-vm-modules npx jest $f; - fi + NODE_OPTIONS=--experimental-vm-modules npx jest $f; done \ No newline at end of file From a7aec5ad85565ff7b5bfa17afbf5e2e177d90d2f Mon Sep 17 00:00:00 2001 From: Martin Minkov Date: Tue, 14 Nov 2023 13:40:47 -0800 Subject: [PATCH 11/23] refactor: rename npm script 'make' to 'build:bindings' in package.json and README-dev.md for better clarity and consistency --- README-dev.md | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README-dev.md b/README-dev.md index 51d6cf75e5..41aaf1de9f 100644 --- a/README-dev.md +++ b/README-dev.md @@ -50,7 +50,7 @@ The compiled artifacts are stored under `src/bindings/compiled`, and are version If you wish to rebuild the OCaml and Rust artifacts, you must be able to build the Mina repo before building the bindings. See the [Mina Dev Readme](https://github.com/MinaProtocol/mina/blob/develop/README-dev.md) for more information. Once you have configured your environment to build Mina, you can build the bindings: ```sh -npm run make +npm run build:bindings ``` This will build the OCaml and Rust artifacts, and copy them to the `src/bindings/compiled` directory. diff --git a/package.json b/package.json index c295598c12..f6f3bd8c4a 100644 --- a/package.json +++ b/package.json @@ -45,10 +45,10 @@ "scripts": { "type-check": "tsc --noEmit", "dev": "npx tsc -p tsconfig.node.json && node src/build/copy-to-dist.js", - "make": "./src/bindings/scripts/update-snarkyjs-bindings.sh", "make:no-types": "npm run clean && make -C ../../.. snarkyjs_no_types", "bindings": "cd ../../.. && ./scripts/update-snarkyjs-bindings.sh && cd src/lib/snarkyjs", "build": "node src/build/copy-artifacts.js && rimraf ./dist/node && npm run dev && node src/build/buildNode.js", + "build:bindings": "./src/bindings/scripts/update-snarkyjs-bindings.sh", "build:test": "npx tsc -p tsconfig.test.json && cp src/snarky.d.ts dist/node/snarky.d.ts", "build:node": "npm run build", "build:web": "rimraf ./dist/web && node src/build/buildWeb.js", From 11d8a64c973c35d382167dbbd82017227122161d Mon Sep 17 00:00:00 2001 From: Martin Minkov Date: Tue, 14 Nov 2023 13:58:50 -0800 Subject: [PATCH 12/23] fix(.prettierignore): update path for kimchi js files to reflect new directory structure, ensuring correct files are ignored by Prettier --- .prettierignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.prettierignore b/.prettierignore index 099c3fecca..fe67df0c2c 100644 --- a/.prettierignore +++ b/.prettierignore @@ -2,4 +2,4 @@ src/bindings/compiled/web_bindings/**/plonk_wasm* src/bindings/compiled/web_bindings/**/*.bc.js src/bindings/compiled/node_bindings/* dist/**/* -src/bindings/kimchi/js/**/*.js +src/mina/src/lib/crypto/kimchi/js/**/*.js From b6ecded32266e9340fda83f3b4df10c9795cb7d4 Mon Sep 17 00:00:00 2001 From: Martin Minkov Date: Wed, 15 Nov 2023 11:20:47 -0800 Subject: [PATCH 13/23] docs(README-dev.md): update build instructions and add details about build scripts - Replace opam with Dune in the list of required tools to reflect changes in the build process - Add a new section about build scripts, explaining the role of update-snarkyjs-bindings.sh - Expand on the OCaml bindings section, detailing the use of Dune and Js_of_ocaml in the build process - Add information about the WebAssembly bindings build process, including the output files - Introduce a section about generated constant types, explaining how they are created and their role in ensuring protocol consistency --- README-dev.md | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/README-dev.md b/README-dev.md index 41aaf1de9f..69ec6c7d61 100644 --- a/README-dev.md +++ b/README-dev.md @@ -19,7 +19,7 @@ Before starting, ensure you have the following tools installed: - [Git](https://git-scm.com/) - [Node.js and npm](https://nodejs.org/) -- [opam](https://opam.ocaml.org/) +- [Dune](https://github.com/ocaml/dune) - [Cargo](https://www.rust-lang.org/learn/get-started) After cloning the repository, you need to fetch the submodules: @@ -55,14 +55,35 @@ npm run build:bindings This will build the OCaml and Rust artifacts, and copy them to the `src/bindings/compiled` directory. +### Build Scripts + +The root build script which kicks off the build process is under `src/bindings/scripts/update-snarkyjs-bindings.sh`. This script is responsible for building the Node.js and web artifacts for o1js, and places them under `src/bindings/compiled`, to be used by o1js. + ### OCaml Bindings o1js depends on Pickles, snarky, and parts of the Mina transaction logic, all of which are compiled to JavaScript and stored as artifacts to be used by o1js natively. The OCaml bindings are located under `src/bindings`. See the [OCaml Bindings README](https://github.com/o1-labs/o1js-bindings/blob/main/README.md) for more information. +To compile the OCaml code, a build tool called Dune is used. Dune is a build system for OCaml projects, and is used in addition with Js_of_ocaml to compile the OCaml code to JavaScript. The dune file that is responsible for compiling the OCaml code is located under `src/bindings/ocaml/dune`. There are two build targets: `snarky_js_node` and `snarky_js_web`, which compile the Mina dependencies as well as link the wasm artifacts to build the Node.js and web artifacts, respectively. The output file is `snark_js_node.bc.js`, which is used by o1js. + ### WebAssembly Bindings o1js additionally depends on Kimchi, which is compiled to WebAssembly. Kimchi is located in the Mina repo, under `src/mina`. See the [Kimchi README](https://github.com/o1-labs/proof-systems/blob/master/README.md) for more information. +To compile the wasm code, a combination of Cargo and Dune is used. Both build files are located under `src/mina/src/lib/crypto/kimchi`, where the `wasm` folder contains the Rust code which is compiled to wasm, and the `js` folder which contains a wrapper around the wasm code which allows Js_of_ocaml to compile against the wasm backend. + +For the wasm build, the output files are: + +- `plonk_wasm_bg.wasm.d.ts`: TypeScript definition files describing the types of .wasm or .js files. +- `plonk_wasm.d.ts`: TypeScript definition file for plonk_wasm.js. +- `plonk_wasm_bg.wasm`: The compiled WebAssembly binary. +- `plonk_wasm.js`: JavaScript file that wraps the WASM code for use in Node.js. + +### Generated Constant Types + +In addition to building the OCaml and Rust code, the build script also generates TypeScript types for constants used in the Mina protocol. These types are generated from the OCaml source files, and are located under `src/bindings/crypto/constants.ts` and `src/bindings/mina-transaction/gen`. When building the bindings, these constants are auto-generated by Dune. If you wish to add a new constant, you can edit the `src/bindings/ocaml/snarky_js_constants` file, and then run `npm run build:bindings` to regenerate the TypeScript files. + +These types are used by o1js to ensure that the constants used in the protocol are consistent with the OCaml source files. + ## Development ### Branch Compatibility From ccc927bf46db2cdc7f796ae3ea968876aee39ce4 Mon Sep 17 00:00:00 2001 From: Martin Minkov Date: Wed, 13 Dec 2023 09:33:00 -0800 Subject: [PATCH 14/23] fix(README-dev.md): specify info for installing deps Co-authored-by: Gregor Mitscha-Baude --- README-dev.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README-dev.md b/README-dev.md index 69ec6c7d61..777b318912 100644 --- a/README-dev.md +++ b/README-dev.md @@ -19,8 +19,8 @@ Before starting, ensure you have the following tools installed: - [Git](https://git-scm.com/) - [Node.js and npm](https://nodejs.org/) -- [Dune](https://github.com/ocaml/dune) -- [Cargo](https://www.rust-lang.org/learn/get-started) +- [Dune](https://github.com/ocaml/dune) (only needed when compiling o1js from source) +- [Cargo](https://www.rust-lang.org/learn/get-started) (only needed when compiling o1js from source) After cloning the repository, you need to fetch the submodules: From f3c5a81cf51a16c2d5bc7201cc4ee5d90daae687 Mon Sep 17 00:00:00 2001 From: Martin Minkov Date: Wed, 13 Dec 2023 09:33:18 -0800 Subject: [PATCH 15/23] feat(README-dev.md): spelling mistake Co-authored-by: Gregor Mitscha-Baude --- README-dev.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README-dev.md b/README-dev.md index 777b318912..1eeb402e4a 100644 --- a/README-dev.md +++ b/README-dev.md @@ -43,7 +43,7 @@ This will compile the TypeScript source files, making it ready for use. The comp If you need 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. -o1js depends on OCaml code that is transplied to JavaScript using [Js_of_ocaml](https://github.com/ocsigen/js_of_ocaml), and Rust code that is transpiled to WebAssembly using [wasm-pack](https://github.com/rustwasm/wasm-pack). These artifacts allow o1js to call into [Pickles](https://github.com/o1-labs/snarkyhttps://github.com/MinaProtocol/mina/blob/develop/src/lib/pickles/README.md), [snarky](https://github.com/o1-labs/snarky), and [Kimchi](https://github.com/o1-labs/proof-systems) to write zk-SNARKs and zkApps. +o1js depends on OCaml code that is transpiled to JavaScript using [Js_of_ocaml](https://github.com/ocsigen/js_of_ocaml), and Rust code that is transpiled to WebAssembly using [wasm-pack](https://github.com/rustwasm/wasm-pack). These artifacts allow o1js to call into [Pickles](https://github.com/o1-labs/snarkyhttps://github.com/MinaProtocol/mina/blob/develop/src/lib/pickles/README.md), [snarky](https://github.com/o1-labs/snarky), and [Kimchi](https://github.com/o1-labs/proof-systems) to write zk-SNARKs and zkApps. The compiled artifacts are stored under `src/bindings/compiled`, and are version-controlled to simplify the build process for end-users. From 74e2d599bb0b5c81709d3192d9b5e96f9044e6c7 Mon Sep 17 00:00:00 2001 From: Martin Minkov Date: Wed, 13 Dec 2023 09:33:30 -0800 Subject: [PATCH 16/23] Update README-dev.md Co-authored-by: Gregor Mitscha-Baude --- README-dev.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README-dev.md b/README-dev.md index 1eeb402e4a..85b2979f37 100644 --- a/README-dev.md +++ b/README-dev.md @@ -73,10 +73,10 @@ To compile the wasm code, a combination of Cargo and Dune is used. Both build fi For the wasm build, the output files are: -- `plonk_wasm_bg.wasm.d.ts`: TypeScript definition files describing the types of .wasm or .js files. -- `plonk_wasm.d.ts`: TypeScript definition file for plonk_wasm.js. - `plonk_wasm_bg.wasm`: The compiled WebAssembly binary. +- `plonk_wasm_bg.wasm.d.ts`: TypeScript definition files describing the types of .wasm or .js files. - `plonk_wasm.js`: JavaScript file that wraps the WASM code for use in Node.js. +- `plonk_wasm.d.ts`: TypeScript definition file for plonk_wasm.js. ### Generated Constant Types From f410f1d6e8546bc8812e5ebc1300ebc59addb7e8 Mon Sep 17 00:00:00 2001 From: Martin Minkov Date: Wed, 13 Dec 2023 09:53:05 -0800 Subject: [PATCH 17/23] refactor(package.json): streamline script commands for better readability and maintainability feat(package.json): add new build commands for bindings, update-bindings, and wasm chore(src/bindings): update subproject commit hash for latest changes --- package.json | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index f6f3bd8c4a..ebb2d0a3e8 100644 --- a/package.json +++ b/package.json @@ -45,10 +45,15 @@ "scripts": { "type-check": "tsc --noEmit", "dev": "npx tsc -p tsconfig.node.json && node src/build/copy-to-dist.js", +<<<<<<< HEAD "make:no-types": "npm run clean && make -C ../../.. snarkyjs_no_types", "bindings": "cd ../../.. && ./scripts/update-snarkyjs-bindings.sh && cd src/lib/snarkyjs", +======= +>>>>>>> cb6190dfa... refactor(package.json): streamline script commands for better readability and maintainability "build": "node src/build/copy-artifacts.js && rimraf ./dist/node && npm run dev && node src/build/buildNode.js", - "build:bindings": "./src/bindings/scripts/update-snarkyjs-bindings.sh", + "build:bindings": "./src/bindings/scripts/build-snarkyjs-node.sh", + "build:update-bindings": "./src/bindings/scripts/update-snarkyjs-bindings.sh", + "build:wasm": "./src/bindings/scripts/update-wasm-and-types.sh", "build:test": "npx tsc -p tsconfig.test.json && cp src/snarky.d.ts dist/node/snarky.d.ts", "build:node": "npm run build", "build:web": "rimraf ./dist/web && node src/build/buildWeb.js", From 9b6561accc5468991f0251107661f49f17f04568 Mon Sep 17 00:00:00 2001 From: Martin Minkov Date: Wed, 13 Dec 2023 11:00:53 -0800 Subject: [PATCH 18/23] feat(mina): add new submodule 'mina' to enhance project functionality --- .gitmodules | 3 +++ src/mina | 1 + 2 files changed, 4 insertions(+) create mode 160000 src/mina diff --git a/.gitmodules b/.gitmodules index b343059624..76a36100bc 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "src/snarkyjs-bindings"] path = src/bindings url = https://github.com/o1-labs/snarkyjs-bindings.git +[submodule "src/mina"] + path = src/mina + url = https://github.com/MinaProtocol/mina.git diff --git a/src/mina b/src/mina new file mode 160000 index 0000000000..4b2ffbc0eb --- /dev/null +++ b/src/mina @@ -0,0 +1 @@ +Subproject commit 4b2ffbc0eb8d9566b38f0deac93747b03586b0c4 From acb2f8dc8c3ec11172087ba9c3f512fb8a833cc5 Mon Sep 17 00:00:00 2001 From: Martin Minkov Date: Wed, 13 Dec 2023 11:01:25 -0800 Subject: [PATCH 19/23] refactor(package.json): remove merge conflict markers and redundant script commands for better readability and maintainability --- package.json | 5 ----- 1 file changed, 5 deletions(-) diff --git a/package.json b/package.json index ebb2d0a3e8..71787f8b3a 100644 --- a/package.json +++ b/package.json @@ -45,11 +45,6 @@ "scripts": { "type-check": "tsc --noEmit", "dev": "npx tsc -p tsconfig.node.json && node src/build/copy-to-dist.js", -<<<<<<< HEAD - "make:no-types": "npm run clean && make -C ../../.. snarkyjs_no_types", - "bindings": "cd ../../.. && ./scripts/update-snarkyjs-bindings.sh && cd src/lib/snarkyjs", -======= ->>>>>>> cb6190dfa... refactor(package.json): streamline script commands for better readability and maintainability "build": "node src/build/copy-artifacts.js && rimraf ./dist/node && npm run dev && node src/build/buildNode.js", "build:bindings": "./src/bindings/scripts/build-snarkyjs-node.sh", "build:update-bindings": "./src/bindings/scripts/update-snarkyjs-bindings.sh", From 097fb2eb6dc44c112f07e39922e599862e386d7e Mon Sep 17 00:00:00 2001 From: Martin Minkov Date: Wed, 13 Dec 2023 12:26:06 -0800 Subject: [PATCH 20/23] chore(bindings, mina): update submodules to latest commits for up-to-date functionalities and bug fixes --- src/bindings | 2 +- src/mina | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bindings b/src/bindings index 285d40ffe3..f5fa4cabe5 160000 --- a/src/bindings +++ b/src/bindings @@ -1 +1 @@ -Subproject commit 285d40ffe37f8e4f73199080ba113d515b83861e +Subproject commit f5fa4cabe536014af4c3ad00700f1b267d4956e3 diff --git a/src/mina b/src/mina index 4b2ffbc0eb..4c9d45ce46 160000 --- a/src/mina +++ b/src/mina @@ -1 +1 @@ -Subproject commit 4b2ffbc0eb8d9566b38f0deac93747b03586b0c4 +Subproject commit 4c9d45ce46afd65ff18dc5f3ff8648cd87c9c697 From 78452c4f317b2f53cc7c6d29d61b0e27f0ed0159 Mon Sep 17 00:00:00 2001 From: Martin Minkov Date: Thu, 14 Dec 2023 10:24:27 -0800 Subject: [PATCH 21/23] Update package.json Co-authored-by: Gregor Mitscha-Baude --- package.json | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/package.json b/package.json index 33d4096bc4..c4e1c73dbf 100644 --- a/package.json +++ b/package.json @@ -42,14 +42,11 @@ "node": ">=16.4.0" }, "scripts": { - "type-check": "tsc --noEmit", - "dev": "npx tsc -p tsconfig.node.json && node src/build/copy-to-dist.js", + "dev": "npx tsc -p tsconfig.test.json && node src/build/copy-to-dist.js", "build": "node src/build/copy-artifacts.js && rimraf ./dist/node && npm run dev && node src/build/buildNode.js", "build:bindings": "./src/bindings/scripts/build-snarkyjs-node.sh", "build:update-bindings": "./src/bindings/scripts/update-snarkyjs-bindings.sh", "build:wasm": "./src/bindings/scripts/update-wasm-and-types.sh", - "build:test": "npx tsc -p tsconfig.test.json && cp src/snarky.d.ts dist/node/snarky.d.ts", - "build:node": "npm run build", "build:web": "rimraf ./dist/web && node src/build/buildWeb.js", "build:examples": "rimraf ./dist/examples && npx tsc -p tsconfig.examples.json || exit 0", "build:docs": "npx typedoc", From 0977aceb7e2255354aba71390b588b1c2a2a8d96 Mon Sep 17 00:00:00 2001 From: Martin Minkov Date: Thu, 14 Dec 2023 10:26:21 -0800 Subject: [PATCH 22/23] style(run-jest-tests.sh): add newline at end of file to comply with POSIX standards --- 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 279218575d..54b84b73c5 100755 --- a/run-jest-tests.sh +++ b/run-jest-tests.sh @@ -4,4 +4,4 @@ shopt -s globstar # to expand '**' into nested directories for f in ./src/**/*.test.ts; do NODE_OPTIONS=--experimental-vm-modules npx jest $f; -done \ No newline at end of file +done From 244924aab9cff2dde270df1c7636cf549b0adf04 Mon Sep 17 00:00:00 2001 From: Martin Minkov Date: Thu, 14 Dec 2023 10:45:41 -0800 Subject: [PATCH 23/23] Revert "Update package.json" This reverts commit 78452c4f317b2f53cc7c6d29d61b0e27f0ed0159. --- package.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index c4e1c73dbf..33d4096bc4 100644 --- a/package.json +++ b/package.json @@ -42,11 +42,14 @@ "node": ">=16.4.0" }, "scripts": { - "dev": "npx tsc -p tsconfig.test.json && node src/build/copy-to-dist.js", + "type-check": "tsc --noEmit", + "dev": "npx tsc -p tsconfig.node.json && node src/build/copy-to-dist.js", "build": "node src/build/copy-artifacts.js && rimraf ./dist/node && npm run dev && node src/build/buildNode.js", "build:bindings": "./src/bindings/scripts/build-snarkyjs-node.sh", "build:update-bindings": "./src/bindings/scripts/update-snarkyjs-bindings.sh", "build:wasm": "./src/bindings/scripts/update-wasm-and-types.sh", + "build:test": "npx tsc -p tsconfig.test.json && cp src/snarky.d.ts dist/node/snarky.d.ts", + "build:node": "npm run build", "build:web": "rimraf ./dist/web && node src/build/buildWeb.js", "build:examples": "rimraf ./dist/examples && npx tsc -p tsconfig.examples.json || exit 0", "build:docs": "npx typedoc",