Skip to content

Commit

Permalink
Merge branch 'perf/loading-time-berkeley' into perf/loading-time-develop
Browse files Browse the repository at this point in the history
  • Loading branch information
mitschabaude committed Aug 22, 2023
2 parents df33066 + e4f330c commit 82808cd
Show file tree
Hide file tree
Showing 15 changed files with 346 additions and 160 deletions.
28 changes: 28 additions & 0 deletions .github/actions/live-tests-shared/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: "Shared steps for live testing jobs"
description: "Shared steps for live testing jobs"
runs:
using: "composite"
steps:
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: "18"
- name: Make helper script executable
run: chmod +x tests/scripts/wait-for-docker-services.sh
shell: bash
- name: Wait for Docker container services to be ready
run: ./tests/scripts/wait-for-docker-services.sh 8080
shell: bash
- name: Build SnarkyJS and Execute Tests
env:
TEST_TYPE: "Live integration tests"
USE_LOCAL_NETWORK: "true"
continue-on-error: false
run: |
git submodule update --init --recursive
npm ci
npm run build:node
touch profiling.md
sh run-ci-tests.sh
cat profiling.md >> $GITHUB_STEP_SUMMARY
shell: bash
18 changes: 9 additions & 9 deletions .github/workflows/build-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ jobs:
]
steps:
- name: Checkout Repository
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Build SnarkyJS and Execute Tests
Expand All @@ -49,9 +49,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install Node Dependencies
Expand All @@ -67,7 +67,7 @@ jobs:
- name: Execute E2E Tests
run: npm run test:e2e
- name: Upload E2E Test Artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
if: always()
with:
name: e2e-tests-report
Expand All @@ -80,9 +80,9 @@ jobs:
needs: [Build-And-Test-Server, Build-And-Test-Web]
steps:
- name: Checkout Repository
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Build SnarkyJS
Expand All @@ -104,9 +104,9 @@ jobs:
needs: [Build-And-Test-Server, Build-And-Test-Web]
steps:
- name: Checkout Repository
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Build mina-signer
Expand Down
86 changes: 86 additions & 0 deletions .github/workflows/live-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Test SnarkyJS against real network
on:
push:
branches:
- main
- berkeley
- develop
pull_request:
branches:
- main
- berkeley
- develop
workflow_dispatch: {}

jobs:
main-branch:
timeout-minutes: 25
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' || (github.event_name == 'pull_request' && github.base_ref == 'main')
services:
mina-local-network:
image: o1labs/mina-local-network:rampup-latest-lightnet
env:
NETWORK_TYPE: 'single-node'
PROOF_LEVEL: 'none'
ports:
- 3085:3085
- 8080:8080
- 8181:8181
# TODO: Disable logging for container as the workaround of long post-job-cleanup phase
# - Will be fixed by improving logging as part of the work on:
# - https://hub.docker.com/r/o1labs/mina-local-network
options: --log-driver=none
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Use shared steps for live testing jobs
uses: ./.github/actions/live-tests-shared

berkeley-branch:
timeout-minutes: 25
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/berkeley' || (github.event_name == 'pull_request' && github.base_ref == 'berkeley')
services:
mina-local-network:
image: o1labs/mina-local-network:berkeley-latest-lightnet
env:
NETWORK_TYPE: 'single-node'
PROOF_LEVEL: 'none'
ports:
- 3085:3085
- 8080:8080
- 8181:8181
# TODO: Disable logging for container as the workaround of long post-job-cleanup phase
# - Will be fixed by improving logging as part of the work on:
# - https://hub.docker.com/r/o1labs/mina-local-network
options: --log-driver=none
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Use shared steps for live testing jobs
uses: ./.github/actions/live-tests-shared

develop-branch:
timeout-minutes: 25
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/develop' || (github.event_name == 'pull_request' && github.base_ref == 'develop')
services:
mina-local-network:
image: o1labs/mina-local-network:develop-latest-lightnet
env:
NETWORK_TYPE: 'single-node'
PROOF_LEVEL: 'none'
ports:
- 3085:3085
- 8080:8080
- 8181:8181
# TODO: Disable logging for container as the workaround of long post-job-cleanup phase
# - Will be fixed by improving logging as part of the work on:
# - https://hub.docker.com/r/o1labs/mina-local-network
options: --log-driver=none
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Use shared steps for live testing jobs
uses: ./.github/actions/live-tests-shared
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,8 @@
"serve:web": "cp src/bindings/compiled/web_bindings/server.js src/bindings/compiled/web_bindings/index.html src/examples/simple_zkapp.js dist/web && node dist/web/server.js",
"prepublish:web": "NODE_ENV=production node src/build/buildWeb.js",
"prepublish:node": "npm run build && NODE_ENV=production node src/build/buildNode.js",
"prepublish:both": "npm run prepublish:web && npm run prepublish:node",
"prepublishOnly": "npm run prepublish:web && npm run prepublish:node",
"bootstrap": "npm run build && node src/build/extractJsooMethods.cjs && npm run build",
"dump-vks": "./run src/examples/vk_regression.ts --bundle --dump ./src/examples/regression_test.json",
"format": "prettier --write --ignore-unknown **/*",
"test": "./run-jest-tests.sh",
"clean": "rimraf ./dist && rimraf ./src/bindings/compiled/_node_bindings",
Expand Down
95 changes: 52 additions & 43 deletions run-ci-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,56 @@
set -e

case $TEST_TYPE in
"Simple integration tests" )
echo "Running basic integration tests";
./run src/examples/zkapps/hello_world/run.ts --bundle
./run src/examples/simple_zkapp.ts --bundle
./run src/examples/zkapps/reducer/reducer_composite.ts --bundle
./run src/examples/zkapps/composability.ts --bundle ;;

"Voting integration tests" )
echo "Running voting integration tests";
./run src/examples/zkapps/voting/run.ts --bundle ;;

"DEX integration tests" )
echo "Running DEX integration tests";
./run src/examples/zkapps/dex/run.ts --bundle
./run src/examples/zkapps/dex/upgradability.ts --bundle ;;

"DEX integration test with proofs" )
echo "Running DEX integration test with proofs";
./run src/examples/zkapps/dex/happy-path-with-proofs.ts --bundle ;;

"Berkeley Live" )
echo "Running Berkeley Live integration tests";
./run src/examples/zkapps/hello_world/run_berkeley.ts --bundle ;;

"Unit tests" )
echo "Running unit tests";
cd src/mina-signer
npm run build
cd ../..
npm run test:unit
npm run test
;;

"Verification Key Regression Check" )
echo "Running Regression checks"
./run ./src/examples/vk_regression.ts --bundle ;;

"CommonJS test" )
echo "Testing CommonJS version";
node src/examples/commonjs.cjs
;;

* ) echo "ERROR: Invalid enviroment variable, not clear what tests to run! $CI_NODE_INDEX"; exit 1 ;;
"Simple integration tests")
echo "Running basic integration tests"
./run src/examples/zkapps/hello_world/run.ts --bundle
./run src/examples/simple_zkapp.ts --bundle
./run src/examples/zkapps/reducer/reducer_composite.ts --bundle
./run src/examples/zkapps/composability.ts --bundle
;;

"Voting integration tests")
echo "Running voting integration tests"
./run src/examples/zkapps/voting/run.ts --bundle
;;

"DEX integration tests")
echo "Running DEX integration tests"
./run src/examples/zkapps/dex/run.ts --bundle
./run src/examples/zkapps/dex/upgradability.ts --bundle
;;

"DEX integration test with proofs")
echo "Running DEX integration test with proofs"
./run src/examples/zkapps/dex/happy-path-with-proofs.ts --bundle
;;

"Live integration tests")
echo "Running integration tests against real Mina network"
./run src/examples/zkapps/hello_world/run_live.ts --bundle
;;

"Unit tests")
echo "Running unit tests"
cd src/mina-signer
npm run build
cd ../..
npm run test:unit
npm run test
;;

"Verification Key Regression Check")
echo "Running Regression checks"
./run ./src/examples/vk_regression.ts --bundle
;;

"CommonJS test")
echo "Testing CommonJS version"
node src/examples/commonjs.cjs
;;

*)
echo "ERROR: Invalid enviroment variable, not clear what tests to run! $CI_NODE_INDEX"
exit 1
;;
esac
2 changes: 1 addition & 1 deletion src/bindings
5 changes: 5 additions & 0 deletions src/examples/benchmarks/import.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
let start = performance.now();
await import('../../snarky.js');
let time = performance.now() - start;

console.log(`import jsoo: ${time.toFixed(0)}ms`);
5 changes: 5 additions & 0 deletions src/examples/benchmarks/import.web.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
let start = performance.now();
await import('snarkyjs');
let time = performance.now() - start;

console.log(`import jsoo: ${time.toFixed(0)}ms`);
4 changes: 2 additions & 2 deletions src/examples/zkapps/hello_world/hello_world.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {
Field,
PrivateKey,
SmartContract,
state,
State,
method,
PrivateKey,
state,
} from 'snarkyjs';

export const adminPrivateKey = PrivateKey.random();
Expand Down
4 changes: 2 additions & 2 deletions src/examples/zkapps/hello_world/run.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { HelloWorld, adminPrivateKey } from './hello_world.js';
import { Mina, PrivateKey, AccountUpdate, Field } from 'snarkyjs';
import { AccountUpdate, Field, Mina, PrivateKey } from 'snarkyjs';
import { getProfiler } from '../../profiler.js';
import { HelloWorld, adminPrivateKey } from './hello_world.js';

const HelloWorldProfier = getProfiler('Hello World');
HelloWorldProfier.start('Hello World test flow');
Expand Down
Loading

0 comments on commit 82808cd

Please sign in to comment.