Skip to content

Use requests builder #2

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
13 changes: 11 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
.yarn
node_modules
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

node_modules

methods/requests.json
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
all-forest-cloud:
k6 cloud run -e K6_TEST_URL=http://localhost:2345/rpc/v1 --local-execution tests/all.js
k6 cloud run -e K6_RPC_URL=http://localhost:2345/rpc/v1 --local-execution tests/all.js

all-lotus-cloud:
k6 cloud run -e K6_TEST_URL=http://localhost:1234/rpc/v1 --local-execution tests/all.js
k6 cloud run -e K6_RPC_URL=http://localhost:1234/rpc/v1 --local-execution tests/all.js

all-forest-local:
k6 run -e K6_TEST_URL=http://localhost:2345/rpc/v1 tests/all.js
k6 run -e K6_RPC_URL=http://localhost:2345/rpc/v1 tests/all.js

all-lotus-local:
Copy link

@hanabi1224 hanabi1224 Jul 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How expensive is build-requests? If it's cheap, should we always depend on it

k6 run -e K6_TEST_URL=http://localhost:1234/rpc/v1 tests/all.js
k6 run -e K6_RPC_URL=http://localhost:1234/rpc/v1 tests/all.js

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let add

build-requests:
    yarn build-requests

.PHONY: all-forest-cloud all-lotus-cloud all-forest-local all-lotus-local
32 changes: 25 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,39 @@ Implementation-agnostic benchmark for RPC

This benchmarking suite requires [k6](https://grafana.com/docs/k6/latest/) installed on the host. Follow the instructions for your operating system. Alternatively, you can run them via Docker.

## Methods Definitions

Before running benchmarks, generate method definitions using the command:

```bash
K6_RPC_URL=http://localhost:2345/rpc/v1 yarn build-requests
```

It will generate real Filecoin and Ethereum JSON-RPC method definitions with up-to-date parameters from live chain state and will store them in the `methods/requests.json` file.
Feel free to adjust parameters manually.

## Local benchmarks

You can run the benchmarks fully locally. To do so, you will need a running Filecoin node; ensure it's synced.

Sample benchmark run:
Benchmark all supported methods:

```bash
k6 run -e K6_RPC_URL=http://localhost:2345/rpc/v1 tests/all.js --duration 30s --vus 20
```

Single method benchmark:

```bash
k6 run -e K6_TEST_URL=http://localhost:2345/rpc/v1 tests/all.js --duration 30s --vus 20
k6 run -e K6_RPC_URL=http://localhost:2345/rpc/v1 K6_METHOD=eth_gasPrice tests/single_method.js --duration 30s --vus 20
```

## Upload benchmarks to Grafana Cloud

You can create a free account on Grafana Cloud (the free tier should suffice if you run the tests locally). Login with `k6 cloud login --token <token>`. Now, you can run the benchmarks locally but have them uploaded to your Grafana Cloud for visual inspection and comparisons.

```bash
k6 cloud run -e K6_TEST_URL=http://localhost:2345/rpc/v1 --local-execution tests/top5.js
k6 cloud run -e K6_RPC_URL=http://localhost:2345/rpc/v1 --local-execution tests/all.js
```

## Configuring benchmarks
Expand All @@ -30,10 +47,11 @@ Read about [k6 options](https://grafana.com/docs/k6/latest/using-k6/k6-options/)

## Environment variables

| Name | Description | Type | Default |
| --------------- | --------------------------- | ---- | ------------------------------ |
| `K6_TEST_URL` | Node RPC endpoint | URL | `http://localhost:2345/rpc/v1` |
| `K6_TEST_DEBUG` | Print additional debug info | bool | false |
| Name | Description | Type | Default |
| --------------- | --------------------------- | ------ | ------------------------------ |
| `K6_RPC_URL` | Node RPC endpoint | URL | `http://localhost:2345/rpc/v1` |
| `K6_METHOD` | Method to benchmark | string | 'eth_gasPrice' |
| `K6_TEST_DEBUG` | Print additional debug info | bool | false |

## Pitfalls

Expand Down
Empty file added methods/.keep
Empty file.
80 changes: 0 additions & 80 deletions methods/index.js

This file was deleted.

Loading