Skip to content

Commit

Permalink
Merge branch 'main' into new-api
Browse files Browse the repository at this point in the history
  • Loading branch information
Trivo25 committed Feb 12, 2025
2 parents 177ab9d + d59955a commit 259dcb8
Show file tree
Hide file tree
Showing 41 changed files with 1,106 additions and 1,335 deletions.
6 changes: 5 additions & 1 deletion .envrc
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
use nix
#!/usr/bin/env bash

export GIT_LFS_SKIP_SMUDGE=1
./pin.sh
use flake o1js#default
8 changes: 0 additions & 8 deletions .eslintignore

This file was deleted.

18 changes: 0 additions & 18 deletions .eslintrc.json

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/build-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ jobs:
strategy: upgrade
env:
INPUT_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Configure Git
run: |
git config --local user.email "[email protected]"
Expand Down
49 changes: 49 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Lint and Format Check
on:
pull_request:
push:
branches:
- main
workflow_dispatch: {}

jobs:
lint-and-format:
if: github.event.pull_request.labels.*.name != 'skip-lint'
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm

- name: Install Dependencies
run: npm ci

- name: Get Changed Files (Compare with Main)
id: get_changed_files
run: |
git fetch origin main --depth=1
CHANGED_FILES=$(git diff --name-only origin/main | grep -E '\.(ts|js)$' || true)
if [ -n "$CHANGED_FILES" ]; then
echo "Files changed:"
echo "$CHANGED_FILES"
echo "$CHANGED_FILES" > changed_files.txt
echo "files_changed=true" >> $GITHUB_OUTPUT
else
echo "No relevant files changed."
echo "files_changed=false" >> $GITHUB_OUTPUT
fi
- name: Run Prettier Check
if: steps.get_changed_files.outputs.files_changed == 'true'
run: xargs npm run format:check < changed_files.txt

- name: Run Oxlint
if: steps.get_changed_files.outputs.files_changed == 'true'
run: xargs npm run lint:strict < changed_files.txt
13 changes: 13 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh

# Check if the developer has enabled pre-commit hooks
if ! git config --get husky.optin > /dev/null; then
echo "⚠️ Husky pre-commit hook skipped. Enable it with: git config husky.optin true"
exit 0
fi

echo "⚠️ Husky pre-commit hook enabled. Disable it with: git config --unset husky.optin"

# Filter for diffed (excluding deleted) js and ts files, and format them according to oxlint and prettier rules
git diff --cached --name-only --diff-filter=d | grep -E '\.(ts|js)$' | xargs npm run lint:fix
git diff --cached --name-only --diff-filter=d | grep -E '\.(ts|js)$' | xargs npm run format
23 changes: 23 additions & 0 deletions .oxlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"extends": "oxlint/recommended",
"rules": {
"erasing-op": "off",
"no-new-array": "off",
"no-this-alias": "off",
"no-unsafe-finally": "off",
"no-unused-labels": "off",
"no-useless-escape": "off",
"no-wrapper-object-types": "off"
},
"ignorePatterns": [
"_build/",
".github/",
"benchmark/",
"dist/",
"node_modules/",
"o1js-reference/",
"src/bindings/",
"src/mina/",
"**/*.d.ts"
]
}
13 changes: 9 additions & 4 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
src/bindings/compiled/web_bindings/**/plonk_wasm*
src/bindings/compiled/web_bindings/**/*.bc.js
src/bindings/compiled/node_bindings/*
dist/**/*
_build/
.github/
benchmark/
dist/
node_modules/
o1js-reference/
src/bindings/
src/mina/
**/*.d.ts
1 change: 1 addition & 0 deletions .prettierrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ module.exports = {
tabWidth: 2,
semi: true,
singleQuote: true,
printWidth: 100,
};
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,25 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
## [Unreleased](https://github.com/o1-labs/o1js/compare/b857516...HEAD)

### Added

- `setFee` and `setFeePerSnarkCost` for `Transaction` and `PendingTransaction` https://github.com/o1-labs/o1js/pull/1968
- Doc comments for various ZkProgram methods https://github.com/o1-labs/o1js/pull/1974
- `MerkleList.popOption()` for popping the last element and also learning if there was one https://github.com/o1-labs/o1js/pull/1997
- Added custom header support for `Fetch` methods such as `fetchEvents`, `fetchActions` etc. and to `Mina` instance. Also added two new methods `setMinaDefaultHeaders` and `setArchiveDefaultHeaders` https://github.com/o1-labs/o1js/pull/2004
- Added style rules for contributors https://github.com/o1-labs/o1js/pull/2012

### Changed

- Sort order for actions now includes the transaction sequence number and the exact account id sequence https://github.com/o1-labs/o1js/pull/1917
- Updated typedoc version for generating docs https://github.com/o1-labs/o1js/pull/1973
- Enable to pass normal JS values (e.g., `bigint` instead of `Field`) to ZkProgram provers https://github.com/o1-labs/o1js/pull/1934
- Also improves the supported JS values for a few important types like `Signature` and `UIntX`
- ECDSA `verifySignedHash()` accepts hash `Bytes` directly for easy use with alternative hash functions https://github.com/o1-labs/o1js/pull/2005

### Fixed

- Fix behavior of `initializeBindings()` when called concurrently, to improve error messages in common failure scenarios https://github.com/o1-labs/o1js/pull/1996
- Fix `ZkProgram` public input/output types https://github.com/o1-labs/o1js/pull/1998

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

Expand Down Expand Up @@ -375,7 +388,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- `Reducer.reduce()` requires the maximum number of actions per method as an explicit (optional) argument https://github.com/o1-labs/o1js/pull/1450
- The default value is 1 and should work for most existing contracts
- `new UInt64()` and `UInt64.from()` no longer unsafely accept a field element as input. https://github.com/o1-labs/o1js/pull/1438 [@julio4](https://github.com/julio4)
As a replacement, `UInt64.Unsafe.fromField()` was introduced
As a replacement, `UInt64.Unsafe.fromField()` was introduced
- This prevents you from accidentally creating a `UInt64` without proving that it fits in 64 bits
- Equivalent changes were made to `UInt32`
- Fixed vulnerability in `Field.to/fromBits()` outlined in [#1023](https://github.com/o1-labs/o1js/issues/1023) by imposing a limit of 254 bits https://github.com/o1-labs/o1js/pull/1461
Expand Down
21 changes: 19 additions & 2 deletions README-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,23 @@ Where:

- `develop`: This branch is maintained across all three repositories. It is used for ongoing (next hard-fork) development, testing new features and integration work.

### Style Guide

This repo uses minimal [oxlint](https://oxc.rs/docs/guide/usage/linter.html) and [prettier](https://prettier.io/docs/) configs to stay tidy. Here are some tips to comply with the style:

1. Check for style violations by running the npm commands `npm run lint path/to/file` and `npm run format:check path/to/file`
- To attempt to fix all style violations in all changed filed, you can run:
- `git diff --cached --name-only --diff-filter=d | grep -E '\.(ts|js)$' | xargs npm run format`
- and `git diff --cached --name-only --diff-filter=d | grep -E '\.(ts|js)$' | xargs npm run lint:fix`
2. Integrate prettier into your dev environment
- For instance the [VS Code](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) plugin allows for format on save
3. Enable pre-commit hooks
- There is an opt-in pre-commit hook avaibale that will attempt to fix styling for all diffed files. Enable it by running `git config husky.optin true`

> [!NOTE]
> You can opt-out of linting in a PR by tagging it with skip-lint, in case the linting script is legitimately blocking an important PR

### Running Tests

To ensure your changes don't break existing functionality, run the test suite:
Expand Down Expand Up @@ -246,7 +263,7 @@ After the Node.js process is running, open the Chrome browser and navigate to `c
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:
```sh
npm run link
```
```
Then in your zkApp codebase, run:
```sh
npm link o1js
Expand All @@ -256,4 +273,4 @@ npm link o1js
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:
```ocaml
let () = print_endline "This is a log" in
```
```
10 changes: 5 additions & 5 deletions README-nix.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ nix develop mina
### Storage handling
Using Nix can take up a lot of disk space if not optimized. Every time you run `nix develop {SOMETHING}`, Nix will create new generations taking gigabytes of data instead of replacing the old ones. This can soon become a problem in your hard disk if you don't handle it carefully. Here are a few indications that can help with this.
Using Nix can take up a lot of disk space if not optimized. Every time you run `nix develop {SOMETHING}`, Nix will create new generations taking gigabytes of data instead of replacing the old ones. This can soon become a problem in your hard disk if you don't handle it carefully. Here are a few indications that can help with this.
Nix has a garbage collector that **is not used by default** after every run. Instead, artifacts get accumulated in your disk unless configured otherwise. But if the full gargabe collector is executed (`nix-store --gc`), it will get the dependencies removed completely, and you can expect that the next time executing the Nix build will take hours to complete.
Expand All @@ -122,16 +122,16 @@ On top of that, adding `auto-optimise-store = true` to `/etc/nix/nix.conf` and r
### Runtime optimization
Other configurations are worth adding into your `/etc/nix/nix.conf`:
Other configurations are worth adding into your `/etc/nix/nix.conf`:
```bash
keep-otuputs = true
keep-otuputs = true
max-jobs = 20
extra-substituters = https://storage.googleapis.com/mina-nix-cache
extra-trusted-public-keys = nix-cache.minaprotocol.org:fdcuDzmnM0Kbf7yU4yywBuUEJWClySc1WIF6t6Mm8h4= nix-cache.minaprotocol.org:D3B1W+V7ND1Fmfii8EhbAbF1JXoe2Ct4N34OKChwk2c= mina-nix-cache-1:djtioLfv2oxuK2lqPUgmZbf8bY8sK/BnYZCU2iU5Q10=
```
The first of those flags tells the garbage collector to keep build time dependencies of current gc-roots, which should help reduce the amount of data that gets removed and rebuilt.
The first of those flags tells the garbage collector to keep build time dependencies of current gc-roots, which should help reduce the amount of data that gets removed and rebuilt.
The second flag increases the default number of jobs being 1, so that rebuilding from scratch will take shorter time.
Expand Down Expand Up @@ -189,7 +189,7 @@ Alternatively, try this change in the `src/mina/flake.nix` file:
```
- devShellPackages = with pkgs; [ rosetta-cli wasm-pack nodejs binaryen ];
+ devShellPackages = with pkgs; [ rosetta-cli wasm-pack nodejs binaryen cargo libiconvI];
+ devShellPackages = with pkgs; [ rosetta-cli wasm-pack nodejs binaryen cargo libiconv];
```
### wasm32-unknown-unknown
Expand Down
2 changes: 1 addition & 1 deletion npmDepsHash
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sha256-hFxCHth04vW95DJCTLHKV2N0v9NNQG57DpucsAq3yvs=
sha256-qu21Wkmk3fNZOOb66vAX3WEsm1aipQNzNoKQBPuIiZ4=
Loading

0 comments on commit 259dcb8

Please sign in to comment.