Skip to content
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
11 changes: 11 additions & 0 deletions scripts/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Benchmark Configuration
BASE_URL=http://localhost:3005
TYPE=eoa
FROM=0x...
CHAIN_ID=1337
SECRET_KEY=your-secret-key
VAULT_ACCESS_TOKEN=your-vault-access-token
Comment on lines +2 to +7
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Sort required keys to satisfy dotenv-linter.

.env.example currently trips the UnorderedKey rule (BASE_URLTYPEFROM …). This will keep failing lint runs until the keys are alphabetized. Please reorder the required block (e.g. BASE_URL, CHAIN_ID, FROM, SECRET_KEY, TYPE, VAULT_ACCESS_TOKEN) so the example passes the check.
(evrone.com)

🧰 Tools
🪛 dotenv-linter (3.3.0)

[warning] 4-4: [UnorderedKey] The FROM key should go before the TYPE key

(UnorderedKey)


[warning] 5-5: [UnorderedKey] The CHAIN_ID key should go before the FROM key

(UnorderedKey)


[warning] 6-6: [UnorderedKey] The SECRET_KEY key should go before the TYPE key

(UnorderedKey)

🤖 Prompt for AI Agents
In scripts/.env.example around lines 2 to 7 the environment keys are out of
alphabetical order causing dotenv-linter's UnorderedKey rule to fail; reorder
the block to alphabetical order (BASE_URL, CHAIN_ID, FROM, SECRET_KEY, TYPE,
VAULT_ACCESS_TOKEN) keeping the existing example values intact so the file
passes linting.


# Optional: Benchmark Parameters
CONCURRENT_REQUESTS=10
TOTAL_REQUESTS=100
1 change: 1 addition & 0 deletions scripts/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json

# Finder (MacOS) folder config
.DS_Store
benchmarks/runs
154 changes: 154 additions & 0 deletions scripts/benchmarks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
# EOA Executor Benchmark

A comprehensive benchmark tool for stress testing the `/v1/write/transaction` endpoint with detailed performance metrics and webhook event tracking.

## Features

- ✅ Concurrent request execution with configurable concurrency
- 📊 Detailed metrics tracking (HTTP response time, submission time, confirmation time)
- 🎣 Built-in webhook server to capture transaction lifecycle events
- 📈 Statistical analysis (p50, p90, p95, p99, min, max, mean)
- 📄 CSV export of individual transaction metrics
- 📊 JSON export of aggregate results
- 🎯 Real-time progress and status updates

## Setup

1. Copy the `.env.example` to `.env` in the `/scripts` directory:
```bash
cp .env.example .env
```

2. Configure your environment variables in `.env`:
```
BASE_URL=http://localhost:3005
TYPE=eoa
FROM=0x1234567890123456789012345678901234567890
CHAIN_ID=1337
SECRET_KEY=your-secret-key
VAULT_ACCESS_TOKEN=your-vault-access-token
CONCURRENT_REQUESTS=10
TOTAL_REQUESTS=100
```

## Usage

Run the benchmark from the `/scripts` directory:

```bash
cd scripts
bun ./benchmarks/eoa.ts
```

## Output

The benchmark creates a timestamped directory `run-<timestamp>/` containing:

- `transactions-<timestamp>.csv` - Individual transaction metrics
- `result-<timestamp>.json` - Aggregate statistics

### CSV Format

Each row contains:
- `transaction_id` - Unique transaction identifier
- `http_response_time_ms` - HTTP request/response time
- `sent_to_submitted_ms` - Time from send to submitted webhook
- `submitted_to_confirmed_ms` - Time from submitted to confirmed webhook
- `total_time_ms` - Total time from send to confirmed
- `status` - Final status (confirmed/failed/pending)
- `error` - Error message if failed

### JSON Format

Aggregate results include:
- Total/successful/failed request counts
- Error rate percentage
- Duration and throughput (req/s)
- Statistical breakdown for all timing metrics (min, max, mean, p50, p90, p95, p99)

## Configuration Options

| Variable | Default | Description |
|----------|---------|-------------|
| `BASE_URL` | `http://localhost:3005` | API endpoint base URL |
| `TYPE` | `eoa` | Execution type |
| `FROM` | *required* | Sender address |
| `CHAIN_ID` | `1337` | Blockchain network ID |
| `SECRET_KEY` | *required* | API secret key |
| `VAULT_ACCESS_TOKEN` | *required* | Vault access token |
| `CONCURRENT_REQUESTS` | `10` | Number of concurrent requests |
| `TOTAL_REQUESTS` | `100` | Total number of requests to send |

## How It Works

1. **Webhook Server**: Starts a local server on port 3070 to receive transaction lifecycle webhooks
2. **Request Sending**: Sends HTTP requests to `/v1/write/transaction` with controlled concurrency
3. **Event Tracking**: Tracks webhook events for each transaction:
- `send` stage with `Success` event = transaction submitted
- `confirm` stage with `Success` event = transaction confirmed
- `Failure` or `Nack` events = transaction failed
4. **Metrics Calculation**: Computes timing metrics and statistics
5. **Output Generation**: Writes CSV and JSON files with results

## Webhook Event Structure

Based on `executors/src/eoa/events.rs`, the webhook payload contains:
```json
{
"transaction_id": "...",
"executor_name": "eoa",
"stage_name": "send" | "confirm",
"event_type": "Success" | "Nack" | "Failure",
"payload": { ... }
}
```

## Example Output

```
🚀 Starting benchmark...
📊 Configuration:
Base URL: http://localhost:3005
Type: eoa
From: 0x1234...
Chain ID: 1337
Total Requests: 100
Concurrent Requests: 10

📤 Sent 10/100 requests...
...
✅ All HTTP requests completed
⏳ Waiting for webhooks to complete...
🎉 All transactions completed!

📊 BENCHMARK RESULTS
============================================================
📈 Overview:
Total Requests: 100
Successful: 98
Failed: 2
Error Rate: 2.00%
Duration: 45.23s
Throughput: 2.21 req/s

⏱️ HTTP Response Times (ms):
Min: 45.23
Mean: 123.45
P50: 110.00
P90: 180.00
P95: 210.00
P99: 250.00
Max: 320.00
...
```

## Tips

- Start with a small `TOTAL_REQUESTS` value to test your setup
- Adjust `CONCURRENT_REQUESTS` based on your server capacity
- Monitor your server logs alongside the benchmark
- The script waits up to 2 minutes for pending webhooks before timing out
- Use the CSV output for detailed per-transaction analysis
- Use the JSON output for automated performance regression testing


Loading