Skip to content

Commit ec97e0c

Browse files
committed
Merge branch 'main' into rpanic/fix/zkprogram-typing
2 parents 4e50fc1 + dea2a1f commit ec97e0c

26 files changed

+680
-332
lines changed

.github/workflows/build-bindings.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,36 @@ concurrency:
1212
cancel-in-progress: true
1313

1414
jobs:
15+
check-npm-deps:
16+
name: check-npm-deps
17+
runs-on: [sdk-self-hosted-linux-amd64-build-system]
18+
steps:
19+
- name: Set up Nix
20+
run: echo "PATH=$PATH:/nix/var/nix/profiles/default/bin" >> $GITHUB_ENV
21+
- name: Disable smudging
22+
run: echo "GIT_LFS_SKIP_SMUDGE=1" >> $GITHUB_ENV
23+
- uses: actions/checkout@v4
24+
with:
25+
submodules: recursive
26+
- name: Try to build
27+
run: |
28+
set -Eeu
29+
./pin.sh
30+
nix build o1js#npm-deps
31+
update-npm-deps:
32+
needs: check-npm-deps
33+
if: ${{ failure() }}
34+
runs-on: [sdk-self-hosted-linux-amd64-build-system]
35+
steps:
36+
- name: Set up Nix
37+
run: echo "PATH=$PATH:/nix/var/nix/profiles/default/bin" >> $GITHUB_ENV
38+
- name: update-hash
39+
run: nix run o1js#update-npm-deps
40+
- uses: parkerbxyz/suggest-changes@v1
41+
with:
42+
comment: 'please update the npm-deps-hash'
43+
event: 'REQUEST_CHANGES'
44+
1545
nix-build:
1646
name: build-bindings-ubuntu
1747
runs-on: [sdk-self-hosted-linux-amd64-build-system]

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,17 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
1919

2020
### Added
2121
- `setFee` and `setFeePerSnarkCost` for `Transaction` and `PendingTransaction` https://github.com/o1-labs/o1js/pull/1968
22+
- Doc comments for various ZkProgram methods https://github.com/o1-labs/o1js/pull/1974
23+
- `MerkleList.popOption()` for popping the last element and also learning if there was one https://github.com/o1-labs/o1js/pull/1997
2224

2325
### Changed
2426
- Sort order for actions now includes the transaction sequence number and the exact account id sequence https://github.com/o1-labs/o1js/pull/1917
27+
- Updated typedoc version for generating docs https://github.com/o1-labs/o1js/pull/1973
28+
29+
### Fixed
30+
31+
- Fix behavior of `initializeBindings()` when called concurrently, to improve error messages in common failure scenarios https://github.com/o1-labs/o1js/pull/1996
32+
- Fix `ZkProgram` public input/output types https://github.com/o1-labs/o1js/pull/1998
2533

2634
## [2.2.0](https://github.com/o1-labs/o1js/compare/e1bac02...b857516) - 2024-12-10
2735

@@ -42,12 +50,14 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
4250
### Changed
4351

4452
- Changed an internal type to improve IntelliSense on ZkProgram methods https://github.com/o1-labs/o1js/pull/1933
53+
- Updated o1js nix devshell to build rust on all executions of `npm run build:update-bindings`
4554

4655
### Fixed
4756

4857
- Compiling stuck in the browser for recursive zkprograms https://github.com/o1-labs/o1js/pull/1906
4958
- Error message in `rangeCheck16` gadget https://github.com/o1-labs/o1js/pull/1920
5059
- Deprecate `testnet` `networkId` in favor of `devnet` https://github.com/o1-labs/o1js/pull/1938
60+
- Fix event data type inconsistency between LocalBlockchain and Mina https://github.com/o1-labs/o1js/pull/1975
5161

5262
## [2.1.0](https://github.com/o1-labs/o1js/compare/b04520d...e1bac02) - 2024-11-13
5363

README-dev.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,3 +241,19 @@ To facilitate this process, use the provided script named `run-debug`. To use th
241241
This script initializes a Node.js process with the `--inspect-brk` flag that starts the Node.js inspector and breaks before the user script starts (i.e., it pauses execution until a debugger is attached). The `--enable-source-maps` flag ensures that source maps are used to allow easy debugging of o1js code directly.
242242

243243
After the Node.js process is running, open the Chrome browser and navigate to `chrome://inspect` to attach the Chrome Debugger to the Node.js process. You can set breakpoints, inspect variables, and profile the performance of your zkApp or o1js. For more information on using the Chrome Debugger, see the [DevTools documentation](https://developer.chrome.com/docs/devtools/).
244+
245+
### Debugging within the SDK
246+
To debug a call into the SDK, you can link your local copy of the SDK with `npm link`. After that, you'll be able to add log statements, set breakpoints, and make code changes. Within the SDK, run:
247+
```sh
248+
npm run link
249+
```
250+
Then in your zkApp codebase, run:
251+
```sh
252+
npm link o1js
253+
```
254+
255+
#### Logging from OCaml
256+
If you need to debug a call into the OCaml code, the process is a little more complicated. The OCaml is compiled into JavaScript with js_of_ocaml during `npm run build:update-bindings`, so you'll need to add your logs into the OCaml code and rebuild the bindings to see them. Logging from OCaml in a way that will reflect as JS `console.log`s in the compiled code can be done like this:
257+
```ocaml
258+
let () = print_endline "This is a log" in
259+
```

README-nix.md

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,7 @@ cd o1js
8181
8282
From a new shell, go to `{REPO_PATH}/o1js` and from there execute `./pin.sh` to
8383
update the submodules and add the flakes entries. Then, you can open a Nix shell
84-
with all the dependencies required executing `nix develop o1js#default`, or
85-
alternatively `nix develop o1js#mina-shell` (which works better from MacOS).
84+
with all the dependencies required executing `nix develop o1js#default`.
8685
8786
```console
8887
./pin.sh
@@ -92,21 +91,7 @@ nix develop o1js#default
9291
The first time you run this command, you can expect it to take hours (or even a full day) to complete. Then, you will observe that the current devshell becomes a Nix shell with the right
9392
configuration for `o1js` and `mina`.
9493
95-
In order to make sure that the bindings will be regenerated in the case that you
96-
are modifying them, make sure to comment out the conditionals in
97-
`src/mina/src/lib/crypto/kimchi_bindings/js/node_js/build.sh` and `src/mina/src/lib/crypto/kimchi_bindings/js/web/build.sh` locally. That's because otherwise the
98-
PLONK_WASM_WEB check prevents `proof-systems` from compiling with each build.
99-
100-
```sh
101-
if true; then # [[ -z "${PLONK_WASM_WEB-}" ]]; then
102-
export RUSTFLAGS="-C target-feature=+atomics,+bulk-memory,+mutable-globals -C link-arg=--no-check-features -C link-arg=--max-memory=4294967296"
103-
rustup run nightly-2023-09-01 wasm-pack build --target web --out-dir ../js/web ../../wasm -- -Z build-std=panic_abort,std
104-
else
105-
cp "$PLONK_WASM_WEB"/* -R .
106-
fi
107-
```
108-
109-
Then, you can build o1js and update the bindings.
94+
From within the shell, you can build o1js and update the bindings.
11095
11196
```console
11297
npm run build
@@ -152,7 +137,7 @@ The second flag increases the default number of jobs being 1, so that rebuilding
152137
153138
The last two lines tell Nix to use the Mina Foundation's cache whenever possible, which should as well speed things up when building code that has been build in Mina's CI before.
154139
155-
## Common errors
140+
## Common Issues
156141
157142
Errors while using Nix have been reported. This section collects a set of common
158143
errors and proposes fixes for them.
@@ -305,4 +290,16 @@ Then, the error message would still contain old directories.
305290
306291
#### Fix
307292
308-
Create a new environment for Nix and start from scratch. In particular, run the garbage collector which will remove old dependencies.
293+
Rerun `pin.sh` and `src/mina/nix/pin.sh`.
294+
295+
### Changes to nix flakes aren't taking effect
296+
On MacOS, nix may ignore changes to files when nix commands are run and reuse the flake cached in its registry. Running commands like `nix develop o1js` and `nix run o1js#update-bindings` will reuse the cached version of the flake. As a result:
297+
- The devshell could be missing newly added dependencies.
298+
- Builds executed directly with `nix run` could be generated from old source files.
299+
#### Fix
300+
There are two ways to ensure Nix recognizes flake changes:
301+
- Rerun `pin.sh` to force an update to the registry, then run your command.
302+
- Reference the flake by its directory path rather than its registry name. This forces Nix to use the current contents of the directory:
303+
```bash
304+
nix develop .'?submodules=1#default'
305+
```

0 commit comments

Comments
 (0)