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

chore: easy-to-run docker compose setup for curio+forest #4848

Merged
merged 14 commits into from
Oct 16, 2024
Merged
51 changes: 51 additions & 0 deletions .github/workflows/forest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,57 @@ jobs:
$SHELL_IMAGE \
sh -c "cp /proofs/* /cache"
sudo chmod -R 755 $FIL_PROOFS_PARAMETER_CACHE
local-devnet-curio-check:
name: Devnet Curio checks
runs-on: ubuntu-24.04
needs:
- build-ubuntu
env:
# We use a custom Dockerfile for CI to speed up the build process.
FOREST_DOCKERFILE_OVERRIDE: scripts/devnet/forest_ci.dockerfile
steps:
- uses: actions/cache@v4
id: cache
with:
path: '${{ env.FIL_PROOFS_PARAMETER_CACHE }}'
key: proof-params-2k
- name: Load cache into volume
if: steps.cache.outputs.cache-hit == 'true'
run: |
docker volume create devnet_filecoin-proofs
docker run --rm \
-v devnet_filecoin-proofs:/proofs \
-v $FIL_PROOFS_PARAMETER_CACHE:/cache \
$SHELL_IMAGE \
sh -c "cp /cache/* /proofs"
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: 'forest-${{ runner.os }}'
- name: Devnet setup
run: |
cp ./scripts/devnet/setup.sh ./scripts/devnet-curio/setup.sh
chmod +x ./scripts/devnet-curio/setup.sh
./scripts/devnet-curio/setup.sh
timeout-minutes: '${{ fromJSON(env.SCRIPT_TIMEOUT_MINUTES) }}'
- name: Devnet check
run: |
cp ./scripts/devnet/check.sh ./scripts/devnet-curio/check.sh
chmod +x ./scripts/devnet-curio/check.sh
./scripts/devnet-curio/check.sh
timeout-minutes: '${{ fromJSON(env.SCRIPT_TIMEOUT_MINUTES) }}'
- name: Dump docker logs
if: always()
uses: jwalton/gh-docker-logs@v2
- name: Prepare cache folder for uploading
if: steps.cache.outputs.cache-hit != 'true'
run: |
docker run --rm \
-v devnet_filecoin-proofs:/proofs \
-v $FIL_PROOFS_PARAMETER_CACHE:/cache \
$SHELL_IMAGE \
sh -c "cp /proofs/* /cache"
sudo chmod -R 755 $FIL_PROOFS_PARAMETER_CACHE
calibnet-rpc-checks:
needs:
- build-ubuntu
Expand Down
6 changes: 4 additions & 2 deletions scripts/devnet-curio/.env
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
CURIO_IMAGE=curio/curio-dev:dev
LOTUS_IMAGE=ghcr.io/chainsafe/lotus-devnet:2024-10-07-6d79e1d
LOTUS_IMAGE=ghcr.io/chainsafe/lotus-devnet:2024-10-10-600728e
FOREST_DATA_DIR=/forest_data
LOTUS_DATA_DIR=/lotus_data
CURIO_REPO_PATH=/var/lib/curio
FIL_PROOFS_PARAMETER_CACHE=/var/tmp/filecoin-proof-parameters
MINER_ACTOR_ADDRESS=t01000
# Necessary because of this bug: https://github.com/filecoin-project/lotus/pull/12574
# Can be removed once the bug is fixed and a new lotus image is released.
DUMMY_MINER_ACTOR_ADDRESS=f01000
LOTUS_RPC_PORT=1234
LOTUS_P2P_PORT=1235
MINER_RPC_PORT=2345
Expand Down
27 changes: 18 additions & 9 deletions scripts/devnet-curio/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,6 @@ default, running it will expose relevant RPC and P2P ports to the host:

## Running the devnet

Prerequisites:

- Fetch the Curio repository
(`git clone https://github.com/filecoin-project/curio`) and run:
- `make docker/curio-all-in-one`
- `make docker/curio`

Run it with:

```shell
Expand Down Expand Up @@ -70,12 +63,28 @@ forest-cli net peers
## Known problems

- YugabyteDB sometimes fails to start. If this happens, restart the devnet.
- As of writing, using Forest with Curio doesn't work. Forest fails to find a
miner actor.

## Local devnet development

If you prefer to have Forest running directly on the host, you can comment it
out and draw inspiration from the `docker-compose.yml` on how to connect it to
Lotus. In short, you will need to obtain the peer id, network name and the
genesis file.

## Testing mining

By default, Curio won't mine any sectors. You can add sectors by starting a new
container:

```
docker exec -it curio /bin/bash
```

And then run:

```
curio seal start --now --cc --actor t01002
```

You can inspect the status at `localhost:4701`. After a few hours, the sectors
should be sealed and proven.
62 changes: 0 additions & 62 deletions scripts/devnet-curio/check.sh

This file was deleted.

103 changes: 103 additions & 0 deletions scripts/devnet-curio/curio.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
#####################################
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this built on every PR and subsequent commits? If so, it'd be better to save it, the same way we do with the Lotus Dockefiles.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll change it to build on demand.

ARG LOTUS_IMAGE
# hadolint ignore=DL3006
FROM ${LOTUS_IMAGE} as lotus-test
FROM golang:1.22.3-bullseye AS curio-builder
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about using debian:bookworm and ubuntu:noble

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to keep it as similar to the "official" curio build environment as possible.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
FROM golang:1.22.3-bullseye AS curio-builder
FROM golang:1.22-bookworm AS curio-builder

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The curio team uses golang:1.22.3-bullseye, so I hesitate to deviate. If bookworm is better, maybe we can upstream the change.


RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates build-essential clang ocl-icd-opencl-dev ocl-icd-libopencl1 jq libhwloc-dev

ENV XDG_CACHE_HOME="/tmp"

### taken from https://github.com/rust-lang/docker-rust/blob/master/1.63.0/buster/Dockerfile
ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH \
RUST_VERSION=1.63.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
RUST_VERSION=1.63.0
RUST_VERSION=1.73.0

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Updated.


SHELL ["/bin/bash", "-o", "pipefail", "-c"]

RUN set -eux; \
dpkgArch="$(dpkg --print-architecture)"; \
case "${dpkgArch##*-}" in \
amd64) rustArch='x86_64-unknown-linux-gnu'; rustupSha256='5cc9ffd1026e82e7fb2eec2121ad71f4b0f044e88bca39207b3f6b769aaa799c' ;; \
arm64) rustArch='aarch64-unknown-linux-gnu'; rustupSha256='e189948e396d47254103a49c987e7fb0e5dd8e34b200aa4481ecc4b8e41fb929' ;; \
*) echo >&2 "unsupported architecture: ${dpkgArch}"; exit 1 ;; \
esac; \
url="https://static.rust-lang.org/rustup/archive/1.25.1/${rustArch}/rustup-init"; \
wget --quiet "$url"; \
echo "${rustupSha256} *rustup-init" | sha256sum -c -; \
chmod +x rustup-init; \
./rustup-init -y --no-modify-path --profile minimal --default-toolchain $RUST_VERSION --default-host ${rustArch}; \
rm rustup-init; \
chmod -R a+w $RUSTUP_HOME $CARGO_HOME; \
rustup --version; \
cargo --version; \
rustc --version;

RUN git clone --depth 1 --branch v1.23.1 https://github.com/filecoin-project/curio.git /opt/curio

WORKDIR /opt/curio

### make configurable filecoin-ffi build
ARG FFI_BUILD_FROM_SOURCE=0
ENV FFI_BUILD_FROM_SOURCE=${FFI_BUILD_FROM_SOURCE}

RUN make clean deps

ARG RUSTFLAGS=""
ARG GOFLAGS=""

RUN make build

#####################################
FROM ubuntu:22.04 AS curio-all-in-one
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
FROM ubuntu:22.04 AS curio-all-in-one
FROM ubuntu:24.04 AS curio-all-in-one


RUN apt-get update && \
apt-get install -y --no-install-recommends dnsutils vim curl aria2 && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Copy libraries and binaries from curio-builder
COPY --from=curio-builder /etc/ssl/certs /etc/ssl/certs
COPY --from=curio-builder /lib/*/libdl.so.2 /lib/
COPY --from=curio-builder /lib/*/librt.so.1 /lib/
COPY --from=curio-builder /lib/*/libgcc_s.so.1 /lib/
COPY --from=curio-builder /lib/*/libutil.so.1 /lib/
COPY --from=curio-builder /usr/lib/*/libltdl.so.7 /lib/
COPY --from=curio-builder /usr/lib/*/libnuma.so.1 /lib/
COPY --from=curio-builder /usr/lib/*/libhwloc.so.* /lib/
COPY --from=curio-builder /usr/lib/*/libOpenCL.so.1 /lib/

# Setup user and OpenCL configuration
RUN useradd -r -u 532 -U fc && \
mkdir -p /etc/OpenCL/vendors && \
echo "libnvidia-opencl.so.1" > /etc/OpenCL/vendors/nvidia.icd

# Environment setup
ENV FILECOIN_PARAMETER_CACHE=/var/tmp/filecoin-proof-parameters \
LOTUS_MINER_PATH=/var/lib/lotus-miner \
LOTUS_PATH=/var/lib/lotus \
CURIO_REPO_PATH=/var/lib/curio

# Copy binaries and scripts
COPY --from=lotus-test /usr/local/bin/lotus /usr/local/bin/
COPY --from=lotus-test /usr/local/bin/lotus-seed /usr/local/bin/
COPY --from=lotus-test /usr/local/bin/lotus-shed /usr/local/bin/
COPY --from=lotus-test /usr/local/bin/lotus-miner /usr/local/bin/
COPY --from=curio-builder /opt/curio/curio /usr/local/bin/
COPY --from=curio-builder /opt/curio/sptool /usr/local/bin/

# Set up directories and permissions
RUN mkdir /var/tmp/filecoin-proof-parameters \
/var/lib/lotus \
/var/lib/lotus-miner \
/var/lib/curio && \
chown fc: /var/tmp/filecoin-proof-parameters /var/lib/lotus /var/lib/lotus-miner /var/lib/curio

# Define volumes
VOLUME ["/var/tmp/filecoin-proof-parameters", "/var/lib/lotus", "/var/lib/lotus-miner", "/var/lib/curio"]

# Expose necessary ports
EXPOSE 1234 2345 12300 4701 32100

CMD ["/bin/bash"]
9 changes: 8 additions & 1 deletion scripts/devnet-curio/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ services:
lotus fetch-params 2048
lotus-seed --sector-dir ${LOTUS_DATA_DIR}/genesis-sectors pre-seal --sector-size 2KiB --num-sectors 2
lotus-seed --sector-dir ${LOTUS_DATA_DIR}/genesis-sectors genesis new ${LOTUS_DATA_DIR}/localnet.json
cp ${LOTUS_DATA_DIR}/genesis-sectors/pre-seal-${DUMMY_MINER_ACTOR_ADDRESS}.json ${LOTUS_DATA_DIR}/genesis-sectors/pre-seal-${MINER_ACTOR_ADDRESS}.json
cp ${LOTUS_DATA_DIR}/genesis-sectors/pre-seal-${DUMMY_MINER_ACTOR_ADDRESS}.key ${LOTUS_DATA_DIR}/genesis-sectors/pre-seal-${MINER_ACTOR_ADDRESS}.key
lotus-seed --sector-dir ${LOTUS_DATA_DIR}/genesis-sectors genesis add-miner ${LOTUS_DATA_DIR}/localnet.json ${LOTUS_DATA_DIR}/genesis-sectors/pre-seal-${MINER_ACTOR_ADDRESS}.json
touch ${LOTUS_DATA_DIR}/NODE_INITIALISED
fi
Expand Down Expand Up @@ -236,7 +238,12 @@ services:
lotus_node:
condition: service_healthy
container_name: curio
image: ${CURIO_IMAGE}
build:
context: .
dockerfile: curio.dockerfile
args:
GOFLAGS: "-tags=debug"
LOTUS_IMAGE: ${LOTUS_IMAGE}
init: true
ports:
- "12300:12300" # API
Expand Down
15 changes: 0 additions & 15 deletions scripts/devnet-curio/forest_ci.dockerfile

This file was deleted.

52 changes: 0 additions & 52 deletions scripts/devnet-curio/lotus.dockerfile

This file was deleted.

Loading
Loading