-
Notifications
You must be signed in to change notification settings - Fork 264
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
Open
chatton
wants to merge
15
commits into
main
Choose a base branch
from
cian/benchmarks-binary
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
923248b
feat: benchmarks container image
auricom dcc24e8
fix: entrypoint
auricom 7a00d39
fix
auricom cd8f880
Fix typo in README for benchmark runner command
auricom 08c8a36
Update Dockerfile to copy ev-benchmarks
auricom a60bf87
Update crontab
auricom 57b02f2
feat(benchmarks): add ev-benchmarks cobra CLI for stress testing via …
chatton d39de67
feat(benchmarks): replace supercronic with in-process scheduler
chatton 6a92190
feat(loadgen): rename benchmarks app and add tests
chatton 5d5fce0
chore: simplify ci, use struct instead of raw json in tests
chatton 8188e91
chore: rename bench -> loadgen
chatton 1ece273
chore: use correct block height
chatton 3e6d05e
Merge branch 'main' into cian/benchmarks-binary
chatton 7ad0018
fix(loadgen): address PR review feedback
chatton 9f5d982
chore: ensure possibility for concurrent spammers if time window is s…
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,129 @@ | ||
| # loadgen | ||
|
|
||
| Standalone load generator for ev-node stress testing. Talks to a [spamoor-daemon](https://github.com/ethpandaops/spamoor) sidecar via HTTP API. Runs an in-process scheduler with configurable regular and burst workloads. | ||
|
|
||
| ## 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 | ||
|
|
||
| ## Commands | ||
|
|
||
| ```text | ||
| ev-loadgen start # run continuous scheduler (regular + burst) | ||
| ev-loadgen check # send 1 tx to verify spamoor → ev-reth connectivity | ||
| ev-loadgen run <matrix.json> # one-shot: run a custom matrix file | ||
| ``` | ||
|
|
||
| ### 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` | `2` | bursts per day, randomly spaced | | ||
| | `--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 | | ||
|
|
||
| Global flag: `--spamoor-url` (or `BENCH_SPAMOOR_URL` env, default `http://spamoor-daemon:8080`) | ||
|
|
||
| ### Scheduling | ||
|
|
||
| - **Regular**: fires immediately at startup, then repeats at `--interval`. Per-run tx count = `tx-per-day / (24h / interval)`. Overrides each matrix entry's `BENCH_COUNT_PER_SPAMMER`. | ||
| - **Burst**: at startup + each midnight UTC, generates N random times across the day. Each burst overrides `BENCH_COUNT_PER_SPAMMER` = `burst-tx-count / NumSpammers`. | ||
| - **Serialization**: a mutex prevents concurrent spamoor access. If burst fires during regular (or vice versa), it waits for the lock. | ||
|
|
||
| ## 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 . | ||
|
|
||
| # run with defaults (~1M tx/day, 2 bursts/day) | ||
| ./ev-loadgen start --spamoor-url=http://localhost:8080 | ||
|
|
||
| # custom config | ||
| ./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`, the `BENCH_COUNT_PER_SPAMMER` value in the matrix is overridden by the computed per-run count. The matrix value is still used by the `run` command. | ||
|
|
||
| ## 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,25 @@ | ||
| package cmd | ||
|
|
||
| import ( | ||
| "time" | ||
|
|
||
| "github.com/evstack/ev-node/apps/loadgen/internal" | ||
| "github.com/spf13/cobra" | ||
| ) | ||
|
|
||
| func newCheckCmd() *cobra.Command { | ||
| var timeout time.Duration | ||
|
|
||
| cmd := &cobra.Command{ | ||
| Use: "check", | ||
| Short: "verify connectivity by sending a single eoatx through spamoor to ev-reth", | ||
| Args: cobra.NoArgs, | ||
| RunE: func(cmd *cobra.Command, args []string) error { | ||
| return internal.RunCheck(cmd.Context(), resolveSpamoorURL(), timeout) | ||
| }, | ||
| } | ||
|
|
||
| cmd.Flags().DurationVar(&timeout, "timeout", 60*time.Second, "max time to wait for tx") | ||
|
|
||
| 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" | ||
| "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(), newCheckCmd()) | ||
|
|
||
| return rootCmd | ||
| } | ||
|
|
||
| func resolveSpamoorURL() string { | ||
| if spamoorFlag != "" { | ||
| return spamoorFlag | ||
| } | ||
| return internal.SpamoorURL() | ||
| } |
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,17 @@ | ||
| package cmd | ||
|
|
||
| import ( | ||
| "github.com/evstack/ev-node/apps/loadgen/internal" | ||
| "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 internal.ExecuteMatrixFromFile(cmd.Context(), args[0], internal.NewSpamoorClient(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.