Skip to content

Commit

Permalink
feat(benchmark): migrate to use lightnet
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinMinkov committed Feb 9, 2024
1 parent 81e2e5f commit 8feee29
Show file tree
Hide file tree
Showing 12 changed files with 246 additions and 259 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ benchmark/*.js
*/resolvers-types.ts
codegen.ts
/zkapp
/benchmark
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ coverage/**/*

# Ignore benchmark results
benchmark/*.json
benchmark/*.csv
51 changes: 0 additions & 51 deletions benchmark/data.csv

This file was deleted.

14 changes: 2 additions & 12 deletions benchmark/graphql.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
config:
target: 'http://localhost:8080'
target: 'http://localhost:3000'
phases:
- duration: 180
arrivalRate: 25
Expand All @@ -13,17 +13,14 @@ config:
arrivalRate: 100
rampTo: 1000
name: 'heavy phase'
processor: 'processor.js'
payload:
path: 'data.csv'
path: 'zkapp.csv'
skipHeader: true
fields:
- 'address'
- 'tokenId'
scenarios:
- name: 'Get Events'
flow:
- function: 'generateRandomBlockRange'
- post:
url: '/'
json:
Expand Down Expand Up @@ -55,14 +52,10 @@ scenarios:
variables:
input:
address: '{{ address }}'
tokenId: '{{ tokenId }}'
to: '{{ to }}'
from: '{{ from }}'
expect:
- statusCode: 200
- name: 'Get Actions'
flow:
- function: 'generateRandomBlockRange'
- post:
url: '/'
json:
Expand Down Expand Up @@ -102,8 +95,5 @@ scenarios:
variables:
input:
address: '{{ address }}'
tokenId: '{{ tokenId }}'
to: '{{ to }}'
from: '{{ from }}'
expect:
- statusCode: 200
22 changes: 0 additions & 22 deletions benchmark/processor.js

This file was deleted.

15 changes: 7 additions & 8 deletions zkapp/run.ts → benchmark/setup.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { Lightnet, PrivateKey } from 'o1js';
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { writeFileSync } from 'node:fs';
import {
setNetworkConfig,
fetchAccountInfo,
Expand All @@ -8,15 +11,9 @@ import {
emitMultipleFieldsEvent,
emitAction,
reduceAction,
startLightnet,
stopLightnet,
} from './utils.js';

// Ensure you are running a local archive node
} from '../zkapp/utils.js';

(async () => {
await startLightnet();

setNetworkConfig();

const zkAppKey = PrivateKey.random();
Expand Down Expand Up @@ -51,5 +48,7 @@ import {

if (keyPairReleaseMessage) console.info(keyPairReleaseMessage);

await stopLightnet();
const filePath = join(dirname(fileURLToPath(import.meta.url)), 'zkapp.csv');
writeFileSync(filePath, `address\n${zkAppKeypair.publicKey.toBase58()}\n`);
console.log(`Public key of zkApp keypair written into ${filePath}`);
})();
7 changes: 7 additions & 0 deletions nodemon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"watch": ["src"],
"ext": "ts",
"execMap": {
"ts": "node --loader ts-node/esm"
}
}
Loading

0 comments on commit 8feee29

Please sign in to comment.