diff --git a/stack-orchestrator/compose/docker-compose-lotus-node.yml b/stack-orchestrator/compose/docker-compose-lotus-node.yml index f017d2b..1e4f332 100644 --- a/stack-orchestrator/compose/docker-compose-lotus-node.yml +++ b/stack-orchestrator/compose/docker-compose-lotus-node.yml @@ -7,6 +7,7 @@ services: lotus: environment: - DOCKER_LOTUS_IMPORT_SNAPSHOT=/var/lotus-snapshots/snapshot + - LOTUS_NETWORK=${CERC_LOTUS_NETWORK} - LOTUS_FEVM_ENABLEETHRPC=true - LOTUS_API_LISTENADDRESS=/ip4/0.0.0.0/tcp/1234/http - LOTUS_LIBP2P_LISTENADDRESSES=/ip4/0.0.0.0/tcp/1235,/ip6/::/tcp/1235,/ip4/0.0.0.0/udp/1235/quic-v1,/ip6/::/udp/1235/quic-v1,/ip4/0.0.0.0/udp/1235/quic-v1/webtransport,/ip6/::/udp/1235/quic-v1/webtransport @@ -16,6 +17,7 @@ services: - parameters:/var/tmp/filecoin-proof-parameters - lotus-repo:/var/lib/lotus - lotus_shared:/root/.lotus + - ../config/lotus-node/docker-lotus-entrypoint.sh:/docker-lotus-entrypoint.sh ports: - "1234" - "1235" diff --git a/stack-orchestrator/config/lotus-node/docker-lotus-entrypoint.sh b/stack-orchestrator/config/lotus-node/docker-lotus-entrypoint.sh new file mode 100755 index 0000000..fd5e939 --- /dev/null +++ b/stack-orchestrator/config/lotus-node/docker-lotus-entrypoint.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +TARGET_LOTUS="/usr/local/bin/lotus" +TARGET_LOTUS_SHED="/usr/local/bin/lotus-shed" + +if [ "$LOTUS_NETWORK" = "calibration" ]; then + echo "Using Calibration Lotus binary" + TARGET_LOTUS="/usr/local/bin/lotus-calibnet" + TARGET_LOTUS_SHED="/usr/local/bin/lotus-calibnet-shed" +fi + +if [ ! -z $DOCKER_LOTUS_IMPORT_SNAPSHOT ]; then + GATE="$LOTUS_PATH"/date_initialized + # Don't init if already initialized. + if [ ! -f "$GATE" ]; then + echo importing minimal snapshot + echo "yes" | $TARGET_LOTUS daemon --import-snapshot "$DOCKER_LOTUS_IMPORT_SNAPSHOT" --halt-after-import + # Block future inits + date > "$GATE" + fi +fi + +# import wallet, if provided +if [ ! -z $DOCKER_LOTUS_IMPORT_WALLET ]; then + $TARGET_LOTUS_SHED keyinfo import "$DOCKER_LOTUS_IMPORT_WALLET" +fi + +exec $TARGET_LOTUS daemon $@ diff --git a/stack-orchestrator/container-build/cerc-lotus-node/Dockerfile b/stack-orchestrator/container-build/cerc-lotus-node/Dockerfile index 2557e82..0229e2a 100644 --- a/stack-orchestrator/container-build/cerc-lotus-node/Dockerfile +++ b/stack-orchestrator/container-build/cerc-lotus-node/Dockerfile @@ -47,6 +47,11 @@ RUN make clean deps && \ install -C ./lotus-shed /usr/local/bin/lotus-shed && \ install -C ./lotus-stats /usr/local/bin/lotus-stats +RUN make clean deps && \ + make calibnet && \ + install -C ./lotus /usr/local/bin/lotus-calibnet && \ + install -C ./lotus-shed /usr/local/bin/lotus-calibnet-shed + ##################################### FROM ubuntu:20.04 AS lotus-base MAINTAINER Lotus Development Team @@ -73,6 +78,8 @@ MAINTAINER Lotus Development Team COPY --from=lotus-builder \ /usr/local/bin/lotus \ /usr/local/bin/lotus-shed \ + /usr/local/bin/lotus-calibnet \ + /usr/local/bin/lotus-calibnet-shed \ /usr/local/bin/ ENV FILECOIN_PARAMETER_CACHE /var/tmp/filecoin-proof-parameters @@ -107,6 +114,8 @@ ENV DOCKER_LOTUS_IMPORT_SNAPSHOT=${DOCKER_LOTUS_IMPORT_SNAPSHOT} COPY --from=lotus-builder /opt/filecoin/lotus /usr/local/bin/ COPY --from=lotus-builder /opt/filecoin/lotus-shed /usr/local/bin/ COPY --from=lotus-builder /opt/filecoin/lotus-stats /usr/local/bin/ +COPY --from=lotus-builder /opt/filecoin/lotus-calibnet /usr/local/bin/ +COPY --from=lotus-builder /opt/filecoin/lotus-calibnet-shed /usr/local/bin/ COPY scripts/docker-lotus-entrypoint.sh /docker-lotus-entrypoint.sh RUN chmod +x /docker-lotus-entrypoint.sh diff --git a/stack-orchestrator/stacks/lotus-node/README.md b/stack-orchestrator/stacks/lotus-node/README.md index 153e3b2..7885ec1 100644 --- a/stack-orchestrator/stacks/lotus-node/README.md +++ b/stack-orchestrator/stacks/lotus-node/README.md @@ -5,12 +5,22 @@ Instructions for deploying a Lotus snap-synced node (for both mainnet and calibn ## Prerequisite Downloaded chain snapshot -```bash -aria2c -o snapshot -x5 https://forest-archive.chainsafe.dev/latest/mainnet/ -# or using wget -wget -O snapshot https://forest-archive.chainsafe.dev/latest/mainnet/ -``` +- For Mainnet + ```bash + aria2c -o mainnet-snapshot.car.zst -x5 https://forest-archive.chainsafe.dev/latest/mainnet/ + + # or using wget + wget -O mainnet-snapshot.car.zst https://forest-archive.chainsafe.dev/latest/mainnet/ + ``` + +- For Calibration Testnet + ``` + aria2c -o calibnet-snapshot.car.zst -x5 https://forest-archive.chainsafe.dev/latest/calibnet/ + + # or using wget + wget -O calibnet-snapshot.car.zst https://forest-archive.chainsafe.dev/latest/calibnet/ + ``` ## Clone the stack repo @@ -39,13 +49,23 @@ $ laconic-so --stack ~/cerc/lotus-stack/stack-orchestrator/stacks/lotus-node dep ## Setup config -Set file path of downloaded snapshot in config.env Inside deployment directory, open the `config.env` file and set following env variables: -```bash -# File path of downloaded snapshot -CERC_LOTUS_SNAPSHOT_PATH=/path-to-file/snapshot -``` +- For Mainnet + ```bash + CERC_LOTUS_NETWORK=mainnet + + # File path of downloaded snapshot + CERC_LOTUS_SNAPSHOT_PATH=/path-to-file/mainnet-snapshot.car.zst + ``` + +- For Calibration + ```bash + CERC_LOTUS_NETWORK=calibration + + # File path of downloaded snapshot + CERC_LOTUS_SNAPSHOT_PATH=/path-to-file/calibnet-snapshot.car.zst + ``` ## Start the container diff --git a/stack-orchestrator/stacks/lotus-node/stack.yml b/stack-orchestrator/stacks/lotus-node/stack.yml index 1043eee..807afbb 100644 --- a/stack-orchestrator/stacks/lotus-node/stack.yml +++ b/stack-orchestrator/stacks/lotus-node/stack.yml @@ -2,8 +2,7 @@ version: "1.0" name: lotus-node description: "Lotus node stack" repos: - # TODO: Use a release version tag - - git.vdb.to/cerc-io/lotus + - git.vdb.to/cerc-io/lotus@v1.27.0-rc3-interal-0.0.1 containers: - cerc/lotus-node pods: