Skip to content

Commit bcc5c4c

Browse files
Add EOA executor benchmark tool with metrics tracking (#59)
1 parent ac2ecf3 commit bcc5c4c

File tree

6 files changed

+685
-2
lines changed

6 files changed

+685
-2
lines changed

scripts/.env.example

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Benchmark Configuration
2+
BASE_URL=http://localhost:3005
3+
TYPE=eoa
4+
FROM=0x...
5+
CHAIN_ID=1337
6+
SECRET_KEY=your-secret-key
7+
VAULT_ACCESS_TOKEN=your-vault-access-token
8+
9+
# Optional: Benchmark Parameters
10+
CONCURRENT_REQUESTS=10
11+
TOTAL_REQUESTS=100

scripts/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,4 @@ report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
3232

3333
# Finder (MacOS) folder config
3434
.DS_Store
35+
benchmarks/runs

scripts/benchmarks/README.md

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
# EOA Executor Benchmark
2+
3+
A comprehensive benchmark tool for stress testing the `/v1/write/transaction` endpoint with detailed performance metrics and webhook event tracking.
4+
5+
## Features
6+
7+
- ✅ Concurrent request execution with configurable concurrency
8+
- 📊 Detailed metrics tracking (HTTP response time, submission time, confirmation time)
9+
- 🎣 Built-in webhook server to capture transaction lifecycle events
10+
- 📈 Statistical analysis (p50, p90, p95, p99, min, max, mean)
11+
- 📄 CSV export of individual transaction metrics
12+
- 📊 JSON export of aggregate results
13+
- 🎯 Real-time progress and status updates
14+
15+
## Setup
16+
17+
1. Copy the `.env.example` to `.env` in the `/scripts` directory:
18+
```bash
19+
cp .env.example .env
20+
```
21+
22+
2. Configure your environment variables in `.env`:
23+
```
24+
BASE_URL=http://localhost:3005
25+
TYPE=eoa
26+
FROM=0x1234567890123456789012345678901234567890
27+
CHAIN_ID=1337
28+
SECRET_KEY=your-secret-key
29+
VAULT_ACCESS_TOKEN=your-vault-access-token
30+
CONCURRENT_REQUESTS=10
31+
TOTAL_REQUESTS=100
32+
```
33+
34+
## Usage
35+
36+
Run the benchmark from the `/scripts` directory:
37+
38+
```bash
39+
cd scripts
40+
bun ./benchmarks/eoa.ts
41+
```
42+
43+
## Output
44+
45+
The benchmark creates a timestamped directory `run-<timestamp>/` containing:
46+
47+
- `transactions-<timestamp>.csv` - Individual transaction metrics
48+
- `result-<timestamp>.json` - Aggregate statistics
49+
50+
### CSV Format
51+
52+
Each row contains:
53+
- `transaction_id` - Unique transaction identifier
54+
- `http_response_time_ms` - HTTP request/response time
55+
- `sent_to_submitted_ms` - Time from send to submitted webhook
56+
- `submitted_to_confirmed_ms` - Time from submitted to confirmed webhook
57+
- `total_time_ms` - Total time from send to confirmed
58+
- `status` - Final status (confirmed/failed/pending)
59+
- `error` - Error message if failed
60+
61+
### JSON Format
62+
63+
Aggregate results include:
64+
- Total/successful/failed request counts
65+
- Error rate percentage
66+
- Duration and throughput (req/s)
67+
- Statistical breakdown for all timing metrics (min, max, mean, p50, p90, p95, p99)
68+
69+
## Configuration Options
70+
71+
| Variable | Default | Description |
72+
|----------|---------|-------------|
73+
| `BASE_URL` | `http://localhost:3005` | API endpoint base URL |
74+
| `TYPE` | `eoa` | Execution type |
75+
| `FROM` | *required* | Sender address |
76+
| `CHAIN_ID` | `1337` | Blockchain network ID |
77+
| `SECRET_KEY` | *required* | API secret key |
78+
| `VAULT_ACCESS_TOKEN` | *required* | Vault access token |
79+
| `CONCURRENT_REQUESTS` | `10` | Number of concurrent requests |
80+
| `TOTAL_REQUESTS` | `100` | Total number of requests to send |
81+
82+
## How It Works
83+
84+
1. **Webhook Server**: Starts a local server on port 3070 to receive transaction lifecycle webhooks
85+
2. **Request Sending**: Sends HTTP requests to `/v1/write/transaction` with controlled concurrency
86+
3. **Event Tracking**: Tracks webhook events for each transaction:
87+
- `send` stage with `Success` event = transaction submitted
88+
- `confirm` stage with `Success` event = transaction confirmed
89+
- `Failure` or `Nack` events = transaction failed
90+
4. **Metrics Calculation**: Computes timing metrics and statistics
91+
5. **Output Generation**: Writes CSV and JSON files with results
92+
93+
## Webhook Event Structure
94+
95+
Based on `executors/src/eoa/events.rs`, the webhook payload contains:
96+
```json
97+
{
98+
"transaction_id": "...",
99+
"executor_name": "eoa",
100+
"stage_name": "send" | "confirm",
101+
"event_type": "Success" | "Nack" | "Failure",
102+
"payload": { ... }
103+
}
104+
```
105+
106+
## Example Output
107+
108+
```
109+
🚀 Starting benchmark...
110+
📊 Configuration:
111+
Base URL: http://localhost:3005
112+
Type: eoa
113+
From: 0x1234...
114+
Chain ID: 1337
115+
Total Requests: 100
116+
Concurrent Requests: 10
117+
118+
📤 Sent 10/100 requests...
119+
...
120+
✅ All HTTP requests completed
121+
⏳ Waiting for webhooks to complete...
122+
🎉 All transactions completed!
123+
124+
📊 BENCHMARK RESULTS
125+
============================================================
126+
📈 Overview:
127+
Total Requests: 100
128+
Successful: 98
129+
Failed: 2
130+
Error Rate: 2.00%
131+
Duration: 45.23s
132+
Throughput: 2.21 req/s
133+
134+
⏱️ HTTP Response Times (ms):
135+
Min: 45.23
136+
Mean: 123.45
137+
P50: 110.00
138+
P90: 180.00
139+
P95: 210.00
140+
P99: 250.00
141+
Max: 320.00
142+
...
143+
```
144+
145+
## Tips
146+
147+
- Start with a small `TOTAL_REQUESTS` value to test your setup
148+
- Adjust `CONCURRENT_REQUESTS` based on your server capacity
149+
- Monitor your server logs alongside the benchmark
150+
- The script waits up to 2 minutes for pending webhooks before timing out
151+
- Use the CSV output for detailed per-transaction analysis
152+
- Use the JSON output for automated performance regression testing
153+
154+

0 commit comments

Comments
 (0)