Skip to content

Commit f40cd4d

Browse files
authored
test: testapp bench (#3214)
1 parent 60c68ea commit f40cd4d

File tree

9 files changed

+343
-197
lines changed

9 files changed

+343
-197
lines changed

apps/testapp/README.md

Lines changed: 61 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,75 @@
11
# Test Application
22

3-
This application serves as an example to help you understand how to create your own application using this framework. It provides a basic implementation that you can use as a reference when building your own solution.
3+
Reference implementation of a key-value store rollup using ev-node. Includes a KV executor, HTTP server for transaction submission, and a stress test tool targeting 10M req/s.
44

5-
## Important Note
5+
## Build
66

7-
When implementing your own application, it's your responsibility to provide the appropriate Executor dependency. This is a crucial component that needs to be properly implemented according to your specific requirements.
7+
```bash
8+
# Build the testapp binary
9+
go build -o testapp .
10+
11+
# Build the stress test tool
12+
go build -o stress-test ./kv/bench/
13+
```
814

9-
## Installation
15+
## Quick Start
1016

11-
To install and test the application, you can use the following command:
17+
You need 3 terminals: one for the local DA, one for the testapp node, and one for the stress test.
1218

1319
```bash
14-
go build .
20+
# Terminal 1: Start local DA (defaults to localhost:7980)
21+
go run ../../tools/local-da
22+
23+
# Terminal 2: Initialize and start the testapp
24+
./testapp init --evnode.node.aggregator --evnode.signer.passphrase_file examples/passphrase.txt
25+
./testapp start --kv-endpoint localhost:9090 --evnode.node.aggregator --evnode.signer.passphrase_file examples/passphrase.txt
26+
27+
# Terminal 3: Run the stress test
28+
./stress-test --addr localhost:9090 --duration 10s --workers 10000
1529
```
1630

17-
This will build and install all necessary dependencies for running the test application.
31+
## Commands
32+
33+
| Command | Description |
34+
| ------------------ | ------------------------------------- |
35+
| `testapp init` | Initialize configuration and genesis |
36+
| `testapp start` | Run the node (aliases: `run`, `node`) |
37+
| `testapp rollback` | Rollback state by one height |
38+
| `testapp version` | Show version info |
39+
| `testapp keys` | Manage signing keys |
40+
| `testapp net-info` | Get info from a running node via RPC |
41+
42+
### Key Flags for `start`
1843

19-
## Usage
44+
| Flag | Description |
45+
| -------------------------- | ------------------------------------------------- |
46+
| `--kv-endpoint <addr>` | Enable the KV HTTP server (e.g. `localhost:9090`) |
47+
| `--evnode.node.aggregator` | Run as aggregator (block producer) |
48+
| `--evnode.node.block_time` | Block interval (default `1s`) |
49+
| `--evnode.da.address` | DA layer address |
50+
| `--home <dir>` | Data directory (default `~/.testapp`) |
2051

21-
This is a reference implementation. Feel free to explore the code and use it as a starting point for your own application. Make sure to:
52+
## HTTP Endpoints
53+
54+
When `--kv-endpoint` is set, the following endpoints are available:
55+
56+
| Method | Path | Description |
57+
| ------ | --------------- | --------------------------------------------------- |
58+
| POST | `/tx` | Submit a transaction (`key=value` body) |
59+
| GET | `/kv?key=<key>` | Retrieve latest value for a key |
60+
| GET | `/store` | List all key-value pairs |
61+
| GET | `/stats` | Get injected/executed tx counts and blocks produced |
62+
63+
## Stress Test
64+
65+
```bash
66+
./stress-test --addr localhost:9090 --duration 10s --workers 1000
67+
```
2268

23-
1. Review the existing code structure
24-
2. Understand how the Executor is implemented
25-
3. Adapt the implementation to your specific needs
69+
| Flag | Default | Description |
70+
| ----------- | ---------------- | ---------------------- |
71+
| `-addr` | `localhost:9090` | Server host:port |
72+
| `-duration` | `10s` | Test duration |
73+
| `-workers` | `1000` | Concurrent TCP workers |
2674

27-
Remember that this is just an example, and your actual implementation might require different approaches depending on your use case.
75+
The test sends transactions via raw persistent TCP connections, reports live RPS, and prints a summary table with avg/peak req/s, server-side block stats, and whether the 10M req/s goal was reached.

apps/testapp/cmd/init.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"os"
77
"strings"
8+
"time"
89

910
"github.com/spf13/cobra"
1011

@@ -34,6 +35,7 @@ func InitCmd() *cobra.Command {
3435
// we use load in order to parse all the flags
3536
cfg, _ := rollconf.Load(cmd)
3637
cfg.Node.Aggregator = aggregator
38+
cfg.Node.BlockTime = rollconf.DurationWrapper{Duration: 10 * time.Millisecond}
3739
if err := cfg.Validate(); err != nil {
3840
return fmt.Errorf("error validating config: %w", err)
3941
}
@@ -102,7 +104,7 @@ func InitCmd() *cobra.Command {
102104

103105
// Add flags to the command
104106
rollconf.AddFlags(initCmd)
105-
initCmd.Flags().String(rollgenesis.ChainIDFlag, "rollkit-test", "chain ID")
107+
initCmd.Flags().String(rollgenesis.ChainIDFlag, "ev-test", "chain ID")
106108

107109
return initCmd
108110
}

apps/testapp/cmd/run.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ func createSequencer(
143143
daClient,
144144
nodeConfig,
145145
[]byte(genesis.ChainID),
146-
1000,
146+
1_000_000,
147147
genesis,
148148
executor,
149149
)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
foo:bar

apps/testapp/kv/bench/README.md

Lines changed: 29 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,51 @@
1-
# KV Executor Benchmark Client
1+
# KV Executor Stress Test
22

3-
This is a command-line client primarily used for benchmarking the KV executor HTTP server by sending transactions. It can also list the current state of the store.
3+
Stress test for the KV executor HTTP server. Sends transactions via raw TCP connections to maximize throughput, targeting 10M req/s.
44

55
## Building
66

77
```bash
8-
go build -o txclient
8+
go build -o stress-test ./kv/bench/
99
```
1010

1111
## Usage
1212

13-
The client runs a transaction benchmark by default.
14-
15-
### Running the Benchmark
13+
Run the testapp first, then the stress test alongside it:
1614

1715
```bash
18-
./txclient [flags]
19-
```
20-
21-
By default, the benchmark runs for 30 seconds, sending 10 random key-value transactions every second to `http://localhost:40042`.
22-
23-
**Benchmark Flags:**
24-
25-
* `-duration <duration>`: Total duration for the benchmark (e.g., `1m`, `30s`). Default: `30s`.
26-
* `-interval <duration>`: Interval between sending batches of transactions (e.g., `1s`, `500ms`). Default: `1s`.
27-
* `-tx-per-interval <int>`: Number of transactions to send in each interval. Default: `10`.
28-
* `-addr <url>`: Specify a different server address. Default: `http://localhost:40042`.
29-
30-
**Transaction Data for Benchmark:**
31-
32-
* **Random Data (Default):** If no transaction data flags are provided, the client sends random `key=value` transactions, where keys are 8 characters and values are 16 characters long.
33-
* **Fixed Key/Value:** Use `-key mykey -value myvalue` to send the *same* transaction `mykey=myvalue` repeatedly during the benchmark.
34-
* **Fixed Raw Data:** Use `-raw "myrawdata"` to send the *same* raw transaction data repeatedly during the benchmark.
16+
# Terminal 1: start the testapp with KV endpoint
17+
./build/testapp start --kv-endpoint localhost:9090
3518

36-
### List all key-value pairs in the store
37-
38-
```bash
39-
./txclient -list [-addr <url>]
19+
# Terminal 2: run the stress test
20+
./stress-test --addr localhost:9090 --duration 10s --workers 1000
4021
```
4122

42-
This will fetch and display all key-value pairs currently in the KV executor's store. It does not run the benchmark.
23+
## Flags
4324

44-
## Examples
25+
| Flag | Default | Description |
26+
|------|---------|-------------|
27+
| `-addr` | `localhost:9090` | Server host:port |
28+
| `-duration` | `10s` | Test duration |
29+
| `-workers` | `1000` | Number of concurrent TCP workers |
30+
| `-target-rps` | `10000000` | Target requests per second (goal) |
4531

46-
Run a 1-minute benchmark sending 20 random transactions every 500ms:
32+
## Output
4733

48-
```bash
49-
./txclient -duration 1m -interval 500ms -tx-per-interval 20
50-
```
34+
The tool prints live progress (req/s) during the run, then a summary table with:
5135

52-
Run a 30-second benchmark repeatedly sending the transaction `user1=alice`:
36+
- Avg req/s and peak req/s
37+
- Total requests, successes, and failures
38+
- Server-side stats: blocks produced, txs executed, avg txs per block
39+
- Whether the 10M req/s goal was reached (displays `SUCCESS` if so)
5340

54-
```bash
55-
./txclient -duration 30s -key user1 -value alice
56-
```
41+
## /stats Endpoint
5742

58-
List all values from a specific server:
43+
The KV executor HTTP server exposes a `/stats` endpoint (GET) returning:
5944

60-
```bash
61-
./txclient -list -addr http://192.168.1.100:40042
45+
```json
46+
{
47+
"injected_txs": 52345678,
48+
"executed_txs": 1234567,
49+
"blocks_produced": 1000
50+
}
6251
```

0 commit comments

Comments
 (0)