GithubHelp home page GithubHelp logo

martinondejka / o1js-bindings Goto Github PK

View Code? Open in Web Editor NEW

This project forked from o1-labs/o1js-bindings

0.0 0.0 0.0 219 MB

Bindings for o1js to lower layers of the proof system and the Mina transaction logic

License: Other

Shell 0.04% JavaScript 97.05% Python 0.01% OCaml 0.45% Rust 0.78% TypeScript 1.66% HTML 0.01%

o1js-bindings's Introduction

o1js bindings

This repository collects code required by o1js to bind to lower layers of the proof system and the Mina transaction logic, which are written in Rust and OCaml.

The repo is included as a git submodule in the o1js repo under src/bindings and is typically used from there.

Directory structure

  • /compiled - compiled JS and Wasm artifacts produced by js_of_ocaml and wasm-bindgen from Rust and OCaml source code. We keep these artifacts in the source tree so that developing on o1js can be done with standard JS tooling and doesn't require setting up the full OCaml/Rust build pipeline.
  • /crypto - pure TS implementations of a subset of the crypto primitives we use, including finite field and elliptic curve arithmetic. This is used by mina-signer (a pure TS package) to hash and sign transactions.
  • /js - JS-side wrappers for the artifacts located in /compiled, which differs between the Node.js and web versions of o1js. Includes code for setting up workers to support using rayon in Rust.
  • /kimchi - bindings to the Kimchi proof system which is implemented in Rust. This contains a Wasm compatibility layer written in Rust as well as a js_of_ocaml-to-wasm-bindgen glue layer written in JS.
  • /lib - miscellaneous low-level TypeScript, which underpins o1js and provides generic ways to connect with a proof system and blockchain protocol.
  • /mina-transaction - TS types and modules that specialize the generic tooling in /lib to Mina's zkApp protocol; mostly auto-generated from OCaml.
  • /ocaml - OCaml library exposing Snarky, Pickles and parts of the Mina transaction logic to JS. Also, OCaml scripts that help auto-generate TypeScript for Mina- and crypto-related types and constants.
  • /scripts - scripts that build parts of o1js from their OCaml and Rust sources, including the contents of /compiled and other generated TS files.
  • MINA_COMMIT - commit hash pointing to the commit of the Mina repo that build artifacts in this repo where generated from.

Building the o1js bindings

To instrument the scripts and build the o1js bindings from source, you need to work from the Mina monorepo.

Inside the Mina repo, you'll find the o1js repo as a git submodule under src/lib/snarkyjs. Inside o1js, the o1js-bindings repo is located at src/bindings. To make sure you have all nested submodules checked out, run (from the Mina root):

git submodule update --init --recursive

Then, switch to the o1js root in src/lib/snarkyjs.

You use these two commands for different purposes:

npm run make

This command:

  • Regenerates TS files in the o1js-bindings source tree
  • Builds the JS/Wasm artifacts for Node.js (also contained in /compiled/node-bindings), but only moves them to their place in the o1js/dist/node folder, which is not part of the source tree.

ℹ️ Use npm run make if you are developing on or testing the OCaml/Rust layers of o1js, and want to rebuild.

npm run bindings

This command:

  • Does everything npm run make does, plus
  • Builds the web version of the o1js bindings, plus
  • Places the generated artifacts in the source tree under /compiled
  • Updates the MINA_COMMIT file

ℹ️ Use npm run bindings to update the source tree after you have finished a batch of work / a PR that touches the OCaml/Rust layers. o1js CI depends on these artifacts, so running this command is a required step before you can merge the changes.

o1js-bindings's People

Contributors

mitschabaude avatar trivo25 avatar dannywillems avatar martinminkov avatar mrmr1993 avatar barriebyron avatar rbonichon avatar wizicer avatar l-as avatar nholland94 avatar comdex avatar ghost-not-in-the-shell avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.