Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce loading time - BERKELEY #1082

Merged
merged 3 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
22 changes: 9 additions & 13 deletions .github/workflows/build-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ on:
- berkeley
- develop
pull_request:
branches:
- main
- berkeley
- develop
workflow_dispatch: {}

jobs:
Expand All @@ -31,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 @@ -53,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 @@ -71,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 @@ -84,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 @@ -108,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`);
9 changes: 2 additions & 7 deletions src/examples/zkapps/hello_world/hello_world.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
import {
Field,
PrivateKey,
SmartContract,
state,
State,
method,
DeployArgs,
PrivateKey,
Permissions,
isReady,
state,
} from 'snarkyjs';

await isReady;

export const adminPrivateKey = PrivateKey.random();
export const adminPublicKey = adminPrivateKey.toPublicKey();

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