Commit 89947282 authored by Bernhard Schuster's avatar Bernhard Schuster
Browse files

fix README and containers

parent 4ff6d8f5
...@@ -2,6 +2,12 @@ ...@@ -2,6 +2,12 @@
Create nemesis nodes with alternate, at best faulty, at worst intentionally destructive behavior traits. Create nemesis nodes with alternate, at best faulty, at worst intentionally destructive behavior traits.
The first argument determines the behavior strain. The currently supported are:
* `suggest-garbage-candidate`
* `back-garbage-candidate`
* `dispute-ancestor`
## Integration test cases ## Integration test cases
To define integration tests create file To define integration tests create file
...@@ -38,16 +44,9 @@ This will also teardown the cluster after completion. ...@@ -38,16 +44,9 @@ This will also teardown the cluster after completion.
In order to build the container image you need to have the latest changes from In order to build the container image you need to have the latest changes from
polkadot and substrate master branches. polkadot and substrate master branches.
There different behavior strains, pick one that you'd like to use with a build arg:
`$VARIANT` is one of:
* `dispute-ancestor`
* `second-garbage`
```sh ```sh
pwd # run this from the current dir pwd # run this from the current dir
podman build --build-arg=$VARIANT -t paritypr/malus:v1 -f Containerfile ../../.. podman build -t paritypr/malus:v1 -f Containerfile ../../..
``` ```
[gurke]: https://github.com/paritytech/gurke [gurke]: https://github.com/paritytech/gurke
......
...@@ -26,10 +26,10 @@ COPY substrate/ /usr/src/polkadot-malus/substrate/ ...@@ -26,10 +26,10 @@ COPY substrate/ /usr/src/polkadot-malus/substrate/
WORKDIR /usr/src/polkadot-malus/polkadot WORKDIR /usr/src/polkadot-malus/polkadot
RUN cargo build -p polkadot-test-malus --release RUN cargo build -p polkadot-test-malus --release
RUN cp -v /usr/src/polkadot-malus/polkadot/target/release/malus-$VARIANT /usr/local/bin RUN cp -v /usr/src/polkadot-malus/polkadot/target/release/malus /usr/local/bin
# check if executable works in this container # check if executable works in this container
RUN /usr/local/bin/malus-$VARIANT --version RUN /usr/local/bin/malus $VARIANT --version
# #
### Runtime ### Runtime
...@@ -39,7 +39,7 @@ FROM debian:buster-slim as runtime ...@@ -39,7 +39,7 @@ FROM debian:buster-slim as runtime
RUN apt-get update && \ RUN apt-get update && \
apt-get install -y curl tini apt-get install -y curl tini
COPY --from=builder /usr/src/polkadot-malus/polkadot/target/release/malus-$VARIANT /usr/local/bin COPY --from=builder /usr/src/polkadot-malus/polkadot/target/release/malus /usr/local/bin
# Non-root user for security purposes. # Non-root user for security purposes.
# #
# UIDs below 10,000 are a security risk, as a container breakout could result # UIDs below 10,000 are a security risk, as a container breakout could result
...@@ -63,18 +63,18 @@ RUN chown -R nonroot. /home/nonroot ...@@ -63,18 +63,18 @@ RUN chown -R nonroot. /home/nonroot
# Tell run test script that it runs in container # Tell run test script that it runs in container
USER nonroot USER nonroot
# check if executable works in this container # check if executable works in this container
RUN /usr/local/bin/malus-$VARIANT --version RUN /usr/local/bin/malus --version
# Tini allows us to avoid several Docker edge cases, see https://github.com/krallin/tini. # Tini allows us to avoid several Docker edge cases, see https://github.com/krallin/tini.
ENTRYPOINT ["tini", "--", "/usr/local/bin/malus-$VARIANT"] ENTRYPOINT ["tini", "--", "/usr/local/bin/malus"]
FROM rust:1.54.0 as planner FROM rust:1.54.0 as planner
WORKDIR /usr/src/polkadot-malus WORKDIR /usr/src/polkadot-malus
# We only pay the installation cost once, # We only pay the installation cost once,
# it will be cached from the second build onwards # it will be cached from the second build onwards
RUN cargo install cargo-chef RUN cargo install cargo-chef
COPY polkadot/ /usr/src/polkadot-malus/polkadot/ COPY polkadot/ /usr/src/polkadot-malus/polkadot/
COPY substrate/ /usr/src/polkadot-malus/substrate/ COPY substrate/ /usr/src/polkadot-malus/substrate/
WORKDIR /usr/src/polkadot-malus/polkadot WORKDIR /usr/src/polkadot-malus/polkadot
...@@ -128,7 +128,7 @@ RUN cargo build -p polkadot-test-malus --release ...@@ -128,7 +128,7 @@ RUN cargo build -p polkadot-test-malus --release
FROM debian:buster-slim as runtime FROM debian:buster-slim as runtime
RUN apt-get update && \ RUN apt-get update && \
apt-get install -y curl tini apt-get install -y curl tini
COPY --from=builder /usr/src/polkadot-malus/polkadot/target/release/malus-$VARIANT /usr/local/bin COPY --from=builder /usr/src/polkadot-malus/polkadot/target/release/malus /usr/local/bin
# Non-root user for security purposes. # Non-root user for security purposes.
# #
# UIDs below 10,000 are a security risk, as a container breakout could result # UIDs below 10,000 are a security risk, as a container breakout could result
...@@ -150,6 +150,6 @@ RUN chown -R nonroot. /home/nonroot ...@@ -150,6 +150,6 @@ RUN chown -R nonroot. /home/nonroot
# Tell run test script that it runs in container # Tell run test script that it runs in container
USER nonroot USER nonroot
# check if executable works in this container # check if executable works in this container
RUN /usr/local/bin/malus-$VARIANT --version RUN /usr/local/bin/malus --version
# Tini allows us to avoid several Docker edge cases, see https://github.com/krallin/tini. # Tini allows us to avoid several Docker edge cases, see https://github.com/krallin/tini.
ENTRYPOINT ["/usr/local/bin/malus-$VARIANT""] ENTRYPOINT ["/usr/local/bin/malus"]
...@@ -25,12 +25,10 @@ RUN export PATH="$PATH:$HOME/.cargo/bin" && \ ...@@ -25,12 +25,10 @@ RUN export PATH="$PATH:$HOME/.cargo/bin" && \
WORKDIR /usr/src/polkadot-malus/polkadot WORKDIR /usr/src/polkadot-malus/polkadot
RUN cargo build -p polkadot-test-malus --release --verbose RUN cargo build -p polkadot-test-malus --release --verbose
RUN cp -v /usr/src/polkadot-malus/polkadot/target/release/malus-dispute-ancestor /usr/local/bin RUN cp -v /usr/src/polkadot-malus/polkadot/target/release/malus /usr/local/bin
RUN cp -v /usr/src/polkadot-malus/polkadot/target/release/malus-second-garbage /usr/local/bin
# check if executable works in this container # check if executable works in this container
RUN /usr/local/bin/malus-dispute-ancestor --version RUN /usr/local/bin/malus --version
RUN /usr/local/bin/malus-second-garbage --version
# #
### Runtime ### Runtime
...@@ -40,8 +38,7 @@ FROM debian:buster-slim as runtime ...@@ -40,8 +38,7 @@ FROM debian:buster-slim as runtime
RUN apt-get update && \ RUN apt-get update && \
apt-get install -y curl tini apt-get install -y curl tini
COPY --from=builder /usr/src/polkadot-malus/polkadot/target/release/malus-malus-dispute-ancestor /usr/local/bin COPY --from=builder /usr/src/polkadot-malus/polkadot/target/release/malus /usr/local/bin
COPY --from=builder /usr/src/polkadot-malus/polkadot/target/release/malus-malus-second-garbage /usr/local/bin
# Non-root user for security purposes. # Non-root user for security purposes.
# #
# UIDs below 10,000 are a security risk, as a container breakout could result # UIDs below 10,000 are a security risk, as a container breakout could result
...@@ -64,7 +61,6 @@ RUN chown -R nonroot. /home/nonroot ...@@ -64,7 +61,6 @@ RUN chown -R nonroot. /home/nonroot
# Use the non-root user to run our application # Use the non-root user to run our application
USER nonroot USER nonroot
# check if executable works in this container # check if executable works in this container
RUN /usr/local/bin/malus-dispute-ancestor --version RUN /usr/local/bin/malus --version
RUN /usr/local/bin/malus-second-garbage --version
# Tini allows us to avoid several Docker edge cases, see https://github.com/krallin/tini. # Tini allows us to avoid several Docker edge cases, see https://github.com/krallin/tini.
ENTRYPOINT ["tini", "--", "/usr/local/bin/malus-dispute-ancestor"] ENTRYPOINT ["tini", "--", "/usr/local/bin/malus"]
...@@ -39,14 +39,12 @@ RUN apt-get update && \ ...@@ -39,14 +39,12 @@ RUN apt-get update && \
# add malus binaries to the docker image # add malus binaries to the docker image
COPY ./malus-dispute-ancestor /usr/local/bin COPY ./malus /usr/local/bin
COPY ./malus-suggest-garbage-candidate /usr/local/bin
USER nonroot USER nonroot
# check if executable works in this container # check if executable works in this container
RUN /usr/local/bin/malus-dispute-ancestor --version RUN /usr/local/bin/malus --version
RUN /usr/local/bin/malus-suggest-garbage-candidate --version
# Tini allows us to avoid several Docker edge cases, see https://github.com/krallin/tini. # Tini allows us to avoid several Docker edge cases, see https://github.com/krallin/tini.
ENTRYPOINT ["tini", "--", "/bin/bash"] ENTRYPOINT ["tini", "--", "/bin/bash"]
...@@ -24,6 +24,6 @@ command = "polkadot" ...@@ -24,6 +24,6 @@ command = "polkadot"
[nodes.david] [nodes.david]
validator = true validator = true
extra-args = ["--dave"]
image = "{{get_env(name="MALUSIMAGE") | safe }}" image = "{{get_env(name="MALUSIMAGE") | safe }}"
command = "/usr/local/bin/malus-dispute-valid-block" command = "/usr/local/bin/malus"
extra-args = ["dispute-valid-block", "--dave"]
...@@ -12,24 +12,24 @@ command = "polkadot" ...@@ -12,24 +12,24 @@ command = "polkadot"
[nodes.bob] [nodes.bob]
validator = true validator = true
extra-args = ["--bob"] extra-args = ["back-garbage-candidate", "--bob"]
image = "{{get_env(name="MALUSIMAGE") | safe }}" image = "{{get_env(name="MALUSIMAGE") | safe }}"
command = "/usr/local/bin/malus-back-garbage-candidate" command = "/usr/local/bin/malus"
[nodes.charlie] [nodes.charlie]
validator = true validator = true
extra-args = ["--charlie"] extra-args = ["back-garbage-candidate", "--charlie"]
image = "{{get_env(name="MALUSIMAGE") | safe }}" image = "{{get_env(name="MALUSIMAGE") | safe }}"
command = "/usr/local/bin/malus-back-garbage-candidate" command = "/usr/local/bin/malus"
[nodes.david] [nodes.david]
validator = true validator = true
extra-args = ["--dave"] extra-args = ["back-garbage-candidate", "--dave"]
image = "{{get_env(name="MALUSIMAGE") | safe }}" image = "{{get_env(name="MALUSIMAGE") | safe }}"
command = "/usr/local/bin/malus-back-garbage-candidate" command = "/usr/local/bin/malus"
[nodes.eve] [nodes.eve]
validator = true validator = true
extra-args = ["--eve"] extra-args = ["suggest-garbage-candidate","--eve"]
image = "{{get_env(name="MALUSIMAGE") | safe }}" image = "{{get_env(name="MALUSIMAGE") | safe }}"
command = "/usr/local/bin/malus-suggest-garbage-candidate" command = "/usr/local/bin/malus"
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment