Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into feature/lookup-runtim…
Browse files Browse the repository at this point in the history
…e-tables
  • Loading branch information
shimkiv committed Nov 27, 2024
2 parents b1d63cd + 7476d6c commit 3f1f01b
Show file tree
Hide file tree
Showing 14 changed files with 167 additions and 26 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
pull_request:
workflow_dispatch: {}

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
benchmarks:
timeout-minutes: 30
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/build-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ on:
pull_request:
workflow_dispatch: {}

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
Prepare:
runs-on: ubuntu-latest
Expand Down
36 changes: 36 additions & 0 deletions .github/workflows/build-bindings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Purpose: We want to build the o1js bindings in CI so that people in the
# community can change them without being scared of breaking things, or
# needing to do the complicated (without nix) build setup.

name: Build o1js bindings

on:
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
nix-build:
name: build-bindings-ubuntu
runs-on: [sdk-self-hosted-linux-amd64-build-system]
steps:
- name: Set up Nix
run: echo "PATH=$PATH:/nix/var/nix/profiles/default/bin" >> $GITHUB_ENV
- name: Disable smudging
run: echo "GIT_LFS_SKIP_SMUDGE=1" >> $GITHUB_ENV
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Build the o1js bindings
run: |
set -Eeu
./pin.sh
nix develop o1js --command bash -c "npm run build:update-bindings"
- name: Cleanup the Nix store
run: |
nix-env --delete-generations old
nix-collect-garbage -d --quiet
nix-store --gc --print-dead
nix-store --optimise
4 changes: 4 additions & 0 deletions .github/workflows/doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ on:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
Build-Doc:
runs-on: ubuntu-latest
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/live-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ on:
- v1
workflow_dispatch: {}

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
master:
timeout-minutes: 45
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

## [Unreleased](https://github.com/o1-labs/o1js/compare/e1bac02...HEAD)

### Fixed

- Compiling stuck in the browser for recursive zkprograms https://github.com/o1-labs/o1js/pull/1906

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

### Added
Expand Down
28 changes: 14 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/bindings
39 changes: 28 additions & 11 deletions src/build/e2e-tests-build-helper.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
import replace from 'replace-in-file';

const options = {
files: './dist/web/examples/zkapps/**/*.js',
from: /from 'o1js'/g,
to: "from '../../../index.js'",
};

try {
const results = await replace(options);
console.log('Replacement results:', results);
} catch (error) {
console.error('Error occurred:', error);
const replaceOptions = [
{
files: './dist/web/examples/zkapps/**/*.js',
from: /from 'o1js'/g,
to: "from '../../../index.js'",
},
{
files: './dist/web/examples/zkprogram/*.js',
from: /from 'o1js'/g,
to: "from '../../index.js'",
},
];

async function performReplacement(options) {
try {
const results = await replace(options);
console.log(`Replacement results for ${options.files}:`, results);
} catch (error) {
console.error(`Error occurred while replacing in ${options.files}:`, error);
}
}

async function main() {
for (const options of replaceOptions) {
await performReplacement(options);
}
}

main();
23 changes: 23 additions & 0 deletions src/examples/zkprogram/recursive-program.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { SelfProof, Field, ZkProgram } from 'o1js';

export const RecursiveProgram = ZkProgram({
name: 'recursive-program',
publicInput: Field,

methods: {
baseCase: {
privateInputs: [],
async method(input: Field) {
input.assertEquals(Field(0));
},
},

inductiveCase: {
privateInputs: [SelfProof],
async method(input: Field, earlierProof: SelfProof<Field, void>) {
earlierProof.verify();
earlierProof.publicInput.add(1).assertEquals(input);
},
},
},
});
4 changes: 4 additions & 0 deletions tests/artifacts/html/on-chain-state-mgmt-zkapp-ui.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ <h3>UI for the On-Chain State Management zkApp</h3>
</div>
<hr />
<div>
<h4>zkProgram Management</h4>
<div>
<button type="button" id="compileButton">Compile ZkProgram</button>
</div>
<h4>zkApp Management</h4>
<div>
<button type="button" id="deployButton">Deploy zkApp</button>
Expand Down
18 changes: 18 additions & 0 deletions tests/artifacts/javascript/on-chain-state-mgmt-zkapp-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ import {
adminPrivateKey,
HelloWorld,
} from './examples/zkapps/hello-world/hello-world.js';
import { RecursiveProgram } from './examples/zkprogram/recursive-program.js';
import { AccountUpdate, Field, Mina, verify } from './index.js';

const compileButton = document.querySelector('#compileButton');
const deployButton = document.querySelector('#deployButton');
const updateButton = document.querySelector('#updateButton');
const clearEventsButton = document.querySelector('#clearEventsButton');
Expand All @@ -25,6 +27,22 @@ const contractAddress = Mina.TestPublicKey.random();
const contract = new HelloWorld(contractAddress);
let verificationKey = null;

compileButton.addEventListener('click', async () => {
compileButton.disabled = true;

logEvents('Compiling ZkProgram', eventsContainer);

try {
await RecursiveProgram.compile();
logEvents('ZkProgram compiled successfully!', eventsContainer);
} catch (exception) {
logEvents(`Compilation failure: ${exception.message}`, eventsContainer);
console.log(exception);
}

compileButton.disabled = false;
});

deployButton.addEventListener('click', async () => {
deployButton.disabled = true;

Expand Down
10 changes: 10 additions & 0 deletions tests/on-chain-state-mgmt-zkapp-ui.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ test.describe('On-Chain State Management zkApp UI', () => {
await onChainStateMgmtZkAppPage.checkO1jsInitialization();
});

test('should compile zkProgram', async ({
onChainStateMgmtZkAppPage,
}) => {
await onChainStateMgmtZkAppPage.goto();
await onChainStateMgmtZkAppPage.checkO1jsInitialization();
await onChainStateMgmtZkAppPage.compileZkProgram();
await onChainStateMgmtZkAppPage.checkZkProgramCompilation();
});


test('should fail to update account state since zkApp was not yet deployed', async ({
onChainStateMgmtZkAppPage,
}) => {
Expand Down
13 changes: 13 additions & 0 deletions tests/pages/on-chain-state-mgmt-zkapp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { expect, type Locator, type Page } from '@playwright/test';

export class OnChainStateMgmtZkAppPage {
readonly page: Page;
readonly compileButton: Locator;
readonly deployButton: Locator;
readonly updateButton: Locator;
readonly clearEventsButton: Locator;
Expand All @@ -11,6 +12,7 @@ export class OnChainStateMgmtZkAppPage {

constructor(page: Page) {
this.page = page;
this.compileButton = page.locator('button[id="compileButton"]');
this.deployButton = page.locator('button[id="deployButton"]');
this.updateButton = page.locator('button[id="updateButton"]');
this.clearEventsButton = page.locator('button[id="clearEventsButton"]');
Expand All @@ -23,6 +25,10 @@ export class OnChainStateMgmtZkAppPage {
await this.page.goto('/on-chain-state-mgmt-zkapp-ui.html');
}

async compileZkProgram() {
await this.compileButton.click();
}

async compileAndDeployZkApp() {
await this.deployButton.click();
}
Expand All @@ -40,6 +46,13 @@ export class OnChainStateMgmtZkAppPage {
await expect(this.eventsContainer).toContainText('o1js initialized after');
}

async checkZkProgramCompilation() {
await expect(this.eventsContainer).toContainText('Compiling ZkProgram');
await expect(this.eventsContainer).toContainText(
'ZkProgram compiled successfully!'
);
}

async checkDeployedZkApp() {
await expect(this.eventsContainer).toContainText('Deploying');
await expect(this.eventsContainer).toContainText('Initial state: 2');
Expand Down

0 comments on commit 3f1f01b

Please sign in to comment.