-
Notifications
You must be signed in to change notification settings - Fork 266
feat(loadgen): adding loadgen binary #3335
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
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
f3e740b
feat: benchmarks container image
auricom b5a76fb
fix: entrypoint
auricom c65ee92
fix
auricom a791709
Fix typo in README for benchmark runner command
auricom eb748d0
Update Dockerfile to copy ev-benchmarks
auricom 8c2ed72
Update crontab
auricom 1227ca7
feat(benchmarks): add ev-benchmarks cobra CLI for stress testing via …
chatton 09e87f4
feat(benchmarks): replace supercronic with in-process scheduler
chatton 9d8676c
feat(loadgen): rename benchmarks app and add tests
chatton 19166ab
chore: simplify ci, use struct instead of raw json in tests
chatton b1997f8
chore: rename bench -> loadgen
chatton 8d03351
chore: use correct block height
chatton 552596a
fix(loadgen): address PR review feedback
chatton 7b75212
chore: ensure possibility for concurrent spammers if time window is s…
chatton 1a4d33e
fix(loadgen): fix burst scheduling window and shutdown races
chatton f1f8491
feat(loadgen): add burst subcommand and make scheduled bursts opt-in
chatton 2a4e863
fix(loadgen): filter spamoor counters by spammer name prefix
chatton fa30616
refactor(loadgen): split internal package and simplify
chatton d64f6e8
chore: apply spammoor fix
chatton 51ef8b3
Merge branch 'main' into cian/benchmarks-binary
chatton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # Build ev-loadgen binary | ||
| [group('loadgen')] | ||
| build-loadgen: | ||
| @echo "--> Building ev-loadgen" | ||
| @mkdir -p {{ build_dir }} | ||
| @cd apps/loadgen && go build -o {{ build_dir }}/ev-loadgen . | ||
| @echo " Check the binary with: {{ build_dir }}/ev-loadgen" | ||
|
|
||
| # Build ev-loadgen Docker image | ||
| [group('loadgen')] | ||
| docker-build-loadgen: | ||
| @echo "--> Building ev-loadgen Docker image" | ||
| @docker build -f apps/loadgen/Dockerfile -t ev-loadgen:dev . | ||
| @echo "--> Docker image built: ev-loadgen:dev" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| FROM golang:1.25-alpine AS build-env | ||
|
|
||
| WORKDIR /src | ||
|
|
||
| COPY apps/loadgen/go.mod apps/loadgen/go.sum ./ | ||
| RUN go mod download | ||
|
|
||
| COPY apps/loadgen/ . | ||
| RUN CGO_ENABLED=0 GOOS=linux go build -o ev-loadgen . | ||
|
|
||
| FROM alpine:3.22.2 | ||
|
|
||
| ENV TZ=UTC | ||
|
|
||
| #hadolint ignore=DL3018 | ||
| RUN apk --no-cache add ca-certificates curl tzdata | ||
|
|
||
| RUN addgroup -S ev && adduser -S ev -G ev | ||
|
|
||
| WORKDIR /home/ev | ||
|
|
||
| COPY --from=build-env /src/ev-loadgen /usr/bin/ev-loadgen | ||
| COPY apps/loadgen/matrices/baseline.json /home/ev/baseline.json | ||
| COPY apps/loadgen/matrices/burst.json /home/ev/burst.json | ||
|
|
||
| USER ev | ||
|
|
||
| CMD ["ev-loadgen", "start"] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,157 @@ | ||
| # loadgen | ||
|
|
||
| Standalone load generator for ev-node stress testing. Talks to a [spamoor-daemon](https://github.com/ethpandaops/spamoor) sidecar via HTTP API. | ||
|
|
||
| ## Architecture | ||
|
|
||
| ```text | ||
| ev-loadgen (this binary) --> spamoor-daemon --> ev-reth RPC | ||
| | | | ||
| reads matrix JSON manages wallets, | ||
| creates/polls spammers signs & sends txs | ||
| ``` | ||
|
|
||
| - **spamoor-daemon** needs: a funded private key + ev-reth RPC URL | ||
| - **ev-loadgen** needs: spamoor-daemon API URL + matrix JSON files | ||
|
|
||
| ## Modes | ||
|
|
||
| ### Daemon mode (`start`) | ||
|
|
||
| Runs a continuous scheduler with regular and burst workloads. Designed for long-running deployments. | ||
|
|
||
| ```sh | ||
| ev-loadgen start --spamoor-url=http://localhost:8080 | ||
| ``` | ||
|
|
||
| Regular workloads fire immediately at startup, then repeat at `--interval`. Per-run tx count = `tx-per-day / (24h / interval)`, overriding each matrix entry's `BENCH_COUNT_PER_SPAMMER`. | ||
|
|
||
| Bursts are randomly spaced throughout a rolling 24h window. Set `--burst-per-day=0` (the default) to disable bursts entirely. | ||
|
|
||
| #### start flags | ||
|
|
||
| | Flag | Env | Default | Description | | ||
| |------|-----|---------|-------------| | ||
| | `--tx-per-day` | `BENCH_TX_PER_DAY` | `1000000` | sustained txs/day | | ||
| | `--interval` | `BENCH_INTERVAL` | `1h` | regular workload frequency | | ||
| | `--burst-tx-count` | `BENCH_BURST_TX_COUNT` | `500000` | txs per burst | | ||
| | `--burst-per-day` | `BENCH_BURST_PER_DAY` | `0` | bursts per day, randomly spaced (0 = disabled) | | ||
| | `--regular-matrix` | `BENCH_REGULAR_MATRIX` | `/home/ev/baseline.json` | path to regular matrix JSON | | ||
| | `--burst-matrix` | `BENCH_BURST_MATRIX` | `/home/ev/burst.json` | path to burst matrix JSON | | ||
|
|
||
| ### CLI mode (one-shot commands) | ||
|
|
||
| #### `run` — execute a matrix file | ||
|
|
||
| Runs all entries from a matrix JSON file with probability filtering and sync waiting, then exits. | ||
|
|
||
| ```sh | ||
| ev-loadgen run matrices/baseline.json --spamoor-url=http://localhost:8080 | ||
| ``` | ||
|
|
||
| #### `burst` — trigger a single burst | ||
|
|
||
| Fires one burst workload immediately and exits. | ||
|
|
||
| ```sh | ||
| ev-loadgen burst --spamoor-url=http://localhost:8080 | ||
| ``` | ||
|
|
||
| | Flag | Env | Default | Description | | ||
| |------|-----|---------|-------------| | ||
| | `--tx-count` | `BENCH_BURST_TX_COUNT` | `500000` | total transactions for the burst | | ||
| | `--burst-matrix` | `BENCH_BURST_MATRIX` | `/home/ev/burst.json` | path to burst matrix JSON | | ||
|
|
||
| ### Global flag | ||
|
|
||
| `--spamoor-url` (or `BENCH_SPAMOOR_URL` env, default `http://spamoor-daemon:8080`) | ||
|
|
||
| ## Quick Start | ||
|
|
||
| ### 1. Start spamoor-daemon | ||
|
|
||
| ```sh | ||
| docker run -d --name spamoor -p 8080:8080 \ | ||
| ethpandaops/spamoor:latest /app/spamoor-daemon \ | ||
| --privkey=<funded-private-key> \ | ||
| --rpchost=http://<ev-reth-host>:8545 \ | ||
| --port=8080 --startup-delay=0 | ||
| ``` | ||
|
|
||
| ### 2. Run loadgen | ||
|
|
||
| ```sh | ||
| # build | ||
| cd apps/loadgen && go build -o ev-loadgen . | ||
|
|
||
| # one-shot matrix run | ||
| ./ev-loadgen run matrices/baseline.json --spamoor-url=http://localhost:8080 | ||
|
|
||
| # continuous daemon (~1M tx/day, no bursts) | ||
| ./ev-loadgen start --spamoor-url=http://localhost:8080 | ||
|
|
||
| # continuous daemon with bursts | ||
| ./ev-loadgen start \ | ||
| --spamoor-url=http://localhost:8080 \ | ||
| --tx-per-day=500000 \ | ||
| --interval=30m \ | ||
| --burst-tx-count=100000 \ | ||
| --burst-per-day=4 | ||
| ``` | ||
|
|
||
| ### Docker Compose | ||
|
|
||
| Spins up both spamoor-daemon and loadgen together: | ||
|
|
||
| ```sh | ||
| export BENCH_PRIVATE_KEY=<funded-private-key> | ||
| export BENCH_ETH_RPC_URL=http://<ev-reth-host>:8545 | ||
| docker compose -f apps/loadgen/docker-compose.yml up | ||
| ``` | ||
|
|
||
| ## Matrix Format | ||
|
|
||
| Each entry specifies a spamoor scenario, tx counts, and optional probability: | ||
|
|
||
| ```json | ||
| { | ||
| "entries": [ | ||
| { | ||
| "test_name": "EOATransfer", | ||
| "scenario": "eoatx", | ||
| "timeout": "15m", | ||
| "env": { | ||
| "BENCH_NUM_SPAMMERS": "4", | ||
| "BENCH_COUNT_PER_SPAMMER": "10500", | ||
| "BENCH_THROUGHPUT": "200", | ||
| "BENCH_MAX_PENDING": "50000", | ||
| "BENCH_MAX_WALLETS": "200", | ||
| "BENCH_BASE_FEE": "500", | ||
| "BENCH_TIP_FEE": "50" | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| ``` | ||
|
|
||
| | Field | Description | | ||
| |---|---| | ||
| | `scenario` | spamoor scenario name (`eoatx`, `gasburnertx`, `erc20tx`, `uniswap-swaps`, etc.) | | ||
| | `probability` | 0.0-1.0, chance of running per invocation (omit = always run) | | ||
| | `timeout` | max duration per entry (default `15m`) | | ||
|
|
||
| When using `start` or `burst`, `BENCH_COUNT_PER_SPAMMER` is overridden by the computed per-run count. The matrix value is used as-is by `run`. | ||
|
|
||
| ## Build | ||
|
|
||
| ```sh | ||
| # binary | ||
| cd apps/loadgen && go build -o ev-loadgen . | ||
|
|
||
| # docker image | ||
| docker build -f apps/loadgen/Dockerfile -t ev-loadgen:dev . | ||
|
|
||
| # via just | ||
| just build-loadgen | ||
| just docker-build-loadgen | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| package cmd | ||
|
|
||
| import ( | ||
| "log" | ||
|
|
||
| "github.com/evstack/ev-node/apps/loadgen/internal/runner" | ||
| "github.com/evstack/ev-node/apps/loadgen/internal/spamoor" | ||
| "github.com/spf13/cobra" | ||
| ) | ||
|
|
||
| func newBurstCmd() *cobra.Command { | ||
| var ( | ||
| txCount int | ||
| matrixPath string | ||
| ) | ||
|
|
||
| cmd := &cobra.Command{ | ||
| Use: "burst", | ||
| Short: "trigger a single burst workload immediately", | ||
| Args: cobra.NoArgs, | ||
| RunE: func(cmd *cobra.Command, args []string) error { | ||
| api := spamoor.NewClient(resolveSpamoorURL()) | ||
|
|
||
| if err := runner.WaitForSync(cmd.Context(), api); err != nil { | ||
| return err | ||
| } | ||
|
|
||
| log.Printf("==> burst workload starting (%d tx)", txCount) | ||
| return runner.ExecuteMatrixWithOverridesFromFile(cmd.Context(), matrixPath, api, txCount) | ||
| }, | ||
| } | ||
|
|
||
| cmd.Flags().IntVar(&txCount, "tx-count", envIntOr("BENCH_BURST_TX_COUNT", 500000), "total transactions for the burst") | ||
| cmd.Flags().StringVar(&matrixPath, "burst-matrix", envStringOr("BENCH_BURST_MATRIX", defaultBurstPath), "path to burst matrix JSON") | ||
|
|
||
| return cmd | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| package cmd | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func TestStartFlags(t *testing.T) { | ||
| startCmd := newStartCmd() | ||
|
|
||
| err := startCmd.ParseFlags([]string{"--regular-matrix", "custom.json"}) | ||
| require.NoError(t, err) | ||
|
|
||
| // Since we can't easily access the cfg inside newStartCmd's closure from here | ||
| // without refactoring, we'll check if the flag is registered correctly. | ||
| flag := startCmd.Flags().Lookup("regular-matrix") | ||
| require.NotNil(t, flag) | ||
| require.Equal(t, "custom.json", flag.Value.String()) | ||
| } | ||
|
|
||
| func TestRunArgs(t *testing.T) { | ||
| runCmd := newRunCmd() | ||
| err := runCmd.Args(runCmd, []string{"matrix.json"}) | ||
| require.NoError(t, err) | ||
|
|
||
| err = runCmd.Args(runCmd, []string{}) | ||
| require.Error(t, err) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| package cmd | ||
|
|
||
| import ( | ||
| "github.com/evstack/ev-node/apps/loadgen/internal/spamoor" | ||
| "github.com/spf13/cobra" | ||
| ) | ||
|
|
||
| var spamoorFlag string | ||
|
|
||
| // NewRootCmd returns the top-level cobra command for ev-loadgen. | ||
| func NewRootCmd() *cobra.Command { | ||
| rootCmd := &cobra.Command{ | ||
| Use: "ev-loadgen", | ||
| Short: "benchmark runner for ev-node stress testing via spamoor", | ||
| } | ||
|
|
||
| rootCmd.PersistentFlags().StringVar(&spamoorFlag, "spamoor-url", "", "spamoor-daemon API URL (env: BENCH_SPAMOOR_URL)") | ||
|
|
||
| rootCmd.AddCommand(newRunCmd(), newStartCmd(), newBurstCmd()) | ||
|
|
||
| return rootCmd | ||
| } | ||
|
|
||
| func resolveSpamoorURL() string { | ||
| if spamoorFlag != "" { | ||
| return spamoorFlag | ||
| } | ||
| return spamoor.URL() | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package cmd | ||
|
|
||
| import ( | ||
| "github.com/evstack/ev-node/apps/loadgen/internal/runner" | ||
| "github.com/evstack/ev-node/apps/loadgen/internal/spamoor" | ||
| "github.com/spf13/cobra" | ||
| ) | ||
|
|
||
| func newRunCmd() *cobra.Command { | ||
| return &cobra.Command{ | ||
| Use: "run <matrix.json>", | ||
| Short: "run benchmarks from a matrix JSON file", | ||
| Args: cobra.ExactArgs(1), | ||
| RunE: func(cmd *cobra.Command, args []string) error { | ||
| return runner.ExecuteMatrixFromFile(cmd.Context(), args[0], spamoor.NewClient(resolveSpamoorURL())) | ||
| }, | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.