1

This question follows those questions below:

Q1 Zombienet: how to test custom parachain collator - block height(producing blocks) test

Q2 Zombienet: Substrate-Parachain-Template ... block height(block producing) test failed

Regarding this Docker template: https://github.com/paritytech/polkadot/blob/master/scripts/ci/dockerfiles/collator_injected.Dockerfile, I got this answer from Q2 is "yes you can that one and add the build phase to inject then the binary."

That Dockerfile for making adder-collator image:

# this file copies from scripts/ci/dockerfiles/Dockerfile and changes only the binary name
FROM docker.io/library/ubuntu:20.04

# metadata
ARG VCS_REF
ARG BUILD_DATE
ARG IMAGE_NAME

LABEL io.parity.image.authors="[email protected]" \
    io.parity.image.vendor="Parity Technologies" \
    io.parity.image.title="${IMAGE_NAME}" \
    io.parity.image.description="Injected adder-collator Docker image" \
    io.parity.image.source="https://github.com/paritytech/polkadot/blob/${VCS_REF}/scripts/ci/dockerfiles/collator_injected.Dockerfile" \
    io.parity.image.revision="${VCS_REF}" \
    io.parity.image.created="${BUILD_DATE}" \
    io.parity.image.documentation="https://github.com/paritytech/polkadot/"

# show backtraces
ENV RUST_BACKTRACE 1

# install tools and dependencies
RUN apt-get update && \
    DEBIAN_FRONTEND=noninteractive apt-get install -y \
        libssl1.1 \
        ca-certificates && \
# apt cleanup
    apt-get autoremove -y && \
    apt-get clean && \
    find /var/lib/apt/lists/ -type f -not -name lock -delete; \
# add user and link ~/.local/share/adder-collator to /data
    useradd -m -u 1000 -U -s /bin/sh -d /adder-collator adder-collator && \
    mkdir -p /data /adder-collator/.local/share && \
    chown -R adder-collator:adder-collator /data && \
    ln -s /data /adder-collator/.local/share/polkadot

# add adder-collator binary to docker image
COPY ./adder-collator /usr/local/bin
COPY ./undying-collator /usr/local/bin

USER adder-collator

# check if executable works in this container
RUN /usr/local/bin/adder-collator --version
RUN /usr/local/bin/undying-collator --version

EXPOSE 30333 9933 9944
VOLUME ["/adder-collator"]

ENTRYPOINT ["/usr/local/bin/adder-collator"]

Then I used that to make my parachain collator image:

FROM gcr.io/p-network-202104/collator:c1 AS builder
# This c1 image has all the substrate-parachain-template code compiled

FROM debian@sha256:6ef4731388c03b38e58ea77aef9396c216095e1843742fc7cf5038901cc1f081
#FROM debian:stretch-slim
#buster-slim

COPY --from=builder ./builds/collator/target/release/parachain-collator /usr/local/bin

# show backtraces
ENV RUST_BACKTRACE 1

# install tools and dependencies
RUN apt-get update && \
  DEBIAN_FRONTEND=noninteractive apt-get install -y \
  libssl1.1 \
  ca-certificates && \
  # apt cleanup
  apt-get autoremove -y && \
  apt-get clean && \
  find /var/lib/apt/lists/ -type f -not -name lock -delete; \
  # add user and link ~/.local/share/adder-collator to /data
  useradd -m -u 1000 -U -s /bin/sh -d /adder-collator adder-collator && \
  mkdir -p /data /adder-collator/.local/share && \
  chown -R adder-collator:adder-collator /data && \
  ln -s /data /adder-collator/.local/share/polkadot

# adder-collator and undying-collator are not found. do I need them?
#COPY ./adder-collator /usr/local/bin
#COPY ./undying-collator /usr/local/bin

USER adder-collator

# adder-collator and undying-collator are not found
#RUN /usr/local/bin/adder-collator --version
#RUN /usr/local/bin/undying-collator --version

# adding code for new parachain collator
RUN /usr/local/bin/parachain-collator --version

EXPOSE 30333 9933 9944
VOLUME ["/adder-collator"]

#ENTRYPOINT ["/usr/local/bin/adder-collator"]  ... files not found
ENTRYPOINT ["/usr/local/bin/parachain-collator"]

In above Dockerfile, I removed adder-collator and undying-collator because they are not in the Substrate-Parachain-template repo. Do I need them?

My Zombienet network definition:

[relaychain]
default_image = "docker.io/parity/polkadot:v0.9.18"
default_command = "polkadot"
default_args = [ "-lparachain=debug" ]

chain = "rococo-local"

  [[relaychain.nodes]]
  name = "alice"
  validator = true

  [[relaychain.nodes]]
  name = "bob"
  validator = true

[[parachains]]
id = 2000
cumulus_based = true

  [parachains.collator]
  name = "collator01"
  image = "gcr.io/p-network-202104/collator:t5"
  command = "parachain-collator"

[types.Header]
number = "u64"
parent_hash = "Hash"
post_state = "Hash"

I made an image from the above Dockerfile, then ran the same Zombienet tests as those in my previous posts. But the test failed for the same error: parachain block height is still zero

About ENTRYPOINT, what executable should I put there?

Should I use parachain-collator in ENTRYPOINT?

ENTRYPOINT ["/usr/local/bin/parachain-collator"]

The code repo: https://github.com/AuroraLantean/-substrate-parachain-template0918

1
  • 1
    Hi @Russo, I can reproduce now and I working on a fix ( and a working example). Thanks!
    – pepoviola
    May 27, 2022 at 9:42

2 Answers 2

4

I have pushed a new version of zombienet (v1.2.36) and created this demo repo substrate-parachain-template-zombienet from the parachain-template and I added two dockerfile options (one injecting the binary and the other compiling and injecting into the final image).

Also, in this repo there is a simple zombienet test case with the network configuration using the image from this repo.

[settings]
enable_tracing = false

[relaychain]
default_image = "docker.io/parity/polkadot:v0.9.22"
default_command = "polkadot"
default_args = [ "-lparachain=debug" ]
chain = "rococo-local"

  [[relaychain.nodes]]
  name = "alice"
  validator = true

  [[relaychain.nodes]]
  name = "bob"
  validator = true

[[parachains]]
id = 2000
cumulus_based = true

  [parachains.collator]
  name = "collator01"
  image = "docker.io/pepoviola/substrate-parachain-template-zombienet:v0.0.0"
  command = "parachain-collator"
  args = ["-lparachain=debug"]

Tests works as expected using kubernetes provider.

-----------------------------------------


     Network launched πŸš€πŸš€

         In namespace zombie-8f6d290a60ae265e022663c1cd09719d with kubernetes provider


         Node name: alice

         Node direct link: https://polkadot.js.org/apps/?rpc=ws%3A%2F%2F127.0.0.1%3A51063#/explorer

         Node prometheus link: http://127.0.0.1:51068/metrics

---



         Node name: bob

         Node direct link: https://polkadot.js.org/apps/?rpc=ws%3A%2F%2F127.0.0.1%3A51143#/explorer

         Node prometheus link: http://127.0.0.1:51148/metrics

---




     Parachain ID: 2000

     Parachain chainSpecPath path: /var/folders/rz/1cyx7hfj31qgb98d8_cg7jwh0000gn/T/zombie-8f6d290a60ae265e022663c1cd09719d_-62735-7Y6C8XAuiuLx/rococo-local-2000.json


         Node name: collator01

         Node direct link: https://polkadot.js.org/apps/?rpc=ws%3A%2F%2F127.0.0.1%3A51215#/explorer

         Node prometheus link: http://127.0.0.1:51220/metrics

---

    βœ” alice: is up (1837ms)
    βœ” bob: is up (1786ms)
2022-05-27 13:44:58        API/INIT: RPC methods not decorated: beefy_getFinalizedHead, mmr_generateBatchProof, state_trieMigrationStatus
    βœ” alice: parachain 2000 is registered within 225 seconds (4742ms)
    βœ” bob: log line matches glob "*rted #1*" within 10 seconds (1678ms)
    βœ” bob: log line matches "Imported #[0-9]+" within 10 seconds (1662ms)
    βœ” bob: log line matches "Imported new block." within 10 seconds (1620ms)
    βœ” alice: parachain 2000 block height is at least 6 within 250 seconds (138055ms)
    βœ” alice: reports node_roles is 4
    βœ” alice: reports sub_libp2p_is_major_syncing is 0

     Node's logs are available in /var/folders/rz/1cyx7hfj31qgb98d8_cg7jwh0000gn/T/zombie-8f6d290a60ae265e022663c1cd09719d_-62735-7Y6C8XAuiuLx/logs

     Deleting network


  9 passing (9m)

Can you use try the new version of zombienet and use this approach to build your image?

Thanks for your feedback!

4
  • wow thank you it works! May I know why you set enable_tracing = false? Do I need that?
    – Russo
    May 30, 2022 at 11:56
  • 1
    Hi @Russo, at the moment is needed because tracing is enabled by default with k8s provider and the parachain-template node doesn't support the tracing flag. I will fix this in a new version of zombienet.
    – pepoviola
    May 30, 2022 at 12:58
  • is there a reason why you and Polkadot team chose Ubuntu as base image? I think Debian is more secure than Ubuntu. Thanks
    – Russo
    May 31, 2022 at 12:49
  • could you help with Github CICD setup with Zombienet? Thanks substrate.stackexchange.com/questions/3096/…
    – Russo
    Jun 7, 2022 at 14:03
0

The Docker base file:

#debian:10-slim
#FROM debian@sha256:6ef4731388c03b38e58ea77aef9396c216095e1843742fc7cf5038901cc1f081
FROM --platform=linux/amd64 docker.io/library/ubuntu:20.04

RUN apt update && apt install -y git clang curl libssl-dev llvm libudev-dev procps vim make wget build-essential
RUN curl https://sh.rustup.rs -sSf >> install-rust.sh
RUN chmod u+x install-rust.sh
RUN ./install-rust.sh -y
RUN PATH=$PATH:$HOME/.cargo/env
SHELL ["bash", "-lc"]
RUN rustup update
RUN rustup update nightly
RUN rustup target add wasm32-unknown-unknown --toolchain nightly

CMD [ "tail", "-f", "/dev/null" ]
# docker build -f zombienet/Dockerfile.base -t gcr.io/p-network-202104/rust:2004ubuntu220530 .
# docker push gcr.io/p-network-202104/rust:2004ubuntu220530

The correct Dockerfile should look like this:

FROM gcr.io/p-network-202104/rust:2004ubuntu220530 AS builder
ARG PROFILE=release

WORKDIR /builds/collator
COPY . /builds/collator

RUN cargo build --locked --${PROFILE}

# This image has to be the same as the base image for the builder above 
FROM --platform=linux/amd64 docker.io/library/ubuntu:20.04
#debian:10-slim
#FROM debian@sha256:6ef4731388c03b38e58ea77aef9396c216095e1843742fc7cf5038901cc1f081
#FROM debian:stretch-slim
#buster-slim

# show backtraces
ENV RUST_BACKTRACE 1

# install tools and dependencies
RUN apt-get update && \
  DEBIAN_FRONTEND=noninteractive apt-get install -y \
  libssl1.1 \
  ca-certificates && \
  # apt cleanup
  apt-get autoremove -y && \
  apt-get clean && \
  find /var/lib/apt/lists/ -type f -not -name lock -delete; \
  # add user and link ~/.local/share/polkadot to /data
  useradd -m -u 1000 -U -s /bin/sh -d /polkadot polkadot && \
  mkdir -p /data /polkadot/.local/share && \
  chown -R polkadot:polkadot /data && \
  ln -s /data /polkadot/.local/share/polkadot


COPY --from=builder /builds/collator/target/release/parachain-collator /usr/local/bin

USER polkadot

# check if executable works in this container
RUN /usr/local/bin/parachain-collator --version

EXPOSE 30333 9933 9944 9615
VOLUME ["/polkadot"]

ENTRYPOINT ["/usr/local/bin/parachain-collator"]
# docker build -f zombienet/Dockerfile -t gcr.io/p-network-202104/collator:v6 .
# docker push gcr.io/p-network-202104/collator:v6

Your Answer

By clicking β€œPost Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.