Skip to content
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

Kch/fix fee history #1

Open
wants to merge 85 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
2a0dcd5
add version checks to remote tests
sslivkoff Jul 12, 2023
fc0ed5a
refactor of many data structures and pipelines
sslivkoff Jul 14, 2023
af14a3f
bump version to 0.3.0a for testing
sslivkoff Jul 14, 2023
fd64682
tweaks for local testing
sslivkoff Jul 14, 2023
d0ab7e1
clean output messages
sslivkoff Jul 14, 2023
cdc736e
fix deep check tests
sslivkoff Jul 14, 2023
d0e4dd6
fix noqa format for github version of ruff
sslivkoff Jul 14, 2023
cf288b0
show client version on multiple lines for clarity
sslivkoff Jul 14, 2023
7a0e7ec
bump to toolcli 0.6.15
sslivkoff Jul 14, 2023
572c3f0
clip equality test diff summaries that are >100 lines long
sslivkoff Jul 14, 2023
9a92f3c
add various stateDiff and vmTrace calls to equality tests
sslivkoff Jul 14, 2023
f17215f
add debug_traceX methods to equality test
sslivkoff Jul 14, 2023
e3256e1
bump to latest ctc for debug traces
sslivkoff Jul 14, 2023
9c6e327
ruff linelength lints
sslivkoff Jul 14, 2023
68e2856
add initial log load test parameterizations
sslivkoff Jul 15, 2023
da1382c
Add vegeta PATH in Docker, fix #24 (#26)
AndreMiras Jul 15, 2023
0874165
add commit hash to installation.flood_version
sslivkoff Jul 15, 2023
d55af3f
have run() return test outputs for python calls
sslivkoff Jul 15, 2023
6b91c74
Merge branch 'main' of github.com:paradigm-operations/rpc_bench
sslivkoff Jul 15, 2023
6342f74
use custom version command to include commit hash and remotes
sslivkoff Jul 15, 2023
3f52adb
fix pyproject.toml dependencies (#25)
AndreMiras Jul 15, 2023
50ce90a
expand installation metadata and add update process
sslivkoff Jul 15, 2023
a454760
follow symlinks of installation path
sslivkoff Jul 15, 2023
b40ab09
add update command
sslivkoff Jul 16, 2023
d5c8a7c
fix pass vegeta_kwargs through call chain
sslivkoff Jul 16, 2023
8734a74
fix check on null git dir
sslivkoff Jul 16, 2023
c9c9a97
change vegeta_kwargs to vegeta_args
sslivkoff Jul 16, 2023
b499c37
implement remote version of update
sslivkoff Jul 16, 2023
7cd1ac0
fix cli passthrough of single vegeta args
sslivkoff Jul 16, 2023
d7b36bc
update to toolcli 0.6.16
sslivkoff Jul 16, 2023
15c7f3b
allow generating xxl block ranges using only xl sample
sslivkoff Jul 16, 2023
048808d
completely avoid generating test clientside when running remote tests
sslivkoff Jul 16, 2023
6cf83fd
specify --work-tree alongside --git-dir in update command
sslivkoff Jul 16, 2023
d3f6db6
use timestamp as default random seed
sslivkoff Jul 16, 2023
ca80e9c
improve cli arg help messages
sslivkoff Jul 16, 2023
4bc0663
add eth_feeHistory load test
sslivkoff Jul 16, 2023
6f70daf
use orjson for encoding/decoding of large json
sslivkoff Jul 16, 2023
0167d65
change --nodes to a positional argument in update command
sslivkoff Jul 16, 2023
1ba1b28
flesh put deep check metrics for failed requests
sslivkoff Jul 17, 2023
f5700e0
clean output formatting of deep check summaries
sslivkoff Jul 17, 2023
3cbf6fc
save additional metadata alongside each test
sslivkoff Jul 17, 2023
c897403
move metadata into SingleRunTestPayload instead of RunOutput
sslivkoff Jul 17, 2023
b86e1cc
Fix polars dependency (#30)
AndreMiras Jul 17, 2023
d42318d
Add Docker build to the CI (#31)
AndreMiras Jul 17, 2023
dcf73c5
Drop the checkthechain clone (#32)
AndreMiras Jul 17, 2023
923f883
add aggregation mode to print cli command
sslivkoff Jul 17, 2023
1c094f9
Merge branch 'main' of github.com:paradigm-operations/rpc_bench
sslivkoff Jul 17, 2023
9e698b0
Docker run from the CI, fixes #34 (#35)
AndreMiras Jul 19, 2023
0e0b58c
use slim python image and multi-stage build
lgingerich Jul 20, 2023
4d3776b
fix Vegeta location
lgingerich Jul 25, 2023
67d3695
fix ruff regression
sslivkoff Jul 26, 2023
8e2cdc2
Improve docs (#38)
sslivkoff Jul 27, 2023
61104d4
add docker notes
sslivkoff Jul 27, 2023
a1a585f
clean toplevel namespace (#39)
sslivkoff Jul 27, 2023
180545e
remove spurious report
sslivkoff Jul 27, 2023
f899efc
update report generation pipeline for namespace refactor
sslivkoff Jul 27, 2023
7b22858
move user guide into readme
sslivkoff Jul 27, 2023
5b169db
add ToC to README.md
sslivkoff Jul 27, 2023
18e182a
fix single node report generation
sslivkoff Jul 28, 2023
453f5a4
update reports with more info
sslivkoff Jul 28, 2023
f1162e5
clean up load test output
sslivkoff Jul 28, 2023
dfa85e9
bump to 0.3.0
sslivkoff Jul 28, 2023
c8a153a
fix version checks for tagged commits
sslivkoff Jul 28, 2023
6164493
bump to 0.3.1
sslivkoff Jul 28, 2023
eb88711
Update README.md with report example (#44)
ZanePeycke Aug 30, 2023
03f93c4
Fix missing curl binary and update CI (#45)
AndreMiras Aug 30, 2023
a0a952e
Merge remote-tracking branch 'upstream/main'
kamilchodola Dec 5, 2023
2d4e771
Remove not needed import
kamilchodola Dec 5, 2023
410f259
eth_call
kamilchodola Feb 21, 2024
caf5325
fixversion
kamilchodola Feb 21, 2024
6a20cb3
fix
kamilchodola Feb 21, 2024
7e41e3d
fix
kamilchodola Feb 21, 2024
9de4232
fixx
kamilchodola Feb 21, 2024
ef14f6a
revert
kamilchodola Feb 21, 2024
6e42b88
fix
kamilchodola Feb 21, 2024
9de7231
recent start/end block for eth_call
kamilchodola Feb 21, 2024
961a276
remove not needed files
kamilchodola Feb 21, 2024
1af935b
Update __init__.py
kamilchodola Mar 19, 2024
33b9cdb
Add proper blocks for all calls
kamilchodola Mar 19, 2024
2cbbc06
Add missing support
kamilchodola Mar 19, 2024
b94f89b
Merge branch 'eth_call_perf' of https://github.com/kamilchodola/flood…
kamilchodola Mar 19, 2024
afef637
Merge pull request #1 from kamilchodola/eth_call_perf
kamilchodola Mar 19, 2024
ed6f2a8
Fix start_blocks
kamilchodola Mar 25, 2024
46d6dc9
Fix order of params in feeHistory
kamilchodola Apr 17, 2024
9b80ddf
Add transaction hash from generation
kamilchodola Apr 17, 2024
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
25 changes: 25 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Docker

on:
push:
branches:
- main
pull_request:

jobs:
docker:
strategy:
matrix:
test: ["eth_getBalance", "eth_getBlockByNumber"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: docker/setup-buildx-action@v2
- run: docker build --tag paradigmxyz/flood:latest .
- run: docker run --rm paradigmxyz/flood:latest version
- name: ${{ matrix.test }}
run: |
docker run --rm paradigmxyz/flood:latest \
${{ matrix.test }} \
node1=https://eth.llamarpc.com \
--duration 3 --rate 1
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@ dist/*
notebooks/*
roadmap/*
todo/*
graveyard.py

*.ipynb
*.html
47 changes: 27 additions & 20 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,32 +1,39 @@
# uploaded to GitHub Container Registry
# https://github.com/paradigmxyz/flood/pkgs/container/flood

FROM python:3.11.3

# create user
# Stage 1: Install flood
FROM python:3.11-slim AS flood-builder
ENV USERNAME="flood"
ENV PATH="${PATH}:/home/${USERNAME}/.local/bin"
RUN adduser $USERNAME
USER $USERNAME

# install flood
RUN mkdir /home/$USERNAME/repos
COPY ./ /home/$USERNAME/repos/flood/
WORKDIR /home/$USERNAME/repos/flood
RUN pip install ./
RUN pip install --user --no-cache-dir ./

# Stage 2: Install vegeta
FROM debian:stable-slim AS vegeta-builder
ENV VEGETA_VERSION=12.8.4
RUN apt-get update && apt-get install -y --no-install-recommends wget ca-certificates \
&& rm -rf /var/lib/apt/lists/* \
&& mkdir /vegeta
WORKDIR /vegeta
RUN wget https://github.com/tsenart/vegeta/releases/download/v${VEGETA_VERSION}/vegeta_${VEGETA_VERSION}_linux_amd64.tar.gz \
&& tar xzf vegeta_${VEGETA_VERSION}_linux_amd64.tar.gz \
&& rm vegeta_${VEGETA_VERSION}_linux_amd64.tar.gz

# install ctc
WORKDIR /home/$USERNAME/repos
RUN git clone https://github.com/checkthechain/checkthechain
WORKDIR /home/$USERNAME/repos/checkthechain
RUN pip install ./
# Final stage: Combine flood and vegeta
FROM python:3.11-slim
ENV USERNAME="flood"
ENV PATH="${PATH}:/home/${USERNAME}/.local/bin"
RUN adduser $USERNAME

# # install vegeta
RUN mkdir -p /home/$USERNAME/bin/vegeta
WORKDIR /home/$USERNAME/bin/vegeta_files
RUN wget https://github.com/tsenart/vegeta/releases/download/v12.8.4/vegeta_12.8.4_linux_amd64.tar.gz
RUN tar xzf vegeta_12.8.4_linux_amd64.tar.gz
WORKDIR /home/$USERNAME/bin/
RUN ln -s /home/$USERNAME/bin/vegeta_files/vegeta /home/$USERNAME/bin/vegeta
RUN apt-get update && apt-get install -y --no-install-recommends curl \
&& rm -rf /var/lib/apt/lists/*
COPY --from=flood-builder /home/$USERNAME/.local /home/$USERNAME/.local
COPY --from=vegeta-builder /vegeta/vegeta /home/$USERNAME/.local/bin/vegeta

# run flood
USER $USERNAME
WORKDIR /home/$USERNAME
ENTRYPOINT ["python", "-m", "flood"]

99 changes: 81 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
![](./assets/cover.png)

[![CI status](https://github.com/paradigmxyz/flood/workflows/Pytest/badge.svg)][gh-ci]
[![Docker](https://github.com/paradigmxyz/flood/actions/workflows/docker.yml/badge.svg)][gh-docker]
[![Telegram Chat][tg-badge]][tg-url]

[gh-ci]: https://github.com/paradigmxyz/flood/actions/workflows/ci.yml
[gh-docker]: https://github.com/paradigmxyz/flood/actions/workflows/docker.yml
[tg-badge]: https://img.shields.io/endpoint?color=neon&logo=telegram&label=chat&url=https%3A%2F%2Ftg.sumanjay.workers.dev%2Fparadigm%5Fflood
[tg-url]: https://t.me/paradigm_flood

Expand All @@ -24,6 +26,21 @@ For each RPC method, `flood` measures how load affects metrics such as:

`flood` can generate tables, figures, and reports for easy sharing of results (example report [here](https://datasets.paradigm.xyz/notebooks/flood/example_report.html))

## Contents
1. ### [Installation](#installation)
1. [Prerequisites](#prerequisites)
2. [Installing Flood](#installing-flood)
3. [Docker](#docker)
2. ### [Usage Guide](#usage-guide)
1. [Basic Load Tests](#basic-load-tests)
2. [Remote Load Tests](#remote-load-tests)
3. [Printing Test Results](#printing-test-results)
4. [Report Generation](#report-generation)
5. [Differential Tests](#differential-tests)
6. [From Python](#from-python)
7. [Performing Deep Checks](#performing-deep-checks)
3. ### [Contributing](#contributing)


## Installation

Expand All @@ -45,29 +62,75 @@ pip install paradigm-flood

Typing `flood help` in your terminal should show help output. If it does not, you probably have not set up `pip` to install items to your `$PATH`. You may need to add something like `export PATH=$PATH:~/.local/bin` to your terminal config file (e.g. `~/.profile`). Alternatively, you can avoid setting up your `$PATH` and just type `python3 -m flood` instead of `flood`.

## Usage
#### Docker

#### run test
```
flood eth_getBlockByNumber NODE1_NAME=NODE1_URL NODE2_NAME=NODE2_URL --rates 10 100 1000 --duration 30
```
Alternatively, flood can be used as a [Docker image](https://github.com/paradigmxyz/flood/pkgs/container/flood).

#### orchestrate tests on remote nodes
```
flood eth_getBlockByNumber NODE1_NAME=NODE1_URL:localhost:8545 NODE2_NAME=NODE2_URL:localhost:8545
```
## Usage guide

#### create report
```
flood report tests/test1_output tests/test2_output
````
`flood` works by bombarding an RPC endpoint with different patterns of RPC calls. Measurements of the RPC endpoint's performance under different controlled loads are then used to paint a detailed view of the node's performance.

Every time flood runs, it saves its parameters and test results to an output directory. You can specify this output directory with the `--output` parameter, otherwise a temporary directory will be created. Running a test will populate the folder with the following files:
- `figures/`: directory containing PNG's summarizing node performance
- `results.json`: results of the test including performance metrics
- `summary.txt`: printed summary of test that was output to the console
- `test.json`: metadata and parameters used to create and run the test

### Basic load tests

Here is an example of a basic test with `flood`. It will benchmark block retrieval from two different nodes. It will test at 3 different rates (10, 100, and 1000 requests per second) and it will test them for 30 seconds each.

`flood eth_getBlockByNumber NODE1_NAME=NODE1_URL NODE2_NAME=NODE2_URL --rates 10 100 1000 --duration 30`

To see all of the parameters available for controlling `flood` tests use `flood --help`

### Remote load tests

Instead of broadcasting RPC calls from whatever machine running the `flood` CLI command, `flood` can broadcast the calls from a remote process on a remote machine. In particular, `flood` can broadcast the calls from the same machine that is running the EVM node in order to eliminate any noise or bottlenecks associated with networking.

This can be accomplished by installing flood on the remote machine and then providing `flood` with login credentials and routing details using the following syntax:

`flood <test> [node_name=][username@]hostname:[test_url] ...`

For example, the following command will test a reth node and an erigon node remotely:

`flood eth_call [email protected]:localhost:8545 [email protected]:localhost:8545`

If there are multiple remote tests, these tests will be run in parallel. After the tests are complete, `flood` will retrieve the results and summarize using the same methodology as a local test.

### Printing test results

By default `flood` produces verbose output of each test as it runs. This can be disabled with the `--quiet` parameter. To re-print the results of an old test, use `flood print <TEST_DIR>`. To print a summary of multiple tests, use `flood print <test_1_dir> <test_2_dir>`.

### Report generation

After running tests, you can generate an HTML + Jupyter report similar to [this](https://datasets.paradigm.xyz/notebooks/flood/example_report.html) one. This is done by running `flood report <TEST_DIR>`. Multiple tests can be combined into one report with `flood repos <TEST_DIR_1> <TEST_DIR_2> ...`.

### Differential tests

Instead of testing the raw performance of an RPC node, `flood` can be used to test the correctness of a node's responses using a differential testing approach. This works by using two nodes and making sure that their responses match under a variety of RPC calls. This is done using the `--equality` parameter. For example:

`flood all reth=91.91.91.91 erigon=92.92.92.92 --equality`

### From python

All of `flood`'s functionality can be used from python instead of the CLI. Some functions:

|description|python|
|-|-|
|Import flood|`import flood`|
|Run tests|`flood.run(...)`|
|Load the parameters of a test|`flood.load_single_run_results_payload(output_dir)`|
|Load the results of a test|`flood.load_single_run_results_payload(output_dir)`|
|Run a live version of a results notebook|`jupyter notebook <TEST_DIR>`|

### Performing deep checks

Under normal operation `flood` relies on vegeta to compute performance summaries of each test. This works well, but sometimes it is desirable to implement custom introspection not available in `vegeta`.

## Code Layout
- `flood/cli`: command line interface
- `flood/generators`: utilities for generating rpc calls with parameterized distributions
- `flood/tests`: implementations of load tests and equality tests
- `flood/user_io`: utiltiies for parsing user io
In particular, `vegeta` counts any status-200 response as a success, even if the contents of the response is an RPC error. Running with the `--deep-check` command will check every response to make sure that it returns well-formed JSON with no RPC errors. With `--deep-check`, `flood` also computes separate performance statistics successful vs failed calls.

If you want to save the timing information and raw contents of every single response from the test to the `results.json` output, use the `--save-raw-output` argument. This allows for performing own custom analyses on the raw data.

## Contributing

Expand Down
28 changes: 21 additions & 7 deletions flood/__init__.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,38 @@
"""tool for benchmarking RPC endpoints"""
# ruff: noqa: F401

from .generators import *
from .runners import *
from .spec import *
from .tests import *
from .user_io import *
import flood.generators
import flood.ops
import flood.runners
import flood.tests
import flood.user_io

from flood.generators import generate_test
from flood.ops import get_flood_version
from flood.ops import get_local_installation
from flood.ops import get_remote_installation
from flood.ops import get_dependency_versions
from flood.runners import load_single_run_test_payload
from flood.runners import load_single_run_results_payload
from flood.runners import run
from flood.tests.equality_tests import run_equality_test
from flood.tests.load_tests import run_load_test
from flood.tests.load_tests import run_load_tests

__version__ = '0.2.5'

__version__ = '0.3.1'


def _clean_package_imports() -> None:
"""remove deep nested modules from flood namespace"""

import sys

flood = sys.modules['flood']
flood_module = sys.modules['flood']
moduletype = type(flood)
delattr(flood, 'annotations')
for key, value in tuple(vars(flood).items()):
for key, value in tuple(vars(flood_module).items()):
if isinstance(value, moduletype):
name = value.__name__
if not name.startswith('flood') or name.count('.') > 1:
Expand Down
9 changes: 4 additions & 5 deletions flood/cli/cli_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

def cd_dir_getter(dirname: str) -> str:
if dirname == 'samples':
return flood.get_flood_samples_dir()
return flood.generators.get_flood_samples_dir()
else:
raise Exception('unknown path: ' + str(dirname))

Expand All @@ -26,10 +26,9 @@ def run_cli(raw_command: str | None = None) -> None:
('samples', 'collect'): 'flood.cli.samples_collect_command',
('samples', 'download'): 'flood.cli.samples_download_command',
('samples', 'ls'): 'flood.cli.samples_ls_command',
(
'version',
): 'toolcli.command_utils.standard_subcommands.version_command',
('version',): 'flood.cli.version_command',
('cd',): 'toolcli.command_utils.standard_subcommands.cd_command',
('update',): 'flood.cli.update_command',
}

config: toolcli.CLIConfig = {
Expand All @@ -40,7 +39,7 @@ def run_cli(raw_command: str | None = None) -> None:
'root_help_arguments': True,
# 'root_help_subcommands': False,
'include_debug_arg': True,
'style_theme': flood.styles,
'style_theme': flood.user_io.styles,
'cd_dir_help': cd_dir_help,
'cd_dir_getter': cd_dir_getter,
}
Expand Down
16 changes: 9 additions & 7 deletions flood/cli/ls_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,26 @@ def get_command_spec() -> toolcli.CommandSpec:
def ls_command() -> None:
import toolstr

styles = flood.user_io.styles

toolstr.print_text_box(
'Available tests',
text_style=flood.styles['metavar'],
style=flood.styles['content'],
text_style=styles['metavar'],
style=styles['content'],
)

print()
toolstr.print_header(
'Single Load Tests',
style=flood.styles['content'],
text_style=flood.styles['metavar'],
style=styles['content'],
text_style=styles['metavar'],
)
for test in flood.get_single_test_generators():
for test in flood.generators.get_single_test_generators():
toolstr.print_bullet(key=test, value='', colon_str='')
print()
toolstr.print_header(
'Multi Load Tests',
style=flood.styles['content'],
text_style=flood.styles['metavar'],
style=styles['content'],
text_style=styles['metavar'],
)
toolstr.print_bullet(key='all', value='', colon_str='')
Loading