Skip to content

Commit

Permalink
Merge pull request eth-educators#266 from yorickdowne/main
Browse files Browse the repository at this point in the history
Initial support for Lodestar consensus client
  • Loading branch information
yorickdowne authored Jul 2, 2021
2 parents 434a8eb + 31e871b commit 4a68611
Show file tree
Hide file tree
Showing 10 changed files with 271 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ If we've helped you out, in-person or by creating this project, a tip will be ve

# Version

This is eth-docker v1.3.3.2
This is eth-docker v1.4
6 changes: 6 additions & 0 deletions default.env
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ BEACON_STATS_API=
# going to use something other than defaults.
EC_P2P_PORT=30303
LH_PORT=9000
LS_PORT=9000
PRYSM_PORT=13000
PRYSM_UDP_PORT=12000
NIM_PORT=9000
Expand Down Expand Up @@ -97,6 +98,11 @@ PRYSM_SRC_BUILD_TARGET=$(git describe --tags $(git rev-list --tags --max-count=1
PRYSM_DOCKER_TAG=stable
PRYSM_DOCKERFILE=Dockerfile.binary

# Lodestar
LS_SRC_BUILD_TARGET=$(git describe --tags $(git rev-list --tags --max-count=1))
LS_DOCKER_TAG=latest
LS_DOCKERFILE=Dockerfile.binary

# Erigon
ERIGON_SRC_BUILD_TARGET=$(git describe --tags $(git rev-list --tags --max-count=1))
ERIGON_DOCKER_TAG=latest
Expand Down
2 changes: 1 addition & 1 deletion eth-deposit-cli/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ RUN mkdir -p /src
WORKDIR /src
RUN bash -c "git clone https://github.com/ethereum/eth2.0-deposit-cli.git && cd eth2.0-deposit-cli && git config advice.detachedHead false && git fetch --all --tags && git checkout ${BUILD_TARGET}"

FROM python:3.7-alpine
FROM python:3.9-alpine

ARG USER=depcli
ARG UID=1000
Expand Down
2 changes: 2 additions & 0 deletions lh-consensus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ services:
- BUILD_TARGET=${LH_SRC_BUILD_TARGET}
- DOCKER_TAG=${LH_DOCKER_TAG}
image: lighthouse:local
user: root
stop_grace_period: 1m
volumes:
- lhconsensus-data:/var/lib/lighthouse
Expand All @@ -20,6 +21,7 @@ services:
expose:
- 5052/tcp
entrypoint:
- docker-entrypoint.sh
- lighthouse
- bn
- --disable-upnp
Expand Down
145 changes: 145 additions & 0 deletions lodestar-base.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
version: "3.4"
services:
consensus:
restart: "${RESTART}"
build:
context: ./lodestar
dockerfile: ${LS_DOCKERFILE}
args:
- BUILD_TARGET=${LS_SRC_BUILD_TARGET}
- DOCKER_TAG=${LS_DOCKER_TAG}
image: lodestar:local
user: lsconsensus
stop_grace_period: 1m
volumes:
- lsconsensus-data:/var/lib/lodestar/consensus
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
ports:
- ${LS_PORT}:${LS_PORT}/tcp
- ${LS_PORT}:${LS_PORT}/udp
expose:
- 9596/tcp
entrypoint:
- node
- --max-old-space-size=8192
- /usr/app/packages/cli/bin/lodestar
- beacon
- --rootDir
- /var/lib/lodestar/consensus
- --api.rest.enabled
- "true"
- --api.rest.host
- 0.0.0.0
- --network.discv5.bindAddr
- "/ip4/0.0.0.0/udp/${LS_PORT}"
- --network.localMultiaddrs
- "/ip4/0.0.0.0/tcp/${LS_PORT}"
- --eth1.providerUrl
- ${EC_NODE}
- --logLevel
- ${LOG_LEVEL}
- --network
- ${NETWORK}
validator:
restart: "${RESTART}"
build:
context: ./lodestar
dockerfile: ${LS_DOCKERFILE}
args:
- BUILD_TARGET=${LS_SRC_BUILD_TARGET}
- DOCKER_TAG=${LS_DOCKER_TAG}
image: lodestar:local
user: lsvalidator
volumes:
- lsvalidator-data:/var/lib/lodestar/validators
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
entrypoint:
- node
- --max-old-space-size=8192
- /usr/app/packages/cli/bin/lodestar
- validator
- --rootDir
- /var/lib/lodestar/validators
- --server
- http://consensus:9596
- --graffiti
- ${GRAFFITI}
- --logLevel
- ${LOG_LEVEL}
- --network
- ${NETWORK}
validator-import:
restart: "${RESTART}"
image: lodestar:local
user: root
volumes:
- lsvalidator-data:/var/lib/lodestar/validators
- ${DEPCLI_LOCALDIR}/validator_keys:/validator_keys
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
entrypoint:
- validator-import.sh
- node
- --max-old-space-size=8192
- /usr/app/packages/cli/bin/lodestar
- account
- validator
- import
- --rootDir
- /var/lib/lodestar/validators
- --directory
- /val_keys
- --network
- ${NETWORK}
validator-exit:
restart: "no"
image: lodestar:local
user: lsvalidator
volumes:
- lsvalidator-data:/var/lib/lodestar/validators
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
entrypoint:
- node
- --max-old-space-size=8192
- /usr/app/packages/cli/bin/lodestar
- account
- validator
- voluntary-exit
- --rootDir
- /var/lib/lodestar/validators
- --server
- http://consensus:9596
- --logLevel
- ${LOG_LEVEL}
- --network
- ${NETWORK}
validator-account:
restart: "no"
image: lodestar:local
user: lsvalidator
volumes:
- lsvalidator-data:/var/lib/lodestar/validators
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
entrypoint:
- node
- --max-old-space-size=8192
- /usr/app/packages/cli/bin/lodestar
- account
- validator
- --rootDir
- /var/lib/lodestar/validators
- --network
- ${NETWORK}
eth:
image: tianon/true
restart: "no"
depends_on:
- consensus
- validator
volumes:
lsconsensus-data:
lsvalidator-data:
44 changes: 44 additions & 0 deletions lodestar/Dockerfile.binary
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
ARG DOCKER_TAG

FROM chainsafe/lodestar:${DOCKER_TAG}

# Here only to avoid build-time errors
ARG BUILD_TARGET

RUN apk update && apk add --no-cache ca-certificates tzdata bash su-exec && rm -rf /var/cache/apk/*

# Scripts that handle permissions
COPY ./validator-import.sh /usr/local/bin/

ARG USER=lsconsensus
ARG UID=10002

# See https://stackoverflow.com/a/55757473/12429735RUN
RUN adduser \
--disabled-password \
--gecos "" \
--home "/nonexistent" \
--shell "/sbin/nologin" \
--no-create-home \
--uid "${UID}" \
"${USER}"

RUN mkdir -p /var/lib/lodestar/consensus && chown ${USER}:${USER} /var/lib/lodestar/consensus && chmod 700 /var/lib/lodestar/consensus

ARG USER=lsvalidator
ARG UID=10000

# See https://stackoverflow.com/a/55757473/12429735RUN
RUN adduser \
--disabled-password \
--gecos "" \
--home "/nonexistent" \
--shell "/sbin/nologin" \
--no-create-home \
--uid "${UID}" \
"${USER}"

# Create data mount point with permissions
RUN mkdir -p /var/lib/lodestar/validators && chown ${USER}:${USER} /var/lib/lodestar/validators && chmod 700 /var/lib/lodestar/validators

ENTRYPOINT ["node", "--max-old-space-size=8192", "/usr/app/packages/cli/bin/lodestar"]
57 changes: 57 additions & 0 deletions lodestar/Dockerfile.source
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
FROM node:16-alpine as build

# Here only to avoid build-time errors
ARG DOCKER_TAG

ARG BUILD_TARGET

RUN apk update && apk add --no-cache git g++ make python3 bash && rm -rf /var/cache/apk/*
RUN ln -s /usr/bin/python3 /usr/bin/python

WORKDIR /usr/app

RUN bash -c "git clone https://github.com/ChainSafe/lodestar.git && cd lodestar && git config advice.detachedHead false && git fetch --all --tags && git checkout ${BUILD_TARGET} && yarn install --non-interactive --frozen-lockfile && node ./scripts/getGitData /usr/app/lodestar/.git-data.json && rm -r .git"

FROM node:16-alpine

RUN apk update && apk add --no-cache ca-certificates tzdata bash su-exec && rm -rf /var/cache/apk/*

WORKDIR /usr/app
COPY --from=build /usr/app/lodestar .
ENV DOCKER_LODESTAR_GIT_DATA_FILEPATH /usr/app/.git-data.json

# Scripts that handle permissions
COPY ./validator-import.sh /usr/local/bin/

ARG USER=lsconsensus
ARG UID=10002

# See https://stackoverflow.com/a/55757473/12429735RUN
RUN adduser \
--disabled-password \
--gecos "" \
--home "/nonexistent" \
--shell "/sbin/nologin" \
--no-create-home \
--uid "${UID}" \
"${USER}"

RUN mkdir -p /var/lib/lodestar/consensus && chown ${USER}:${USER} /var/lib/lodestar/consensus && chmod 700 /var/lib/lodestar/consensus

ARG USER=lsvalidator
ARG UID=10000

# See https://stackoverflow.com/a/55757473/12429735RUN
RUN adduser \
--disabled-password \
--gecos "" \
--home "/nonexistent" \
--shell "/sbin/nologin" \
--no-create-home \
--uid "${UID}" \
"${USER}"

# Create data mount point with permissions
RUN mkdir -p /var/lib/lodestar/validators && chown ${USER}:${USER} /var/lib/lodestar/validators && chmod 700 /var/lib/lodestar/validators

ENTRYPOINT ["node", "--max-old-space-size=8192", "/usr/app/packages/cli/bin/lodestar"]
12 changes: 12 additions & 0 deletions lodestar/validator-import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
set -Eeuo pipefail

# Copy keys, then restart script without root
if [ "$(id -u)" = '0' ]; then
mkdir /val_keys
cp /validator_keys/* /val_keys/
chown lsvalidator:lsvalidator /val_keys/*
exec su-exec lsvalidator "$BASH_SOURCE" "$@"
fi

exec "$@"
1 change: 1 addition & 0 deletions prysm-consensus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ services:
target: consensus
<<: *prysm-build
image: prysm-consensus:local
user: root
stop_grace_period: 1m
volumes:
- prysmconsensus-data:/var/lib/prysm
Expand Down
2 changes: 2 additions & 0 deletions teku-consensus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ services:
- DOCKER_TAG=${TEKU_DOCKER_TAG}
dockerfile: ${TEKU_DOCKERFILE}
image: teku:local
user: root
stop_grace_period: 1m
volumes:
- tekuconsensus-data:/var/lib/teku
Expand All @@ -20,6 +21,7 @@ services:
- ${TEKU_PORT}:${TEKU_PORT}/tcp
- ${TEKU_PORT}:${TEKU_PORT}/udp
entrypoint:
- docker-entrypoint.sh
- /opt/teku/bin/teku
- --data-path=/var/lib/teku
- --log-destination=CONSOLE
Expand Down

0 comments on commit 4a68611

Please sign in to comment.