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

Created abci test harness #800

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .cargo/config
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
build-all = "build --workspace --all-targets --"
build-wasm-tendermint = "build -p tendermint --manifest-path tendermint/Cargo.toml --target wasm32-unknown-unknown --release --no-default-features --"
build-wasm-light-client = "build -p tendermint-light-client --manifest-path light-client/Cargo.toml --target wasm32-unknown-unknown --release --no-default-features --"
build-abci = "build --manifest-path abci/Cargo.toml --bin kvstore-rs --features binary,kvstore-app"
test-all-features = "test --all-features --no-fail-fast"
82 changes: 27 additions & 55 deletions tools/abci-test/Makefile.toml
Original file line number Diff line number Diff line change
@@ -1,80 +1,52 @@
[env]
TENDERMINT_CONTAINER = "abci-test-tendermint"
TENDERMINT_IMAGE = "informaldev/tendermint:0.34.0"
KVSTORE_CONTAINER = "abci-test-kvstore"
KVSTORE_IMAGE = "informaldev/kvstore-rs:0.18.0"
CONTAINER_NAME = "abci-test"
DOCKER_IMAGE = "informaldev/abci-harness:0.34.0"
HOST_RPC_PORT = 26657
CARGO_MAKE_WAIT_MILLISECONDS = 3500

# abci-test infrastructure:
# cargo make build-linux-abci - build the ABCI app using Docker (helpful on a Mac)
# cargo make - run the test harness and all tests. Expects a Linux ABCI app already built.
# cargo make docker-up-debug - troubleshoot the infra setup (useful to see docker error messages or the kvstore log).

[tasks.default]
clear = true
dependencies = [
"docker-up",
"wait",
"run",
"docker-down"
]
dependencies = [ "docker-up", "wait", "test", "docker-down" ]

[tasks.run]
command = "cargo"
args = [ "run", "--", "--verbose" ]
[tasks.build-linux-abci]
command = "docker"
args = [ "run", "--rm", "--volume", "${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/..:/usr/src/myapp", "--workdir", "/usr/src/myapp", "rust:latest", "cargo", "build-abci" ]

[tasks.docker-down]
dependencies = [ "docker-stop", "docker-rm" ]

[tasks.docker-up]
dependencies = [ "kvstore-up", "tendermint-up" ]

[tasks.kvstore-up]
command = "docker"
args = [
"run",
"--name", "${KVSTORE_CONTAINER}",
"--rm",
"--net=host",
"--detach",
"${KVSTORE_IMAGE}",
"--verbose"
]
args = ["run", "--name", "${CONTAINER_NAME}", "--rm", "--publish", "26657:${HOST_RPC_PORT}", "--volume", "${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/../target/debug:/abci", "--detach", "${DOCKER_IMAGE}", "--verbose" ]
dependencies = ["docker-up-stop-old", "docker-up-rm-old"]

[tasks.tendermint-up]
[tasks.docker-up-debug]
command = "docker"
args = [
"run",
"--name", "${TENDERMINT_CONTAINER}",
"--rm",
"--net=host",
"--detach",
"${TENDERMINT_IMAGE}",
"node",
"--proxy_app", "tcp://127.0.0.1:26658"
]

[tasks.kvstore-stop]
command = "docker"
args = [ "stop", "-t", "3", "${KVSTORE_CONTAINER}" ]
ignore_errors = true
private = true
args = ["run", "--name", "${CONTAINER_NAME}", "--rm", "--publish", "26657:${HOST_RPC_PORT}", "--volume", "${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/../target/debug:/abci", "${DOCKER_IMAGE}", "--verbose" ]
dependencies = ["docker-up-stop-old", "docker-up-rm-old"]

[tasks.tendermint-stop]
command = "docker"
args = [ "stop", "${TENDERMINT_CONTAINER}" ]
ignore_errors = true
private = true
[tasks.test]
args = ["run", "--all-features"]

[tasks.kvstore-rm]
[tasks.docker-stop]
command = "docker"
args = [ "rm", "--force", "${KVSTORE_CONTAINER}" ]
args = ["stop", "${CONTAINER_NAME}"]
ignore_errors = true
private = true

[tasks.tendermint-rm]
[tasks.docker-rm]
command = "docker"
args = [ "rm", "--force", "${TENDERMINT_CONTAINER}" ]
args = ["rm", "--force", "${CONTAINER_NAME}"]
ignore_errors = true
private = true

[tasks.docker-stop]
dependencies = [ "tendermint-stop", "kvstore-stop" ]
[tasks.docker-up-stop-old]
alias = "docker-stop"

[tasks.docker-rm]
dependencies = [ "tendermint-rm", "kvstore-rm" ]
[tasks.docker-up-rm-old]
alias = "docker-rm"
41 changes: 0 additions & 41 deletions tools/abci-test/run.sh

This file was deleted.

20 changes: 20 additions & 0 deletions tools/docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,23 @@ Both wallets have `uatom`, `stake` and `n0token` added.
Both wallets have an initial signed transaction created for easier population of the network before testing. These transactions
will send uatom tokens from c0 -> c1 and vice versa. They are both signed as `sequence 0` in the wallet, so they can only
be executed as the first transaction of the corresponding wallet.

# abci-harness
This image is used during CI testing in the abci-rs crate.
It tests compatibility with the Tendermint Go implementation.
It derives from the Tendermint Docker image above, but it expects a volume attached at `/abci` that contains the ABCI
application to be tested. The name of the ABCI application is `kvstore-rs` by default. This can be changed by setting the
`ABCI_APP` environment variable.

The image will fire up a Tendermint node (auto-creating the configuration) and then execute the ABCI application
from the attached volume. It logs the Tendermint node log into kvstore-rs.tendermint and the ABCI application log into
kvstore-rs.log on the attached volume.

This image has both the `muslc` and `glibc` libraries installed for easy testing of dynamically linked binaries.

Example:
```bash
docker run -it --rm -v $PWD/target/debug:/abci -p 26657:26657 informaldev/abci-harness:0.34.0
```

The image version reflects the Tendermint Go binary version.
31 changes: 31 additions & 0 deletions tools/docker/abci-harness-0.34.0/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
FROM alpine:3.13.1
LABEL maintainer="hello@informal.systems"

ENV TMHOME=/tendermint
#GLIBC for Alpine from: https://github.com/sgerrand/alpine-pkg-glibc
RUN wget https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub \
-O /etc/apk/keys/sgerrand.rsa.pub && \
wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.32-r0/glibc-2.32-r0.apk \
https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.32-r0/glibc-bin-2.32-r0.apk \
https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.32-r0/glibc-i18n-2.32-r0.apk && \
apk add --no-cache glibc-2.32-r0.apk glibc-bin-2.32-r0.apk glibc-i18n-2.32-r0.apk && \
rm glibc-2.32-r0.apk glibc-bin-2.32-r0.apk glibc-i18n-2.32-r0.apk && \
/usr/glibc-compat/bin/localedef -i en_US -f UTF-8 en_US.UTF-8 && \
apk --no-cache add jq bash file && \
wget https://github.com/freshautomations/sconfig/releases/download/v0.1.0/sconfig_linux_amd64 \
-O /usr/bin/sconfig && \
chmod 755 /usr/bin/sconfig && \
addgroup tendermint && \
adduser -S -G tendermint tendermint -h "$TMHOME"
USER tendermint
WORKDIR $TMHOME

EXPOSE 26656 26657 26658 26660
STOPSIGNAL SIGTERM

ARG TENDERMINT=tendermint
COPY $TENDERMINT /usr/bin/tendermint

COPY entrypoint /usr/bin/entrypoint
ENTRYPOINT ["/usr/bin/entrypoint"]
VOLUME [ "$TMHOME", "/abci" ]
40 changes: 40 additions & 0 deletions tools/docker/abci-harness-0.34.0/entrypoint
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env sh
set -euo pipefail

ABCI_PATH="/abci/${ABCI_APP:-kvstore-rs}"

if [ ! -x "${ABCI_PATH}" ]; then
echo "Could not find executable ABCI app at ${ABCI_PATH} ."
echo "Add a volume with the file and use the ABCI_APP environment variable to point to a different file."
exit 1
else
FILE_TYPE="$(file -b "${ABCI_PATH}")"
if [ -n "${FILE_TYPE##ELF 64-bit*}" ]; then
echo "File is not an ELF 64-bit binary (${FILE_TYPE})."
echo "Build the ABCI application for Linux using Docker:"
echo "docker run -it --rm --user \"\$(id -u)\":\"\$(id -g)\" -v \"\$PWD\":/usr/src/myapp -w /usr/src/myapp rust:latest cargo build-abci"
exit 1
fi
fi

if [ ! -d "${TMHOME}/config" ]; then

echo "Running tendermint init to create configuration."
/usr/bin/tendermint init

sconfig -s ${TMHOME}/config/config.toml \
moniker=${MONIKER:-dockernode} \
consensus.timeout_commit=500ms \
rpc.laddr=tcp://0.0.0.0:26657 \
p2p.addr_book_strict=false \
instrumentation.prometheus=true

sconfig -s ${TMHOME}/config/genesis.json \
chain_id=${CHAIN_ID:-dockerchain} \
consensus_params.block.time_iota_ms=500

fi

exec /usr/bin/tendermint node 2>&1 > "${ABCI_PATH}.tendermint" &

exec "${ABCI_PATH}" "$@" 2>&1 | tee "${ABCI_PATH}.log"
9 changes: 0 additions & 9 deletions tools/docker/kvstore-rs/Dockerfile

This file was deleted.

1 change: 1 addition & 0 deletions tools/docker/tendermint-0.34.0/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tendermint