This repository has been archived by the owner on Nov 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 266
instructions for running without kubernetes ('monolithic mode') #324
Open
pintail-xyz
wants to merge
2
commits into
flashbots:main
Choose a base branch
from
pintail-xyz:monolithic-instructions
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 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 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,101 @@ | ||
# Running mev-inspect-py without kubernetes ('monolithic mode') | ||
|
||
Running mev-inspect-py outside of kubernetes can be useful for debug purposes. In this case, the steps for installation are: | ||
1. Install dependencies (pyenv, poetry, postgres) | ||
1. Set up python virtual environment using matching python version (3.9.x) and install required python modules using poetry | ||
1. Create postgres database | ||
1. Run database migrations | ||
|
||
The database credentials and archive node address used by mev-inspect-py need to be loaded into environment variables (both for database migrations and to run mev-inspect-py). | ||
|
||
## Ubuntu install instructions | ||
|
||
So, starting from a clean Ubuntu 22.04 installation, the prerequisites for pyenv, psycopg2 (python3-dev libpq-dev) and postgres (postgresql postgresql-contrib) can be installed with | ||
|
||
`sudo apt install -y make build-essential git libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev liblzma-dev python3-dev libpq-dev postgresql postgresql-contrib` | ||
|
||
### pyenv | ||
Install pyenv using the web installer | ||
|
||
`curl https://pyenv.run | bash` | ||
|
||
and add the following to `~/.bashrc` (if running locally) or `~/.profile` (if running over ssh). | ||
|
||
``` | ||
export PYENV_ROOT="$HOME/.pyenv" | ||
command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH" | ||
eval "$(pyenv init -)" | ||
``` | ||
|
||
Then update the current shell by running `source ~/.bashrc` or `source ~/.profile` as appropriate. | ||
|
||
### Poetry | ||
|
||
Install Poetry using the web installer | ||
|
||
`curl -sSL https://install.python-poetry.org | python3 -` | ||
|
||
add the following to `~/.bashrc` (if running locally) or `~/.profile` (if running over ssh) | ||
|
||
`export PATH="/home/user/.local/bin:$PATH"` | ||
|
||
If running over ssh you should also add the following to `~/.profile` to prevent [Poetry errors](https://github.com/python-poetry/poetry/issues/1917) from a lack of active keyring: | ||
|
||
`export PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring` | ||
|
||
Again update current shell by running `source ~/.bashrc` or `source ~/.profile` as appropriate. | ||
|
||
### mev-inspect-py | ||
|
||
With all dependencies now installed, clone the mev-inspec-py repo | ||
``` | ||
git clone https://github.com/flashbots/mev-inspect-py.git | ||
cd mev-inspect-py | ||
``` | ||
We now install the required pythn version and use Poetry to install the required python modules into a virtual environment. | ||
|
||
``` | ||
pyenv install 3.9.16 | ||
pyenv local 3.9.16 | ||
poetry env use 3.9.16 | ||
poetry install | ||
``` | ||
|
||
### Create database | ||
mev-inspect-py outputs to a postgres database, so we need to set this up. | ||
``` | ||
sudo -u postgres psql | ||
\password | ||
[set a password at the prompt] | ||
create database mev_inspect; | ||
\q | ||
``` | ||
### Environment variables | ||
We will need to set a few environment variables to use mev-inspect-py. **These will be required every time mev-inspect-py runs**, so again you may wish to add these to your `~/.bashrc` and/or `~/.profile` as appropriate. Note that you need to substitute your password and archive node URL in the below. | ||
``` | ||
export POSTGRES_USER=postgres | ||
export POSTGRES_PASSWORD=[the password you set above] | ||
export POSTGRES_HOST=localhost | ||
export RPC_URL="http://127.0.0.1:8545" | ||
``` | ||
### Database migrations | ||
Finally run the database migrations and fetch price information: | ||
|
||
``` | ||
poetry run alembic upgrade head | ||
poetry run fetch-all-prices | ||
``` | ||
|
||
## Usage instructions | ||
The same functionality available through kubernetes can be run in 'monolithic mode', but the relevant functions now need to be invoked by Poetry directly. So to inspect a single block, run for example: | ||
|
||
`poetry run inspect-block 16379706` | ||
|
||
Or to inspect a range of blocks: | ||
|
||
`poetry run inspect-many-blocks 16379606 16379706` | ||
|
||
Or to run the test suite: | ||
|
||
`poetry run pytest tests` | ||
|
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe you'd want to give instructions for running postgres in a docker container, like
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now added.