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

Feat/docker run commands from sh #13

Merged
merged 8 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
8 changes: 5 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
LOG_LEVEL="info" # debug, info, warn, error
LOG_LEVEL="info" # debug, info, warn, error
WORKER_NUM=10 # Number of workers to run concurrent alchemy/EL node requests
WHALE_THRESHOLD=100 # Threshold for whale detection (min amount of validators)

# UPDATE THESE VALUES
DB_URL="postgres://user:password@localhost:5432/dbName" # URL to connect to the postgres database
WORKER_NUM=15 # Number of workers to run concurrent alchemy/EL node requests
ALCHEMY_URL="https://eth-mainnet.g.alchemy.com/v2/KEY" # Alchemy API URL
EL_ENDPOINT="http://localhost:8545" # Ethereum Layer 1 endpoint, can also be alchemy or infura
WHALE_THRESHOLD=100 # Threshold for whale detection (min amount of validators)

DATABASE_NAME=name # Your database name
DATABASE_USERNAME=user # Your database username
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ ADD . .
RUN go get
RUN go build -o ./build/eth_pokhar


FROM alpine:latest
WORKDIR /
COPY --from=builder /app/build/eth_pokhar ./
COPY --from=builder /app/db/migrations ./db/migrations

ENTRYPOINT ["sh", "-c"]
COPY --from=builder /app/run.sh ./run.sh
RUN chmod +x ./run.sh
CMD [ "sh", "./run.sh" ]
santi1234567 marked this conversation as resolved.
Show resolved Hide resolved
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ Finally, run the tool with the following command:
docker-compose up -d
```

In case that you don't want to update de depositor transactions (which can take up to 20 hours), you can run the following command:

```bash
ONLY_DEPOSITS=true docker-compose up -d
santi1234567 marked this conversation as resolved.
Show resolved Hide resolved
```

This will set the [`--only-deposits`](#beacon_depositors_transactions) flag to true.

## Output

The tool will create a database with the following tables:
Expand Down
25 changes: 8 additions & 17 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,14 @@ services:
context: ./
dockerfile: Dockerfile
init: true
command: >-
"
./eth_pokhar beacon_depositors_transactions
--log-level=${LOG_LEVEL}
--el-endpoint=${EL_ENDPOINT}
--db-url=${DB_URL}
--workers-num=${WORKER_NUM}
--alchemy-url=${ALCHEMY_URL}
&&
./eth_pokhar identify
--log-level=${LOG_LEVEL}
--el-endpoint=${EL_ENDPOINT}
--db-url=${DB_URL}
--workers-num=${WORKER_NUM}
--alchemy-url=${ALCHEMY_URL}
--recreate-table"
--whale-threshold=${WHALE_THRESHOLD}
environment:
- LOG_LEVEL=${LOG_LEVEL}
- EL_ENDPOINT=${EL_ENDPOINT}
- DB_URL=${DB_URL}
- WORKER_NUM=${WORKER_NUM}
- ALCHEMY_URL=${ALCHEMY_URL}
- WHALE_THRESHOLD=${WHALE_THRESHOLD}
- ONLY_DEPOSITS=${ONLY_DEPOSITS:-false}
network_mode: "host"
depends_on:
db:
Expand Down
12 changes: 12 additions & 0 deletions run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

echo ${ONLY_DEPOSITS}

# If ONLY_DEPOSITS is true then use --only-deposits flag, else use the default
if [ "${ONLY_DEPOSITS}" = "true" ]; then
./eth_pokhar beacon_depositors_transactions --log-level=${LOG_LEVEL} --el-endpoint=${EL_ENDPOINT} --db-url=${DB_URL} --workers-num=${WORKER_NUM} --alchemy-url=${ALCHEMY_URL} --only-deposits
else
./eth_pokhar beacon_depositors_transactions --log-level=${LOG_LEVEL} --el-endpoint=${EL_ENDPOINT} --db-url=${DB_URL} --workers-num=${WORKER_NUM} --alchemy-url=${ALCHEMY_URL}
fi

./eth_pokhar identify --log-level=${LOG_LEVEL} --el-endpoint=${EL_ENDPOINT} --db-url=${DB_URL} --workers-num=${WORKER_NUM} --alchemy-url=${ALCHEMY_URL} --recreate-table --whale-threshold=${WHALE_THRESHOLD}